mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
revert back to absolute routing
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import { useMatch, useResolvedPath } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
export const useRouterTab = () => {
|
export const useRouterTab = () => {
|
||||||
// const loc = useLocation().pathname;
|
const loc = useLocation().pathname;
|
||||||
// const routerTab = loc.substring(0, loc.lastIndexOf('/')) ? loc : false;
|
const routerTab = loc.substring(0, loc.lastIndexOf('/')) ? loc : false;
|
||||||
|
|
||||||
const routerTabPath = useResolvedPath(':tab');
|
// const routerTabPath = useResolvedPath(':tab');
|
||||||
const routerTabPathMatch = useMatch(routerTabPath.pathname);
|
// const routerTabPathMatch = useMatch(routerTabPath.pathname);
|
||||||
const routerTab = routerTabPathMatch?.params?.tab || false;
|
// const routerTab = routerTabPathMatch?.params?.tab || false;
|
||||||
|
|
||||||
return { routerTab } as const;
|
return { routerTab } as const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,8 +22,12 @@ const AccessPoint: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="status" label={LL.STATUS_OF(LL.ACCESS_POINT(1))} />
|
<Tab value="/ap/status" label={LL.STATUS_OF(LL.ACCESS_POINT(1))} />
|
||||||
<Tab value="settings" label={LL.SETTINGS_OF(LL.ACCESS_POINT(1))} disabled={!authenticatedContext.me.admin} />
|
<Tab
|
||||||
|
value="/ap/settings"
|
||||||
|
label={LL.SETTINGS_OF(LL.ACCESS_POINT(1))}
|
||||||
|
disabled={!authenticatedContext.me.admin}
|
||||||
|
/>
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="status" element={<APStatusForm />} />
|
<Route path="status" element={<APStatusForm />} />
|
||||||
@@ -36,7 +40,7 @@ const AccessPoint: FC = () => {
|
|||||||
</RequireAdmin>
|
</RequireAdmin>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/*" element={<Navigate replace to="status" />} />
|
<Route path="*" element={<Navigate replace to="/ap/status" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ const Mqtt: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="status" label={LL.STATUS_OF('MQTT')} />
|
<Tab value="/mqtt/status" label={LL.STATUS_OF('MQTT')} />
|
||||||
<Tab value="settings" label={LL.SETTINGS_OF('MQTT')} disabled={!authenticatedContext.me.admin} />
|
<Tab value="/mqtt/settings" label={LL.SETTINGS_OF('MQTT')} disabled={!authenticatedContext.me.admin} />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="status" element={<MqttStatusForm />} />
|
<Route path="status" element={<MqttStatusForm />} />
|
||||||
@@ -34,7 +34,7 @@ const Mqtt: FC = () => {
|
|||||||
</RequireAdmin>
|
</RequireAdmin>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/*" element={<Navigate replace to="status" />} />
|
<Route path="*" element={<Navigate replace to="/mqtt/status" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,9 +44,13 @@ const NetworkConnection: FC = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="status" label={LL.STATUS_OF(LL.NETWORK(1))} />
|
<Tab value="/network/status" label={LL.STATUS_OF(LL.NETWORK(1))} />
|
||||||
<Tab value="scan" label={LL.NETWORK_SCAN()} disabled={!authenticatedContext.me.admin} />
|
<Tab value="/network/scan" label={LL.NETWORK_SCAN()} disabled={!authenticatedContext.me.admin} />
|
||||||
<Tab value="settings" label={LL.SETTINGS_OF(LL.NETWORK(1))} disabled={!authenticatedContext.me.admin} />
|
<Tab
|
||||||
|
value="/network/settings"
|
||||||
|
label={LL.SETTINGS_OF(LL.NETWORK(1))}
|
||||||
|
disabled={!authenticatedContext.me.admin}
|
||||||
|
/>
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="status" element={<NetworkStatusForm />} />
|
<Route path="status" element={<NetworkStatusForm />} />
|
||||||
@@ -66,7 +70,7 @@ const NetworkConnection: FC = () => {
|
|||||||
</RequireAdmin>
|
</RequireAdmin>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/*" element={<Navigate replace to="status" />} />
|
<Route path="*" element={<Navigate replace to="/network/status" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</WiFiConnectionContext.Provider>
|
</WiFiConnectionContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const NetworkTime: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="status" label={LL.STATUS_OF('NTP')} />
|
<Tab value="/ntp/status" label={LL.STATUS_OF('NTP')} />
|
||||||
<Tab value="settings" label={LL.SETTINGS_OF('NTP')} disabled={!authenticatedContext.me.admin} />
|
<Tab value="/ntp/settings" label={LL.SETTINGS_OF('NTP')} disabled={!authenticatedContext.me.admin} />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="status" element={<NTPStatusForm />} />
|
<Route path="status" element={<NTPStatusForm />} />
|
||||||
@@ -33,7 +33,7 @@ const NetworkTime: FC = () => {
|
|||||||
</RequireAdmin>
|
</RequireAdmin>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/*" element={<Navigate replace to="status" />} />
|
<Route path="*" element={<Navigate replace to="/ntp/status" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ const Security: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="users" label={LL.MANAGE_USERS()} />
|
<Tab value="/security/users" label={LL.MANAGE_USERS()} />
|
||||||
<Tab value="settings" label={LL.SETTINGS_OF(LL.SECURITY(1))} />
|
<Tab value="/security/settings" label={LL.SETTINGS_OF(LL.SECURITY(1))} />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="users" element={<ManageUsersForm />} />
|
<Route path="users" element={<ManageUsersForm />} />
|
||||||
<Route path="settings" element={<SecuritySettingsForm />} />
|
<Route path="settings" element={<SecuritySettingsForm />} />
|
||||||
<Route path="/*" element={<Navigate replace to="users" />} />
|
<Route path="*" element={<Navigate replace to="/security/users" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ const System: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="status" label={LL.STATUS_OF(LL.SYSTEM(1))} />
|
<Tab value="/system/status" label={LL.STATUS_OF(LL.SYSTEM(1))} />
|
||||||
<Tab value="log" label={LL.LOG_OF(LL.SYSTEM(2))} />
|
<Tab value="/system/log" label={LL.LOG_OF(LL.SYSTEM(2))} />
|
||||||
<Tab value="ota" label={LL.SETTINGS_OF('OTA')} disabled={!me.admin} />
|
<Tab value="/system/ota" label={LL.SETTINGS_OF('OTA')} disabled={!me.admin} />
|
||||||
<Tab value="upload" label={LL.UPLOAD_DOWNLOAD()} disabled={!me.admin} />
|
<Tab value="/system/upload" label={LL.UPLOAD_DOWNLOAD()} disabled={!me.admin} />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="status" element={<SystemStatusForm />} />
|
<Route path="status" element={<SystemStatusForm />} />
|
||||||
@@ -47,7 +47,7 @@ const System: FC = () => {
|
|||||||
</RequireAdmin>
|
</RequireAdmin>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/*" element={<Navigate replace to="status" />} />
|
<Route path="*" element={<Navigate replace to="/system/status" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ const Dashboard: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="devices" label={LL.DEVICES()} />
|
<Tab value="/dashboard/devices" label={LL.DEVICES()} />
|
||||||
<Tab value="sensors" label={LL.SENSORS()} />
|
<Tab value="/dashboard/sensors" label={LL.SENSORS()} />
|
||||||
<Tab value="status" label="Status" />
|
<Tab value="/dashboard/status" label="Status" />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="devices" element={<DashboardDevices />} />
|
<Route path="devices" element={<DashboardDevices />} />
|
||||||
<Route path="sensors" element={<DashboardSensors />} />
|
<Route path="sensors" element={<DashboardSensors />} />
|
||||||
<Route path="status" element={<DashboardStatus />} />
|
<Route path="status" element={<DashboardStatus />} />
|
||||||
<Route path="/*" element={<Navigate replace to="devices" />} />
|
<Route path="*" element={<Navigate replace to="/dashboard/devices" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ const Settings: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RouterTabs value={routerTab}>
|
<RouterTabs value={routerTab}>
|
||||||
<Tab value="application" label={LL.APPLICATION_SETTINGS()} />
|
<Tab value="/settings/application" label={LL.APPLICATION_SETTINGS()} />
|
||||||
<Tab value="customization" label={LL.CUSTOMIZATIONS()} />
|
<Tab value="/settings/customization" label={LL.CUSTOMIZATIONS()} />
|
||||||
<Tab value="scheduler" label={LL.SCHEDULER()} />
|
<Tab value="/settings/scheduler" label={LL.SCHEDULER()} />
|
||||||
<Tab value="customentities" label={LL.CUSTOM_ENTITIES(0)} />
|
<Tab value="/settings/customentities" label={LL.CUSTOM_ENTITIES(0)} />
|
||||||
</RouterTabs>
|
</RouterTabs>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="application" element={<SettingsApplication />} />
|
<Route path="application" element={<SettingsApplication />} />
|
||||||
<Route path="customization" element={<SettingsCustomization />} />
|
<Route path="customization" element={<SettingsCustomization />} />
|
||||||
<Route path="scheduler" element={<SettingsScheduler />} />
|
<Route path="scheduler" element={<SettingsScheduler />} />
|
||||||
<Route path="customentities" element={<SettingsEntities />} />
|
<Route path="customentities" element={<SettingsEntities />} />
|
||||||
<Route path="/*" element={<Navigate replace to="application" />} />
|
<Route path="*" element={<Navigate replace to="/settings/application" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user