remove www directory, as it is a build artefact
replace custom made notification component with notistack
This commit is contained in:
@ -6,7 +6,7 @@ import Typography from '@material-ui/core/Typography';
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
import { APP_NAME } from '../constants/App';
|
||||
import ForwardIcon from '@material-ui/icons/Forward';
|
||||
import { withNotifier } from '../components/SnackbarNotification';
|
||||
import { withSnackbar } from 'notistack';
|
||||
import { SIGN_IN_ENDPOINT } from '../constants/Endpoints';
|
||||
import { withAuthenticationContext } from '../authentication/Context';
|
||||
import PasswordValidator from '../components/PasswordValidator';
|
||||
@ -84,7 +84,9 @@ class SignInPage extends Component {
|
||||
authenticationContext.signIn(json.access_token);
|
||||
})
|
||||
.catch(error => {
|
||||
this.props.raiseNotification(error.message);
|
||||
this.props.enqueueSnackbar(error.message, {
|
||||
variant: 'warning',
|
||||
});
|
||||
this.setState({ processing: false });
|
||||
});
|
||||
};
|
||||
@ -132,5 +134,5 @@ class SignInPage extends Component {
|
||||
}
|
||||
|
||||
export default withAuthenticationContext(
|
||||
withNotifier(withStyles(styles)(SignInPage))
|
||||
withSnackbar(withStyles(styles)(SignInPage))
|
||||
);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { SCAN_NETWORKS_ENDPOINT, LIST_NETWORKS_ENDPOINT } from '../constants/Endpoints';
|
||||
import { SCAN_NETWORKS_ENDPOINT, LIST_NETWORKS_ENDPOINT } from '../constants/Endpoints';
|
||||
import SectionContent from '../components/SectionContent';
|
||||
import WiFiNetworkSelector from '../forms/WiFiNetworkSelector';
|
||||
import {withNotifier} from '../components/SnackbarNotification';
|
||||
import { withSnackbar } from 'notistack';
|
||||
import { redirectingAuthorizedFetch } from '../authentication/Authentication';
|
||||
|
||||
const NUM_POLLS = 10
|
||||
@ -17,10 +17,10 @@ class WiFiNetworkScanner extends Component {
|
||||
super(props);
|
||||
this.pollCount = 0;
|
||||
this.state = {
|
||||
scanningForNetworks: true,
|
||||
errorMessage:null,
|
||||
networkList: null
|
||||
};
|
||||
scanningForNetworks: true,
|
||||
errorMessage: null,
|
||||
networkList: null
|
||||
};
|
||||
this.pollNetworkList = this.pollNetworkList.bind(this);
|
||||
this.requestNetworkScan = this.requestNetworkScan.bind(this);
|
||||
}
|
||||
@ -38,7 +38,7 @@ class WiFiNetworkScanner extends Component {
|
||||
|
||||
scanNetworks() {
|
||||
this.pollCount = 0;
|
||||
this.setState({scanningForNetworks:true, networkList: null, errorMessage:null});
|
||||
this.setState({ scanningForNetworks: true, networkList: null, errorMessage: null });
|
||||
redirectingAuthorizedFetch(SCAN_NETWORKS_ENDPOINT).then(response => {
|
||||
if (response.status === 202) {
|
||||
this.schedulePollTimeout();
|
||||
@ -46,8 +46,10 @@ class WiFiNetworkScanner extends Component {
|
||||
}
|
||||
throw Error("Scanning for networks returned unexpected response code: " + response.status);
|
||||
}).catch(error => {
|
||||
this.props.raiseNotification("Problem scanning: " + error.message);
|
||||
this.setState({scanningForNetworks:false, networkList: null, errorMessage:error.message});
|
||||
this.props.enqueueSnackbar("Problem scanning: " + error.message, {
|
||||
variant: 'error',
|
||||
});
|
||||
this.setState({ scanningForNetworks: false, networkList: null, errorMessage: error.message });
|
||||
});
|
||||
}
|
||||
|
||||
@ -57,12 +59,12 @@ class WiFiNetworkScanner extends Component {
|
||||
|
||||
retryError() {
|
||||
return {
|
||||
name:RETRY_EXCEPTION_TYPE,
|
||||
message:"Network list not ready, will retry in " + POLLING_FREQUENCY + "ms."
|
||||
name: RETRY_EXCEPTION_TYPE,
|
||||
message: "Network list not ready, will retry in " + POLLING_FREQUENCY + "ms."
|
||||
};
|
||||
}
|
||||
|
||||
compareNetworks(network1,network2) {
|
||||
compareNetworks(network1, network2) {
|
||||
if (network1.rssi < network2.rssi)
|
||||
return 1;
|
||||
if (network1.rssi > network2.rssi)
|
||||
@ -72,30 +74,32 @@ class WiFiNetworkScanner extends Component {
|
||||
|
||||
pollNetworkList() {
|
||||
redirectingAuthorizedFetch(LIST_NETWORKS_ENDPOINT)
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
return response.json();
|
||||
}
|
||||
if (response.status === 202) {
|
||||
if (++this.pollCount < NUM_POLLS){
|
||||
this.schedulePollTimeout();
|
||||
throw this.retryError();
|
||||
}else{
|
||||
throw Error("Device did not return network list in timely manner.");
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
throw Error("Device returned unexpected response code: " + response.status);
|
||||
})
|
||||
.then(json => {
|
||||
if (response.status === 202) {
|
||||
if (++this.pollCount < NUM_POLLS) {
|
||||
this.schedulePollTimeout();
|
||||
throw this.retryError();
|
||||
} else {
|
||||
throw Error("Device did not return network list in timely manner.");
|
||||
}
|
||||
}
|
||||
throw Error("Device returned unexpected response code: " + response.status);
|
||||
})
|
||||
.then(json => {
|
||||
json.networks.sort(this.compareNetworks)
|
||||
this.setState({scanningForNetworks:false, networkList: json, errorMessage:null})
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.name !== RETRY_EXCEPTION_TYPE) {
|
||||
this.props.raiseNotification("Problem scanning: " + error.message);
|
||||
this.setState({scanningForNetworks:false, networkList: null, errorMessage:error.message});
|
||||
}
|
||||
});
|
||||
this.setState({ scanningForNetworks: false, networkList: json, errorMessage: null })
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.name !== RETRY_EXCEPTION_TYPE) {
|
||||
this.props.enqueueSnackbar("Problem scanning: " + error.message, {
|
||||
variant: 'error',
|
||||
});
|
||||
this.setState({ scanningForNetworks: false, networkList: null, errorMessage: error.message });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -103,11 +107,11 @@ class WiFiNetworkScanner extends Component {
|
||||
return (
|
||||
<SectionContent title="Network Scanner">
|
||||
<WiFiNetworkSelector scanningForNetworks={scanningForNetworks}
|
||||
networkList={networkList}
|
||||
errorMessage={errorMessage}
|
||||
requestNetworkScan={this.requestNetworkScan}
|
||||
selectNetwork={this.props.selectNetwork}
|
||||
/>
|
||||
networkList={networkList}
|
||||
errorMessage={errorMessage}
|
||||
requestNetworkScan={this.requestNetworkScan}
|
||||
selectNetwork={this.props.selectNetwork}
|
||||
/>
|
||||
</SectionContent>
|
||||
)
|
||||
}
|
||||
@ -118,4 +122,4 @@ WiFiNetworkScanner.propTypes = {
|
||||
selectNetwork: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default withNotifier(WiFiNetworkScanner);
|
||||
export default withSnackbar(WiFiNetworkScanner);
|
||||
|
Reference in New Issue
Block a user