-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev2' of https://github.com/emsesp/EMS-ESP32 into dev2
- Loading branch information
Showing
94 changed files
with
3,896 additions
and
3,754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VITE_ALOVA_TIPS=0 | ||
REACT_APP_ALOVA_TIPS=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,65 @@ | ||
import { useCallback, useEffect } from 'react'; | ||
import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-dom'; | ||
import { Navigate, Routes, Route } from 'react-router-dom'; | ||
import Dashboard from './project/Dashboard'; | ||
import Help from './project/Help'; | ||
import Settings from './project/Settings'; | ||
import type { AxiosError } from 'axios'; | ||
import type { FC } from 'react'; | ||
|
||
import * as AuthenticationApi from 'api/authentication'; | ||
import { AXIOS } from 'api/endpoints'; | ||
import { Layout, RequireAdmin } from 'components'; | ||
|
||
import AccessPoint from 'framework/ap/AccessPoint'; | ||
import Mqtt from 'framework/mqtt/Mqtt'; | ||
import NetworkConnection from 'framework/network/NetworkConnection'; | ||
import NetworkTime from 'framework/ntp/NetworkTime'; | ||
import Security from 'framework/security/Security'; | ||
import System from 'framework/system/System'; | ||
|
||
const AuthenticatedRouting: FC = () => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleApiResponseError = useCallback( | ||
(error: AxiosError) => { | ||
if (error.response && error.response.status === 401) { | ||
AuthenticationApi.storeLoginRedirect(location); | ||
navigate('/unauthorized'); | ||
} | ||
return Promise.reject(error); | ||
}, | ||
[location, navigate] | ||
); | ||
|
||
useEffect(() => { | ||
const axiosHandlerId = AXIOS.interceptors.response.use((response) => response, handleApiResponseError); | ||
return () => AXIOS.interceptors.response.eject(axiosHandlerId); | ||
}, [handleApiResponseError]); | ||
const AuthenticatedRouting: FC = () => ( | ||
// TODO not sure if this is needed, to redirect on 401. If so add incerceptor to Alova | ||
// const location = useLocation(); | ||
// const navigate = useNavigate(); | ||
// const handleApiResponseError = useCallback( | ||
// (error: AxiosError) => { | ||
// if (error.response && error.response.status === 401) { | ||
// AuthenticationApi.storeLoginRedirect(location); | ||
// navigate('/unauthorized'); | ||
// } | ||
// return Promise.reject(error); | ||
// }, | ||
// [location, navigate] | ||
// ); | ||
// useEffect(() => { | ||
// const axiosHandlerId = AXIOS.interceptors.response.use((response) => response, handleApiResponseError); | ||
// return () => AXIOS.interceptors.response.eject(axiosHandlerId); | ||
// }, [handleApiResponseError]); | ||
|
||
return ( | ||
<Layout> | ||
<Routes> | ||
<Route path="/dashboard/*" element={<Dashboard />} /> | ||
<Route | ||
path="/settings/*" | ||
element={ | ||
<RequireAdmin> | ||
<Settings /> | ||
</RequireAdmin> | ||
} | ||
/> | ||
<Route path="/help/*" element={<Help />} /> | ||
<Layout> | ||
<Routes> | ||
<Route path="/dashboard/*" element={<Dashboard />} /> | ||
<Route | ||
path="/settings/*" | ||
element={ | ||
<RequireAdmin> | ||
<Settings /> | ||
</RequireAdmin> | ||
} | ||
/> | ||
<Route path="/help/*" element={<Help />} /> | ||
|
||
<Route path="/network/*" element={<NetworkConnection />} /> | ||
<Route path="/ap/*" element={<AccessPoint />} /> | ||
<Route path="/ntp/*" element={<NetworkTime />} /> | ||
<Route path="/mqtt/*" element={<Mqtt />} /> | ||
<Route | ||
path="/security/*" | ||
element={ | ||
<RequireAdmin> | ||
<Security /> | ||
</RequireAdmin> | ||
} | ||
/> | ||
<Route path="/system/*" element={<System />} /> | ||
<Route path="/*" element={<Navigate to="/" />} /> | ||
</Routes> | ||
</Layout> | ||
); | ||
}; | ||
<Route path="/network/*" element={<NetworkConnection />} /> | ||
<Route path="/ap/*" element={<AccessPoint />} /> | ||
<Route path="/ntp/*" element={<NetworkTime />} /> | ||
<Route path="/mqtt/*" element={<Mqtt />} /> | ||
<Route | ||
path="/security/*" | ||
element={ | ||
<RequireAdmin> | ||
<Security /> | ||
</RequireAdmin> | ||
} | ||
/> | ||
<Route path="/system/*" element={<System />} /> | ||
<Route path="/*" element={<Navigate to="/" />} /> | ||
</Routes> | ||
</Layout> | ||
); | ||
|
||
export default AuthenticatedRouting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
import { AXIOS } from './endpoints'; | ||
import type { AxiosPromise } from 'axios'; | ||
import { alovaInstance } from './endpoints'; | ||
|
||
import type { APSettings, APStatus } from 'types'; | ||
|
||
export function readAPStatus(): AxiosPromise<APStatus> { | ||
return AXIOS.get('/apStatus'); | ||
} | ||
|
||
export function readAPSettings(): AxiosPromise<APSettings> { | ||
return AXIOS.get('/apSettings'); | ||
} | ||
|
||
export function updateAPSettings(apSettings: APSettings): AxiosPromise<APSettings> { | ||
return AXIOS.post('/apSettings', apSettings); | ||
} | ||
export const readAPStatus = () => alovaInstance.Get<APStatus>('/rest/apStatus'); | ||
export const readAPSettings = () => alovaInstance.Get<APSettings>('/rest/apSettings'); | ||
export const updateAPSettings = (data: APSettings) => alovaInstance.Post<APSettings>('/rest/apSettings', data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.