@@ -140,13 +118,13 @@ class APStatus extends Component {
:
- status ? this.renderAPStatus(status, fullDetails, classes)
+ data ? this.renderAPStatus(data, fullDetails, classes)
:
{errorMessage}
-
@@ -156,4 +134,4 @@ class APStatus extends Component {
}
}
-export default withNotifier(withStyles(styles)(APStatus));
+export default restComponent(AP_STATUS_ENDPOINT, withStyles(styles)(APStatus));
diff --git a/interface/src/containers/NTPStatus.js b/interface/src/containers/NTPStatus.js
index 74344b9..a25c57b 100644
--- a/interface/src/containers/NTPStatus.js
+++ b/interface/src/containers/NTPStatus.js
@@ -19,11 +19,9 @@ import * as Highlight from '../constants/Highlight';
import { unixTimeToTimeAndDate } from '../constants/TimeFormat';
import { NTP_STATUS_ENDPOINT } from '../constants/Endpoints';
-import {withNotifier} from '../components/SnackbarNotification';
+import { restComponent } from '../components/RestComponent';
import SectionContent from '../components/SectionContent';
-import { simpleGet } from '../helpers/SimpleGet';
-
import moment from 'moment';
const styles = theme => ({
@@ -48,51 +46,30 @@ const styles = theme => ({
class NTPStatus extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- status:null,
- fetched: false,
- errorMessage:null
- };
-
- this.setState = this.setState.bind(this);
- this.loadNTPStatus = this.loadNTPStatus.bind(this);
- }
-
componentDidMount() {
- this.loadNTPStatus();
+ this.props.loadData();
}
- loadNTPStatus() {
- simpleGet(
- NTP_STATUS_ENDPOINT,
- this.setState,
- this.props.raiseNotification
- );
- }
-
- renderNTPStatus(status, fullDetails, classes){
+ renderNTPStatus(data, fullDetails, classes){
const listItems = [];
listItems.push(
-
+
-
+
);
listItems.push();
- if (isSynchronized(status)) {
+ if (isSynchronized(data)) {
listItems.push(
-
+
);
listItems.push();
@@ -103,7 +80,7 @@ class NTPStatus extends Component {
- 0 ? unixTimeToTimeAndDate(status.last_sync) : "never" } />
+ 0 ? unixTimeToTimeAndDate(data.last_sync) : "never" } />
);
listItems.push();
@@ -113,7 +90,7 @@ class NTPStatus extends Component {
-
+
);
listItems.push();
@@ -123,7 +100,7 @@ class NTPStatus extends Component {
-
+
);
listItems.push();
@@ -133,7 +110,7 @@ class NTPStatus extends Component {
-
+
);
@@ -142,7 +119,7 @@ class NTPStatus extends Component {
{listItems}
-
+
Refresh
@@ -150,8 +127,7 @@ class NTPStatus extends Component {
}
render() {
- const { status, fetched, errorMessage } = this.state;
- const { classes, fullDetails } = this.props;
+ const { data, fetched, errorMessage, classes, fullDetails } = this.props;
return (
@@ -164,13 +140,13 @@ class NTPStatus extends Component {
:
- status ? this.renderNTPStatus(status, fullDetails, classes)
+ data ? this.renderNTPStatus(data, fullDetails, classes)
:
{errorMessage}
-
+
Refresh
@@ -180,4 +156,4 @@ class NTPStatus extends Component {
}
}
-export default withNotifier(withStyles(styles)(NTPStatus));
+export default restComponent(NTP_STATUS_ENDPOINT, withStyles(styles)(NTPStatus));
diff --git a/interface/src/containers/WiFiStatus.js b/interface/src/containers/WiFiStatus.js
index 0a36d51..7103643 100644
--- a/interface/src/containers/WiFiStatus.js
+++ b/interface/src/containers/WiFiStatus.js
@@ -5,14 +5,13 @@ import Button from 'material-ui/Button';
import { LinearProgress } from 'material-ui/Progress';
import Typography from 'material-ui/Typography';
-import {withNotifier} from '../components/SnackbarNotification';
import SectionContent from '../components/SectionContent';
import { WIFI_STATUS_ENDPOINT } from '../constants/Endpoints';
import { isConnected, connectionStatus, connectionStatusHighlight } from '../constants/WiFiConnectionStatus';
import * as Highlight from '../constants/Highlight';
-import { simpleGet } from '../helpers/SimpleGet';
+import { restComponent } from '../components/RestComponent';
import List, { ListItem, ListItemText } from 'material-ui/List';
import Avatar from 'material-ui/Avatar';
@@ -47,21 +46,8 @@ const styles = theme => ({
class WiFiStatus extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- status:null,
- fetched: false,
- errorMessage:null
- };
-
- this.setState = this.setState.bind(this);
- this.loadWiFiStatus = this.loadWiFiStatus.bind(this);
- }
-
componentDidMount() {
- this.loadWiFiStatus();
+ this.props.loadData();
}
dnsServers(status) {
@@ -71,27 +57,19 @@ class WiFiStatus extends Component {
return status.dns_ip_1 + (status.dns_ip_2 ? ','+status.dns_ip_2 : '');
}
- loadWiFiStatus() {
- simpleGet(
- WIFI_STATUS_ENDPOINT,
- this.setState,
- this.props.raiseNotification
- );
- }
-
- renderWiFiStatus(status, fullDetails, classes) {
+ renderWiFiStatus(data, fullDetails, classes) {
const listItems = [];
listItems.push(
-
+
-
+
);
- if (fullDetails && isConnected(status)) {
+ if (fullDetails && isConnected(data)) {
listItems.push();
listItems.push(
@@ -99,7 +77,7 @@ class WiFiStatus extends Component {
-
+
);
listItems.push();
@@ -107,7 +85,7 @@ class WiFiStatus extends Component {
listItems.push(
IP
-
+
);
listItems.push();
@@ -115,7 +93,7 @@ class WiFiStatus extends Component {
listItems.push(
#
-
+
);
listItems.push();
@@ -125,7 +103,7 @@ class WiFiStatus extends Component {
-
+
);
listItems.push();
@@ -135,7 +113,7 @@ class WiFiStatus extends Component {
-
+
);
}
@@ -145,7 +123,7 @@ class WiFiStatus extends Component {
{listItems}
-
+
Refresh
@@ -154,8 +132,7 @@ class WiFiStatus extends Component {
}
render() {
- const { status, fetched, errorMessage } = this.state;
- const { classes, fullDetails } = this.props;
+ const { data, fetched, errorMessage, classes, fullDetails } = this.props;
return (
@@ -168,13 +145,13 @@ class WiFiStatus extends Component {
:
- status ? this.renderWiFiStatus(status, fullDetails, classes)
+ data ? this.renderWiFiStatus(data, fullDetails, classes)
:
{errorMessage}
-
+
Refresh
@@ -184,4 +161,4 @@ class WiFiStatus extends Component {
}
}
-export default withNotifier(withStyles(styles)(WiFiStatus));
+export default restComponent(WIFI_STATUS_ENDPOINT, withStyles(styles)(WiFiStatus));