Rick Watson
5 years ago
6 changed files with 80 additions and 62 deletions
-
8interface/src/AppRouting.js
-
2interface/src/authentication/Authentication.js
-
2interface/src/components/MenuAppBar.js
-
54interface/src/containers/WiFiConfiguration.js
-
4interface/src/sections/Security.js
-
72interface/src/sections/WiFiConnection.js
@ -1,54 +0,0 @@ |
|||
import React, { Component } from 'react'; |
|||
|
|||
import Tabs from '@material-ui/core/Tabs'; |
|||
import Tab from '@material-ui/core/Tab'; |
|||
|
|||
import MenuAppBar from '../components/MenuAppBar'; |
|||
import WiFiNetworkScanner from './WiFiNetworkScanner'; |
|||
import WiFiSettings from './WiFiSettings'; |
|||
import WiFiStatus from './WiFiStatus'; |
|||
|
|||
class WiFiConfiguration extends Component { |
|||
|
|||
constructor(props) { |
|||
super(props); |
|||
this.state = { |
|||
selectedTab: "wifiStatus", |
|||
selectedNetwork: null |
|||
}; |
|||
this.selectNetwork = this.selectNetwork.bind(this); |
|||
this.deselectNetwork = this.deselectNetwork.bind(this); |
|||
} |
|||
|
|||
// TODO - slightly inapproperate use of callback ref possibly.
|
|||
selectNetwork(network) { |
|||
this.setState({ selectedTab: "wifiSettings", selectedNetwork:network }); |
|||
} |
|||
|
|||
// deselects the network after the settings component mounts.
|
|||
deselectNetwork(network) { |
|||
this.setState({ selectedNetwork:null }); |
|||
} |
|||
|
|||
handleTabChange = (event, selectedTab) => { |
|||
this.setState({ selectedTab }); |
|||
}; |
|||
|
|||
render() { |
|||
const { selectedTab } = this.state; |
|||
return ( |
|||
<MenuAppBar sectionTitle="WiFi Configuration"> |
|||
<Tabs value={selectedTab} onChange={this.handleTabChange} indicatorColor="primary" textColor="primary" variant="fullWidth"> |
|||
<Tab value="wifiStatus" label="WiFi Status" /> |
|||
<Tab value="networkScanner" label="Network Scanner" /> |
|||
<Tab value="wifiSettings" label="WiFi Settings" /> |
|||
</Tabs> |
|||
{selectedTab === "wifiStatus" && <WiFiStatus />} |
|||
{selectedTab === "networkScanner" && <WiFiNetworkScanner selectNetwork={this.selectNetwork} />} |
|||
{selectedTab === "wifiSettings" && <WiFiSettings deselectNetwork={this.deselectNetwork} selectedNetwork={this.state.selectedNetwork} />} |
|||
</MenuAppBar> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default WiFiConfiguration; |
@ -0,0 +1,72 @@ |
|||
import React, { Component } from 'react'; |
|||
import { Redirect, Switch } from 'react-router-dom' |
|||
|
|||
import Tabs from '@material-ui/core/Tabs'; |
|||
import Tab from '@material-ui/core/Tab'; |
|||
|
|||
import AuthenticatedRoute from '../authentication/AuthenticatedRoute'; |
|||
import MenuAppBar from '../components/MenuAppBar'; |
|||
import WiFiNetworkScanner from '../containers/WiFiNetworkScanner'; |
|||
import WiFiSettings from '../containers/WiFiSettings'; |
|||
import WiFiStatus from '../containers/WiFiStatus'; |
|||
|
|||
class WiFiConnection extends Component { |
|||
|
|||
constructor(props) { |
|||
super(props); |
|||
this.state = { |
|||
selectedNetwork: null |
|||
}; |
|||
this.selectNetwork = this.selectNetwork.bind(this); |
|||
this.deselectNetwork = this.deselectNetwork.bind(this); |
|||
} |
|||
|
|||
selectNetwork(network) { |
|||
this.setState({ selectedNetwork: network }); |
|||
this.props.history.push('/wifi/settings'); |
|||
} |
|||
|
|||
deselectNetwork(network) { |
|||
this.setState({ selectedNetwork: null }); |
|||
} |
|||
|
|||
handleTabChange = (event, path) => { |
|||
this.props.history.push(path); |
|||
}; |
|||
|
|||
render() { |
|||
const ConfiguredWiFiNetworkScanner = (props) => { |
|||
return ( |
|||
<WiFiNetworkScanner |
|||
selectNetwork={this.selectNetwork} |
|||
{...props} |
|||
/> |
|||
); |
|||
}; |
|||
const ConfiguredWiFiSettings = (props) => { |
|||
return ( |
|||
<WiFiSettings |
|||
deselectNetwork={this.deselectNetwork} selectedNetwork={this.state.selectedNetwork} |
|||
{...props} |
|||
/> |
|||
); |
|||
}; |
|||
return ( |
|||
<MenuAppBar sectionTitle="WiFi Connection"> |
|||
<Tabs value={this.props.match.url} onChange={this.handleTabChange} indicatorColor="primary" textColor="primary" variant="fullWidth"> |
|||
<Tab value="/wifi/status" label="WiFi Status" /> |
|||
<Tab value="/wifi/scan" label="Scan Networks" /> |
|||
<Tab value="/wifi/settings" label="WiFi Settings" /> |
|||
</Tabs> |
|||
<Switch> |
|||
<AuthenticatedRoute exact={true} path="/wifi/status" component={WiFiStatus} /> |
|||
<AuthenticatedRoute exact={true} path="/wifi/scan" component={ConfiguredWiFiNetworkScanner} /> |
|||
<AuthenticatedRoute exact={true} path="/wifi/settings" component={ConfiguredWiFiSettings} /> |
|||
<Redirect to="/wifi/status" /> |
|||
</Switch> |
|||
</MenuAppBar> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default WiFiConnection; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue