fixed issue with adding devices to group

This commit is contained in:
Carter 2025-04-29 10:45:24 -06:00
parent 765ac72431
commit 539dd667c7
3 changed files with 13 additions and 24 deletions

View file

@ -278,7 +278,6 @@ export default function SmartBreadcrumb(props: Props) {
const breadcrumbLinks = (): ReactNode[] => { const breadcrumbLinks = (): ReactNode[] => {
const breadcrumbMap = getBreadcrumbMap(); const breadcrumbMap = getBreadcrumbMap();
//console.log(breadcrumbMap)
let links: ReactNode[] = []; let links: ReactNode[] = [];
let pathnames = location.pathname.split("/").filter((x: any) => x); let pathnames = location.pathname.split("/").filter((x: any) => x);
@ -288,24 +287,15 @@ export default function SmartBreadcrumb(props: Props) {
return [linkComponent("/", "Dashboard", true)]; return [linkComponent("/", "Dashboard", true)];
} }
// if (prependPaths) pathnames.unshift(...prependPaths)
// if (prependPaths) pathnames.push(...prependPaths)
if (prependPaths) pathnames.splice(pathnames.length - 1, 0, ...prependPaths); if (prependPaths) pathnames.splice(pathnames.length - 1, 0, ...prependPaths);
//console.log(pathnames)
pathnames.forEach((_value: any, index: any) => { pathnames.forEach((_value: any, index: any) => {
const lastPath = index === pathnames.length - 1; const lastPath = index === pathnames.length - 1;
//console.log(lastPath)
const to = `/${pathnames.slice(0, index + 1).join("/")}`; const to = `/${pathnames.slice(0, index + 1).join("/")}`;
//console.log("to: " + to)
let label = breadcrumbMap[to]; let label = breadcrumbMap[to];
//console.log("label: "+label)
let result = to.split("/").filter(str => str !== ""); let result = to.split("/").filter(str => str !== "");
//console.log("result: " + result.toString())
if (!label) { if (!label) {
//console.log("no label")
if (result.length > 1) { if (result.length > 1) {
if (result[result.length - 1] !== "components") { if (result[result.length - 1] !== "components") {
label = breadcrumbMap["/" + result[result.length - 1]]; label = breadcrumbMap["/" + result[result.length - 1]];
@ -317,12 +307,10 @@ export default function SmartBreadcrumb(props: Props) {
} }
if (!blacklist.includes(to) && label) { if (!blacklist.includes(to) && label) {
//console.log("push link")
links.push(linkComponent(to, label, lastPath)); links.push(linkComponent(to, label, lastPath));
} }
}); });
//console.log(links)
return links; return links;
}; };

View file

@ -151,7 +151,6 @@ export default function GroupSettings(props: Props) {
.then((response: any) => { .then((response: any) => {
success(groupName + " was successfully created"); success(groupName + " was successfully created");
close(); close();
console.log(response)
group.settings.groupId = parseInt(response.data.id) group.settings.groupId = parseInt(response.data.id)
if (addGroupCallback) addGroupCallback(group.settings) if (addGroupCallback) addGroupCallback(group.settings)
else refreshCallback(); else refreshCallback();
@ -232,9 +231,11 @@ export default function GroupSettings(props: Props) {
}; };
const changeDevices = (device: number) => { const changeDevices = (device: number) => {
console.log("change")
let updatedGroup = Group.clone(group); let updatedGroup = Group.clone(group);
const exists = updatedGroup.settings.devices.includes(device); const exists = updatedGroup.settings.devices.includes(device);
if (exists) { if (exists) {
console.log("exists")
updatedGroup.settings.devices = updatedGroup.settings.devices.filter( updatedGroup.settings.devices = updatedGroup.settings.devices.filter(
groupDevice => groupDevice !== device groupDevice => groupDevice !== device
); );
@ -328,7 +329,7 @@ export default function GroupSettings(props: Props) {
<Checkbox <Checkbox
edge="end" edge="end"
onChange={() => changeDevices(device.id())} onChange={() => changeDevices(device.id())}
checked={groupDeviceNumbers.includes(device.id())} checked={group.settings.devices.includes(device.id())}
inputProps={{ "aria-labelledby": label }} inputProps={{ "aria-labelledby": label }}
disabled={!canEdit} disabled={!canEdit}
/> />

View file

@ -77,16 +77,16 @@ export default function GroupsPage() {
const columns = (): Column<pond.Group>[] => { const columns = (): Column<pond.Group>[] => {
return [ return [
{ // {
title: "Size", // title: "Size",
render: (group) => { // render: (group) => {
return ( // return (
<Box className={classes.smallCellContainer}> // <Box className={classes.smallCellContainer}>
{group.settings?.devices?.length ? group.settings.devices.length : 0} // {group.settings?.devices?.length ? group.settings.devices.length : 0}
</Box> // </Box>
) // )
} // }
}, // },
{ {
title: "Group Name", title: "Group Name",
render: (group) => { render: (group) => {