mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
@@ -5,7 +5,7 @@ import { api } from "./api";
|
|||||||
import { defaultGraph } from "./defaultGraph.js";
|
import { defaultGraph } from "./defaultGraph.js";
|
||||||
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo";
|
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo";
|
||||||
import { addDomClippingSetting } from "./domWidget";
|
import { addDomClippingSetting } from "./domWidget";
|
||||||
import { createImageHost, calculateImageGrid } from "./ui/imagePreview.js"
|
import { createImageHost, calculateImageGrid } from "./ui/imagePreview"
|
||||||
import type { ComfyExtension } from "/types/comfy";
|
import type { ComfyExtension } from "/types/comfy";
|
||||||
import type { IWidget, LGraph, LGraphCanvas, LGraphNode } from "/types/litegraph";
|
import type { IWidget, LGraph, LGraphCanvas, LGraphNode } from "/types/litegraph";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { api } from "./api";
|
import { api } from "./api";
|
||||||
import { ComfyDialog as _ComfyDialog } from "./ui/dialog.js";
|
import { ComfyDialog as _ComfyDialog } from "./ui/dialog";
|
||||||
import { toggleSwitch } from "./ui/toggleSwitch.js";
|
import { toggleSwitch } from "./ui/toggleSwitch";
|
||||||
import { ComfySettingsDialog } from "./ui/settings.js";
|
import { ComfySettingsDialog } from "./ui/settings";
|
||||||
import { ComfyApp, app } from "./app";
|
import { ComfyApp, app } from "./app";
|
||||||
|
|
||||||
export const ComfyDialog = _ComfyDialog;
|
export const ComfyDialog = _ComfyDialog;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { $el } from "../ui";
|
import { $el } from "../ui";
|
||||||
|
|
||||||
export class ComfyDialog {
|
export class ComfyDialog {
|
||||||
|
element: HTMLElement;
|
||||||
|
textElement: HTMLElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.element = $el("div.comfy-modal", { parent: document.body }, [
|
this.element = $el("div.comfy-modal", { parent: document.body }, [
|
||||||
$el("div.comfy-modal-content", [$el("p", { $: (p) => (this.textElement = p) }), ...this.createButtons()]),
|
$el("div.comfy-modal-content", [$el("p", { $: (p) => (this.textElement = p) }), ...this.createButtons()]),
|
||||||
@@ -50,7 +50,7 @@ export function createImageHost(node) {
|
|||||||
if (elH < 190) {
|
if (elH < 190) {
|
||||||
elH = 190;
|
elH = 190;
|
||||||
}
|
}
|
||||||
el.style.setProperty("--comfy-widget-min-height", elH);
|
el.style.setProperty("--comfy-widget-min-height", elH.toString());
|
||||||
} else {
|
} else {
|
||||||
el.style.setProperty("--comfy-widget-min-height", null);
|
el.style.setProperty("--comfy-widget-min-height", null);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { $el } from "../ui";
|
import { $el } from "../ui";
|
||||||
import { api } from "../api";
|
import { api } from "../api";
|
||||||
import { ComfyDialog } from "./dialog.js";
|
import { ComfyDialog } from "./dialog";
|
||||||
import type { ComfyApp } from "../app";
|
import type { ComfyApp } from "../app";
|
||||||
|
|
||||||
/* The Setting entry stored in `ComfySettingsDialog` */
|
/* The Setting entry stored in `ComfySettingsDialog` */
|
||||||
|
|||||||
@@ -6,14 +6,16 @@ import { $el } from "../ui";
|
|||||||
/**
|
/**
|
||||||
* Creates a toggle switch element
|
* Creates a toggle switch element
|
||||||
* @param { string } name
|
* @param { string } name
|
||||||
* @param { Array<string | ToggleSwitchItem } items
|
* @param { Array<string> | ToggleSwitchItem } items
|
||||||
* @param { Object } [opts]
|
* @param { Object } [opts]
|
||||||
* @param { (e: { item: ToggleSwitchItem, prev?: ToggleSwitchItem }) => void } [opts.onChange]
|
* @param { (e: { item: ToggleSwitchItem, prev?: ToggleSwitchItem }) => void } [opts.onChange]
|
||||||
*/
|
*/
|
||||||
export function toggleSwitch(name, items, { onChange } = {}) {
|
export function toggleSwitch(name, items, e?) {
|
||||||
|
const onChange = e?.onChange;
|
||||||
|
|
||||||
let selectedIndex;
|
let selectedIndex;
|
||||||
let elements;
|
let elements;
|
||||||
|
|
||||||
function updateSelected(index) {
|
function updateSelected(index) {
|
||||||
if (selectedIndex != null) {
|
if (selectedIndex != null) {
|
||||||
elements[selectedIndex].classList.remove("comfy-toggle-selected");
|
elements[selectedIndex].classList.remove("comfy-toggle-selected");
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
import { api } from "../api";
|
import { api } from "../api";
|
||||||
import { $el } from "../ui";
|
import { $el } from "../ui";
|
||||||
import { addStylesheet } from "../utils";
|
import { addStylesheet } from "../utils";
|
||||||
import { createSpinner } from "./spinner.js";
|
import { createSpinner } from "./spinner";
|
||||||
|
|
||||||
|
interface SelectedUser {
|
||||||
|
username: string;
|
||||||
|
userId: string;
|
||||||
|
created: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class UserSelectionScreen {
|
export class UserSelectionScreen {
|
||||||
async show(users, user) {
|
async show(users, user): Promise<SelectedUser>{
|
||||||
// This will rarely be hit so move the loading to on demand
|
// This will rarely be hit so move the loading to on demand
|
||||||
await addStylesheet(import.meta.url);
|
await addStylesheet(import.meta.url);
|
||||||
const userSelection = document.getElementById("comfy-user-selection");
|
const userSelection = document.getElementById("comfy-user-selection");
|
||||||
@@ -48,6 +54,9 @@ export class UserSelectionScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new user
|
// Create new user
|
||||||
|
// @ts-ignore
|
||||||
|
// Property 'readonly' does not exist on type 'HTMLSelectElement'.ts(2339)
|
||||||
|
// Property 'readonly' does not exist on type 'HTMLInputElement'. Did you mean 'readOnly'?ts(2551)
|
||||||
input.disabled = select.disabled = input.readonly = select.readonly = true;
|
input.disabled = select.disabled = input.readonly = select.readonly = true;
|
||||||
const spinner = createSpinner();
|
const spinner = createSpinner();
|
||||||
button.prepend(spinner);
|
button.prepend(spinner);
|
||||||
@@ -56,7 +65,7 @@ export class UserSelectionScreen {
|
|||||||
if (resp.status >= 300) {
|
if (resp.status >= 300) {
|
||||||
let message = "Error creating user: " + resp.status + " " + resp.statusText;
|
let message = "Error creating user: " + resp.status + " " + resp.statusText;
|
||||||
try {
|
try {
|
||||||
const res = await resp.json();
|
const res = await resp.json();
|
||||||
if(res.error) {
|
if(res.error) {
|
||||||
message = res.error;
|
message = res.error;
|
||||||
}
|
}
|
||||||
@@ -69,6 +78,9 @@ export class UserSelectionScreen {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
spinner.remove();
|
spinner.remove();
|
||||||
error.textContent = err.message ?? err.statusText ?? err ?? "An unknown error occurred.";
|
error.textContent = err.message ?? err.statusText ?? err ?? "An unknown error occurred.";
|
||||||
|
// @ts-ignore
|
||||||
|
// Property 'readonly' does not exist on type 'HTMLSelectElement'.ts(2339)
|
||||||
|
// Property 'readonly' does not exist on type 'HTMLInputElement'. Did you mean 'readOnly'?ts(2551)
|
||||||
input.disabled = select.disabled = input.readonly = select.readonly = false;
|
input.disabled = select.disabled = input.readonly = select.readonly = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -106,7 +118,7 @@ export class UserSelectionScreen {
|
|||||||
userSelection.classList.add("no-users");
|
userSelection.classList.add("no-users");
|
||||||
input.focus();
|
input.focus();
|
||||||
}
|
}
|
||||||
}).then((r) => {
|
}).then((r: SelectedUser) => {
|
||||||
userSelection.remove();
|
userSelection.remove();
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user