mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge pull request #1090 from proddy/dev
remove project router, make everything from root
This commit is contained in:
@@ -42,9 +42,7 @@ const App: FC = () => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* <FeaturesLoader> */}
|
|
||||||
<AppRouting />
|
<AppRouting />
|
||||||
{/* </FeaturesLoader> */}
|
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</CustomTheme>
|
</CustomTheme>
|
||||||
</TypesafeI18n>
|
</TypesafeI18n>
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-
|
|||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
import * as AuthenticationApi from 'api/authentication';
|
import * as AuthenticationApi from 'api/authentication';
|
||||||
import { PROJECT_PATH } from 'api/env';
|
|
||||||
import { AXIOS } from 'api/endpoints';
|
import { AXIOS } from 'api/endpoints';
|
||||||
import { Layout, RequireAdmin } from 'components';
|
import { Layout, RequireAdmin } from 'components';
|
||||||
|
|
||||||
import ProjectRouting from 'project/ProjectRouting';
|
import Dashboard from './project/Dashboard';
|
||||||
|
import Settings from './project/Settings';
|
||||||
|
import Help from './project/Help';
|
||||||
|
|
||||||
import NetworkConnection from 'framework/network/NetworkConnection';
|
import NetworkConnection from 'framework/network/NetworkConnection';
|
||||||
import AccessPoint from 'framework/ap/AccessPoint';
|
import AccessPoint from 'framework/ap/AccessPoint';
|
||||||
@@ -39,7 +40,17 @@ const AuthenticatedRouting: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path={`/${PROJECT_PATH}/*`} element={<ProjectRouting />} />
|
<Route path="/dashboard/*" element={<Dashboard />} />
|
||||||
|
<Route
|
||||||
|
path="/settings/*"
|
||||||
|
element={
|
||||||
|
<RequireAdmin>
|
||||||
|
<Settings />
|
||||||
|
</RequireAdmin>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route path="/help/*" element={<Help />} />
|
||||||
|
|
||||||
<Route path="/network/*" element={<NetworkConnection />} />
|
<Route path="/network/*" element={<NetworkConnection />} />
|
||||||
<Route path="/ap/*" element={<AccessPoint />} />
|
<Route path="/ap/*" element={<AccessPoint />} />
|
||||||
<Route path="/ntp/*" element={<NetworkTime />} />
|
<Route path="/ntp/*" element={<NetworkTime />} />
|
||||||
|
|||||||
@@ -6,13 +6,10 @@ import { Path } from 'react-router-dom';
|
|||||||
import { Me, SignInRequest, SignInResponse } from 'types';
|
import { Me, SignInRequest, SignInResponse } from 'types';
|
||||||
|
|
||||||
import { ACCESS_TOKEN, AXIOS } from './endpoints';
|
import { ACCESS_TOKEN, AXIOS } from './endpoints';
|
||||||
import { PROJECT_PATH } from './env';
|
|
||||||
|
|
||||||
export const SIGN_IN_PATHNAME = 'loginPathname';
|
export const SIGN_IN_PATHNAME = 'loginPathname';
|
||||||
export const SIGN_IN_SEARCH = 'loginSearch';
|
export const SIGN_IN_SEARCH = 'loginSearch';
|
||||||
|
|
||||||
export const getDefaultRoute = `/${PROJECT_PATH}`;
|
|
||||||
|
|
||||||
export function verifyAuthorization(): AxiosPromise<void> {
|
export function verifyAuthorization(): AxiosPromise<void> {
|
||||||
return AXIOS.get('/verifyAuthorization');
|
return AXIOS.get('/verifyAuthorization');
|
||||||
}
|
}
|
||||||
@@ -21,9 +18,6 @@ export function signIn(request: SignInRequest): AxiosPromise<SignInResponse> {
|
|||||||
return AXIOS.post('/signIn', request);
|
return AXIOS.post('/signIn', request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fallback to sessionStorage if localStorage is absent. WebView may not have local storage enabled.
|
|
||||||
*/
|
|
||||||
export function getStorage() {
|
export function getStorage() {
|
||||||
return localStorage || sessionStorage;
|
return localStorage || sessionStorage;
|
||||||
}
|
}
|
||||||
@@ -45,7 +39,7 @@ export function fetchLoginRedirect(): Partial<Path> {
|
|||||||
const signInSearch = getStorage().getItem(SIGN_IN_SEARCH);
|
const signInSearch = getStorage().getItem(SIGN_IN_SEARCH);
|
||||||
clearLoginRedirect();
|
clearLoginRedirect();
|
||||||
return {
|
return {
|
||||||
pathname: signInPathname || `/${PROJECT_PATH}`,
|
pathname: signInPathname || `/dashboard`,
|
||||||
search: (signInPathname && signInSearch) || undefined
|
search: (signInPathname && signInSearch) || undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export const PROJECT_NAME = 'EMS-ESP';
|
export const PROJECT_NAME = 'EMS-ESP';
|
||||||
export const PROJECT_PATH = 'project';
|
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ import SettingsIcon from '@mui/icons-material/Settings';
|
|||||||
import LockIcon from '@mui/icons-material/Lock';
|
import LockIcon from '@mui/icons-material/Lock';
|
||||||
import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';
|
import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';
|
||||||
|
|
||||||
import ProjectMenu from 'project/ProjectMenu';
|
import TuneIcon from '@mui/icons-material/Tune';
|
||||||
|
import DashboardIcon from '@mui/icons-material/Dashboard';
|
||||||
|
import InfoIcon from '@mui/icons-material/Info';
|
||||||
|
|
||||||
|
import LayoutMenuItem from 'components/layout/LayoutMenuItem';
|
||||||
|
|
||||||
import LayoutMenuItem from './LayoutMenuItem';
|
|
||||||
import { AuthenticatedContext } from 'contexts/authentication';
|
import { AuthenticatedContext } from 'contexts/authentication';
|
||||||
|
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
@@ -23,7 +26,14 @@ const LayoutMenu: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<List disablePadding component="nav">
|
<List disablePadding component="nav">
|
||||||
<ProjectMenu />
|
<LayoutMenuItem icon={DashboardIcon} label={LL.DASHBOARD()} to={`/dashboard`} />
|
||||||
|
<LayoutMenuItem
|
||||||
|
icon={TuneIcon}
|
||||||
|
label={LL.SETTINGS_OF('')}
|
||||||
|
to={`/settings`}
|
||||||
|
disabled={!authenticatedContext.me.admin}
|
||||||
|
/>
|
||||||
|
<LayoutMenuItem icon={InfoIcon} label={LL.HELP_OF('')} to={`/help`} />
|
||||||
<Divider />
|
<Divider />
|
||||||
</List>
|
</List>
|
||||||
<List disablePadding component="nav">
|
<List disablePadding component="nav">
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { FC, useContext } from 'react';
|
|
||||||
|
|
||||||
import { List } from '@mui/material';
|
|
||||||
|
|
||||||
import { AuthenticatedContext } from 'contexts/authentication';
|
|
||||||
|
|
||||||
import { PROJECT_PATH } from 'api/env';
|
|
||||||
|
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
|
||||||
|
|
||||||
import TuneIcon from '@mui/icons-material/Tune';
|
|
||||||
import DashboardIcon from '@mui/icons-material/Dashboard';
|
|
||||||
import LayoutMenuItem from 'components/layout/LayoutMenuItem';
|
|
||||||
import InfoIcon from '@mui/icons-material/Info';
|
|
||||||
|
|
||||||
const ProjectMenu: FC = () => {
|
|
||||||
const authenticatedContext = useContext(AuthenticatedContext);
|
|
||||||
const { LL } = useI18nContext();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<List>
|
|
||||||
<LayoutMenuItem icon={DashboardIcon} label={LL.DASHBOARD()} to={`/${PROJECT_PATH}/dashboard`} />
|
|
||||||
<LayoutMenuItem
|
|
||||||
icon={TuneIcon}
|
|
||||||
label={LL.SETTINGS_OF('')}
|
|
||||||
to={`/${PROJECT_PATH}/settings`}
|
|
||||||
disabled={!authenticatedContext.me.admin}
|
|
||||||
/>
|
|
||||||
<LayoutMenuItem icon={InfoIcon} label={LL.HELP_OF('')} to={`/${PROJECT_PATH}/help`} />
|
|
||||||
</List>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ProjectMenu;
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { Navigate, Routes, Route } from 'react-router-dom';
|
|
||||||
|
|
||||||
import { RequireAdmin } from 'components';
|
|
||||||
|
|
||||||
import Dashboard from './Dashboard';
|
|
||||||
import Settings from './Settings';
|
|
||||||
import Help from './Help';
|
|
||||||
|
|
||||||
const ProjectRouting: FC = () => {
|
|
||||||
return (
|
|
||||||
<Routes>
|
|
||||||
<Route path="dashboard/*" element={<Dashboard />} />
|
|
||||||
<Route
|
|
||||||
path="settings/*"
|
|
||||||
element={
|
|
||||||
<RequireAdmin>
|
|
||||||
<Settings />
|
|
||||||
</RequireAdmin>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route path="help/*" element={<Help />} />
|
|
||||||
<Route path="/*" element={<Navigate to="dashboard/data" />} />
|
|
||||||
</Routes>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ProjectRouting;
|
|
||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.6.0-dev.0"
|
#define EMSESP_APP_VERSION "3.6.0-dev.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user