Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { EStatus, ProgressBarUIBase } from './progressBarUIBase.js';
|
|
|
|
export class ProgressBarUI extends ProgressBarUIBase {
|
|
htmlProgressSliderRef: HTMLDivElement;
|
|
htmlProgressLabelRef: HTMLDivElement;
|
|
currentStatus: EStatus;
|
|
timeStart: number;
|
|
currentProgress: number;
|
|
showProgressBarFlag: boolean;
|
|
|
|
constructor(
|
|
public override rootElement: HTMLElement,
|
|
public showSectionFlag: boolean,
|
|
private centerNode: () => void,
|
|
) {
|
|
super('crystools-progressBar-root', rootElement);
|
|
this.createDOM();
|
|
}
|
|
|
|
createDOM = (): void => {
|
|
this.rootElement.setAttribute('title', 'click to see the current working node');
|
|
this.rootElement.addEventListener('click', this.centerNode);
|
|
|
|
const progressBar = document.createElement('div');
|
|
progressBar.classList.add('crystools-progress-bar');
|
|
this.rootElement.append(progressBar);
|
|
|
|
const progressSlider = document.createElement('div');
|
|
this.htmlProgressSliderRef = progressSlider;
|
|
progressSlider.classList.add('crystools-slider');
|
|
progressBar.append(this.htmlProgressSliderRef);
|
|
|
|
const progressLabel = document.createElement('div');
|
|
progressLabel.classList.add('crystools-label');
|
|
progressLabel.innerHTML = '0%';
|
|
this.htmlProgressLabelRef = progressLabel;
|
|
progressBar.append(this.htmlProgressLabelRef);
|
|
};
|
|
|
|
// eslint-disable-next-line complexity
|
|
updateDisplay = (currentStatus: EStatus, timeStart: number, currentProgress: number): void => {
|
|
if (!(this.showSectionFlag && this.showProgressBarFlag)) {
|
|
return;
|
|
}
|
|
|
|
if (!(this.htmlProgressLabelRef && this.htmlProgressSliderRef)) {
|
|
console.error('htmlProgressLabelRef or htmlProgressSliderRef is undefined');
|
|
return;
|
|
}
|
|
|
|
// console.log('only if showSection and progressBar', timeStart, currentProgress);
|
|
|
|
this.currentStatus = currentStatus;
|
|
this.timeStart = timeStart;
|
|
this.currentProgress = currentProgress;
|
|
|
|
if (currentStatus === EStatus.executed) {
|
|
// finished
|
|
this.htmlProgressLabelRef.innerHTML = 'cached';
|
|
|
|
const timeElapsed = Date.now() - timeStart;
|
|
if (timeStart > 0 && timeElapsed > 0) {
|
|
this.htmlProgressLabelRef.innerHTML = new Date(timeElapsed).toISOString().substr(11, 8);
|
|
}
|
|
this.htmlProgressSliderRef.style.width = '0';
|
|
|
|
} else if (currentStatus === EStatus.execution_error) {
|
|
// an error occurred
|
|
this.htmlProgressLabelRef.innerHTML = 'ERROR';
|
|
this.htmlProgressSliderRef.style.backgroundColor = 'var(--error-text)';
|
|
|
|
} else if (currentStatus === EStatus.executing) {
|
|
// on going
|
|
this.htmlProgressLabelRef.innerHTML = `${currentProgress}%`;
|
|
this.htmlProgressSliderRef.style.width = this.htmlProgressLabelRef.innerHTML;
|
|
this.htmlProgressSliderRef.style.backgroundColor = 'green'; // by reset the color
|
|
}
|
|
|
|
};
|
|
|
|
public showSection = (value: boolean): void => {
|
|
this.showSectionFlag = value;
|
|
this.displaySection();
|
|
};
|
|
|
|
// remember it can't have more parameters because it is used on settings automatically
|
|
public showProgressBar = (value: boolean): void => {
|
|
this.showProgressBarFlag = value;
|
|
this.displaySection();
|
|
};
|
|
|
|
private displaySection = (): void => {
|
|
this.rootElement.style.display = (this.showSectionFlag && this.showProgressBarFlag) ? 'block' : 'none';
|
|
};
|
|
}
|