Some checks are pending
farmcontrol/farmcontrol-ui/pipeline/head Build queued...
274 lines
6.4 KiB
JavaScript
274 lines
6.4 KiB
JavaScript
import DownloadIcon from '../../components/Icons/DownloadIcon'
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import GCodeFileIcon from '../../components/Icons/GCodeFileIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import ReloadIcon from '../../components/Icons/ReloadIcon'
|
|
|
|
export const GCodeFile = {
|
|
name: 'gcodeFile',
|
|
label: 'GCode File',
|
|
prefix: 'GCF',
|
|
icon: GCodeFileIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/production/gcodefiles/info?gcodeFileId=${_id}`
|
|
},
|
|
{
|
|
name: 'reload',
|
|
label: 'Reload',
|
|
icon: ReloadIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/gcodefiles/info?gcodeFileId=${_id}&action=reload`
|
|
},
|
|
{
|
|
name: 'download',
|
|
label: 'Download',
|
|
row: true,
|
|
icon: DownloadIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/gcodefiles/info?gcodeFileId=${_id}&action=download`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/gcodefiles/info?gcodeFileId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/gcodefiles/info?gcodeFileId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/production/gcodefiles/info?gcodeFileId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
}
|
|
],
|
|
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'filamentSku',
|
|
'cost',
|
|
'gcodeFileInfo.estimatedPrintingTimeNormalMode',
|
|
'gcodeFileInfo.sparseInfillDensity',
|
|
'gcodeFileInfo.sparseInfillPattern',
|
|
'gcodeFileInfo.nozzleTemperature',
|
|
'gcodeFileInfo.hotPlateTemp',
|
|
'updatedAt'
|
|
],
|
|
filters: ['_id', 'name', 'cost', 'updatedAt'],
|
|
sorters: ['name', 'cost', 'createdAt', 'updatedAt'],
|
|
group: ['filamentSku'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'gcodeFile',
|
|
columnFixed: 'left',
|
|
value: null,
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
value: null,
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'gcodeFile',
|
|
showCopy: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
type: 'text',
|
|
value: null,
|
|
required: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
value: null,
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'file',
|
|
label: 'File',
|
|
type: 'file',
|
|
value: null,
|
|
required: true,
|
|
showPreview: false,
|
|
showHyperlink: true,
|
|
filter: ['.gcode', '.g'],
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'filamentSku',
|
|
label: 'Filament SKU',
|
|
type: 'object',
|
|
value: null,
|
|
objectType: 'filamentSku',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'cost',
|
|
label: 'Cost',
|
|
type: 'number',
|
|
roundNumber: 2,
|
|
value: (objectData) => {
|
|
const fs = objectData?.filamentSku
|
|
const costPerKg =
|
|
fs?.overrideCost ? fs?.cost : fs?.filament?.cost
|
|
if (!costPerKg || !objectData?.file?.metaData?.filamentUsedG) return undefined
|
|
return objectData.file.metaData.filamentUsedG * (costPerKg / 1000)
|
|
},
|
|
readOnly: true,
|
|
prefix: '£',
|
|
columnWidth: 100
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedG',
|
|
label: 'Est Print Time',
|
|
value: null,
|
|
type: 'text',
|
|
readOnly: true,
|
|
columnWidth: 130
|
|
},
|
|
{
|
|
name: 'file.metaData.sparseInfillDensity',
|
|
label: 'Infill Density',
|
|
columnWidth: 150,
|
|
type: 'text',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.sparseInfillPattern',
|
|
label: 'Infill Pattern',
|
|
type: 'text',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedMm',
|
|
label: 'Filament Used (mm)',
|
|
type: 'number',
|
|
readOnly: true,
|
|
suffix: 'mm',
|
|
columnWidth: 160
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedG',
|
|
label: 'Filament Used (g)',
|
|
type: 'number',
|
|
suffix: 'g',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'file.metaData.nozzleTemperature',
|
|
label: 'Hotend Temp',
|
|
columnWidth: 150,
|
|
type: 'number',
|
|
suffix: '°',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.hotPlateTemp',
|
|
label: 'Bed Temp',
|
|
columnWidth: 150,
|
|
type: 'number',
|
|
suffix: '°',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentSettingsId',
|
|
label: 'Filament Profile',
|
|
type: 'text',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'file.metaData.printSettingsId',
|
|
label: 'Print Profile',
|
|
type: 'text',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'parts',
|
|
label: 'Parts',
|
|
type: 'objectChildren',
|
|
objectType: 'part',
|
|
properties: [
|
|
{
|
|
name: 'part',
|
|
label: 'Part',
|
|
type: 'object',
|
|
objectType: 'part',
|
|
required: true,
|
|
showHyperlink: true
|
|
},
|
|
{
|
|
name: 'quantity',
|
|
label: 'Quantity',
|
|
type: 'number',
|
|
required: true
|
|
}
|
|
],
|
|
rollups: [
|
|
{
|
|
name: 'totalQuantity',
|
|
label: 'Total',
|
|
type: 'number',
|
|
property: 'quantity',
|
|
value: (objectData) => {
|
|
return objectData?.parts?.reduce(
|
|
(acc, part) => acc + part.quantity,
|
|
0
|
|
)
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|