rjwats@gmail.com
6 years ago
6 changed files with 77 additions and 204 deletions
-
23interface/src/components/RestComponent.js
-
61interface/src/containers/APSettings.js
-
1interface/src/containers/APStatus.js
-
59interface/src/containers/NTPSettings.js
-
67interface/src/containers/OTASettings.js
-
70interface/src/containers/WiFiSettings.js
@ -1,69 +1,32 @@ |
|||
import React, { Component } from 'react'; |
|||
|
|||
import { AP_SETTINGS_ENDPOINT } from '../constants/Endpoints'; |
|||
import {withNotifier} from '../components/SnackbarNotification'; |
|||
import { restComponent } from '../components/RestComponent'; |
|||
import SectionContent from '../components/SectionContent'; |
|||
import APSettingsForm from '../forms/APSettingsForm'; |
|||
import { simpleGet } from '../helpers/SimpleGet'; |
|||
import { simplePost } from '../helpers/SimplePost'; |
|||
|
|||
class APSettings extends Component { |
|||
|
|||
constructor(props) { |
|||
super(props); |
|||
|
|||
this.state = { |
|||
apSettings:null, |
|||
apSettingsFetched: false, |
|||
errorMessage:null |
|||
}; |
|||
|
|||
this.setState = this.setState.bind(this); |
|||
this.loadAPSettings = this.loadAPSettings.bind(this); |
|||
this.saveAPSettings = this.saveAPSettings.bind(this); |
|||
} |
|||
|
|||
componentDidMount() { |
|||
this.loadAPSettings(); |
|||
this.props.loadData(); |
|||
} |
|||
|
|||
loadAPSettings() { |
|||
simpleGet( |
|||
AP_SETTINGS_ENDPOINT, |
|||
this.setState, |
|||
this.props.raiseNotification, |
|||
"apSettings", |
|||
"apSettingsFetched" |
|||
); |
|||
} |
|||
|
|||
saveAPSettings(e) { |
|||
simplePost( |
|||
AP_SETTINGS_ENDPOINT, |
|||
this.state, |
|||
this.setState, |
|||
this.props.raiseNotification, |
|||
"apSettings", |
|||
"apSettingsFetched" |
|||
); |
|||
} |
|||
|
|||
wifiSettingValueChange = name => event => { |
|||
const { apSettings } = this.state; |
|||
apSettings[name] = event.target.value; |
|||
this.setState({apSettings}); |
|||
}; |
|||
|
|||
render() { |
|||
const { apSettingsFetched, apSettings, errorMessage } = this.state; |
|||
const { data, fetched, errorMessage } = this.props; |
|||
return ( |
|||
<SectionContent title="AP Settings"> |
|||
<APSettingsForm apSettingsFetched={apSettingsFetched} apSettings={apSettings} errorMessage={errorMessage} |
|||
onSubmit={this.saveAPSettings} onReset={this.loadAPSettings} handleValueChange={this.wifiSettingValueChange} /> |
|||
<APSettingsForm |
|||
apSettings={data} |
|||
apSettingsFetched={fetched} |
|||
errorMessage={errorMessage} |
|||
onSubmit={this.props.saveData} |
|||
onReset={this.props.loadData} |
|||
handleValueChange={this.props.handleValueChange} |
|||
/> |
|||
</SectionContent> |
|||
) |
|||
} |
|||
|
|||
} |
|||
|
|||
export default withNotifier(APSettings); |
|||
export default restComponent(AP_SETTINGS_ENDPOINT, APSettings); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue