format job duration and avoid duplicate ids
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 3m52s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 15s

This commit is contained in:
2026-10-02 23:07:08 +00:00
parent b834f55581
commit 8f6b706a49
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
import { CommonModule } from '@angular/common'; import { Component,inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; interface Asset{filename:string;url:string;type:string;} interface Model{nodeId:string;type:string;name:string;} interface Job{promptId:string;title:string;status:string;queuedAt:number|null;durationMs:number|null;outputCount:number;assets:Asset[];models:Model[];} interface Device{name:string;type:string;vramTotal:number;vramFree:number;} interface ServerStatus{reachable:boolean;version:string;os:string;pythonVersion:string;devices:Device[];}
@Component({standalone:true,imports:[CommonModule],templateUrl:'./jobs.page.html',styleUrls:['./jobs.page.scss']}) export class JobsPage { jobs:Job[]=[];server:ServerStatus|null=null;loading=true;error='';serverError='';private http=inject(HttpClient);constructor(){this.reload();}reload():void{this.loading=true;this.error='';this.loadServerStatus();this.http.get<{jobs:Job[]}>('/api/jobs').subscribe({next:x=>{this.jobs=x.jobs;this.loading=false;},error:e=>{this.error=e.status===502?'ComfyUI is unavailable right now.':'Unable to load jobs.';this.loading=false;}});}loadServerStatus():void{this.serverError='';this.http.get<{status:ServerStatus}>('/api/server-status').subscribe({next:x=>this.server=x.status,error:()=>{this.server=null;this.serverError='Unable to read server status';}});}formatDuration(value:number|null):string{if(value===null)return '—';const seconds=value/1000;if(seconds<1)return `${Math.round(value)} ms`;if(seconds<60)return `${seconds.toFixed(1)} s`;return `${Math.floor(seconds/60)}m ${Math.round(seconds%60)}s`;}formatBytes(value:number):string{if(!value)return '—';return `${(value/1073741824).toFixed(1)} GB`;}isVideo(asset:Asset):boolean{return asset.type==='video';}}
@Component({standalone:true,imports:[CommonModule],templateUrl:'./jobs.page.html',styleUrls:['./jobs.page.scss']}) export class JobsPage { jobs:Job[]=[];server:ServerStatus|null=null;loading=true;error='';serverError='';private http=inject(HttpClient);constructor(){this.reload();}reload():void{this.loading=true;this.error='';this.loadServerStatus();this.http.get<{jobs:Job[]}>('/api/jobs').subscribe({next:x=>{this.jobs=x.jobs;this.loading=false;},error:e=>{this.error=e.status===502?'ComfyUI is unavailable right now.':'Unable to load jobs.';this.loading=false;}});}loadServerStatus():void{this.serverError='';this.http.get<{status:ServerStatus}>('/api/server-status').subscribe({next:x=>this.server=x.status,error:()=>{this.server=null;this.serverError='Unable to read server status';}});}formatDuration(value:number|null):string{if(value===null)return '—';const totalSeconds=Math.max(0,Math.round(value/1000));return `${Math.floor(totalSeconds/60)}m ${totalSeconds%60}s`;}formatBytes(value:number):string{if(!value)return '—';return `${(value/1073741824).toFixed(1)} GB`;}isVideo(asset:Asset):boolean{return asset.type==='video';}}