Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.7 KiB

5 years ago
  1. import React, { Component } from 'react';
  2. import { Switch, Redirect } from 'react-router';
  3. import * as Authentication from './authentication/Authentication';
  4. import AuthenticationWrapper from './authentication/AuthenticationWrapper';
  5. import UnauthenticatedRoute from './authentication/UnauthenticatedRoute';
  6. import AuthenticatedRoute from './authentication/AuthenticatedRoute';
  7. import SignIn from './SignIn';
  8. import ProjectRouting from './project/ProjectRouting';
  9. import WiFiConnection from './wifi/WiFiConnection';
  10. import AccessPoint from './ap/AccessPoint';
  11. import NetworkTime from './ntp/NetworkTime';
  12. import Security from './security/Security';
  13. import System from './system/System';
  14. import { PROJECT_PATH } from './api';
  15. import Mqtt from './mqtt/Mqtt';
  16. class AppRouting extends Component {
  17. componentDidMount() {
  18. Authentication.clearLoginRedirect();
  19. }
  20. render() {
  21. return (
  22. <AuthenticationWrapper>
  23. <Switch>
  24. <UnauthenticatedRoute exact path="/" component={SignIn} />
  25. <AuthenticatedRoute exact path={`/${PROJECT_PATH}/*`} component={ProjectRouting} />
  26. <AuthenticatedRoute exact path="/wifi/*" component={WiFiConnection} />
  27. <AuthenticatedRoute exact path="/ap/*" component={AccessPoint} />
  28. <AuthenticatedRoute exact path="/ntp/*" component={NetworkTime} />
  29. <AuthenticatedRoute exact path="/mqtt/*" component={Mqtt} />
  30. <AuthenticatedRoute exact path="/security/*" component={Security} />
  31. <AuthenticatedRoute exact path="/system/*" component={System} />
  32. <Redirect to="/" />
  33. </Switch>
  34. </AuthenticationWrapper>
  35. )
  36. }
  37. }
  38. export default AppRouting;