Initial read-only ComfyUI jobs portal
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<header class="topbar" *ngIf="user"><a routerLink="/jobs" class="brand">ComfyUI <span>Jobs</span></a><nav><a routerLink="/jobs">Remote jobs</a><button type="button" (click)="logout()">Sign out</button></nav></header><main class="shell"><router-outlet /></main>
|
||||
@@ -0,0 +1 @@
|
||||
.topbar{display:flex;align-items:center;justify-content:space-between;padding:1rem 5vw;border-bottom:1px solid #dce3ed;background:#fff}.brand{font-weight:800;color:#18283d;text-decoration:none}.brand span{color:#3b82f6}.topbar nav{display:flex;gap:1rem;align-items:center}.topbar a{color:#42526b;text-decoration:none}.topbar button{border:0;background:transparent;color:#42526b;cursor:pointer}.shell{max-width:1280px;margin:0 auto;padding:2rem 5vw}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { CommonModule } from '@angular/common'; import { Component,OnInit,inject } from '@angular/core'; import { Router,RouterLink,RouterOutlet } from '@angular/router'; import { AuthService,AuthUser } from './auth.service';
|
||||
@Component({selector:'cp-root',standalone:true,imports:[CommonModule,RouterOutlet,RouterLink],templateUrl:'./app.component.html',styleUrls:['./app.component.scss']}) export class AppComponent implements OnInit { user:AuthUser|null=null; private auth=inject(AuthService); private router=inject(Router); ngOnInit():void{this.auth.user$.subscribe(user=>this.user=user);this.auth.me().subscribe();} logout():void{this.auth.logout().subscribe(()=>this.router.navigateByUrl('/login'));} }
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ApplicationConfig, mergeApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
import { appConfig } from './app.config';
|
||||
|
||||
const serverConfig: ApplicationConfig = { providers: [provideServerRendering()] };
|
||||
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideAnimations } from '@angular/platform-browser/animations';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { routes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideAnimations(), provideHttpClient(), provideRouter(routes)],
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
import { Routes } from '@angular/router'; import { authGuard } from './auth.guard';
|
||||
export const routes: Routes = [{path:'',pathMatch:'full',redirectTo:'jobs'},{path:'login',loadComponent:()=>import('./pages/login.page').then(m=>m.LoginPage)},{path:'jobs',canActivate:[authGuard],loadComponent:()=>import('./pages/jobs.page').then(m=>m.JobsPage)},{path:'**',redirectTo:'jobs'}];
|
||||
@@ -0,0 +1,2 @@
|
||||
import { inject } from '@angular/core'; import { CanActivateFn,Router } from '@angular/router'; import { catchError,map,of } from 'rxjs'; import { AuthService } from './auth.service';
|
||||
export const authGuard:CanActivateFn=()=>inject(AuthService).me().pipe(map(user=>user?true:inject(Router).createUrlTree(['/login'])),catchError(()=>of(inject(Router).createUrlTree(['/login']))));
|
||||
@@ -0,0 +1,3 @@
|
||||
import { Injectable,inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { BehaviorSubject,Observable,map,tap } from 'rxjs';
|
||||
export interface AuthUser { username:string; displayName?:string; role:'admin'|'user'; }
|
||||
@Injectable({providedIn:'root'}) export class AuthService { private http=inject(HttpClient); private subject=new BehaviorSubject<AuthUser|null>(null); user$=this.subject.asObservable(); me():Observable<AuthUser|null>{return this.http.get<{user:AuthUser|null}>('/api/me').pipe(map(x=>x.user),tap(x=>this.subject.next(x)));} login(username:string,password:string,remember:boolean):Observable<AuthUser>{return this.http.post<{user:AuthUser}>('/api/login',{username,password,remember}).pipe(map(x=>x.user),tap(x=>this.subject.next(x)));} logout():Observable<void>{return this.http.post<void>('/api/logout',{}).pipe(tap(()=>this.subject.next(null)));} }
|
||||
@@ -0,0 +1 @@
|
||||
<section class="jobs"><div class="heading"><div><div class="eyebrow">REMOTE JOBS</div><h1>Job monitor</h1><p>Read-only view of the remote ComfyUI queue and history.</p></div><button class="refresh" type="button" (click)="reload()">Refresh</button></div><div class="notice" *ngIf="error">{{error}}</div><div class="loading" *ngIf="loading">Loading remote jobs…</div><div class="empty" *ngIf="!loading&&!error&&!jobs.length">No remote jobs were returned.</div><div class="grid"><article class="job" *ngFor="let job of jobs"><div class="jobhead"><h2>{{job.title}}</h2><span [class]="'status '+job.status">{{job.status}}</span></div><div class="meta"><span>ID {{job.promptId}}</span><span>{{job.outputCount}} output{{job.outputCount===1?'':'s'}}</span></div><div class="assets" *ngIf="job.assets.length"><span *ngFor="let asset of job.assets">{{asset.filename}}</span></div></article></div></section>
|
||||
@@ -0,0 +1 @@
|
||||
.heading{display:flex;justify-content:space-between;align-items:start;gap:1rem;margin-bottom:2rem}.eyebrow{font-size:.75rem;font-weight:800;letter-spacing:.12em;color:#3b82f6}h1{margin:.35rem 0}.heading p{color:#63738a}.refresh{padding:.65rem 1rem;border:1px solid #cbd5e1;border-radius:8px;background:#fff;cursor:pointer}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:1rem}.job{background:#fff;border:1px solid #dce3ed;border-radius:14px;padding:1.25rem}.jobhead{display:flex;justify-content:space-between;gap:1rem}.job h2{font-size:1rem;margin:0;color:#18283d}.status{font-size:.75rem;border-radius:999px;padding:.25rem .55rem;background:#e8eef7}.status.completed{background:#dcfce7;color:#166534}.status.failed{background:#fee2e2;color:#991b1b}.meta{display:flex;gap:1rem;color:#63738a;font-size:.8rem;margin-top:.8rem}.assets{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:1rem}.assets span{background:#f1f5f9;border-radius:6px;padding:.25rem .4rem;font-size:.75rem}.notice{padding:1rem;background:#fff1f0;color:#b42318;border-radius:10px}.loading,.empty{padding:3rem;text-align:center;color:#63738a}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { CommonModule } from '@angular/common'; import { Component,inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; interface Job{promptId:string;title:string;status:string;outputCount:number;assets:Array<{filename:string}>;}
|
||||
@Component({standalone:true,imports:[CommonModule],templateUrl:'./jobs.page.html',styleUrls:['./jobs.page.scss']}) export class JobsPage { jobs:Job[]=[];loading=true;error='';private http=inject(HttpClient);constructor(){this.reload();}reload():void{this.loading=true;this.error='';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;}});}}
|
||||
@@ -0,0 +1 @@
|
||||
<section class="login"><div class="panel"><div class="eyebrow">COMFYUI JOBS</div><h1>Sign in</h1><p>View remote ComfyUI jobs and their current output state.</p><form (ngSubmit)="submit()"><label>Username<input name="username" [(ngModel)]="username" autocomplete="username" required></label><label>Password<input name="password" type="password" [(ngModel)]="password" autocomplete="current-password" required></label><label class="remember"><input type="checkbox" name="remember" [(ngModel)]="remember"> Remember me</label><button type="submit">Sign in</button><div class="error" *ngIf="error">{{error}}</div></form></div></section>
|
||||
@@ -0,0 +1 @@
|
||||
.login{min-height:70vh;display:grid;place-items:center}.panel{width:min(100%,420px);padding:2.5rem;background:#fff;border:1px solid #dce3ed;border-radius:20px;box-shadow:0 18px 50px #233b5d18}.eyebrow{font-size:.75rem;font-weight:800;letter-spacing:.12em;color:#3b82f6}.panel h1{margin:.4rem 0}.panel p{color:#63738a}.panel form{display:grid;gap:1rem}.panel label{display:grid;gap:.4rem;color:#42526b;font-weight:600}.panel input:not([type=checkbox]){padding:.75rem;border:1px solid #cbd5e1;border-radius:8px;font:inherit}.remember{display:flex!important;align-items:center;font-weight:400!important}.panel button{padding:.8rem;border:0;border-radius:8px;background:#2563eb;color:white;font-weight:700}.error{color:#b42318;background:#fff1f0;padding:.7rem;border-radius:8px}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { CommonModule } from '@angular/common'; import { Component,inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { Router } from '@angular/router'; import { AuthService } from '../auth.service';
|
||||
@Component({standalone:true,imports:[CommonModule,FormsModule],templateUrl:'./login.page.html',styleUrls:['./login.page.scss']}) export class LoginPage { username='';password='';remember=true;error='';private auth=inject(AuthService);private router=inject(Router);submit():void{this.error='';this.auth.login(this.username,this.password,this.remember).subscribe({next:()=>this.router.navigateByUrl('/jobs'),error:()=>this.error='Invalid username or password.'});} }
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>ComfyUI Jobs</title><base href="/"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><cp-root></cp-root></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
export { config } from './app/app.config.server';
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'zone.js';
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
bootstrapApplication(AppComponent, appConfig).catch(console.error);
|
||||
@@ -0,0 +1 @@
|
||||
@use './styles/theme'; html{overflow-x:clip}body{margin:0;background:#f5f7fb;color:#18283d;font-family:Inter,'Segoe UI',system-ui,sans-serif}button,input{font:inherit}
|
||||
@@ -0,0 +1,86 @@
|
||||
$primary: #5b6cff;
|
||||
$secondary: #6c757d;
|
||||
$body-bg: #f8f9fc;
|
||||
$body-color: #1f2937;
|
||||
$border-radius: 0.25rem;
|
||||
$border-radius-sm: 0.2rem;
|
||||
$border-radius-lg: 0.35rem;
|
||||
$border-radius-xl: 0.5rem;
|
||||
$border-radius-xxl: 0.75rem;
|
||||
$card-border-radius: 0.25rem;
|
||||
$input-border-radius: 0.25rem;
|
||||
$btn-border-radius: 0.25rem;
|
||||
$nav-pills-border-radius: 0.2rem;
|
||||
$nav-link-padding-y: 0.6rem;
|
||||
$nav-link-padding-x: 0.9rem;
|
||||
$enable-shadows: true;
|
||||
|
||||
@import 'bootstrap/scss/functions';
|
||||
@import 'bootstrap/scss/variables';
|
||||
@import 'bootstrap/scss/variables-dark';
|
||||
@import 'bootstrap/scss/maps';
|
||||
@import 'bootstrap/scss/mixins';
|
||||
@import 'bootstrap/scss/root';
|
||||
@import 'bootstrap/scss/reboot';
|
||||
@import 'bootstrap/scss/type';
|
||||
@import 'bootstrap/scss/images';
|
||||
@import 'bootstrap/scss/containers';
|
||||
@import 'bootstrap/scss/grid';
|
||||
@import 'bootstrap/scss/forms';
|
||||
@import 'bootstrap/scss/buttons';
|
||||
@import 'bootstrap/scss/nav';
|
||||
@import 'bootstrap/scss/navbar';
|
||||
@import 'bootstrap/scss/badge';
|
||||
@import 'bootstrap/scss/card';
|
||||
@import 'bootstrap/scss/close';
|
||||
@import 'bootstrap/scss/modal';
|
||||
@import 'bootstrap/scss/offcanvas';
|
||||
@import 'bootstrap/scss/dropdown';
|
||||
@import '@splidejs/splide/dist/css/splide.min.css';
|
||||
@import 'bootstrap/scss/helpers';
|
||||
@import 'bootstrap/scss/utilities';
|
||||
@import 'bootstrap/scss/utilities/api';
|
||||
|
||||
:root {
|
||||
--cp-sidebar-bg: #243244;
|
||||
--cp-sidebar-muted: rgba(255, 255, 255, 0.65);
|
||||
--cp-sidebar-active-bg: rgba(255, 255, 255, 0.14);
|
||||
--cp-sidebar-active-color: #fff;
|
||||
--cp-shell-bg: #f8f9fc;
|
||||
}
|
||||
|
||||
html[data-theme='dark'] { color-scheme: dark; }
|
||||
body { background: var(--cp-shell-bg); font-family: 'Ubuntu', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
|
||||
.shell { min-height: 100vh; }
|
||||
.sidebar { background: var(--cp-sidebar-bg); }
|
||||
.sidebar .nav-link { color: var(--cp-sidebar-muted); }
|
||||
.sidebar .nav-link.active, .sidebar .nav-link:hover { color: var(--cp-sidebar-active-color); background: var(--cp-sidebar-active-bg); }
|
||||
.content-panel { border: 1px solid rgba(15,23,42,.08); border-radius: var(--bs-border-radius-sm); box-shadow: 0 0.75rem 1.5rem rgba(15,23,42,.06); }
|
||||
|
||||
.auth-shell {
|
||||
min-height: calc(100vh - 2rem);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.auth-panel {
|
||||
width: min(100%, 30rem);
|
||||
}
|
||||
|
||||
.auth-mark {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
background: var(--bs-primary-bg-subtle);
|
||||
color: var(--bs-primary);
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.auth-shell {
|
||||
min-height: 100vh;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.auth-panel {
|
||||
width: min(100%, 34rem);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user