305 lines
7.1 KiB
JavaScript
305 lines
7.1 KiB
JavaScript
import PrinterIcon from '../../components/Icons/PrinterIcon'
|
|
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',
|
|
label: 'Printer',
|
|
prefix: 'PRN',
|
|
icon: PrinterIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/production/printers/info?printerId=${_id}`
|
|
},
|
|
|
|
{
|
|
name: 'reload',
|
|
label: 'Reload',
|
|
icon: ReloadIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/info?printerId=${_id}&action=reload`
|
|
},
|
|
{
|
|
name: 'control',
|
|
label: 'Control',
|
|
row: true,
|
|
icon: PlayCircleIcon,
|
|
url: (_id) => `/dashboard/production/printers/control?printerId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
row: true,
|
|
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'],
|
|
filters: ['name', '_id', 'state', 'tags'],
|
|
sorters: ['name', 'state', 'connectedAt'],
|
|
group: ['tags'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'printer',
|
|
showCopy: true
|
|
},
|
|
{
|
|
name: 'connectedAt',
|
|
label: 'Connected At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200,
|
|
columnFixed: 'left'
|
|
},
|
|
{
|
|
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: 'vendor',
|
|
label: 'Vendor',
|
|
type: 'object',
|
|
objectType: 'vendor',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'vendor._id',
|
|
label: 'Vendor ID',
|
|
type: 'id',
|
|
objectType: 'vendor',
|
|
showHyperlink: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'host',
|
|
label: 'Host',
|
|
type: 'object',
|
|
objectType: 'host',
|
|
required: true
|
|
},
|
|
{
|
|
name: 'host._id',
|
|
label: 'Host ID',
|
|
type: 'id',
|
|
objectType: 'host',
|
|
showHyperlink: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'moonraker.host',
|
|
label: 'Hostname',
|
|
type: 'text',
|
|
required: true
|
|
},
|
|
{
|
|
name: 'moonraker.port',
|
|
label: 'Port',
|
|
type: 'number',
|
|
required: true
|
|
},
|
|
{
|
|
name: 'moonraker.apiKey',
|
|
label: 'API Key',
|
|
type: 'secret',
|
|
reveal: true,
|
|
required: false
|
|
},
|
|
{
|
|
name: 'moonraker.protocol',
|
|
label: 'Protocol',
|
|
type: 'wsprotocol',
|
|
required: true
|
|
},
|
|
{
|
|
name: 'tags',
|
|
label: 'Tags',
|
|
type: 'tags',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'firmware',
|
|
label: 'Firmware Version',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'currentFilamentStock',
|
|
label: 'Filament Stock',
|
|
type: 'object',
|
|
objectType: 'filamentStock',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'currentFilamentStock._id',
|
|
label: 'Filament Stock ID',
|
|
type: 'id',
|
|
objectType: 'filamentStock',
|
|
showHyperlink: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'currentJob',
|
|
label: 'Current Job',
|
|
type: 'object',
|
|
objectType: 'job',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'currentJob._id',
|
|
label: 'Current Job ID',
|
|
type: 'id',
|
|
objectType: 'job',
|
|
showHyperlink: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'currentSubJob',
|
|
label: 'Current Sub Job',
|
|
type: 'object',
|
|
objectType: 'subJob',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'currentSubJob._id',
|
|
label: 'Current Sub Job ID',
|
|
type: 'id',
|
|
objectType: 'subJob',
|
|
showHyperlink: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'alerts',
|
|
label: 'Alerts',
|
|
type: 'alerts',
|
|
required: false
|
|
}
|
|
]
|
|
}
|