UI: Fix up wrong message when submitting config
This commit is contained in:
parent
d09958e079
commit
40cb73e7e8
|
@ -162,16 +162,10 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
configSubmit() {
|
configSubmit() {
|
||||||
this.sendConfig()
|
this.sendCredentials().then(res => {
|
||||||
.then(() => {
|
if(res.ok) {
|
||||||
this.setState({
|
this.sendConfig();
|
||||||
lastAction: configSaveAction
|
}
|
||||||
});
|
|
||||||
this.setInitialConfig(this.state.configuration);
|
|
||||||
this.props.onStatusChange();
|
|
||||||
}).catch(error => {
|
|
||||||
console.log('Bad configuration: ' + error.toString());
|
|
||||||
this.setState({lastAction: 'invalid_configuration'});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,22 +271,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
sendConfig() {
|
sendConfig() {
|
||||||
let config = JSON.parse(JSON.stringify(this.state.configuration))
|
let config = JSON.parse(JSON.stringify(this.state.configuration))
|
||||||
config = reformatConfig(config, true);
|
config = reformatConfig(config, true);
|
||||||
|
console.log(config);
|
||||||
this.authFetch(CONFIGURED_PROPAGATION_CREDENTIALS_URL,
|
|
||||||
{
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: JSON.stringify(formatCredentialsForIsland(this.state.credentials))
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (!res.ok) {
|
|
||||||
throw Error()
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}).catch((error) => {
|
|
||||||
console.log(`bad configuration ${error}`);
|
|
||||||
this.setState({lastAction: 'invalid_configuration'});
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.authFetch(CONFIG_URL,
|
this.authFetch(CONFIG_URL,
|
||||||
|
@ -301,6 +280,29 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify(config)
|
body: JSON.stringify(config)
|
||||||
})
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (!res.ok) {
|
||||||
|
console.log(`bad configuration submited ${res.status}`);
|
||||||
|
this.setState({lastAction: 'invalid_configuration'});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
lastAction: configSaveAction
|
||||||
|
});
|
||||||
|
this.setInitialConfig(this.state.configuration);
|
||||||
|
this.props.onStatusChange();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCredentials() {
|
||||||
|
return (
|
||||||
|
this.authFetch(CONFIGURED_PROPAGATION_CREDENTIALS_URL,
|
||||||
|
{
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify(formatCredentialsForIsland(this.state.credentials))
|
||||||
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw Error()
|
throw Error()
|
||||||
|
|
Loading…
Reference in New Issue