Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
64e2603542 |
100
.gitea/workflows/publish.yaml
Normal file
100
.gitea/workflows/publish.yaml
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# TODO: Need to install node here... How the fuck am I going to cache that bullshit...
|
||||||
|
# Figure out how to cache bullshit node
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /opt/hostedtoolcache
|
||||||
|
GOMODCACHE: /opt/hostedtoolcache/go/pkg/mod
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
check-latest: true
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Setup Wails
|
||||||
|
run: |
|
||||||
|
# Install Wails CLI (if needed)
|
||||||
|
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||||
|
|
||||||
|
- name: Build wails
|
||||||
|
run: wails build -platform darwin/amd64,darwin/arm64,windows/amd64,windows/arm64,linux/amd64,linux/arm64
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
body: |
|
||||||
|
Release notes for ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: Upload Windows AMD64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-amd64.exe
|
||||||
|
asset_name: calorie-counter-amd64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Upload Windows ARM64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-arm64.exe
|
||||||
|
asset_name: calorie-counter-arm64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Upload Linux AMD64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-amd64.exe
|
||||||
|
asset_name: calorie-counter-amd64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Upload Linux ARM64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-arm64.exe
|
||||||
|
asset_name: calorie-counter-arm64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Upload Darwin AMD64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-amd64.exe
|
||||||
|
asset_name: calorie-counter-amd64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Upload Darwin ARM64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/bin/calorie-counter-arm64.exe
|
||||||
|
asset_name: calorie-counter-arm64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
6
app.go
6
app.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
@@ -136,8 +135,3 @@ func (a *App) SetSetting(key string, value int64) WailsGenericAck {
|
|||||||
}
|
}
|
||||||
return WailsGenericAck{Success: true}
|
return WailsGenericAck{Success: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
//region other
|
|
||||||
func (a *App) Close() {
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
@@ -1,15 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||||
<title>calorie-counter</title>
|
<title>calorie-counter</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="./src/main.ts" type="module"></script>
|
<script src="./src/main.ts" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@@ -1,30 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Header from "$lib/components/Header.svelte";
|
import Header from "$lib/components/Header.svelte";
|
||||||
import Router from "$lib/router/Router.svelte";
|
import Router from "$lib/router/Router.svelte";
|
||||||
import { Close } from "$wails/main/App";
|
import { Toaster } from 'svelte-sonner'
|
||||||
import { Toaster } from "svelte-sonner";
|
|
||||||
import * as srouter from "svelte-spa-router";
|
|
||||||
import { location } from "svelte-spa-router";
|
|
||||||
|
|
||||||
function keyDown(event: KeyboardEvent) {
|
|
||||||
if (event.ctrlKey && event.key == "r") {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
if (event.ctrlKey && event.key == "w") {
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
if (event.ctrlKey && event.key == "Tab") {
|
|
||||||
if ($location == "/") {
|
|
||||||
srouter.replace("/Weight");
|
|
||||||
} else if ($location == "/Weight") {
|
|
||||||
srouter.replace("/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={keyDown} />
|
|
||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<template>
|
<template>
|
||||||
<Header />
|
<Header />
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
let per100: string = "";
|
let per100: string = "";
|
||||||
let per100Edited: boolean = false;
|
let per100Edited: boolean = false;
|
||||||
let per100Element: HTMLTableCellElement;
|
let per100Element: HTMLTableCellElement;
|
||||||
let nameElement: HTMLTableCellElement;
|
|
||||||
|
|
||||||
async function update(event: KeyboardEvent & { currentTarget: EventTarget & HTMLTableCellElement }) {
|
async function update(event: KeyboardEvent & { currentTarget: EventTarget & HTMLTableCellElement }) {
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
description = description.trim();
|
description = description.trim();
|
||||||
per100 = per100.trim();
|
per100 = per100.trim();
|
||||||
|
|
||||||
if (!per100Edited && event.currentTarget == per100Element) per100Edited = true;
|
if (!per100Edited && event.currentTarget === per100Element) per100Edited = true;
|
||||||
|
|
||||||
if (event.key == "Enter") {
|
if (event.key == "Enter") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -49,7 +48,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
foodStore.update((value) => [res.data, ...value]);
|
foodStore.update((value) => [res.data, ...value]);
|
||||||
nameElement.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!per100Edited)
|
if (!per100Edited)
|
||||||
@@ -77,7 +75,6 @@
|
|||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
autofocus
|
autofocus
|
||||||
on:keydown={update}
|
on:keydown={update}
|
||||||
bind:this={nameElement}
|
|
||||||
>
|
>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
|
@@ -34,10 +34,9 @@
|
|||||||
remainingToday = $settingsStore.target;
|
remainingToday = $settingsStore.target;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let todayDate = formatter.format(now);
|
let todayDate = formatter.format(now);
|
||||||
const [day, month, year] = todayDate.split("/");
|
const [day, month, year] = todayDate.split('/');
|
||||||
todayDate = `${year}-${month}-${day}`;
|
todayDate = `${year}-${month}-${day}`;
|
||||||
|
|
||||||
if ($foodStore) {
|
|
||||||
$foodStore.forEach((food) => {
|
$foodStore.forEach((food) => {
|
||||||
if (food.date.split("T")[0] == todayDate) {
|
if (food.date.split("T")[0] == todayDate) {
|
||||||
remainingToday -= food.energy;
|
remainingToday -= food.energy;
|
||||||
@@ -45,7 +44,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
remainingToday = Math.round(remainingToday);
|
remainingToday = Math.round(remainingToday);
|
||||||
computeColor();
|
computeColor();
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { GenerateColor, RemoveExistingColors } from "$lib/utils";
|
import { GenerateColor } from "$lib/utils";
|
||||||
import { main } from "$wails/models";
|
import { main } from "$wails/models";
|
||||||
import EmptyFoodComp from "./EmptyFoodComp.svelte";
|
import EmptyFoodComp from "./EmptyFoodComp.svelte";
|
||||||
import FoodComp from "./FoodComp.svelte";
|
import FoodComp from "./FoodComp.svelte";
|
||||||
|
|
||||||
export let items: main.Food[] = [];
|
export let items: main.Food[] = [];
|
||||||
RemoveExistingColors();
|
|
||||||
|
|
||||||
let minCal = 1e5;
|
let minCal = 1e5;
|
||||||
let maxCal = 0;
|
let maxCal = 0;
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { link, location } from "svelte-spa-router";
|
import { link, location } from "svelte-spa-router";
|
||||||
import { faGear} from "@fortawesome/free-solid-svg-icons";
|
import { faGear } from "@fortawesome/free-solid-svg-icons";
|
||||||
import Fa from "svelte-fa";
|
import Fa from "svelte-fa";
|
||||||
import Settings from "./Settings/Settings.svelte";
|
import Settings from "./Settings/Settings.svelte";
|
||||||
import EnergyToday from "./Energy/EnergyToday.svelte";
|
import EnergyToday from "./Energy/EnergyToday.svelte";
|
||||||
import RefreshComponent from "./RefreshComponent.svelte";
|
|
||||||
Fa;
|
Fa;
|
||||||
|
|
||||||
type Link = {
|
type Link = {
|
||||||
@@ -89,7 +88,6 @@
|
|||||||
<Fa icon={faGear} scale={2} />
|
<Fa icon={faGear} scale={2} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<RefreshComponent />
|
|
||||||
<EnergyToday />
|
<EnergyToday />
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { dailyFoodStore } from "$lib/store/Energy/dailyFoodStore";
|
|
||||||
import { monthlyFoodStore } from "$lib/store/Energy/monthlyFoodStore";
|
|
||||||
import { weeklyFoodStore } from "$lib/store/Energy/weeklyFoodStore";
|
|
||||||
import { yearlyFoodStore } from "$lib/store/Energy/yearlyFoodStore";
|
|
||||||
import { dailyWeightStore } from "$lib/store/Weight/dailyWeightStore";
|
|
||||||
import { monthlyWeightStore } from "$lib/store/Weight/monthlyWeightStore";
|
|
||||||
import { weeklyWeightStore } from "$lib/store/Weight/weeklyWeightStore";
|
|
||||||
import { yearlyWeightStore } from "$lib/store/Weight/yearlyWeightStore";
|
|
||||||
import { faRefresh } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import Fa from "svelte-fa";
|
|
||||||
Fa;
|
|
||||||
|
|
||||||
// YES refresh DOES exist FFS
|
|
||||||
function refreshStores() {
|
|
||||||
// @ts-ignore
|
|
||||||
dailyFoodStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
weeklyFoodStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
monthlyFoodStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
yearlyFoodStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
dailyWeightStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
weeklyWeightStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
monthlyWeightStore.refresh();
|
|
||||||
// @ts-ignore
|
|
||||||
yearlyWeightStore.refresh();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
||||||
<div class="absolute right-20 pt-4 pb-4 pr-8 pl-8 cursor-pointer" on:click={refreshStores}>
|
|
||||||
<button>
|
|
||||||
<Fa icon={faRefresh} scale={2} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { GenerateColor, RemoveExistingColors } from "$lib/utils";
|
import { GenerateColor } from "$lib/utils";
|
||||||
import EmptyWeightComp from "$components/Weight/EmptyWeightComp.svelte";
|
import EmptyWeightComp from "$components/Weight/EmptyWeightComp.svelte";
|
||||||
import WeightComp from "$components/Weight/WeightComp.svelte";
|
import WeightComp from "$components/Weight/WeightComp.svelte";
|
||||||
import { main } from "$wails/models";
|
import { main } from "$wails/models";
|
||||||
|
|
||||||
export let items: main.Weight[] = [];
|
export let items: main.Weight[] = [];
|
||||||
RemoveExistingColors();
|
|
||||||
|
|
||||||
const dateColors: Map<string, string> = new Map<string, string>();
|
const dateColors: Map<string, string> = new Map<string, string>();
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
let forceUpdate = false;
|
let forceUpdate = false;
|
||||||
weightStore.subscribe(() => {
|
weightStore.subscribe(() => {
|
||||||
|
console.log("updte");
|
||||||
forceUpdate = !forceUpdate;
|
forceUpdate = !forceUpdate;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -68,11 +68,8 @@ function GenerateRandomHSL(): Color {
|
|||||||
|
|
||||||
const existingColors: Color[] = [];
|
const existingColors: Color[] = [];
|
||||||
|
|
||||||
function RemoveExistingColors() {
|
|
||||||
existingColors.length = 0;
|
|
||||||
}
|
|
||||||
function GenerateColor(): string {
|
function GenerateColor(): string {
|
||||||
const minDistance = 5;
|
const minDistance = 15;
|
||||||
|
|
||||||
let newColor: Color;
|
let newColor: Color;
|
||||||
let isDistinct = false;
|
let isDistinct = false;
|
||||||
@@ -92,10 +89,8 @@ function GenerateColor(): string {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDistinct) {
|
|
||||||
existingColors.push(newColor);
|
existingColors.push(newColor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// We can not reach this point without having a color generated
|
// We can not reach this point without having a color generated
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -109,5 +104,5 @@ function LerpColor(color1: Color, color2: Color, t: number): Color {
|
|||||||
return { h, s, l };
|
return { h, s, l };
|
||||||
}
|
}
|
||||||
|
|
||||||
export { GenerateColor, LerpColor, RemoveExistingColors };
|
export { GenerateColor, LerpColor };
|
||||||
export type { Color };
|
export type { Color };
|
||||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -2,8 +2,6 @@
|
|||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
import {main} from '../models';
|
import {main} from '../models';
|
||||||
|
|
||||||
export function Close():Promise<void>;
|
|
||||||
|
|
||||||
export function CreateFood(arg1:main.Food):Promise<main.WailsFood1>;
|
export function CreateFood(arg1:main.Food):Promise<main.WailsFood1>;
|
||||||
|
|
||||||
export function CreateWeight(arg1:main.Weight):Promise<main.WailsWeight1>;
|
export function CreateWeight(arg1:main.Weight):Promise<main.WailsWeight1>;
|
||||||
|
@@ -2,10 +2,6 @@
|
|||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
|
|
||||||
export function Close() {
|
|
||||||
return window['go']['main']['App']['Close']();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CreateFood(arg1) {
|
export function CreateFood(arg1) {
|
||||||
return window['go']['main']['App']['CreateFood'](arg1);
|
return window['go']['main']['App']['CreateFood'](arg1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user