Add printer control actions for firmware and queue management
This commit is contained in:
parent
594c9a99ce
commit
3c9071be33
@ -1,4 +1,4 @@
|
|||||||
import { useState, useRef, useEffect } from 'react'
|
import { useState, useRef, useEffect, useContext } from 'react'
|
||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
import { Space, Flex, Card, Splitter, Divider } from 'antd'
|
import { Space, Flex, Card, Splitter, Divider } from 'antd'
|
||||||
import loglevel from 'loglevel'
|
import loglevel from 'loglevel'
|
||||||
@ -26,6 +26,7 @@ import FilamentStockIcon from '../../../Icons/FilamentStockIcon.jsx'
|
|||||||
import MissingPlaceholder from '../../common/MissingPlaceholder.jsx'
|
import MissingPlaceholder from '../../common/MissingPlaceholder.jsx'
|
||||||
import { useMediaQuery } from 'react-responsive'
|
import { useMediaQuery } from 'react-responsive'
|
||||||
import AlertsDisplay from '../../common/AlertsDisplay.jsx'
|
import AlertsDisplay from '../../common/AlertsDisplay.jsx'
|
||||||
|
import { ApiServerContext } from '../../context/ApiServerContext.jsx'
|
||||||
|
|
||||||
const log = loglevel.getLogger('ControlPrinter')
|
const log = loglevel.getLogger('ControlPrinter')
|
||||||
log.setLevel(config.logLevel)
|
log.setLevel(config.logLevel)
|
||||||
@ -49,6 +50,7 @@ const ControlPrinter = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const { connected, sendObjectAction } = useContext(ApiServerContext)
|
||||||
const [sideBarVisible, setSideBarVisible] = useState(
|
const [sideBarVisible, setSideBarVisible] = useState(
|
||||||
collapseState.temperature ||
|
collapseState.temperature ||
|
||||||
collapseState.position ||
|
collapseState.position ||
|
||||||
@ -88,6 +90,38 @@ const ControlPrinter = () => {
|
|||||||
finishEdit: () => {
|
finishEdit: () => {
|
||||||
objectFormRef?.current.handleUpdate()
|
objectFormRef?.current.handleUpdate()
|
||||||
return true
|
return true
|
||||||
|
},
|
||||||
|
restartFirmware: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'restartPrinterFirmware'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
restartMoonraker: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'restartMoonraker'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
restart: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'restartPrinter'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
startQueue: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'startQueue'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +162,7 @@ const ControlPrinter = () => {
|
|||||||
id={printerId}
|
id={printerId}
|
||||||
disabled={objectFormState.loading}
|
disabled={objectFormState.loading}
|
||||||
visibleActions={{ edit: false }}
|
visibleActions={{ edit: false }}
|
||||||
|
objectData={objectFormState.objectData}
|
||||||
/>
|
/>
|
||||||
<ViewButton
|
<ViewButton
|
||||||
disabled={objectFormState.loading}
|
disabled={objectFormState.loading}
|
||||||
@ -194,6 +229,19 @@ const ControlPrinter = () => {
|
|||||||
actions={actions}
|
actions={actions}
|
||||||
loading={objectFormState.loading}
|
loading={objectFormState.loading}
|
||||||
ref={actionHandlerRef}
|
ref={actionHandlerRef}
|
||||||
|
>
|
||||||
|
<Flex vertical>
|
||||||
|
<Splitter className={'farmcontrol-splitter'}>
|
||||||
|
<Splitter.Panel>
|
||||||
|
<Flex vertical gap={'large'}>
|
||||||
|
<InfoCollapse
|
||||||
|
title={'Printer'}
|
||||||
|
icon={<PrinterIcon />}
|
||||||
|
collapseKey='printer'
|
||||||
|
active={collapseState.printer}
|
||||||
|
onToggle={(expanded) =>
|
||||||
|
updateCollapseState('printer', expanded)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={printerId}
|
id={printerId}
|
||||||
@ -209,19 +257,6 @@ const ControlPrinter = () => {
|
|||||||
objectData: printerObjectData
|
objectData: printerObjectData
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Flex vertical>
|
|
||||||
<Splitter className={'farmcontrol-splitter'}>
|
|
||||||
<Splitter.Panel>
|
|
||||||
<Flex vertical gap={'large'}>
|
|
||||||
<InfoCollapse
|
|
||||||
title={'Printer'}
|
|
||||||
icon={<PrinterIcon />}
|
|
||||||
collapseKey='printer'
|
|
||||||
active={collapseState.printer}
|
|
||||||
onToggle={(expanded) =>
|
|
||||||
updateCollapseState('printer', expanded)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<ObjectInfo
|
<ObjectInfo
|
||||||
loading={printerObjectLoading}
|
loading={printerObjectLoading}
|
||||||
column={sideBarVisible ? 1 : undefined}
|
column={sideBarVisible ? 1 : undefined}
|
||||||
@ -236,11 +271,15 @@ const ControlPrinter = () => {
|
|||||||
'moonraker.protocol': false,
|
'moonraker.protocol': false,
|
||||||
'moonraker.host': false,
|
'moonraker.host': false,
|
||||||
tags: false,
|
tags: false,
|
||||||
firmware: false
|
firmware: false,
|
||||||
|
alerts: false
|
||||||
}}
|
}}
|
||||||
objectData={printerObjectData}
|
objectData={printerObjectData}
|
||||||
type='printer'
|
type='printer'
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</ObjectForm>
|
||||||
</InfoCollapse>
|
</InfoCollapse>
|
||||||
<InfoCollapse
|
<InfoCollapse
|
||||||
title={'Job'}
|
title={'Job'}
|
||||||
@ -251,9 +290,9 @@ const ControlPrinter = () => {
|
|||||||
updateCollapseState('job', expanded)
|
updateCollapseState('job', expanded)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{printerObjectData?.currentJob?._id ? (
|
{objectFormState.objectData?.currentJob?._id ? (
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={printerObjectData.currentJob._id}
|
id={objectFormState.objectData.currentJob._id}
|
||||||
type='job'
|
type='job'
|
||||||
onStateChange={() => {}}
|
onStateChange={() => {}}
|
||||||
>
|
>
|
||||||
@ -291,9 +330,9 @@ const ControlPrinter = () => {
|
|||||||
updateCollapseState('subJob', expanded)
|
updateCollapseState('subJob', expanded)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{printerObjectData?.currentSubJob?._id ? (
|
{objectFormState.objectData?.currentSubJob?._id ? (
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={printerObjectData.currentSubJob._id}
|
id={objectFormState.objectData.currentSubJob._id}
|
||||||
type='subjob'
|
type='subjob'
|
||||||
onStateChange={() => {}}
|
onStateChange={() => {}}
|
||||||
>
|
>
|
||||||
@ -331,9 +370,11 @@ const ControlPrinter = () => {
|
|||||||
updateCollapseState('filamentStock', expanded)
|
updateCollapseState('filamentStock', expanded)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{printerObjectData?.currentFilamentStock?._id ? (
|
{objectFormState.objectData?.currentFilamentStock?._id ? (
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={printerObjectData.currentFilamentStock._id}
|
id={
|
||||||
|
objectFormState.objectData.currentFilamentStock._id
|
||||||
|
}
|
||||||
type='filamentStock'
|
type='filamentStock'
|
||||||
onStateChange={() => {}}
|
onStateChange={() => {}}
|
||||||
>
|
>
|
||||||
@ -382,9 +423,6 @@ const ControlPrinter = () => {
|
|||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
|
||||||
}}
|
|
||||||
</ObjectForm>
|
|
||||||
</ActionHandler>
|
</ActionHandler>
|
||||||
<InfoCollapse
|
<InfoCollapse
|
||||||
title='Notes'
|
title='Notes'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user