Some checks are pending
farmcontrol/farmcontrol-ui/pipeline/head Build queued...
432 lines
11 KiB
JavaScript
432 lines
11 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 CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import PlayCircleIcon from '../../components/Icons/PlayCircleIcon'
|
|
import PauseCircleIcon from '../../components/Icons/PauseCircleIcon'
|
|
import StopCircleIcon from '../../components/Icons/StopCircleIcon'
|
|
import FilamentStockIcon from '../../components/Icons/FilamentStockIcon'
|
|
import ControlIcon from '../../components/Icons/ControlIcon'
|
|
import JobIcon from '../../components/Icons/JobIcon'
|
|
|
|
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: ControlIcon,
|
|
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`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/info?printerId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/info?printerId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{ 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: 'job',
|
|
label: 'Job',
|
|
icon: JobIcon,
|
|
disabled: (objectData) => {
|
|
return objectData?.online == false
|
|
},
|
|
children: [
|
|
{
|
|
name: 'startQueue',
|
|
label: 'Start Queue',
|
|
icon: PlayCircleIcon,
|
|
disabled: (objectData) => {
|
|
return (
|
|
objectData?.state?.type == 'error' ||
|
|
objectData?.state?.type == 'printing' ||
|
|
objectData?.state?.type == 'paused' ||
|
|
objectData?.queue?.length == 0 ||
|
|
objectData?.queue?.length == undefined
|
|
)
|
|
},
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/control?printerId=${_id}&action=startQueue`
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'pauseJob',
|
|
label: 'Pause Job',
|
|
icon: PauseCircleIcon,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'printing'
|
|
},
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/control?printerId=${_id}&action=pauseJob`
|
|
},
|
|
{
|
|
name: 'resumeJob',
|
|
label: 'Resume Job',
|
|
icon: PlayCircleIcon,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'paused'
|
|
},
|
|
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 != 'paused'
|
|
)
|
|
},
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/control?printerId=${_id}&action=cancelJob`
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'filamentStock',
|
|
label: 'Filament Stock',
|
|
icon: FilamentStockIcon,
|
|
disabled: (objectData) => {
|
|
return objectData?.online == false
|
|
},
|
|
children: [
|
|
{
|
|
name: 'loadFilamentStock',
|
|
label: 'Load Filament Stock',
|
|
icon: FilamentStockIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/control?printerId=${_id}&action=loadFilamentStock`,
|
|
disabled: (objectData) => {
|
|
return (
|
|
objectData?.state?.type == 'printing' ||
|
|
objectData?.state?.type == 'error' ||
|
|
objectData?.currentFilamentStock != null
|
|
)
|
|
}
|
|
},
|
|
{
|
|
name: 'unloadFilamentStock',
|
|
label: 'Unload Filament Stock',
|
|
icon: FilamentStockIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/printers/control?printerId=${_id}&action=unloadFilamentStock`,
|
|
disabled: (objectData) => {
|
|
return (
|
|
objectData?.state?.type == 'printing' ||
|
|
objectData?.state?.type == 'error' ||
|
|
objectData?.currentFilamentStock == null
|
|
)
|
|
}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'state',
|
|
'host',
|
|
'tags',
|
|
'connectedAt',
|
|
'updatedAt'
|
|
],
|
|
filters: ['name', '_id', 'state', 'tags'],
|
|
sorters: ['name', 'state', 'connectedAt'],
|
|
group: ['tags'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'printer',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'printer',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200,
|
|
columnFixed: 'left'
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'Status',
|
|
type: 'state',
|
|
objectType: 'printer',
|
|
showName: false,
|
|
readOnly: true,
|
|
columnWidth: 250
|
|
},
|
|
{
|
|
name: 'connectedAt',
|
|
label: 'Connected At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'online',
|
|
label: 'Online',
|
|
type: 'bool',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'active',
|
|
label: 'Active',
|
|
type: 'bool',
|
|
required: true,
|
|
columnWidth: 125
|
|
},
|
|
{
|
|
name: 'vendor',
|
|
label: 'Vendor',
|
|
type: 'object',
|
|
objectType: 'vendor',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'host',
|
|
label: 'Host',
|
|
type: 'object',
|
|
objectType: 'host',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'moonraker.host',
|
|
label: 'Hostname',
|
|
type: 'text',
|
|
required: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'moonraker.port',
|
|
label: 'Port',
|
|
type: 'number',
|
|
required: true,
|
|
columnWidth: 85
|
|
},
|
|
{
|
|
name: 'moonraker.apiKey',
|
|
label: 'API Key',
|
|
type: 'secret',
|
|
reveal: true,
|
|
required: false,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'moonraker.protocol',
|
|
label: 'Protocol',
|
|
type: 'wsprotocol',
|
|
required: true,
|
|
columnWidth: 110
|
|
},
|
|
{
|
|
name: 'tags',
|
|
label: 'Tags',
|
|
type: 'tags',
|
|
required: false,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'firmware',
|
|
label: 'Firmware Version',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'currentFilamentStock',
|
|
label: 'Filament Stock',
|
|
type: 'object',
|
|
objectType: 'filamentStock',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'currentJob',
|
|
label: 'Current Job',
|
|
type: 'object',
|
|
objectType: 'job',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'currentSubJob',
|
|
label: 'Current Sub Job',
|
|
type: 'object',
|
|
objectType: 'subJob',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'alerts',
|
|
label: 'Alerts',
|
|
type: 'alerts',
|
|
required: false,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'queue',
|
|
label: 'Queue',
|
|
type: 'objectList',
|
|
objectType: 'subJob',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'standby.count',
|
|
label: 'Ready',
|
|
type: 'number',
|
|
sum: ['standby.count', 'complete.count'],
|
|
color: 'success'
|
|
},
|
|
{
|
|
name: 'printing.count',
|
|
label: 'Printing',
|
|
type: 'number',
|
|
color: 'processing'
|
|
},
|
|
{
|
|
name: 'error.count',
|
|
label: 'Error',
|
|
type: 'number',
|
|
color: 'error'
|
|
},
|
|
{
|
|
name: 'offline.count',
|
|
label: 'Offline',
|
|
type: 'number',
|
|
color: 'default'
|
|
}
|
|
]
|
|
}
|