Add filament stock management to ControlPrinter component with modal integration for loading and unloading filament. Implement new actions for pausing, resuming, and canceling jobs, enhancing printer control functionality.
This commit is contained in:
parent
afe25c1e09
commit
91e7121fd5
@ -1,6 +1,6 @@
|
|||||||
import { useState, useRef, useEffect, useContext } 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, Modal } from 'antd'
|
||||||
import loglevel from 'loglevel'
|
import loglevel from 'loglevel'
|
||||||
import config from '../../../../config.js'
|
import config from '../../../../config.js'
|
||||||
import useCollapseState from '../../hooks/useCollapseState.js'
|
import useCollapseState from '../../hooks/useCollapseState.js'
|
||||||
@ -28,6 +28,9 @@ import { useMediaQuery } from 'react-responsive'
|
|||||||
import AlertsDisplay from '../../common/AlertsDisplay.jsx'
|
import AlertsDisplay from '../../common/AlertsDisplay.jsx'
|
||||||
import { ApiServerContext } from '../../context/ApiServerContext.jsx'
|
import { ApiServerContext } from '../../context/ApiServerContext.jsx'
|
||||||
|
|
||||||
|
import LoadFilamentStock from '../../Inventory/FilamentStocks/LoadFilamentStock.jsx'
|
||||||
|
import UnloadFilamentStock from '../../Inventory/FilamentStocks/UnloadFilamentStock.jsx'
|
||||||
|
|
||||||
const log = loglevel.getLogger('ControlPrinter')
|
const log = loglevel.getLogger('ControlPrinter')
|
||||||
log.setLevel(config.logLevel)
|
log.setLevel(config.logLevel)
|
||||||
|
|
||||||
@ -57,6 +60,9 @@ const ControlPrinter = () => {
|
|||||||
collapseState.movement
|
collapseState.movement
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const [loadFilamentStockOpen, setLoadFilamentStockOpen] = useState(false)
|
||||||
|
const [unloadFilamentStockOpen, setUnloadFilamentStockOpen] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSideBarVisible(
|
setSideBarVisible(
|
||||||
collapseState.temperature ||
|
collapseState.temperature ||
|
||||||
@ -122,6 +128,39 @@ const ControlPrinter = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
},
|
||||||
|
pauseJob: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'pauseJob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
|
resumeJob: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'resumeJob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
cancelJob: () => {
|
||||||
|
if (connected == true) {
|
||||||
|
sendObjectAction(printerId, 'printer', {
|
||||||
|
type: 'cancelJob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
loadFilamentStock: () => {
|
||||||
|
setLoadFilamentStockOpen(true)
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
unloadFilamentStock: () => {
|
||||||
|
setUnloadFilamentStockOpen(true)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +185,7 @@ const ControlPrinter = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Flex
|
<Flex
|
||||||
gap='large'
|
gap='large'
|
||||||
vertical='true'
|
vertical='true'
|
||||||
@ -272,7 +312,15 @@ const ControlPrinter = () => {
|
|||||||
'moonraker.host': false,
|
'moonraker.host': false,
|
||||||
tags: false,
|
tags: false,
|
||||||
firmware: false,
|
firmware: false,
|
||||||
alerts: false
|
alerts: false,
|
||||||
|
online: false,
|
||||||
|
active: false,
|
||||||
|
currentFilamentStock: false,
|
||||||
|
'currentFilamentStock._id': false,
|
||||||
|
currentJob: false,
|
||||||
|
'currentJob._id': false,
|
||||||
|
currentSubJob: false,
|
||||||
|
'currentSubJob._id': false
|
||||||
}}
|
}}
|
||||||
objectData={printerObjectData}
|
objectData={printerObjectData}
|
||||||
type='printer'
|
type='printer'
|
||||||
@ -333,7 +381,7 @@ const ControlPrinter = () => {
|
|||||||
{objectFormState.objectData?.currentSubJob?._id ? (
|
{objectFormState.objectData?.currentSubJob?._id ? (
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={objectFormState.objectData.currentSubJob._id}
|
id={objectFormState.objectData.currentSubJob._id}
|
||||||
type='subjob'
|
type='subJob'
|
||||||
onStateChange={() => {}}
|
onStateChange={() => {}}
|
||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
@ -370,10 +418,12 @@ const ControlPrinter = () => {
|
|||||||
updateCollapseState('filamentStock', expanded)
|
updateCollapseState('filamentStock', expanded)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{objectFormState.objectData?.currentFilamentStock?._id ? (
|
{objectFormState.objectData?.currentFilamentStock
|
||||||
|
?._id ? (
|
||||||
<ObjectForm
|
<ObjectForm
|
||||||
id={
|
id={
|
||||||
objectFormState.objectData.currentFilamentStock._id
|
objectFormState.objectData.currentFilamentStock
|
||||||
|
._id
|
||||||
}
|
}
|
||||||
type='filamentStock'
|
type='filamentStock'
|
||||||
onStateChange={() => {}}
|
onStateChange={() => {}}
|
||||||
@ -438,6 +488,35 @@ const ControlPrinter = () => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</div>
|
</div>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Modal
|
||||||
|
open={loadFilamentStockOpen}
|
||||||
|
onCancel={() => setLoadFilamentStockOpen(false)}
|
||||||
|
footer={null}
|
||||||
|
width='700px'
|
||||||
|
destroyOnHidden={true}
|
||||||
|
>
|
||||||
|
<LoadFilamentStock
|
||||||
|
printer={objectFormState.objectData}
|
||||||
|
onOk={() => setLoadFilamentStockOpen(false)}
|
||||||
|
reset={false}
|
||||||
|
filamentStockLoaded={false}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
open={unloadFilamentStockOpen}
|
||||||
|
onCancel={() => setUnloadFilamentStockOpen(false)}
|
||||||
|
footer={null}
|
||||||
|
width='700px'
|
||||||
|
destroyOnHidden={true}
|
||||||
|
>
|
||||||
|
<UnloadFilamentStock
|
||||||
|
printer={objectFormState.objectData}
|
||||||
|
onOk={() => setUnloadFilamentStockOpen(false)}
|
||||||
|
reset={false}
|
||||||
|
filamentStockLoaded={false}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user