Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prodigy mx #206

Merged
merged 13 commits into from
Mar 22, 2024
Prev Previous commit
Next Next commit
add reset name
  • Loading branch information
geoffhouse committed Mar 22, 2024
commit 512fa722a7059513fa8146723552d7f5f780696d
20 changes: 20 additions & 0 deletions src/modules/prodigy-mx/client/components/GroupButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import DeleteIcon from "@mui/icons-material/Delete";
import BallotIcon from "@mui/icons-material/Ballot";
import EditIcon from "@mui/icons-material/Edit";
import AxiosDelete from "@utils/AxiosDelete";
import RestartAltIcon from "@mui/icons-material/RestartAlt";

export default function GroupButton({ panelId, group, onClick, groupType, editMode = false, onChange, onEditButtons }) {
const sendAlert = useAlert();
Expand Down Expand Up @@ -35,6 +36,19 @@ export default function GroupButton({ panelId, group, onClick, groupType, editMo
}
};

const handleResetNameClicked = async (event, item) => {
if (
await AxiosCommand(
`/container/${panelId}/group/rename/${encodeURIComponent(groupType)}/${encodeURIComponent(group.index)}`
)
) {
sendAlert(`Renamed group: ${group.label}`, { variant: "success" });
} else {
sendAlert(`Failed to rename group: ${group.label}`, { variant: "error" });
}
onChange();
};

const handleDeleteClicked = async (event, item) => {
if (await AxiosDelete(`/container/${panelId}/group/${groupType}/${group.index}`)) {
sendAlert(`Deleted group: ${group.label}`, { variant: "success" });
Expand Down Expand Up @@ -64,6 +78,12 @@ export default function GroupButton({ panelId, group, onClick, groupType, editMo
{
title: "-",
},
{
title: "Reset Name",
disabled: !group.fixed,
icon: <RestartAltIcon fontSize="small" />,
onClick: handleResetNameClicked,
},
{
title: "Rename",
icon: <EditIcon fontSize="small" />,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/prodigy-mx/container/api/routes/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const groupDelete = require("@services/group-delete");
const groupAdd = require("@services/group-add");
const groupList = require("@services/group-list");

router.get("/:tyoe", async function (req, res, next) {
router.get("/:type", async function (req, res, next) {
try {
res.json({
status: "success",
Expand Down