fixed linking between groups and devices
This commit is contained in:
parent
77fb5a6bcf
commit
8fc8745862
3 changed files with 12 additions and 5 deletions
|
|
@ -84,7 +84,6 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
}
|
||||
}
|
||||
const regexMatch = or(location.pathname.match(/\/groups\/([^/]+)/), [])
|
||||
// console.log(or(regexMatch[1], "0").toString())
|
||||
return or(regexMatch[1], "0").toString();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -200,13 +200,21 @@ export default function Devices() {
|
|||
setLimit(event.target.value);
|
||||
};
|
||||
|
||||
const appendToUrl = (appendage: number | string) => {
|
||||
// const appendToUrl = (appendage: number | string) => {
|
||||
// const basePath = location.pathname.replace(/\/$/, "");
|
||||
// return(`${basePath}/${appendage}`);
|
||||
// };
|
||||
|
||||
const prependToUrl = (prependage: number | string) => {
|
||||
console.log(location.pathname)
|
||||
const basePath = location.pathname.replace(/\/$/, "");
|
||||
return(`${basePath}/${appendage}`);
|
||||
return(`/${prependage}/${basePath}`.replace(/\/{2,}/g, "/").replace(/(\/[^/]+)\/\1+/g, "$1"));
|
||||
};
|
||||
|
||||
const toDevice = (device: Device) => {
|
||||
navigate(appendToUrl(or(device.settings?.deviceId, "")), { state: {device: device} })
|
||||
let url = prependToUrl(getGroup() ? "groups/" + getGroup().id() : "")
|
||||
url = url + "/" + device.id()
|
||||
navigate(url, { replace: true, state: {device: device} })
|
||||
};
|
||||
|
||||
const handleTabChange = (_event: React.SyntheticEvent, newValue: string) => {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export default function GroupPage() {
|
|||
}, [group, limit, page, order, orderBy, search])
|
||||
|
||||
const toDevice = (device: Device) => {
|
||||
navigate(appendToUrl(or(device.settings?.deviceId, "")), { state: {device: device} })
|
||||
navigate(appendToUrl(or("devices/"+device.settings?.deviceId, "")), { state: {device: device} })
|
||||
};
|
||||
|
||||
const columns = (): Column<Device>[] => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue