UI: Adjust config page to use new reset endpoint

This commit is contained in:
vakarisz 2022-07-08 10:58:53 +03:00
parent d1b586d260
commit 6725b01342
1 changed files with 5 additions and 10 deletions

View File

@ -21,6 +21,7 @@ import {SCHEMA} from '../../services/configuration/config_schema.js';
import {reformatConfig} from '../configuration-components/ReformatHook'; import {reformatConfig} from '../configuration-components/ReformatHook';
const CONFIG_URL = '/api/agent-configuration'; const CONFIG_URL = '/api/agent-configuration';
const RESET_URL = '/api/reset-agent-configuration';
export const API_PBA_LINUX = '/api/file-upload/PBAlinux'; export const API_PBA_LINUX = '/api/file-upload/PBAlinux';
export const API_PBA_WINDOWS = '/api/file-upload/PBAwindows'; export const API_PBA_WINDOWS = '/api/file-upload/PBAwindows';
@ -145,7 +146,7 @@ class ConfigurePageComponent extends AuthComponent {
configSubmit() { configSubmit() {
return this.sendConfig() return this.sendConfig()
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(() => {
this.setState({ this.setState({
lastAction: configSaveAction lastAction: configSaveAction
}); });
@ -279,22 +280,16 @@ class ConfigurePageComponent extends AuthComponent {
}; };
resetConfig = () => { resetConfig = () => {
this.authFetch(CONFIG_URL, this.authFetch(RESET_URL,
{ {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'reset': true})
}) })
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(() => {
res.configuration = reformatConfig(res.configuration);
this.setState({ this.setState({
lastAction: 'reset', lastAction: 'reset',
schema: res.schema,
configuration: res.configuration,
currentFormData: res.configuration[this.state.selectedSection]
}); });
this.setInitialConfig(res.configuration); this.updateConfig();
this.props.onStatusChange(); this.props.onStatusChange();
} }
).then(() => { ).then(() => {