reboot, clearQueue, interrupt
This commit is contained in:
@@ -213,4 +213,8 @@ export default {
|
||||
'Photoshop is not connected': 'Photoshop 未连接',
|
||||
'select...': '请选择',
|
||||
'click to edit': '点击编辑',
|
||||
|
||||
// comfy call error
|
||||
'ComfyManager not found, cannot reboot': 'Comfy Manager未安装,无法重启',
|
||||
'Failed to reboot ComfyUI': '重启ComfyUI失败',
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ import { getStoredWidgetValue } from "../hooks/widgetable.mts";
|
||||
|
||||
export interface WorkflowCaller {
|
||||
pageInstanceRun(sid: string, from_sid: string, size?: number): void;
|
||||
setWidgetValue(workflowAgent: PageStore | null | undefined, params: WorkflowCalleeActions['setWidgetValue']['params']): Promise<void>;
|
||||
openWorkflow(workflowAgent: PageStore | null | undefined, params: WorkflowCalleeActions['open']['params']): Promise<void>;
|
||||
saveWorkflow(workflowAgent: PageStore | null | undefined, params: WorkflowCalleeActions['save']['params']): Promise<void>;
|
||||
logout(workflowAgent: PageStore | null | undefined): Promise<void>;
|
||||
setWidgetValue(workflowAgent: PageStore | null, params: WorkflowCalleeActions['setWidgetValue']['params']): Promise<void>;
|
||||
openWorkflow(workflowAgent: PageStore | null, params: WorkflowCalleeActions['open']['params']): Promise<void>;
|
||||
saveWorkflow(workflowAgent: PageStore | null, params: WorkflowCalleeActions['save']['params']): Promise<void>;
|
||||
logout(workflowAgent: PageStore | null): Promise<void>;
|
||||
interrupt(workflowAgentSID: string): Promise<void>;
|
||||
clearQueue(workflowAgentSID: string): Promise<void>;
|
||||
reboot(workflowAgentSID: string): Promise<WorkflowCalleeActions['reboot']['result']>;
|
||||
}
|
||||
|
||||
export interface WorkflowCallerActions {
|
||||
@@ -152,6 +155,37 @@ export function WorkflowCallerSocket(SocketClass: SocketConstructor<Socket>) {
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
public async interrupt(workflowAgentSID: string) {
|
||||
await new Promise<any>((resolve, reject) => {
|
||||
this.socket.emit('F_workflow', {
|
||||
action: 'interrupt',
|
||||
sid: workflowAgentSID
|
||||
}, (payload: any) => {
|
||||
resolve(payload);
|
||||
});
|
||||
})
|
||||
}
|
||||
public async clearQueue(workflowAgentSID: string) {
|
||||
await new Promise<any>((resolve, reject) => {
|
||||
this.socket.emit('F_workflow', {
|
||||
action: 'clearQueue',
|
||||
sid: workflowAgentSID
|
||||
}, (payload: any) => {
|
||||
resolve(payload);
|
||||
});
|
||||
})
|
||||
}
|
||||
public async reboot(workflowAgentSID: string) {
|
||||
return await new Promise<WorkflowCalleeActions['reboot']['result']>((resolve, reject) => {
|
||||
this.socket.emit('F_workflow', {
|
||||
action: 'reboot',
|
||||
sid: workflowAgentSID
|
||||
}, (payload: WorkflowCalleeActions['reboot']['result']) => {
|
||||
resolve(payload);
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
|
||||
export default class StopIcon extends React.Component<{
|
||||
size?: number,
|
||||
hollowStyle?: boolean
|
||||
}> {
|
||||
render() {
|
||||
return (
|
||||
<div slot="icon" className="sdppp-icon">
|
||||
<svg width={this.props.size || 20} height={this.props.size || 20} viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1.504a.5.5 0 01.5-.5h11a.5.5 0 01.5.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-11z" fill="currentColor"></path></svg>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@ declare module "SDPPPInternal" {
|
||||
type: string;
|
||||
subfolder: string;
|
||||
} | undefined>;
|
||||
interrupt: () => Promise<void>;
|
||||
clearQueue: () => Promise<void>;
|
||||
reboot: () => Promise<void>;
|
||||
}
|
||||
|
||||
export interface SDPPPWebpageInstance {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
useSDPPPContext,
|
||||
useAgentState,
|
||||
} from "./SDPPPInternalBridge"
|
||||
import StopIcon from "../../common/tsx/icons/StopIcon"
|
||||
|
||||
// 状态显示组件
|
||||
const WorkflowStatus = () => {
|
||||
@@ -113,6 +114,16 @@ const RunButton = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// const TestButtons = () => {
|
||||
// const { interrupt, clearQueue, reboot } = useSDPPPComfyCaller();
|
||||
|
||||
// return (
|
||||
// <sp-action-button onClick={() => { reboot() }}>
|
||||
// <StopIcon />
|
||||
// </sp-action-button>
|
||||
// )
|
||||
// }
|
||||
|
||||
export function WorkflowEditWrap({
|
||||
WorkflowEditPhotoshop
|
||||
}: {
|
||||
@@ -134,6 +145,7 @@ export function WorkflowEditWrap({
|
||||
</div>
|
||||
<div className="workflow-edit-button-line workflow-edit-controls-linetwo">
|
||||
<WorkflowStatus />
|
||||
{/* <TestButtons /> */}
|
||||
<EditButton />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import i18n from "../../../common/i18n.mts";
|
||||
import { Socket, SocketConstructor } from "../../../common/socket/Socket.mjs";
|
||||
import { WorkflowCallerActions } from "../../../plugins/common/socket/WorkflowCaller.mjs";
|
||||
import { pageStore } from "../../common/models/photoshopModels.mjs";
|
||||
@@ -52,6 +53,19 @@ export interface WorkflowCalleeActions {
|
||||
logout: {
|
||||
params: {
|
||||
}
|
||||
},
|
||||
interrupt: {
|
||||
params: {}
|
||||
},
|
||||
clearQueue: {
|
||||
params: {}
|
||||
},
|
||||
reboot: {
|
||||
params: {},
|
||||
result: {
|
||||
error?: string,
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +85,10 @@ export function WorkflowCalleeSocket(SocketClass: SocketConstructor<Socket>) {
|
||||
payload.action == 'setWidgetValue' ||
|
||||
payload.action == 'run' ||
|
||||
payload.action == 'setNodeTitle' ||
|
||||
payload.action == 'logout'
|
||||
payload.action == 'logout' ||
|
||||
payload.action == 'interrupt' ||
|
||||
payload.action == 'clearQueue' ||
|
||||
payload.action == 'reboot'
|
||||
) {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
@@ -253,6 +270,31 @@ export function WorkflowCalleeSocket(SocketClass: SocketConstructor<Socket>) {
|
||||
node.title = title;
|
||||
node.setProperty('sdppp_widgetable_title', title);
|
||||
}
|
||||
public async interrupt(params: WorkflowCalleeActions['interrupt']['params']) {
|
||||
await app.api.interrupt();
|
||||
}
|
||||
public async clearQueue(params: WorkflowCalleeActions['clearQueue']['params']) {
|
||||
await app.api.clearItems('queue')
|
||||
|
||||
}
|
||||
public async reboot(params: WorkflowCalleeActions['reboot']['params']) {
|
||||
const response = await fetch('./api/manager/reboot')
|
||||
if (response.status == 404) {
|
||||
return {
|
||||
error: i18n('ComfyManager not found, cannot reboot'),
|
||||
success: false
|
||||
}
|
||||
} else if (response.status == 200) {
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
error: i18n('Failed to reboot ComfyUI') + response.statusText,
|
||||
success: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user