use fragments where possible, and drop keys.
This commit is contained in:
parent
2c732d3281
commit
0b334a8ade
@ -61,7 +61,6 @@ class SnackbarNotification extends React.Component {
|
|||||||
message={<span id="message-id">{this.state.message}</span>}
|
message={<span id="message-id">{this.state.message}</span>}
|
||||||
action={
|
action={
|
||||||
<IconButton
|
<IconButton
|
||||||
key="close"
|
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
color="inherit"
|
color="inherit"
|
||||||
className={classes.close}
|
className={classes.close}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
|
|
||||||
import { withStyles } from 'material-ui/styles';
|
import { withStyles } from 'material-ui/styles';
|
||||||
import Button from 'material-ui/Button';
|
import Button from 'material-ui/Button';
|
||||||
@ -48,53 +48,46 @@ class APStatus extends Component {
|
|||||||
return data.active ? "Active" : "Inactive";
|
return data.active ? "Active" : "Inactive";
|
||||||
}
|
}
|
||||||
|
|
||||||
// active, ip_address, mac_address, station_num
|
createListItems(data, fullDetails, classes){
|
||||||
|
return (
|
||||||
renderAPStatus(data, fullDetails, classes){
|
<Fragment>
|
||||||
const listItems = [];
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="ap_status">
|
|
||||||
<Avatar className={classes["apStatus_" + this.apStatusHighlight(data)]}>
|
<Avatar className={classes["apStatus_" + this.apStatusHighlight(data)]}>
|
||||||
<SettingsInputAntennaIcon />
|
<SettingsInputAntennaIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Status" secondary={this.apStatus(data)} />
|
<ListItemText primary="Status" secondary={this.apStatus(data)} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ap_status_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="ip_address">
|
|
||||||
<Avatar>IP</Avatar>
|
<Avatar>IP</Avatar>
|
||||||
<ListItemText primary="IP Address" secondary={data.ip_address} />
|
<ListItemText primary="IP Address" secondary={data.ip_address} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ip_address_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="mac_address">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<DeviceHubIcon />
|
<DeviceHubIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="MAC Address" secondary={data.mac_address} />
|
<ListItemText primary="MAC Address" secondary={data.mac_address} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="mac_address_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="station_num">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<ComputerIcon />
|
<ComputerIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="AP Clients" secondary={data.station_num} />
|
<ListItemText primary="AP Clients" secondary={data.station_num} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<Divider inset component="li" />
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
listItems.push(<Divider key="station_num_divider" inset component="li" />);
|
}
|
||||||
|
|
||||||
|
renderAPStatus(data, fullDetails, classes){
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<List>
|
<List>
|
||||||
{listItems}
|
<Fragment>
|
||||||
|
{this.createListItems(data, fullDetails, classes)}
|
||||||
|
</Fragment>
|
||||||
</List>
|
</List>
|
||||||
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
||||||
Refresh
|
Refresh
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
|
|
||||||
import { withStyles } from 'material-ui/styles';
|
import { withStyles } from 'material-ui/styles';
|
||||||
import Button from 'material-ui/Button';
|
import Button from 'material-ui/Button';
|
||||||
@ -50,74 +50,64 @@ class NTPStatus extends Component {
|
|||||||
this.props.loadData();
|
this.props.loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNTPStatus(data, fullDetails, classes){
|
createListItems(data, fullDetails, classes){
|
||||||
const listItems = [];
|
return (
|
||||||
|
<Fragment>
|
||||||
listItems.push(
|
<ListItem>
|
||||||
<ListItem key="ntp_status">
|
|
||||||
<Avatar className={classes["ntpStatus_" + ntpStatusHighlight(data)]}>
|
<Avatar className={classes["ntpStatus_" + ntpStatusHighlight(data)]}>
|
||||||
<UpdateIcon />
|
<UpdateIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Status" secondary={ntpStatus(data)} />
|
<ListItemText primary="Status" secondary={ntpStatus(data)} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ntp_status_divider" inset component="li" />);
|
{ isSynchronized(data) &&
|
||||||
|
<Fragment>
|
||||||
if (isSynchronized(data)) {
|
<ListItem>
|
||||||
listItems.push(
|
|
||||||
<ListItem key="time_now">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<AccessTimeIcon />
|
<AccessTimeIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Time Now" secondary={unixTimeToTimeAndDate(data.now)} />
|
<ListItemText primary="Time Now" secondary={unixTimeToTimeAndDate(data.now)} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="time_now_divider" inset component="li" />);
|
<ListItem>
|
||||||
}
|
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="last_sync">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<SwapVerticalCircleIcon />
|
<SwapVerticalCircleIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Last Sync" secondary={data.last_sync > 0 ? unixTimeToTimeAndDate(data.last_sync) : "never" } />
|
<ListItemText primary="Last Sync" secondary={data.last_sync > 0 ? unixTimeToTimeAndDate(data.last_sync) : "never" } />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="last_sync_divider" inset component="li" />);
|
</Fragment>
|
||||||
|
}
|
||||||
listItems.push(
|
<ListItem>
|
||||||
<ListItem key="ntp_server">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<DNSIcon />
|
<DNSIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="NTP Server" secondary={data.server} />
|
<ListItemText primary="NTP Server" secondary={data.server} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ntp_server_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="sync_interval">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<TimerIcon />
|
<TimerIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Sync Interval" secondary={moment.duration(data.interval, 'seconds').humanize()} />
|
<ListItemText primary="Sync Interval" secondary={moment.duration(data.interval, 'seconds').humanize()} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="sync_interval_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="uptime">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<AvTimerIcon />
|
<AvTimerIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Uptime" secondary={moment.duration(data.uptime, 'seconds').humanize()} />
|
<ListItemText primary="Uptime" secondary={moment.duration(data.uptime, 'seconds').humanize()} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<Divider inset component="li" />
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderNTPStatus(data, fullDetails, classes){
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<List>
|
<List>
|
||||||
{listItems}
|
{this.createListItems(data, fullDetails, classes)}
|
||||||
</List>
|
</List>
|
||||||
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
||||||
Refresh
|
Refresh
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
|
|
||||||
import { withStyles } from 'material-ui/styles';
|
import { withStyles } from 'material-ui/styles';
|
||||||
import Button from 'material-ui/Button';
|
import Button from 'material-ui/Button';
|
||||||
@ -57,71 +57,61 @@ class WiFiStatus extends Component {
|
|||||||
return status.dns_ip_1 + (status.dns_ip_2 ? ','+status.dns_ip_2 : '');
|
return status.dns_ip_1 + (status.dns_ip_2 ? ','+status.dns_ip_2 : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
renderWiFiStatus(data, fullDetails, classes) {
|
createListItems(data, fullDetails, classes) {
|
||||||
const listItems = [];
|
return (
|
||||||
|
<Fragment>
|
||||||
listItems.push(
|
<ListItem>
|
||||||
<ListItem key="connection_status">
|
|
||||||
<Avatar className={classes["wifiStatus_" + connectionStatusHighlight(data)]}>
|
<Avatar className={classes["wifiStatus_" + connectionStatusHighlight(data)]}>
|
||||||
<WifiIcon />
|
<WifiIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Connection Status" secondary={connectionStatus(data)} />
|
<ListItemText primary="Connection Status" secondary={connectionStatus(data)} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
|
{
|
||||||
if (fullDetails && isConnected(data)) {
|
(fullDetails && isConnected(data)) &&
|
||||||
listItems.push(<Divider key="connection_status_divider" inset component="li" />);
|
<Fragment>
|
||||||
|
<ListItem>
|
||||||
listItems.push(
|
|
||||||
<ListItem key="ssid">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<SettingsInputAntennaIcon />
|
<SettingsInputAntennaIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="SSID" secondary={data.ssid} />
|
<ListItemText primary="SSID" secondary={data.ssid} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ssid_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="ip_address">
|
|
||||||
<Avatar>IP</Avatar>
|
<Avatar>IP</Avatar>
|
||||||
<ListItemText primary="IP Address" secondary={data.local_ip} />
|
<ListItemText primary="IP Address" secondary={data.local_ip} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="ip_address_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="subnet_mask">
|
|
||||||
<Avatar>#</Avatar>
|
<Avatar>#</Avatar>
|
||||||
<ListItemText primary="Subnet Mask" secondary={data.subnet_mask} />
|
<ListItemText primary="Subnet Mask" secondary={data.subnet_mask} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="subnet_mask_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="gateway_ip">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<SettingsInputComponentIcon />
|
<SettingsInputComponentIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Gateway IP" secondary={data.gateway_ip ? data.gateway_ip : "none"} />
|
<ListItemText primary="Gateway IP" secondary={data.gateway_ip ? data.gateway_ip : "none"} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
<Divider inset component="li" />
|
||||||
listItems.push(<Divider key="gateway_ip_divider" inset component="li" />);
|
<ListItem>
|
||||||
|
|
||||||
listItems.push(
|
|
||||||
<ListItem key="dns_server_ip">
|
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<DNSIcon />
|
<DNSIcon />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="DNS Server IP" secondary={this.dnsServers(data)} />
|
<ListItemText primary="DNS Server IP" secondary={this.dnsServers(data)} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<Divider inset component="li" />
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderWiFiStatus(data, fullDetails, classes) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<List>
|
<List>
|
||||||
{listItems}
|
{this.createListItems(data, fullDetails, classes)}
|
||||||
</List>
|
</List>
|
||||||
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
<Button variant="raised" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
||||||
Refresh
|
Refresh
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { withStyles } from 'material-ui/styles';
|
import { withStyles } from 'material-ui/styles';
|
||||||
@ -62,8 +62,8 @@ class APSettingsForm extends React.Component {
|
|||||||
|
|
||||||
{
|
{
|
||||||
isAPEnabled(apSettings.provision_mode) &&
|
isAPEnabled(apSettings.provision_mode) &&
|
||||||
[
|
<Fragment>
|
||||||
<TextValidator key="ssid"
|
<TextValidator
|
||||||
validators={['required', 'matchRegexp:^.{0,32}$']}
|
validators={['required', 'matchRegexp:^.{0,32}$']}
|
||||||
errorMessages={['Access Point SSID is required', 'Access Point SSID must be 32 characeters or less']}
|
errorMessages={['Access Point SSID is required', 'Access Point SSID must be 32 characeters or less']}
|
||||||
name="ssid"
|
name="ssid"
|
||||||
@ -72,8 +72,8 @@ class APSettingsForm extends React.Component {
|
|||||||
value={apSettings.ssid}
|
value={apSettings.ssid}
|
||||||
onChange={handleValueChange('ssid')}
|
onChange={handleValueChange('ssid')}
|
||||||
margin="normal"
|
margin="normal"
|
||||||
/>,
|
/>
|
||||||
<TextValidator key="password"
|
<TextValidator
|
||||||
validators={['required', 'matchRegexp:^.{0,64}$']}
|
validators={['required', 'matchRegexp:^.{0,64}$']}
|
||||||
errorMessages={['Access Point Password is required', 'Access Point Password must be 64 characters or less']}
|
errorMessages={['Access Point Password is required', 'Access Point Password must be 64 characters or less']}
|
||||||
name="password"
|
name="password"
|
||||||
@ -83,7 +83,7 @@ class APSettingsForm extends React.Component {
|
|||||||
onChange={handleValueChange('password')}
|
onChange={handleValueChange('password')}
|
||||||
margin="normal"
|
margin="normal"
|
||||||
/>
|
/>
|
||||||
]
|
</Fragment>
|
||||||
}
|
}
|
||||||
|
|
||||||
<Button variant="raised" color="primary" className={classes.button} type="submit">
|
<Button variant="raised" color="primary" className={classes.button} type="submit">
|
||||||
|
@ -82,7 +82,7 @@ class OTASettingsForm extends React.Component {
|
|||||||
margin="normal"
|
margin="normal"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextValidator key="password"
|
<TextValidator
|
||||||
validators={['required', 'matchRegexp:^.{0,64}$']}
|
validators={['required', 'matchRegexp:^.{0,64}$']}
|
||||||
errorMessages={['OTA Password is required', 'OTA Point Password must be 64 characters or less']}
|
errorMessages={['OTA Password is required', 'OTA Point Password must be 64 characters or less']}
|
||||||
name="password"
|
name="password"
|
||||||
|
@ -36,8 +36,8 @@ class WiFiNetworkSelector extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderNetwork(network) {
|
renderNetwork(network) {
|
||||||
return ([
|
return (
|
||||||
<ListItem key={network.ssid} button onClick={() => this.props.selectNetwork(network)}>
|
<ListItem key={network.bssid} button onClick={() => this.props.selectNetwork(network)}>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar>
|
<Avatar>
|
||||||
{isNetworkOpen(network) ? <LockOpenIcon /> : <LockIcon />}
|
{isNetworkOpen(network) ? <LockOpenIcon /> : <LockIcon />}
|
||||||
@ -53,7 +53,6 @@ class WiFiNetworkSelector extends Component {
|
|||||||
</Badge>
|
</Badge>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class WiFiSettingsForm extends React.Component {
|
|||||||
const { selectedNetwork, deselectNetwork } = this.props;
|
const { selectedNetwork, deselectNetwork } = this.props;
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
<ListItem key={selectedNetwork.ssid}>
|
<ListItem>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar>
|
<Avatar>
|
||||||
{isNetworkOpen(selectedNetwork) ? <LockOpenIcon /> : <LockIcon />}
|
{isNetworkOpen(selectedNetwork) ? <LockOpenIcon /> : <LockIcon />}
|
||||||
|
Loading…
Reference in New Issue
Block a user