Add DocumentPrintButton to various management components and update objectData handling

This commit is contained in:
Tom Butcher 2025-09-05 23:16:42 +01:00
parent 204a881dfa
commit fbdb451659
14 changed files with 145 additions and 13 deletions

View File

@ -17,6 +17,7 @@ import FilamentStockIcon from '../../../Icons/FilamentStockIcon'
import NoteIcon from '../../../Icons/NoteIcon'
import AuditLogIcon from '../../../Icons/AuditLogIcon'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder'
import DocumentPrintButton from '../../common/DocumentPrintButton'
const FilamentStockInfo = () => {
const location = useLocation()
@ -39,7 +40,8 @@ const FilamentStockInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -75,6 +77,7 @@ const FilamentStockInfo = () => {
type='filamentStock'
id={filamentStockId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -87,6 +90,11 @@ const FilamentStockInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='filamentStock'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -18,6 +18,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('DocumentPrinterInfo')
log.setLevel(config.logLevel)
@ -92,6 +93,7 @@ const DocumentPrinterInfo = () => {
type='documentPrinter'
id={documentPrinterId}
disabled={loading}
objectData={objectData}
/>
<ViewButton
disabled={loading}
@ -107,6 +109,11 @@ const DocumentPrinterInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='documentPrinter'
objectData={objectData}
disabled={loading}
/>
</Space>
<LockIndicator lock={lock} />
</Space>

View File

@ -19,6 +19,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('DocumentSizeInfo')
log.setLevel(config.logLevel)
@ -43,7 +44,8 @@ const DocumentSizeInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -79,6 +81,7 @@ const DocumentSizeInfo = () => {
type='documentSize'
id={documentSizeId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -90,6 +93,11 @@ const DocumentSizeInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='documentSize'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -19,6 +19,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('DocumentTemplateInfo')
log.setLevel(config.logLevel)
@ -45,7 +46,8 @@ const DocumentTemplateInfo = () => {
editLoading: false,
formValid: false,
locked: false,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -84,6 +86,7 @@ const DocumentTemplateInfo = () => {
type='documentTemplate'
id={documentTemplateId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -95,6 +98,11 @@ const DocumentTemplateInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='documentTemplate'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -20,6 +20,7 @@ import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import FilamentIcon from '../../../Icons/FilamentIcon.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('FilamentInfo')
log.setLevel(config.logLevel)
@ -44,7 +45,8 @@ const FilamentInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -83,6 +85,7 @@ const FilamentInfo = () => {
type='filament'
id={filamentId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -95,6 +98,11 @@ const FilamentInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='filament'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -20,6 +20,8 @@ import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import HostOTP from './HostOtp.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import PrinterIcon from '../../../Icons/PrinterIcon.jsx'
const log = loglevel.getLogger('HostInfo')
log.setLevel(config.logLevel)
@ -31,7 +33,7 @@ const HostInfo = () => {
const hostId = new URLSearchParams(location.search).get('hostId')
const [collapseState, updateCollapseState] = useCollapseState('HostInfo', {
info: true,
stocks: true,
printers: true,
notes: true,
auditLogs: true
})
@ -42,7 +44,8 @@ const HostInfo = () => {
editLoading: false,
formValid: false,
locked: false,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -85,17 +88,24 @@ const HostInfo = () => {
type='host'
id={hostId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
items={[
{ key: 'info', label: 'Host Information' },
{ key: 'printers', label: 'Printers' },
{ key: 'notes', label: 'Notes' },
{ key: 'auditLogs', label: 'Audit Logs' }
]}
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='host'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>
@ -158,6 +168,27 @@ const HostInfo = () => {
</InfoCollapse>
</ActionHandler>
<InfoCollapse
title='Printers'
icon={<PrinterIcon />}
active={collapseState.printers}
onToggle={(expanded) => updateCollapseState('printers', expanded)}
collapseKey='printers'
>
{objectFormState.loading ? (
<InfoCollapsePlaceholder />
) : (
<ObjectTable
type='printer'
masterFilter={{ 'host._id': hostId }}
visibleColumns={{
host: false,
'host._id': false
}}
/>
)}
</InfoCollapse>
<InfoCollapse
title='Notes'
icon={<NoteIcon />}

View File

@ -15,6 +15,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const NoteTypeInfo = () => {
const location = useLocation()
@ -33,7 +34,8 @@ const NoteTypeInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -69,6 +71,7 @@ const NoteTypeInfo = () => {
type='noteType'
id={noteTypeId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -79,6 +82,11 @@ const NoteTypeInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='noteType'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -18,6 +18,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('NoteInfo')
log.setLevel(config.logLevel)
@ -37,7 +38,8 @@ const NoteInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -77,6 +79,7 @@ const NoteInfo = () => {
type='note'
id={noteId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -88,6 +91,11 @@ const NoteInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='note'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -16,6 +16,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import { ApiServerContext } from '../../context/ApiServerContext'
const PartInfo = () => {
@ -78,6 +79,7 @@ const PartInfo = () => {
type='part'
id={partId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -89,6 +91,11 @@ const PartInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='part'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -17,6 +17,7 @@ import ObjectTable from '../../common/ObjectTable.jsx'
import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const ProductInfo = () => {
const location = useLocation()
@ -70,6 +71,7 @@ const ProductInfo = () => {
type='product'
id={productId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -82,6 +84,11 @@ const ProductInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='product'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -17,6 +17,7 @@ import ActionHandler from '../../common/ActionHandler'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const UserInfo = () => {
const location = useLocation()
@ -33,7 +34,8 @@ const UserInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -69,6 +71,7 @@ const UserInfo = () => {
type='user'
id={userId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -80,6 +83,11 @@ const UserInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='user'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -18,6 +18,7 @@ import ActionHandler from '../../common/ActionHandler.jsx'
import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('VendorInfo')
log.setLevel(config.logLevel)
@ -37,7 +38,8 @@ const VendorInfo = () => {
editLoading: false,
formValid: false,
lock: null,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -77,6 +79,7 @@ const VendorInfo = () => {
type='vendor'
id={vendorId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -88,6 +91,11 @@ const VendorInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='vendor'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -20,6 +20,7 @@ import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import EyeIcon from '../../../Icons/EyeIcon.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const { Text } = Typography
@ -46,7 +47,8 @@ const GCodeFileInfo = () => {
editLoading: false,
formValid: false,
locked: false,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -85,6 +87,7 @@ const GCodeFileInfo = () => {
type='gcodeFile'
id={gcodeFileId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -97,6 +100,11 @@ const GCodeFileInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='gcodeFile'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>

View File

@ -20,6 +20,7 @@ import ObjectActions from '../../common/ObjectActions.jsx'
import ObjectTable from '../../common/ObjectTable.jsx'
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import JobIcon from '../../../Icons/JobIcon.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
const log = loglevel.getLogger('JobInfo')
log.setLevel(config.logLevel)
@ -41,7 +42,8 @@ const JobInfo = () => {
editLoading: false,
formValid: false,
locked: false,
loading: false
loading: false,
objectData: {}
})
const actions = {
@ -80,6 +82,7 @@ const JobInfo = () => {
type='job'
id={jobId}
disabled={objectFormState.loading}
objectData={objectFormState.objectData}
/>
<ViewButton
disabled={objectFormState.loading}
@ -92,6 +95,11 @@ const JobInfo = () => {
visibleState={collapseState}
updateVisibleState={updateCollapseState}
/>
<DocumentPrintButton
type='job'
objectData={objectFormState.objectData}
disabled={objectFormState.loading}
/>
</Space>
<LockIndicator lock={objectFormState.lock} />
</Space>