mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-30 02:29:12 +03:00
updates to web pages
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { useContext, type FC } from 'react';
|
||||
import { Navigate, Routes, Route } from 'react-router-dom';
|
||||
import Help from './project/Help';
|
||||
import type { FC } from 'react';
|
||||
import { Layout, RequireAdmin } from 'components';
|
||||
import { Layout } from 'components';
|
||||
import { AuthenticatedContext } from 'contexts/authentication';
|
||||
import Settings from 'framework/Settings';
|
||||
import AccessPoint from 'framework/ap/AccessPoint';
|
||||
import Mqtt from 'framework/mqtt/Mqtt';
|
||||
@@ -18,49 +19,35 @@ import Devices from 'project/Devices';
|
||||
import Scheduler from 'project/Scheduler';
|
||||
import Sensors from 'project/Sensors';
|
||||
|
||||
const AuthenticatedRouting: FC = () => (
|
||||
<Layout>
|
||||
<Routes>
|
||||
<Route path="/devices/*" element={<Devices />} />
|
||||
<Route path="/sensors/*" element={<Sensors />} />
|
||||
|
||||
<Route path="/customizations/*" element={<Customization />} />
|
||||
<Route path="/scheduler/*" element={<Scheduler />} />
|
||||
<Route path="/customentities/*" element={<CustomEntities />} />
|
||||
|
||||
{/* TODO only show the rest here if admin */}
|
||||
|
||||
<Route path="/status/*" element={<Status />} />
|
||||
|
||||
<Route
|
||||
path="settings/*"
|
||||
element={
|
||||
<RequireAdmin>
|
||||
<Settings />
|
||||
</RequireAdmin>
|
||||
}
|
||||
/>
|
||||
<Route path="/settings/network/*" element={<NetworkConnection />} />
|
||||
<Route path="/settings/ems-esp/*" element={<ApplicationSettings />} />
|
||||
<Route path="/settings/ap/*" element={<AccessPoint />} />
|
||||
<Route path="/settings/ntp/*" element={<NetworkTime />} />
|
||||
<Route path="/settings/mqtt/*" element={<Mqtt />} />
|
||||
<Route path="/settings/ota/*" element={<OTASettingsForm />} />
|
||||
<Route
|
||||
path="/settings/security/*"
|
||||
element={
|
||||
<RequireAdmin>
|
||||
<Security />
|
||||
</RequireAdmin>
|
||||
}
|
||||
/>
|
||||
<Route path="/settings/upload/*" element={<UploadDownload />} />
|
||||
|
||||
<Route path="/help/*" element={<Help />} />
|
||||
|
||||
<Route path="/*" element={<Navigate to="/" />} />
|
||||
</Routes>
|
||||
</Layout>
|
||||
);
|
||||
const AuthenticatedRouting: FC = () => {
|
||||
const { me } = useContext(AuthenticatedContext);
|
||||
return (
|
||||
<Layout>
|
||||
<Routes>
|
||||
<Route path="/devices/*" element={<Devices />} />
|
||||
<Route path="/sensors/*" element={<Sensors />} />
|
||||
<Route path="/status/*" element={<Status />} />
|
||||
<Route path="/help/*" element={<Help />} />
|
||||
<Route path="/*" element={<Navigate to="/" />} />
|
||||
{me.admin && (
|
||||
<>
|
||||
<Route path="/customizations/*" element={<Customization />} />
|
||||
<Route path="/scheduler/*" element={<Scheduler />} />
|
||||
<Route path="/customentities/*" element={<CustomEntities />} />
|
||||
<Route path="/settings/*" element={<Settings />} />
|
||||
<Route path="/settings/network/*" element={<NetworkConnection />} />
|
||||
<Route path="/settings/ems-esp/*" element={<ApplicationSettings />} />
|
||||
<Route path="/settings/ap/*" element={<AccessPoint />} />
|
||||
<Route path="/settings/ntp/*" element={<NetworkTime />} />
|
||||
<Route path="/settings/mqtt/*" element={<Mqtt />} />
|
||||
<Route path="/settings/ota/*" element={<OTASettingsForm />} />
|
||||
<Route path="/settings/security/*" element={<Security />} />
|
||||
<Route path="/settings/upload/*" element={<UploadDownload />} />
|
||||
</>
|
||||
)}
|
||||
</Routes>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthenticatedRouting;
|
||||
|
||||
Reference in New Issue
Block a user