Add the whole api stack for weight

This commit is contained in:
2024-08-09 23:18:50 +02:00
parent 57d88c093e
commit 1edc3e83ef
11 changed files with 570 additions and 16 deletions

View File

@@ -4,20 +4,32 @@ import {main} from '../models';
export function CreateFood(arg1:main.Food):Promise<main.WailsFood1>;
export function CreateWeight(arg1:main.Weight):Promise<main.WailsWeight1>;
export function GetDailyFood():Promise<main.WailsAggregateFood>;
export function GetDailyWeight():Promise<main.WailsAggregateWeight>;
export function GetFood():Promise<main.WailsFood>;
export function GetLastPer100(arg1:string):Promise<main.WailsPer100>;
export function GetMonthlyFood():Promise<main.WailsAggregateFood>;
export function GetMonthlyWeight():Promise<main.WailsAggregateWeight>;
export function GetSettings():Promise<main.settings>;
export function GetWeeklyFood():Promise<main.WailsAggregateFood>;
export function GetWeeklyWeight():Promise<main.WailsAggregateWeight>;
export function GetWeight():Promise<main.WailsWeight>;
export function GetYearlyFood():Promise<main.WailsAggregateFood>;
export function GetYearlyWeight():Promise<main.WailsAggregateWeight>;
export function SetSetting(arg1:string,arg2:number):Promise<main.WailsGenericAck>;
export function UpdateFood(arg1:main.Food):Promise<main.WailsFood1>;

View File

@@ -6,10 +6,18 @@ export function CreateFood(arg1) {
return window['go']['main']['App']['CreateFood'](arg1);
}
export function CreateWeight(arg1) {
return window['go']['main']['App']['CreateWeight'](arg1);
}
export function GetDailyFood() {
return window['go']['main']['App']['GetDailyFood']();
}
export function GetDailyWeight() {
return window['go']['main']['App']['GetDailyWeight']();
}
export function GetFood() {
return window['go']['main']['App']['GetFood']();
}
@@ -22,6 +30,10 @@ export function GetMonthlyFood() {
return window['go']['main']['App']['GetMonthlyFood']();
}
export function GetMonthlyWeight() {
return window['go']['main']['App']['GetMonthlyWeight']();
}
export function GetSettings() {
return window['go']['main']['App']['GetSettings']();
}
@@ -30,10 +42,22 @@ export function GetWeeklyFood() {
return window['go']['main']['App']['GetWeeklyFood']();
}
export function GetWeeklyWeight() {
return window['go']['main']['App']['GetWeeklyWeight']();
}
export function GetWeight() {
return window['go']['main']['App']['GetWeight']();
}
export function GetYearlyFood() {
return window['go']['main']['App']['GetYearlyFood']();
}
export function GetYearlyWeight() {
return window['go']['main']['App']['GetYearlyWeight']();
}
export function SetSetting(arg1, arg2) {
return window['go']['main']['App']['SetSetting'](arg1, arg2);
}

View File

@@ -18,6 +18,20 @@ export namespace main {
this.energy = source["energy"];
}
}
export class AggregatedWeight {
period: string;
amount: number;
static createFrom(source: any = {}) {
return new AggregatedWeight(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.period = source["period"];
this.amount = source["amount"];
}
}
export class Food {
rowid: number;
date: string;
@@ -76,6 +90,40 @@ export namespace main {
return a;
}
}
export class WailsAggregateWeight {
data: AggregatedWeight[];
success: boolean;
error?: string;
static createFrom(source: any = {}) {
return new WailsAggregateWeight(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], AggregatedWeight);
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 WailsFood {
data: Food[];
success: boolean;
@@ -174,6 +222,91 @@ export namespace main {
this.error = source["error"];
}
}
export class Weight {
rowid: number;
date: string;
food: number;
static createFrom(source: any = {}) {
return new Weight(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.rowid = source["rowid"];
this.date = source["date"];
this.food = source["food"];
}
}
export class WailsWeight {
data: Weight[];
success: boolean;
error?: string;
static createFrom(source: any = {}) {
return new WailsWeight(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Weight);
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 WailsWeight1 {
data: Weight;
success: boolean;
error?: string;
static createFrom(source: any = {}) {
return new WailsWeight1(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Weight);
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 settings {
foodDaysLookback: number;
foodAggregatedDaysLookback: number;