- Created package.json for Wails JavaScript runtime library. - Added TypeScript definitions for runtime functions. - Implemented runtime.js with event handling and logging functions. - Initialized Go module with dependencies for Wails and other libraries. - Added main.go for application entry point and asset embedding. - Configured wails.json for application settings and build commands.
70 lines
1.9 KiB
TypeScript
Executable File
70 lines
1.9 KiB
TypeScript
Executable File
export namespace backend {
|
|
|
|
export class ProcessInfo {
|
|
pid: number;
|
|
name: string;
|
|
cpu: number;
|
|
mem: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ProcessInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.pid = source["pid"];
|
|
this.name = source["name"];
|
|
this.cpu = source["cpu"];
|
|
this.mem = source["mem"];
|
|
}
|
|
}
|
|
export class Metrics {
|
|
cpu_percent: number;
|
|
total_mem: number;
|
|
free_mem: number;
|
|
processes: ProcessInfo[];
|
|
timestamp: number;
|
|
gpu_name?: string;
|
|
gpu_total_mem?: number;
|
|
gpu_used_mem?: number;
|
|
gpu_util_percent?: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Metrics(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.cpu_percent = source["cpu_percent"];
|
|
this.total_mem = source["total_mem"];
|
|
this.free_mem = source["free_mem"];
|
|
this.processes = this.convertValues(source["processes"], ProcessInfo);
|
|
this.timestamp = source["timestamp"];
|
|
this.gpu_name = source["gpu_name"];
|
|
this.gpu_total_mem = source["gpu_total_mem"];
|
|
this.gpu_used_mem = source["gpu_used_mem"];
|
|
this.gpu_util_percent = source["gpu_util_percent"];
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|