File size: 1,288 Bytes
932ae62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-check

import { ComfyButton } from "../components/button.js";
import { ComfyViewList, ComfyViewListButton } from "./viewList.js";
import { api } from "../../api.js";

export class ComfyViewQueueButton extends ComfyViewListButton {
	constructor(app) {
		super(app, {
			button: new ComfyButton({
				content: "View Queue",
				icon: "format-list-numbered",
				tooltip: "View queue",
				classList: "comfyui-button comfyui-queue-button",
			}),
			list: ComfyViewQueueList,
			mode: "Queue",
		});
	}
}

export class ComfyViewQueueList extends ComfyViewList {
	getRow = (item, section) => {
		if (section !== "Running") {
			return super.getRow(item, section);
		}
		return {
			text: item.prompt[0] + "",
			actions: [
				{
					text: "Load",
					action: async () => {
						try {
							await this.app.loadGraphData(item.prompt[3].extra_pnginfo.workflow);
							if (item.outputs) {
								this.app.nodeOutputs = item.outputs;
							}
						} catch (error) {
							alert("Error loading workflow: " + error.message);
							console.error(error);
						}
					},
				},
				{
					text: "Cancel",
					action: async () => {
						try {
							await api.interrupt();
						} catch (error) {}
					},
				},
			],
		};
	}
}