import React, { Component } from 'react'; import { withStyles } from 'material-ui/styles'; import Button from 'material-ui/Button'; import { LinearProgress } from 'material-ui/Progress'; import Typography from 'material-ui/Typography'; import List, { ListItem, ListItemText } from 'material-ui/List'; import Avatar from 'material-ui/Avatar'; import Divider from 'material-ui/Divider'; import SettingsInputAntennaIcon from 'material-ui-icons/SettingsInputAntenna'; import DeviceHubIcon from 'material-ui-icons/DeviceHub'; import ComputerIcon from 'material-ui-icons/Computer'; import SnackbarNotification from '../components/SnackbarNotification' import SectionContent from '../components/SectionContent' import * as Highlight from '../constants/Highlight'; import { AP_STATUS_ENDPOINT } from '../constants/Endpoints'; import { simpleGet } from '../helpers/SimpleGet'; const styles = theme => ({ ["apStatus_" + Highlight.SUCCESS]: { backgroundColor: theme.palette.highlight_success }, ["apStatus_" + Highlight.IDLE]: { backgroundColor: theme.palette.highlight_idle }, fetching: { margin: theme.spacing.unit * 4, textAlign: "center" }, button: { marginRight: theme.spacing.unit * 2, marginTop: theme.spacing.unit * 2, } }); class APStatus extends Component { constructor(props) { super(props); this.state = { status:null, fetched: false, errorMessage:null }; this.setState = this.setState.bind(this); this.loadAPStatus = this.loadAPStatus.bind(this); this.raiseNotification=this.raiseNotification.bind(this); } componentDidMount() { this.loadAPStatus(); } loadAPStatus() { simpleGet( AP_STATUS_ENDPOINT, this.setState, this.raiseNotification ); } raiseNotification(errorMessage) { this.snackbarNotification(errorMessage); } apStatusHighlight(status){ return status.active ? Highlight.SUCCESS : Highlight.IDLE; } apStatus(status){ return status.active ? "Active" : "Inactive"; } // active, ip_address, mac_address, station_num renderAPStatus(status, fullDetails, classes){ const listItems = []; listItems.push( ); listItems.push(); listItems.push( IP ); listItems.push(); listItems.push( ); listItems.push(); listItems.push( ); listItems.push(); return (
{listItems}
); } render() { const { status, fetched, errorMessage } = this.state; const { classes, fullDetails } = this.props; return ( this.snackbarNotification = snackbarNotification} /> { !fetched ?
Loading...
: status ? this.renderAPStatus(status, fullDetails, classes) :
{errorMessage}
}
) } } export default withStyles(styles)(APStatus);