Fix: no-cache headers for static files, null guards in loadQueue/loadGallery, error boundaries in initializeApp, add paused to queue filter
This commit is contained in:
+16
@@ -19,6 +19,22 @@ import app.upscaler as upscaler
|
|||||||
|
|
||||||
app = FastAPI(title="AI Video Upscaler Dashboard")
|
app = FastAPI(title="AI Video Upscaler Dashboard")
|
||||||
|
|
||||||
|
# Middleware to prevent browser caching of static files (dev mode)
|
||||||
|
from starlette.middleware.base import BaseHTTPMiddleware
|
||||||
|
from starlette.requests import Request
|
||||||
|
|
||||||
|
class NoCacheStaticMiddleware(BaseHTTPMiddleware):
|
||||||
|
async def dispatch(self, request: Request, call_next):
|
||||||
|
response = await call_next(request)
|
||||||
|
path = request.url.path
|
||||||
|
if path.endswith(('.js', '.css', '.html')) or path == '/':
|
||||||
|
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
|
||||||
|
response.headers["Pragma"] = "no-cache"
|
||||||
|
response.headers["Expires"] = "0"
|
||||||
|
return response
|
||||||
|
|
||||||
|
app.add_middleware(NoCacheStaticMiddleware)
|
||||||
|
|
||||||
# CORS middleware for local development
|
# CORS middleware for local development
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
|
|||||||
+7
-7
@@ -1494,7 +1494,7 @@ async function loadQueue() {
|
|||||||
const jobs = await res.json();
|
const jobs = await res.json();
|
||||||
|
|
||||||
const displayJobs = jobs.filter(job =>
|
const displayJobs = jobs.filter(job =>
|
||||||
["queued", "analyzing", "extracting", "upscaling", "restoring_faces", "interpolating", "assembling", "completed", "failed", "cancelled", "interrupted"].includes(job.status)
|
["queued", "analyzing", "extracting", "upscaling", "restoring_faces", "interpolating", "assembling", "completed", "failed", "cancelled", "interrupted", "paused"].includes(job.status)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (displayJobs.length === 0) {
|
if (displayJobs.length === 0) {
|
||||||
@@ -1520,7 +1520,7 @@ async function loadQueue() {
|
|||||||
|
|
||||||
let metaHtml = `
|
let metaHtml = `
|
||||||
<span><i class="fa-solid fa-microchip"></i> Model: ${modelLabel} (${scaleLabel})</span>
|
<span><i class="fa-solid fa-microchip"></i> Model: ${modelLabel} (${scaleLabel})</span>
|
||||||
<span><i class="fa-solid fa-file-video"></i> Source: ${job.video_path.split('/').pop()}</span>
|
<span><i class="fa-solid fa-file-video"></i> Source: ${job.video_path ? job.video_path.split('/').pop() : 'Unknown'}</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let errorHtml = "";
|
let errorHtml = "";
|
||||||
@@ -2033,11 +2033,11 @@ async function loadUploadsBrowser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function initializeApp() {
|
async function initializeApp() {
|
||||||
await loadModels();
|
try { await loadModels(); } catch(e) { console.error("initializeApp: loadModels failed:", e); }
|
||||||
await checkActiveJobs();
|
try { await checkActiveJobs(); } catch(e) { console.error("initializeApp: checkActiveJobs failed:", e); }
|
||||||
await loadGallery(); // Load enhancement gallery at page load
|
try { await loadGallery(); } catch(e) { console.error("initializeApp: loadGallery failed:", e); }
|
||||||
await loadQueue(); // Load active jobs queue at page load
|
try { await loadQueue(); } catch(e) { console.error("initializeApp: loadQueue failed:", e); }
|
||||||
await loadUploadsBrowser(); // Load previously uploaded videos browser
|
try { await loadUploadsBrowser(); } catch(e) { console.error("initializeApp: loadUploadsBrowser failed:", e); }
|
||||||
|
|
||||||
// Load GPU Diagnostics
|
// Load GPU Diagnostics
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user