diff --git a/src/database/models/DocumentJob.js b/src/database/models/DocumentJob.js index e1b5c55..28a7233 100644 --- a/src/database/models/DocumentJob.js +++ b/src/database/models/DocumentJob.js @@ -2,11 +2,12 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon' import ReloadIcon from '../../components/Icons/ReloadIcon' import EditIcon from '../../components/Icons/EditIcon' import DocumentJobIcon from '../../components/Icons/DocumentJobIcon' +import dayjs from 'dayjs' export const DocumentJob = { name: 'documentJob', label: 'Document Job', - prefix: 'DSZ', + prefix: 'DJB', icon: DocumentJobIcon, actions: [ { @@ -60,7 +61,9 @@ export const DocumentJob = { columnWidth: 200, columnFixed: 'left', value: (objectData) => { - return `${objectData?.documentTemplate?.name || 'No template'} (${objectData?.object?.name || 'No name'})` + if (objectData?.createdAt == undefined) { + return `${objectData?.documentTemplate?.name || 'No template'} ${dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')} (${objectData?.object?.name || objectData?.object?._id})` + } } }, { @@ -69,6 +72,14 @@ export const DocumentJob = { type: 'dateTime', readOnly: true }, + { + name: 'state', + label: 'Status', + type: 'state', + objectType: 'printer', + showName: false, + readOnly: true + }, { name: 'objectType', label: 'Object Type', @@ -86,6 +97,15 @@ export const DocumentJob = { return objectData?.objectType } }, + { + name: 'object._id', + label: 'Object ID', + type: 'id', + showHyperlink: true, + objectType: (objectData) => { + return objectData?.objectType + } + }, { name: 'documentTemplate', label: 'Template', @@ -101,6 +121,13 @@ export const DocumentJob = { } } }, + { + name: 'documentTemplate._id', + label: 'Template ID', + type: 'id', + showHyperlink: true, + objectType: 'documentTemplate' + }, { name: 'documentPrinter', label: 'Printer', @@ -114,6 +141,13 @@ export const DocumentJob = { online: true } } + }, + { + name: 'documentPrinter._id', + label: 'Printer ID', + type: 'id', + showHyperlink: true, + objectType: 'documentPrinter' } ] } diff --git a/src/database/models/DocumentPrinter.js b/src/database/models/DocumentPrinter.js index f71d656..a42b111 100644 --- a/src/database/models/DocumentPrinter.js +++ b/src/database/models/DocumentPrinter.js @@ -74,52 +74,88 @@ export const DocumentPrinter = { readOnly: true }, { - name: 'documentSize', - label: 'Document Size', + name: 'state', + label: 'Status', + type: 'state', + objectType: 'printer', + showName: false, + readOnly: true + }, + { + name: 'active', + label: 'Active', + type: 'bool', + required: true + }, + { + name: 'online', + label: 'Online', + type: 'bool', + readOnly: true + }, + { + name: 'host', + label: 'Host', required: true, type: 'object', + objectType: 'host', + showHyperlink: true + }, + { + name: 'host._id', + label: 'Host ID', + type: 'id', + objectType: 'host', + showCopy: true, + showHyperlink: true + }, + { + name: 'connection.mode', + label: 'Mode', + type: 'select', + options: [ + { label: 'Network', value: 'network' }, + { label: 'Serial', value: 'serial' } + ], + required: true + }, + { + name: 'connection.interface', + label: 'Interface', + type: 'select', + options: [ + { label: 'CUPS', value: 'cups' }, + { label: 'Epson Receipt', value: 'epsonReceipt' }, + { label: 'Star Receipt', value: 'starReceipt' } + ], + required: true + }, + { + name: 'connection.host', + label: 'Connection String', + type: 'text', + required: true + }, + { + name: 'currentDocumentSize', + label: 'Current Document Size', + required: false, + type: 'object', objectType: 'documentSize' }, { - name: 'documentSize._id', - label: 'Document Size ID', + name: 'currentDocumentSize._id', + label: 'Current Document Size ID', type: 'id', objectType: 'documentSize', showCopy: true, showHyperlink: true }, - { - name: 'active', - label: 'Active', - required: true, - type: 'bool' - }, { name: 'tags', label: 'Tags', required: false, type: 'tags' - }, - { name: 'global', label: 'Global', required: false, type: 'bool' }, - { - name: 'parent', - label: 'Parent', - required: false, - type: 'object', - objectType: 'documentPrinter', - disabled: (documentPrinter) => { - if (documentPrinter.global == true) { - documentPrinter.parent = null - } - return documentPrinter.global - } - }, - { - name: 'parent._id', - label: 'Parent ID', - required: false, - type: 'id', - objectType: 'documentPrinter' } ] } diff --git a/src/database/models/Printer.js b/src/database/models/Printer.js index f8695ce..0efb91c 100644 --- a/src/database/models/Printer.js +++ b/src/database/models/Printer.js @@ -5,7 +5,7 @@ import EditIcon from '../../components/Icons/EditIcon' import PlayCircleIcon from '../../components/Icons/PlayCircleIcon' import PauseCircleIcon from '../../components/Icons/PauseCircleIcon' import StopCircleIcon from '../../components/Icons/StopCircleIcon' - +import FilamentStockIcon from '../../components/Icons/FilamentStockIcon' export const Printer = { name: 'printer', label: 'Printer', @@ -94,8 +94,8 @@ export const Printer = { }, children: [ { - name: 'Start', - label: 'Start', + name: 'startQueue', + label: 'Start Queue', icon: PlayCircleIcon, disabled: (objectData) => { console.log(objectData?.subJobs?.length) @@ -109,28 +109,60 @@ export const Printer = { url: (_id) => `/dashboard/production/printers/control?printerId=${_id}&action=startQueue` }, + { type: 'divider' }, { - name: 'pause', - label: 'Pause', + name: 'pauseJob', + label: 'Pause Job', icon: PauseCircleIcon, disabled: (objectData) => { return objectData?.state?.type != 'printing' }, url: (_id) => - `/dashboard/production/printers/control?printerId=${_id}&action=pauseQueue` + `/dashboard/production/printers/control?printerId=${_id}&action=pauseJob` }, { - name: 'Stop', - label: 'Stop', + name: 'resumeJob', + label: 'Resume Job', + icon: PlayCircleIcon, + disabled: (objectData) => { + return objectData?.state?.type != 'printing' + }, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=resumeJob` + }, + { + name: 'cancelJob', + label: 'Cancel Job', icon: StopCircleIcon, disabled: (objectData) => { return ( - objectData?.state?.type != 'printing' || + objectData?.state?.type != 'printing' && objectData?.state?.type != 'error' ) }, url: (_id) => - `/dashboard/production/printers/control?printerId=${_id}&action=stopQueue` + `/dashboard/production/printers/control?printerId=${_id}&action=cancelJob` + } + ] + }, + { + name: 'filamentStock', + label: 'Filament Stock', + icon: FilamentStockIcon, + children: [ + { + name: 'loadFilamentStock', + label: 'Load Filament Stock', + icon: FilamentStockIcon, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=loadFilamentStock` + }, + { + name: 'unloadFilamentStock', + label: 'Unload Filament Stock', + icon: FilamentStockIcon, + url: (_id) => + `/dashboard/production/printers/control?printerId=${_id}&action=unloadFilamentStock` } ] } @@ -299,6 +331,14 @@ export const Printer = { label: 'Alerts', type: 'alerts', required: false + }, + { + name: 'subJobs', + label: 'Queue', + type: 'objectList', + objectType: 'subJob', + required: false, + readOnly: true } ] }