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.

38 lines
1.4 KiB

  1. import React, { Component } from 'react';
  2. import { Redirect, Switch, RouteComponentProps } from 'react-router-dom'
  3. import { Tabs, Tab } from '@material-ui/core';
  4. import { withAuthenticatedContext, AuthenticatedContextProps, AuthenticatedRoute } from '../authentication';
  5. import { MenuAppBar } from '../components';
  6. import SystemStatusController from './SystemStatusController';
  7. import OTASettingsController from './OTASettingsController';
  8. type SystemProps = AuthenticatedContextProps & RouteComponentProps;
  9. class System extends Component<SystemProps> {
  10. handleTabChange = (event: React.ChangeEvent<{}>, path: string) => {
  11. this.props.history.push(path);
  12. };
  13. render() {
  14. const { authenticatedContext } = this.props;
  15. return (
  16. <MenuAppBar sectionTitle="System">
  17. <Tabs value={this.props.match.url} onChange={this.handleTabChange} variant="fullWidth">
  18. <Tab value="/system/status" label="System Status" />
  19. <Tab value="/system/ota" label="OTA Settings" disabled={!authenticatedContext.me.admin} />
  20. </Tabs>
  21. <Switch>
  22. <AuthenticatedRoute exact path="/system/status" component={SystemStatusController} />
  23. <AuthenticatedRoute exact path="/system/ota" component={OTASettingsController} />
  24. <Redirect to="/system/status" />
  25. </Switch>
  26. </MenuAppBar>
  27. )
  28. }
  29. }
  30. export default withAuthenticatedContext(System);