Same pattern as GameStream (commit 6a46007), adapted for CollabTable being genuinely multi-user (not single-admin): admin user management (list/create/update/delete, role reassignment, superadmin protection) is fully proxied to AuthGuard, which already enforces the same rules CollabTable checked locally. Cookie forwarding, no local session token, AUTHGUARD_URL optional (unset = auth fully disabled), transport failures always surface as errAuthGuardUnavailable rather than ever letting a request through - proven with live tests against a closed socket. CollabTable's device-sync API token feature (separate from browser sessions) is deliberately left local-only regardless of AUTHGUARD_URL, keyed by a new currentUserID helper (AuthGuard's id when enabled, the shared placeholder id 0 when disabled) - a real, functional token either way, not faked data. Real bug found and fixed: api_tokens.user_id had a hard FK into the local auth_users table, which would reject new tokens once accounts stop being written locally. Dropped the now-invalid FK. Known, accepted gap (same as GameStream): self-service profile editing for non-admin accounts is lost, since AuthGuard only exposes an admin endpoint, no self-edit. TOTP QR issuer branding now comes from AuthGuard rather than CollabTable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
134 lines
5.2 KiB
JavaScript
134 lines
5.2 KiB
JavaScript
// NCProgressBar - shared horizontal progress bar component
|
|
// Served at /shared/js/ui/progress-bar.js by applySharedBase.
|
|
//
|
|
// The 'progress-shimmer' CSS class (defined in index.css) drives the animated
|
|
// gradient fill used during indeterminate/in-progress states.
|
|
//
|
|
// API:
|
|
// const {track, fill} = NCProgressBar.create([opts]) -> builds DOM pair (NOT inserted)
|
|
// NCProgressBar.set(fill, pct, [opts]) -> set fill to pct (0-100); opts.shimmer=bool
|
|
// NCProgressBar.setShimmer(fill, on) -> add/remove 'progress-shimmer' class
|
|
//
|
|
// create() opts:
|
|
// height : CSS height utility class from index.css (default 'h-2')
|
|
// rounded : CSS rounded utility class from index.css (default 'rounded-full')
|
|
// trackClass : CSS bg utility class for the track (default 'bg-slate-800')
|
|
// fillClass : CSS bg utility class for the fill (default 'bg-[var(--color-action)]')
|
|
// shimmer : bool - start with shimmer on (default false)
|
|
|
|
(function (global) {
|
|
'use strict';
|
|
|
|
/**
|
|
* Build a progress-bar track+fill pair without inserting into DOM.
|
|
* @param {object} [opts]
|
|
* @returns {{ track: HTMLElement, fill: HTMLElement }}
|
|
*/
|
|
function create(opts) {
|
|
opts = opts || {};
|
|
var height = opts.height || 'h-2';
|
|
var rounded = opts.rounded || 'rounded-full';
|
|
var trackCls = opts.trackClass || 'bg-slate-800';
|
|
var fillCls = opts.fillClass || 'bg-[var(--color-action)]';
|
|
var shimmer = !!opts.shimmer;
|
|
|
|
var track = document.createElement('div');
|
|
track.className = [height, rounded, trackCls, 'overflow-hidden'].join(' ');
|
|
|
|
var fill = document.createElement('div');
|
|
fill.className = ['h-full', rounded, fillCls, 'transition-[width]', 'duration-300'].join(' ');
|
|
if (shimmer) fill.classList.add('progress-shimmer');
|
|
fill.style.width = '0%';
|
|
|
|
track.appendChild(fill);
|
|
return { track: track, fill: fill };
|
|
}
|
|
|
|
/**
|
|
* Toggle the shimmer animation on a fill element.
|
|
* @param {Element} fillEl
|
|
* @param {boolean} on
|
|
*/
|
|
function setShimmer(fillEl, on) {
|
|
if (!fillEl) return;
|
|
if (on) fillEl.classList.add('progress-shimmer');
|
|
else fillEl.classList.remove('progress-shimmer');
|
|
}
|
|
|
|
/**
|
|
* Set the fill width percentage (clamped 0-100).
|
|
* @param {Element} fillEl
|
|
* @param {number} pct 0-100
|
|
* @param {object} [opts] opts.shimmer - if boolean, also toggle shimmer
|
|
*/
|
|
function set(fillEl, pct, opts) {
|
|
if (!fillEl) return;
|
|
var clamped = Math.max(0, Math.min(100, Number(pct) || 0));
|
|
fillEl.style.width = clamped + '%';
|
|
if (opts && typeof opts.shimmer === 'boolean') setShimmer(fillEl, opts.shimmer);
|
|
}
|
|
|
|
/**
|
|
* Renders a highly styled processing progress bar into the specified container.
|
|
* Useful for showing download or generation progress with a label.
|
|
* @param {HTMLElement} container - DOM element to render into
|
|
* @param {object} [opts] - opts.barId, opts.labelId, opts.metaId, opts.statusDotId, opts.statusTextId, opts.statusText
|
|
*/
|
|
function renderProcessingContainer(container, opts) {
|
|
if (!container) return;
|
|
opts = opts || {};
|
|
var barId = opts.barId || 'processingProgressBar';
|
|
var labelId = opts.labelId || 'processingProgressLabel';
|
|
var metaId = opts.metaId || '';
|
|
var statusDotId = opts.statusDotId || '';
|
|
var statusTextId = opts.statusTextId || '';
|
|
var statusText = opts.statusText || 'ComfyUI: checking\u2026';
|
|
|
|
var metaHtml = metaId
|
|
? '<div id="' +
|
|
metaId +
|
|
'" class="mt-2 text-center text-xs text-[var(--color-text-dim)] empty:hidden"></div>'
|
|
: '';
|
|
|
|
var barTrackHtml = `<div class="relative h-5 w-full bg-slate-900 overflow-hidden rounded-md border border-slate-800 shadow-inner">
|
|
<div
|
|
id="${barId}"
|
|
class="h-full w-0 bg-[var(--color-action)] transition-[width] duration-200 ease-in-out"
|
|
></div>
|
|
<div
|
|
id="${labelId}"
|
|
class="pointer-events-none absolute inset-0 flex items-center justify-center text-xs font-bold uppercase tracking-widest text-[#fff] [text-shadow:0_1px_2px_rgba(0,0,0,0.8),_0_0_4px_rgba(0,0,0,0.8)] leading-none"
|
|
>
|
|
Idle
|
|
</div>
|
|
</div>`;
|
|
|
|
var statusHtml = statusDotId
|
|
? `<div class="flex items-center gap-1.5 text-[var(--font-size-xs)] text-[var(--color-text-dim)]">
|
|
<span id="${statusDotId}" class="inline-block h-2 w-2 rounded-full bg-slate-600 flex-shrink-0 transition-colors duration-300" aria-hidden="true"></span>
|
|
<span id="${statusTextId}">${statusText}</span>
|
|
</div>`
|
|
: '';
|
|
|
|
var innerHtml = statusDotId
|
|
? `<div class="flex flex-col gap-2">${barTrackHtml}${statusHtml}</div>`
|
|
: barTrackHtml;
|
|
|
|
container.innerHTML = `
|
|
<div class="rounded-lg border border-slate-800 bg-slate-900 overflow-hidden">
|
|
<div class="p-4 max-[480px]:p-3">
|
|
${innerHtml}
|
|
${metaHtml}
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
global.NCProgressBar = {
|
|
create: create,
|
|
set: set,
|
|
setShimmer: setShimmer,
|
|
renderProcessingContainer: renderProcessingContainer,
|
|
};
|
|
})(window);
|