Commit d83569f9 authored by Jérémy Jaouen's avatar Jérémy Jaouen
Browse files

clean Wizard: Front-End part

parent e8f80740
......@@ -94,6 +94,16 @@ class CentreonConfigurationRemote extends CentreonWebServiceAbstract
return $statement->fetchAll();
}
public function postGetCentralDefaultIp(): string
{
$statement = $this->pearDB->query("
SELECT address FROM `platform_topology`
WHERE `type` = 'central'
");
$result = $statement->fetch();
return $result['address'];
}
/**
* Get Pollers servers waitlist
*
......
......@@ -45,7 +45,6 @@ class RemoteServerFormStepOne extends Component {
this.initializeFromRest(waitList.length > 0);
}
this.setState({
centreon_folder: '/centreon/',
initialized: true,
});
};
......@@ -57,7 +56,7 @@ class RemoteServerFormStepOne extends Component {
};
render() {
const { error, handleSubmit, onSubmit, waitList, t } = this.props;
const { error, handleSubmit, onSubmit, waitList, defaultCentralIp, t } = this.props;
const { inputTypeManual } = this.state;
return (
<div className={styles['form-wrapper']}>
......@@ -121,26 +120,6 @@ class RemoteServerFormStepOne extends Component {
type="text"
validate={validateFieldRequired(t)}
/>
<Field
component={InputField}
label={`${t('Centreon Web Folder on Remote')}:`}
name="centreon_folder"
placeholder="/centreon/"
type="text"
validate={validateFieldRequired(t)}
/>
<Field
component={CheckboxField}
label={t('Do not check SSL certificate validation')}
name="no_check_certificate"
/>
<Field
component={CheckboxField}
label={t(
'Do not use configured proxy to connect to this server',
)}
name="no_proxy"
/>
</div>
) : null}
......@@ -208,26 +187,6 @@ class RemoteServerFormStepOne extends Component {
type="text"
validate={validateFieldRequired(t)}
/>
<Field
component={InputField}
label={`${t('Centreon Web Folder on Remote')}:`}
name="centreon_folder"
placeholder="/centreon/"
type="text"
validate={validateFieldRequired(t)}
/>
<Field
component={CheckboxField}
label={t('Do not check SSL certificate validation')}
name="no_check_certificate"
/>
<Field
component={CheckboxField}
label={t(
'Do not use configured proxy to connect to this server',
)}
name="no_proxy"
/>
</div>
) : null}
......
......@@ -29,12 +29,17 @@ class RemoteServerStepOneRoute extends Component {
state = {
waitList: null,
defaultCentralIp: null,
};
wizardFormWaitListApi = axios(
'internal.php?object=centreon_configuration_remote&action=getWaitList',
);
wizardFormDefaultCentralApi = axios(
'internal.php?object=centreon_configuration_remote&action=getCentralDefaultIp',
);
getWaitList = () => {
this.wizardFormWaitListApi
.post()
......@@ -46,8 +51,20 @@ class RemoteServerStepOneRoute extends Component {
});
};
getDefaultCentralIp = () => {
this.wizardFormDefaultCentralApi
.post()
.then((response) => {
this.setState({ defaultCentralIp: response.data})
})
.catch(() => {
this.setState({ defaultCentralIp: null });
});
}
componentDidMount = () => {
this.getWaitList();
this.getDefaultCentralIp();
};
handleSubmit = (data) => {
......@@ -59,12 +76,12 @@ class RemoteServerStepOneRoute extends Component {
render() {
const { links } = this;
const { pollerData } = this.props;
const { waitList } = this.state;
const { waitList, defaultCentralIp } = this.state;
return (
<BaseWizard>
<ProgressBar links={links} />
<Form
initialValues={{ ...pollerData, centreon_folder: '/centreon/' }}
initialValues={{ ...pollerData, centreon_central_ip: defaultCentralIp }}
waitList={waitList}
onSubmit={this.handleSubmit.bind(this)}
/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment