diff --git a/frontend/src/lib/components/Energy/EmptyFoodComp.svelte b/frontend/src/lib/components/Energy/EmptyFoodComp.svelte index d5fa9b8..a6e0753 100644 --- a/frontend/src/lib/components/Energy/EmptyFoodComp.svelte +++ b/frontend/src/lib/components/Energy/EmptyFoodComp.svelte @@ -54,7 +54,8 @@ if (!per100Edited) GetLastPer100(name.trim()).then((res) => { - if (res.success) { + console.log(res.data); + if (res.success && res.data) { console.log(res.data[0].food); per100 = res.data[0].per100.toString(); } diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index 407ee01..a9f604f 100644 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -14,7 +14,7 @@ export function GetDailyWeight():Promise; export function GetFood():Promise; -export function GetLastPer100(arg1:string):Promise; +export function GetLastPer100(arg1:string):Promise; export function GetMonthlyFood():Promise; diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 2b2eb15..f32e5f7 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -56,6 +56,32 @@ export namespace main { this.energy = source["energy"]; } } + export class FoodSearch { + rowid: number; + date: string; + food: string; + description: string; + amount: number; + per100: number; + energy: number; + score: number; + + static createFrom(source: any = {}) { + return new FoodSearch(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.rowid = source["rowid"]; + this.date = source["date"]; + this.food = source["food"]; + this.description = source["description"]; + this.amount = source["amount"]; + this.per100 = source["per100"]; + this.energy = source["energy"]; + this.score = source["score"]; + } + } export class WailsAggregateFood { data: AggregatedFood[]; success: boolean; @@ -192,6 +218,40 @@ export namespace main { return a; } } + export class WailsFoodSearch { + data: FoodSearch[]; + success: boolean; + error?: string; + + static createFrom(source: any = {}) { + return new WailsFoodSearch(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.data = this.convertValues(source["data"], FoodSearch); + this.success = source["success"]; + this.error = source["error"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } export class WailsGenericAck { success: boolean; error?: string; @@ -306,6 +366,7 @@ export namespace main { weightYearlyLookback: number; target: number; limit: number; + searchLimit: number; static createFrom(source: any = {}) { return new settings(source); @@ -327,6 +388,7 @@ export namespace main { this.weightYearlyLookback = source["weightYearlyLookback"]; this.target = source["target"]; this.limit = source["limit"]; + this.searchLimit = source["searchLimit"]; } }