- Updated multiple models to change the column identifier from '_id' to '_reference' for consistency across the database schema. - Adjusted relevant filters and properties to align with the new column naming convention.
250 lines
5.7 KiB
JavaScript
250 lines
5.7 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: [
|
|
'name',
|
|
'_reference',
|
|
'filament',
|
|
'gcodeFileInfo.estimatedPrintingTimeNormalMode',
|
|
'gcodeFileInfo.sparseInfillDensity',
|
|
'gcodeFileInfo.sparseInfillPattern',
|
|
'gcodeFileInfo.nozzleTemperature',
|
|
'gcodeFileInfo.hotPlateTemp',
|
|
'updatedAt'
|
|
],
|
|
filters: ['_id', 'name', 'updatedAt'],
|
|
sorters: ['name', 'createdAt', 'updatedAt'],
|
|
group: ['filament'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'gcodeFile',
|
|
columnFixed: 'left',
|
|
value: null,
|
|
showCopy: true
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
value: null,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
type: 'text',
|
|
value: null,
|
|
required: true
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
value: null,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file',
|
|
label: 'File',
|
|
type: 'file',
|
|
value: null,
|
|
required: true,
|
|
showPreview: false,
|
|
showHyperlink: true,
|
|
filter: ['.gcode', '.g']
|
|
},
|
|
{
|
|
name: 'filament',
|
|
label: 'Filament',
|
|
type: 'object',
|
|
value: null,
|
|
objectType: 'filament',
|
|
required: true,
|
|
showHyperlink: true
|
|
},
|
|
{
|
|
name: 'cost',
|
|
label: 'Cost',
|
|
type: 'number',
|
|
roundNumber: 2,
|
|
value: (objectData) => {
|
|
return (
|
|
objectData?.file?.metaData?.filamentUsedG *
|
|
(objectData?.filament?.cost / 1000)
|
|
)
|
|
},
|
|
readOnly: true,
|
|
prefix: '£'
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedG',
|
|
label: 'Est Print Time',
|
|
value: null,
|
|
type: 'text',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.sparseInfillDensity',
|
|
label: 'Infill Density',
|
|
columnWidth: 150,
|
|
type: 'text',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.sparseInfillPattern',
|
|
label: 'Infill Pattern',
|
|
type: 'text',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedMm',
|
|
label: 'Filament Used (mm)',
|
|
type: 'number',
|
|
readOnly: true,
|
|
suffix: 'mm'
|
|
},
|
|
{
|
|
name: 'file.metaData.filamentUsedG',
|
|
label: 'Filament Used (g)',
|
|
type: 'number',
|
|
suffix: 'g',
|
|
readOnly: true
|
|
},
|
|
{
|
|
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
|
|
},
|
|
{
|
|
name: 'file.metaData.printSettingsId',
|
|
label: 'Print Profile',
|
|
type: 'text',
|
|
readOnly: true
|
|
},
|
|
{
|
|
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
|
|
)
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|