Initial read-only ComfyUI jobs portal
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
name: Deploy ComfyUI Jobs
|
||||
on:
|
||||
push:
|
||||
branches: [develop, qa, main]
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
- name: Deploy selected environment
|
||||
shell: bash
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
GITEA_REF: ${{ gitea.ref }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
case "$GITEA_REF" in
|
||||
refs/heads/develop) TARGET_DIR=/mnt/appdata/dev/ComfyUiPortal; COMPOSE_FILE=docker-compose.dev.yml; PROJECT=comfyuiportal-next-dev; PORT=7002; HEALTH_URL=http://192.168.1.15:7002; BRANCH=develop ;;
|
||||
refs/heads/qa) TARGET_DIR=/mnt/appdata/qa/ComfyUiPortal; COMPOSE_FILE=docker-compose.qa.yml; PROJECT=comfyuiportal-next-qa; PORT=6002; HEALTH_URL=http://192.168.1.15:6002; BRANCH=qa ;;
|
||||
refs/heads/main) TARGET_DIR=/mnt/appdata/prod/ComfyUiPortal; COMPOSE_FILE=docker-compose.prod.yml; PROJECT=comfyuiportal-next-prod; PORT=5002; HEALTH_URL=http://192.168.1.15:5002; BRANCH=main ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
|
||||
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
|
||||
set -Eeuo pipefail
|
||||
mkdir -p '$TARGET_DIR'
|
||||
if [ ! -d '$TARGET_DIR/.git' ]; then git clone --branch '$BRANCH' --single-branch '$REPO_URL' '$TARGET_DIR'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL' && GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH' && git reset --hard 'origin/$BRANCH' && git clean -fdx; fi
|
||||
cd '$TARGET_DIR'
|
||||
docker ps -q --filter publish=$PORT | xargs -r docker rm -f
|
||||
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' down --remove-orphans || true
|
||||
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' up -d --build
|
||||
"
|
||||
for attempt in 1 2 3 4 5 6; do curl --fail --silent --show-error --max-time 15 "$HEALTH_URL/api/health" && exit 0 || sleep 5; done
|
||||
exit 1
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Test and build ComfyUI Jobs
|
||||
on:
|
||||
push:
|
||||
branches: [develop, qa, main]
|
||||
pull_request:
|
||||
branches: [develop, qa, main]
|
||||
jobs:
|
||||
test-build:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
- run: python3 scripts/verify-branch-port-mapping.py .
|
||||
- run: npm ci --include=dev
|
||||
- run: npm test
|
||||
- run: npm run lint
|
||||
- run: npm run build
|
||||
@@ -0,0 +1,7 @@
|
||||
node_modules/
|
||||
.angular/
|
||||
frontend/dist/
|
||||
out-tsc/
|
||||
data/
|
||||
.playwright-browsers/
|
||||
*.log
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install --include=dev
|
||||
COPY . .
|
||||
RUN npm run build:frontend
|
||||
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=build /app .
|
||||
EXPOSE 7002
|
||||
CMD ["node", "server.js"]
|
||||
@@ -0,0 +1,16 @@
|
||||
# ComfyUI Jobs
|
||||
|
||||
The next ComfyUI portal is intentionally limited to authenticated, read-only remote job monitoring. It does not expose prompt submission, workflow authoring, imports, or admin mutation routes.
|
||||
|
||||
## Local development
|
||||
|
||||
```sh
|
||||
npm ci
|
||||
ADMIN_USERNAME=admin ADMIN_PASSWORD='set-locally' npm run dev
|
||||
```
|
||||
|
||||
The first run seeds `data/users.json` from `ADMIN_USERNAME` and `ADMIN_PASSWORD`; subsequent runs use the persisted hashed record. Do not commit `data/` or credentials.
|
||||
|
||||
## Deployment
|
||||
|
||||
Gitea Actions deploys `develop`, `qa`, and `main` to the existing ComfyUiPortal target directories and preserves the existing 7002/6002/5002 port contract. On first startup of a fresh data directory, provide `ADMIN_USERNAME` and `ADMIN_PASSWORD` in the deployment host environment. Existing target data is retained during repository cutover.
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"projects": {
|
||||
"comfy-uiportal-frontend": {
|
||||
"projectType": "application",
|
||||
"root": "frontend",
|
||||
"sourceRoot": "frontend/src",
|
||||
"prefix": "cp",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "frontend/dist/browser",
|
||||
"index": "frontend/src/index.html",
|
||||
"main": "frontend/src/main.ts",
|
||||
"polyfills": [],
|
||||
"tsConfig": "frontend/tsconfig.app.json",
|
||||
"assets": [],
|
||||
"styles": ["frontend/src/styles.scss"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"namedChunks": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"builder": "@angular-devkit/build-angular:server",
|
||||
"options": {
|
||||
"outputPath": "frontend/dist/server",
|
||||
"main": "frontend/src/main.server.ts",
|
||||
"tsConfig": "frontend/tsconfig.server.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
container_name: comfy-uiportal-dev
|
||||
environment:
|
||||
PORT: 7002
|
||||
BRANCH_NAME: develop
|
||||
APP_DATA_DIR: /mnt/appdata/dev/ComfyUiPortal/data
|
||||
ports:
|
||||
- "7002:7002"
|
||||
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
container_name: comfy-uiportal-next-prod
|
||||
environment:
|
||||
PORT: 5002
|
||||
BRANCH_NAME: main
|
||||
APP_DATA_DIR: /mnt/appdata/prod/ComfyUiPortal/data
|
||||
ADMIN_USERNAME: ${ADMIN_USERNAME:-}
|
||||
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-}
|
||||
ports:
|
||||
- "5002:5002"
|
||||
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
container_name: comfy-uiportal-next-qa
|
||||
environment:
|
||||
PORT: 6002
|
||||
BRANCH_NAME: qa
|
||||
APP_DATA_DIR: /mnt/appdata/qa/ComfyUiPortal/data
|
||||
ADMIN_USERNAME: ${ADMIN_USERNAME:-}
|
||||
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-}
|
||||
ports:
|
||||
- "6002:6002"
|
||||
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
image: comfy-uiportal:${BRANCH_NAME:-main}
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ${APP_DATA_DIR:-./data}:/app/data
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": { "outDir": "../out-tsc/app", "types": [] },
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": { "outDir": "../out-tsc/server", "types": ["node"] },
|
||||
"files": ["src/main.server.ts"],
|
||||
"include": ["src/**/*.d.ts"]
|
||||
}
|
||||
Generated
+14987
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "comfy-uiportal-next",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"description": "SSR Angular 20 Bootstrap 5 portal shell",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"build:frontend": "node ./node_modules/@angular/cli/bin/ng.js build --configuration production && node ./node_modules/@angular/cli/bin/ng.js run comfy-uiportal-frontend:server",
|
||||
"build": "npm run build:frontend",
|
||||
"lint": "tsc -p tsconfig.json --noEmit",
|
||||
"dev": "npm run build:frontend && node server.js",
|
||||
"start": "node server.js",
|
||||
"test": "node --test server.test.js",
|
||||
"test:playwright": "node ./scripts/setup-playwright-runtime.js && playwright test --config=playwright.config.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "^20.3.0",
|
||||
"@angular/common": "^20.3.0",
|
||||
"@angular/compiler": "^20.3.0",
|
||||
"@angular/core": "^20.3.0",
|
||||
"@angular/forms": "^20.3.0",
|
||||
"@angular/platform-browser": "^20.3.0",
|
||||
"@angular/platform-browser-dynamic": "^20.3.0",
|
||||
"@angular/platform-server": "^20.3.19",
|
||||
"@angular/router": "^20.3.0",
|
||||
"@angular/ssr": "^20.3.24",
|
||||
"@fortawesome/fontawesome-free": "^7.2.0",
|
||||
"@splidejs/splide": "^4.1.4",
|
||||
"bootstrap": "^5.3.3",
|
||||
"express": "^5.2.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"sharp": "^0.34.5",
|
||||
"tslib": "^2.8.1",
|
||||
"vanilla-jsoneditor": "^3.12.0",
|
||||
"zone.js": "^0.15.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^20.3.24",
|
||||
"@angular/cli": "^20.3.24",
|
||||
"@angular/compiler-cli": "^20.3.19",
|
||||
"@playwright/test": "^1.60.0",
|
||||
"typescript": "^5.9.3",
|
||||
"ws": "^8.18.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
root = Path(sys.argv[1] if len(sys.argv) > 1 else ".")
|
||||
expected = {"docker-compose.dev.yml": "7002:7002", "docker-compose.qa.yml": "6002:6002", "docker-compose.prod.yml": "5002:5002"}
|
||||
for filename, mapping in expected.items():
|
||||
contents = (root / filename).read_text()
|
||||
if mapping not in contents:
|
||||
raise SystemExit(f"{filename} is missing {mapping}")
|
||||
print("branch/port mapping verified")
|
||||
@@ -0,0 +1,35 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const app = express();
|
||||
const port = Number(process.env.PORT || 7002);
|
||||
const dataDir = path.join(__dirname, 'data');
|
||||
const usersPath = path.join(dataDir, 'users.json');
|
||||
const browserDir = path.join(__dirname, 'frontend', 'dist', 'browser');
|
||||
const indexHtml = path.join(browserDir, 'index.html');
|
||||
const comfyBase = String(process.env.COMFYUI_URL || 'http://127.0.0.1:8188').replace(/\/$/, '');
|
||||
app.use(express.json({ limit: '1mb' }));
|
||||
function readJson(file, fallback) { try { return JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return fallback; } }
|
||||
function writeJson(file, value) { fs.mkdirSync(dataDir, { recursive: true }); fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 }); }
|
||||
function hashPassword(password, salt) { return crypto.pbkdf2Sync(String(password || ''), String(salt || ''), 120000, 32, 'sha256').toString('hex'); }
|
||||
function users() { const stored = readJson(usersPath, []); if (Array.isArray(stored) && stored.length) return stored; const username = String(process.env.ADMIN_USERNAME || '').trim(); const password = String(process.env.ADMIN_PASSWORD || ''); if (!username || !password) return []; const salt = crypto.randomBytes(16).toString('hex'); const seeded = [{ id: 'user_admin', username, displayName: username, role: 'admin', active: true, passwordSalt: salt, passwordHash: hashPassword(password, salt) }]; writeJson(usersPath, seeded); return seeded; }
|
||||
function cookies(req) { return Object.fromEntries(String(req.headers.cookie || '').split(';').map((part) => part.trim()).filter(Boolean).map((part) => { const [key, ...rest] = part.split('='); return [key, decodeURIComponent(rest.join('='))]; })); }
|
||||
function currentUser(req) { const username = cookies(req).cp_auth; const user = users().find((item) => item.username === username && item.active !== false); return user ? { id: user.id, username: user.username, displayName: user.displayName, role: user.role } : null; }
|
||||
function requireUser(req, res) { const user = currentUser(req); if (!user) { res.status(401).json({ error: 'Unauthorized' }); return null; } return user; }
|
||||
function comfyUrl(endpoint) { return `${comfyBase}${endpoint.startsWith('/') ? endpoint : `/${endpoint}`}`; }
|
||||
async function comfyJson(endpoint) { const response = await fetch(comfyUrl(endpoint)); if (!response.ok) throw new Error(`ComfyUI returned HTTP ${response.status}`); return response.json(); }
|
||||
function statusFromHistory(entry) { const status = entry?.status || {}; const failed = Array.isArray(status.messages) && status.messages.some((message) => String(message?.[0] || '').toLowerCase().includes('error')); return failed ? 'failed' : status.completed ? 'completed' : entry ? 'running' : 'queued'; }
|
||||
function jobFromHistory(promptId, entry) { const outputs = Object.values(entry?.outputs || {}); const assets = outputs.flatMap((output) => [...(output?.images || []), ...(output?.gifs || []), ...(output?.videos || [])]).filter((asset) => asset?.filename); return { promptId, title: entry?.prompt?.extra_data?.title || `ComfyUI job ${promptId}`, status: statusFromHistory(entry), queuedAt: entry?.status?.messages?.[0]?.[1] || '', outputCount: assets.length, assets }; }
|
||||
async function listJobs() { const history = await comfyJson('/history'); return Object.entries(history || {}).map(([promptId, entry]) => jobFromHistory(promptId, entry)).sort((a, b) => String(b.promptId).localeCompare(String(a.promptId))); }
|
||||
app.get('/api/health', (_req, res) => res.json({ ok: true, service: 'comfyui-portal-next' }));
|
||||
app.post('/api/login', (req, res) => { const user = users().find((item) => item.username === String(req.body?.username || '').trim()); if (!user || !user.active || hashPassword(req.body?.password, user.passwordSalt) !== user.passwordHash) return res.status(401).json({ error: 'Invalid credentials' }); const maxAge = req.body?.remember ? '; Max-Age=2592000' : ''; res.setHeader('Set-Cookie', `cp_auth=${encodeURIComponent(user.username)}; Path=/; HttpOnly; SameSite=Lax${maxAge}`); res.json({ user: { id: user.id, username: user.username, displayName: user.displayName, role: user.role } }); });
|
||||
app.post('/api/logout', (_req, res) => { res.setHeader('Set-Cookie', 'cp_auth=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0'); res.json({ ok: true }); });
|
||||
app.get('/api/me', (req, res) => res.json({ user: currentUser(req) }));
|
||||
app.get('/api/jobs', async (req, res) => { if (!requireUser(req, res)) return; try { res.json({ jobs: await listJobs() }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI jobs' }); } });
|
||||
app.get('/api/jobs/:promptId', async (req, res) => { if (!requireUser(req, res)) return; try { const history = await comfyJson(`/history/${encodeURIComponent(req.params.promptId)}`); const entry = history?.[req.params.promptId] || history; if (!entry) return res.status(404).json({ error: 'Job not found' }); res.json({ job: jobFromHistory(req.params.promptId, entry) }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI job' }); } });
|
||||
app.use((req, res, next) => { if (req.path.startsWith('/login') || req.path.startsWith('/api/')) return next(); if (!currentUser(req)) return res.redirect('/login'); next(); });
|
||||
app.use(express.static(browserDir, { index: false }));
|
||||
app.use((_req, res) => { if (!fs.existsSync(indexHtml)) return res.status(500).send('Build output missing.'); res.type('html').send(fs.readFileSync(indexHtml, 'utf8')); });
|
||||
if (require.main === module) app.listen(port, () => console.log(`ComfyUiPortal Next listening on ${port}`));
|
||||
module.exports = { app, jobFromHistory, statusFromHistory };
|
||||
@@ -0,0 +1,12 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { jobFromHistory, statusFromHistory } = require('./server');
|
||||
|
||||
test('maps completed ComfyUI history into a read-only job summary', () => {
|
||||
const job = jobFromHistory('abc123', { prompt: { extra_data: { title: 'Portrait' } }, status: { completed: true }, outputs: { '7': { images: [{ filename: 'result.png' }] } } });
|
||||
assert.deepEqual(job, { promptId: 'abc123', title: 'Portrait', status: 'completed', queuedAt: '', outputCount: 1, assets: [{ filename: 'result.png' }] });
|
||||
});
|
||||
|
||||
test('classifies failed history without exposing mutation paths', () => {
|
||||
assert.equal(statusFromHistory({ status: { messages: [['execution_error', {}]] } }), 'failed');
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"paths": {}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user