-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from bbc/prodigy-mx
Prodigy mx
- Loading branch information
Showing
73 changed files
with
180,282 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- auto detection of modules is done - but needs testing! | ||
- validate config params | ||
- spinner while edit buttons dialog loads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import BugModuleWrapper from "@core/BugModuleWrapper"; | ||
import { Route } from "react-router-dom"; | ||
|
||
const MainPanel = React.lazy(() => import("./panels/MainPanel")); | ||
const ConfigPanel = React.lazy(() => import("./panels/ConfigPanel")); | ||
|
||
export default function Module(props) { | ||
return ( | ||
<BugModuleWrapper {...props}> | ||
<Route exact path="/panel/:panelId/display/:tab"> | ||
<MainPanel {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId/display/:tab/:sourceGroup/:destinationGroup"> | ||
<MainPanel editMode={false} {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId/edit/"> | ||
<MainPanel editMode={true} {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId/edit/display/:tab"> | ||
<MainPanel editMode={true} {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId/edit/display/:tab/:sourceGroup/:destinationGroup"> | ||
<MainPanel editMode={true} {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId/config"> | ||
<ConfigPanel {...props} /> | ||
</Route> | ||
<Route exact path="/panel/:panelId"> | ||
<MainPanel {...props} /> | ||
</Route> | ||
</BugModuleWrapper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from "react"; | ||
import BugToolbarWrapper from "@core/BugToolbarWrapper"; | ||
import Button from "@mui/material/Button"; | ||
import EditIcon from "@mui/icons-material/Edit"; | ||
import { Link } from "react-router-dom"; | ||
import { useLocation } from "react-router-dom"; | ||
import DoneIcon from "@mui/icons-material/Done"; | ||
import { usePanelStatus } from "@hooks/PanelStatus"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import ListItemIcon from "@mui/material/ListItemIcon"; | ||
import ListItemText from "@mui/material/ListItemText"; | ||
import CheckIcon from "@mui/icons-material/Check"; | ||
import Divider from "@mui/material/Divider"; | ||
import { useSelector } from "react-redux"; | ||
import AxiosPut from "@utils/AxiosPut"; | ||
import { useHistory } from "react-router-dom"; | ||
|
||
export default function Toolbar({ panelId, ...props }) { | ||
const toolbarProps = { ...props }; | ||
const location = useLocation(); | ||
const panelStatus = usePanelStatus(); | ||
const panelConfig = useSelector((state) => state.panelConfig); | ||
const history = useHistory(); | ||
|
||
if (!panelStatus) { | ||
return null; | ||
} | ||
|
||
const editMode = location.pathname.indexOf("/edit") > -1; | ||
|
||
const handleUseTakeClicked = async (event, item) => { | ||
await AxiosPut(`/api/panelconfig/${panelId}`, { | ||
useTake: !panelConfig?.data?.useTake, | ||
}); | ||
}; | ||
|
||
const handleEditClicked = (event, item) => { | ||
const urlParts = location.pathname.split("/"); | ||
if (urlParts.length === 3) { | ||
history.push(`/panel/${panelId}/edit`); | ||
} else if (urlParts.length === 5) { | ||
history.push(`/panel/${panelId}/edit/${urlParts.slice(-2).join("/")}`); | ||
} else if (urlParts.length === 7) { | ||
history.push(`/panel/${panelId}/edit/${urlParts.slice(-4).join("/")}`); | ||
} | ||
}; | ||
|
||
const handleDoneClicked = (event, item) => { | ||
const urlParts = location.pathname.split("/"); | ||
if (urlParts.length === 4) { | ||
history.push(`/panel/${panelId}/`); | ||
} else if (urlParts.length === 6) { | ||
history.push(`/panel/${panelId}/${urlParts.slice(-2).join("/")}`); | ||
} else if (urlParts.length === 8) { | ||
history.push(`/panel/${panelId}/${urlParts.slice(-4).join("/")}`); | ||
} | ||
}; | ||
|
||
const getParams = (matchCount) => { | ||
const urlParts = location.pathname.split("/"); | ||
if (urlParts.length === matchCount) { | ||
return urlParts.slice(-2).join("/"); | ||
} | ||
return ""; | ||
}; | ||
|
||
const buttons = () => ( | ||
<> | ||
{editMode ? ( | ||
<Button variant="outlined" color="primary" startIcon={<DoneIcon />} onClick={handleDoneClicked}> | ||
Done | ||
</Button> | ||
) : ( | ||
<Button variant="outlined" color="primary" startIcon={<EditIcon />} onClick={handleEditClicked}> | ||
Edit | ||
</Button> | ||
)} | ||
</> | ||
); | ||
|
||
const menuItems = () => { | ||
return [ | ||
<Divider key="divider1" />, | ||
<MenuItem key="usetake" onClick={handleUseTakeClicked}> | ||
<ListItemIcon>{panelConfig?.data?.useTake ? <CheckIcon fontSize="small" /> : null}</ListItemIcon> | ||
<ListItemText primary="Confirm Take" /> | ||
</MenuItem>, | ||
]; | ||
}; | ||
|
||
toolbarProps["buttons"] = panelStatus.hasCritical ? null : buttons(); | ||
toolbarProps["menuItems"] = menuItems(); | ||
toolbarProps["onClick"] = null; | ||
return <BugToolbarWrapper {...toolbarProps} />; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/modules/prodigy-mx/client/components/AddGroupButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Button from "@mui/material/Button"; | ||
import AddIcon from "@mui/icons-material/Add"; | ||
|
||
export default function AddGroupButton({ onClick }) { | ||
return ( | ||
<Button | ||
sx={{ | ||
borderRadius: "3px", | ||
margin: "4px", | ||
width: "128px", | ||
height: "48px", | ||
"@media (max-width:800px)": { | ||
height: "36px", | ||
width: "92px", | ||
}, | ||
}} | ||
variant="outlined" | ||
color="secondary" | ||
onClick={onClick} | ||
> | ||
<AddIcon /> | ||
</Button> | ||
); | ||
} |
70 changes: 70 additions & 0 deletions
70
src/modules/prodigy-mx/client/components/AddGroupDialog.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from "react"; | ||
import Dialog from "@mui/material/Dialog"; | ||
import DialogActions from "@mui/material/DialogActions"; | ||
import DialogContent from "@mui/material/DialogContent"; | ||
import DialogTitle from "@mui/material/DialogTitle"; | ||
import Button from "@mui/material/Button"; | ||
import FormControl from "@mui/material/FormControl"; | ||
import TextField from "@mui/material/TextField"; | ||
import Autocomplete from "@mui/material/Autocomplete"; | ||
|
||
export default function AddGroupDialog({ onDismiss, onConfirm, groups }) { | ||
const [selectedGroups, setSelectedGroups] = React.useState([]); | ||
|
||
const modifiedGroups = groups.map((group) => { | ||
return { | ||
id: group.index, | ||
label: group.label, | ||
}; | ||
}); | ||
|
||
return ( | ||
<Dialog open onClose={onDismiss}> | ||
<form | ||
onSubmit={(event) => { | ||
event.preventDefault(); | ||
}} | ||
> | ||
<DialogTitle id="alert-dialog-title">Add to Groups</DialogTitle> | ||
<DialogContent> | ||
<FormControl> | ||
<Autocomplete | ||
sx={{ width: "20rem" }} | ||
multiple | ||
filterSelectedOptions | ||
options={modifiedGroups} | ||
fullWidth | ||
freeSolo={false} | ||
onChange={(event, values) => { | ||
setSelectedGroups(values); | ||
}} | ||
value={selectedGroups} | ||
renderInput={(params) => ( | ||
<TextField {...params} fullWidth variant="standard" label="Select groups ..." /> | ||
)} | ||
/> | ||
</FormControl> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={onDismiss} color="primary"> | ||
Cancel | ||
</Button> | ||
<Button | ||
type="submit" | ||
onClick={(event) => | ||
onConfirm( | ||
event, | ||
selectedGroups.map((group) => group.id) | ||
) | ||
} | ||
color="primary" | ||
autoFocus | ||
disabled={selectedGroups.length === 0} | ||
> | ||
Add | ||
</Button> | ||
</DialogActions> | ||
</form> | ||
</Dialog> | ||
); | ||
} |
Oops, something went wrong.