From 5434b10923708aea2379021aeacabe0c37d5e99f Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 17 Nov 2025 18:48:13 +0000 Subject: [PATCH] Add printer control actions: restart, start, pause, and stop --- src/database/models/Printer.js | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/database/models/Printer.js b/src/database/models/Printer.js index 85ca8c1..f8695ce 100644 --- a/src/database/models/Printer.js +++ b/src/database/models/Printer.js @@ -3,6 +3,8 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon' import ReloadIcon from '../../components/Icons/ReloadIcon' import EditIcon from '../../components/Icons/EditIcon' import PlayCircleIcon from '../../components/Icons/PlayCircleIcon' +import PauseCircleIcon from '../../components/Icons/PauseCircleIcon' +import StopCircleIcon from '../../components/Icons/StopCircleIcon' export const Printer = { name: 'printer', @@ -40,6 +42,97 @@ export const Printer = { icon: EditIcon, url: (_id) => `/dashboard/production/printers/info?printerId=${_id}&action=edit` + }, + { type: 'divider' }, + { + name: 'restartSubmenu', + label: 'Restart', + icon: ReloadIcon, + disabled: (objectData) => { + return objectData?.online == false + }, + children: [ + { + name: 'restart', + label: 'Restart', + icon: ReloadIcon, + disabled: (objectData) => { + return objectData?.online == false + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=restart` + }, + { + name: 'restartFirmware', + label: 'Restart Firmware', + icon: ReloadIcon, + disabled: (objectData) => { + return objectData?.online == false + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=restartFirmware` + }, + { type: 'divider' }, + { + name: 'restartMoonraker', + label: 'Restart Moonraker', + icon: ReloadIcon, + disabled: (objectData) => { + return objectData?.online == false + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=restartMoonraker` + } + ] + }, + { + name: 'queue', + label: 'Queue', + icon: PlayCircleIcon, + disabled: (objectData) => { + return objectData?.online == false + }, + children: [ + { + name: 'Start', + label: 'Start', + icon: PlayCircleIcon, + disabled: (objectData) => { + console.log(objectData?.subJobs?.length) + return ( + objectData?.state?.type == 'error' || + objectData?.state?.type == 'printing' || + objectData?.subJobs?.length == 0 || + objectData?.subJobs?.length == undefined + ) + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=startQueue` + }, + { + name: 'pause', + label: 'Pause', + icon: PauseCircleIcon, + disabled: (objectData) => { + return objectData?.state?.type != 'printing' + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=pauseQueue` + }, + { + name: 'Stop', + label: 'Stop', + icon: StopCircleIcon, + disabled: (objectData) => { + return ( + objectData?.state?.type != 'printing' || + objectData?.state?.type != 'error' + ) + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=stopQueue` + } + ] } ], columns: ['name', '_id', 'state', 'tags', 'connectedAt'],