2022-06-22 00:47:19 +00:00
|
|
|
import { useState, useContext, useEffect } from "react";
|
2022-05-17 12:32:04 +00:00
|
|
|
import StoreContext from "../ctx/StoreContext.jsx";
|
|
|
|
import JobContext from "../ctx/JobContext.jsx";
|
2022-06-22 00:47:19 +00:00
|
|
|
import JobBox from "./components/JobBox.jsx";
|
|
|
|
import JobTestSelector from "./components/JobTestSelector.jsx";
|
|
|
|
|
|
|
|
import Button from "@mui/material/Button";
|
|
|
|
import Dialog from "@mui/material/Dialog";
|
|
|
|
import DialogActions from "@mui/material/DialogActions";
|
|
|
|
import DialogContent from "@mui/material/DialogContent";
|
|
|
|
|
|
|
|
import DialogTitle from "@mui/material/DialogTitle";
|
2022-05-17 12:32:04 +00:00
|
|
|
|
2022-05-23 00:24:21 +00:00
|
|
|
import ClickAwayListener from "@mui/material/ClickAwayListener";
|
|
|
|
import SpeedDial from "@mui/material/SpeedDial";
|
|
|
|
import SpeedDialAction from "@mui/material/SpeedDialAction";
|
|
|
|
import SpeedDialIcon from "@mui/material/SpeedDialIcon";
|
2022-05-17 12:32:04 +00:00
|
|
|
|
2022-05-23 00:24:21 +00:00
|
|
|
import PageviewIcon from "@mui/icons-material/Pageview";
|
|
|
|
import ViewColumnIcon from "@mui/icons-material/ViewColumn";
|
|
|
|
import ViewCarouselIcon from "@mui/icons-material/ViewCarousel";
|
2022-05-17 12:32:04 +00:00
|
|
|
|
|
|
|
export default function Jobs() {
|
|
|
|
const {
|
|
|
|
state: jobState,
|
|
|
|
dispatch: jobDispatch,
|
|
|
|
jobUpdate,
|
|
|
|
jobCreate,
|
|
|
|
} = useContext(JobContext);
|
|
|
|
|
|
|
|
const { state: store, updateStore } = useContext(StoreContext);
|
|
|
|
const [quickOpen, setQuickOpen] = useState(false);
|
2022-06-22 00:47:19 +00:00
|
|
|
const [jobDialogOpen, setJobDialogOpen] = useState(false);
|
2022-05-23 00:24:21 +00:00
|
|
|
|
2022-05-17 12:32:04 +00:00
|
|
|
const actions = [
|
2022-05-23 00:24:21 +00:00
|
|
|
{ name: "Suite", icon: <ViewCarouselIcon /> },
|
|
|
|
{ name: "Compound", icon: <ViewColumnIcon /> },
|
|
|
|
{ name: "Manual", icon: <PageviewIcon /> },
|
|
|
|
];
|
2022-06-22 00:47:19 +00:00
|
|
|
|
|
|
|
const quickOpenClick = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
if(!store.simplifiedControls) return setQuickOpen(!quickOpen);
|
|
|
|
setJobDialogOpen(true);
|
|
|
|
}
|
|
|
|
const quickOpenClose = () => setQuickOpen(false);
|
|
|
|
|
|
|
|
|
|
|
|
const handleClickOpen = () => setJobDialogOpen(true);
|
|
|
|
const handleClose = () => setJobDialogOpen(false);
|
|
|
|
const [queued, setQueued] = useState([]);
|
|
|
|
useEffect(() => {
|
|
|
|
}, [jobState.jobs]);
|
2022-05-23 00:24:21 +00:00
|
|
|
|
2022-05-17 12:32:04 +00:00
|
|
|
return (
|
|
|
|
<div className="jobs">
|
2022-06-22 00:47:19 +00:00
|
|
|
{jobState.jobs.map((v, i) => (
|
|
|
|
<JobBox key={i} job={v} />
|
|
|
|
))}
|
|
|
|
|
|
|
|
<Dialog open={jobDialogOpen} onClose={handleClose} maxWidth="xs">
|
|
|
|
<DialogTitle>New Job</DialogTitle>
|
|
|
|
<DialogContent>
|
|
|
|
<span>Some Selectors</span>
|
|
|
|
<JobTestSelector queued={queued} availableTests={store.catalog} setQueued={setQueued} />
|
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
|
|
|
<Button onClick={handleClose}>Cancel</Button>
|
|
|
|
<Button onClick={handleClose} autoFocus>
|
|
|
|
Start
|
|
|
|
</Button>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
|
|
|
|
2022-05-23 00:24:21 +00:00
|
|
|
<ClickAwayListener onClickAway={quickOpenClose}>
|
|
|
|
<SpeedDial
|
|
|
|
ariaLabel="New Job"
|
|
|
|
sx={{ position: "fixed", bottom: 16, right: 16 }}
|
|
|
|
icon={<SpeedDialIcon />}
|
|
|
|
onClick={quickOpenClick}
|
|
|
|
open={quickOpen}
|
|
|
|
>
|
|
|
|
{actions.map((action) => (
|
|
|
|
<SpeedDialAction
|
|
|
|
key={action.name}
|
|
|
|
icon={action.icon}
|
|
|
|
tooltipTitle={action.name}
|
2022-06-22 00:47:19 +00:00
|
|
|
onClick={handleClickOpen}
|
2022-05-23 00:24:21 +00:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</SpeedDial>
|
|
|
|
</ClickAwayListener>
|
2022-05-17 12:32:04 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|