Implement search on the frontend
This commit is contained in:
@@ -54,7 +54,8 @@
|
|||||||
|
|
||||||
if (!per100Edited)
|
if (!per100Edited)
|
||||||
GetLastPer100(name.trim()).then((res) => {
|
GetLastPer100(name.trim()).then((res) => {
|
||||||
if (res.success) {
|
console.log(res.data);
|
||||||
|
if (res.success && res.data) {
|
||||||
console.log(res.data[0].food);
|
console.log(res.data[0].food);
|
||||||
per100 = res.data[0].per100.toString();
|
per100 = res.data[0].per100.toString();
|
||||||
}
|
}
|
||||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -14,7 +14,7 @@ export function GetDailyWeight():Promise<main.WailsAggregateWeight>;
|
|||||||
|
|
||||||
export function GetFood():Promise<main.WailsFood>;
|
export function GetFood():Promise<main.WailsFood>;
|
||||||
|
|
||||||
export function GetLastPer100(arg1:string):Promise<main.WailsFood1>;
|
export function GetLastPer100(arg1:string):Promise<main.WailsFoodSearch>;
|
||||||
|
|
||||||
export function GetMonthlyFood():Promise<main.WailsAggregateFood>;
|
export function GetMonthlyFood():Promise<main.WailsAggregateFood>;
|
||||||
|
|
||||||
|
@@ -56,6 +56,32 @@ export namespace main {
|
|||||||
this.energy = source["energy"];
|
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 {
|
export class WailsAggregateFood {
|
||||||
data: AggregatedFood[];
|
data: AggregatedFood[];
|
||||||
success: boolean;
|
success: boolean;
|
||||||
@@ -192,6 +218,40 @@ export namespace main {
|
|||||||
return a;
|
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 {
|
export class WailsGenericAck {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
@@ -306,6 +366,7 @@ export namespace main {
|
|||||||
weightYearlyLookback: number;
|
weightYearlyLookback: number;
|
||||||
target: number;
|
target: number;
|
||||||
limit: number;
|
limit: number;
|
||||||
|
searchLimit: number;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new settings(source);
|
return new settings(source);
|
||||||
@@ -327,6 +388,7 @@ export namespace main {
|
|||||||
this.weightYearlyLookback = source["weightYearlyLookback"];
|
this.weightYearlyLookback = source["weightYearlyLookback"];
|
||||||
this.target = source["target"];
|
this.target = source["target"];
|
||||||
this.limit = source["limit"];
|
this.limit = source["limit"];
|
||||||
|
this.searchLimit = source["searchLimit"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user