- client: pass all params to the check_config request

This commit is contained in:
Ildar Kamalov 2020-02-13 13:49:16 +03:00
parent 194bed72f5
commit 019bff0851
2 changed files with 47 additions and 33 deletions

View File

@ -70,7 +70,7 @@ class Settings extends Component {
}); });
} }
getStaticIpMessage = (staticIp, handleStaticIp) => { getStaticIpMessage = (staticIp) => {
const { static: status, ip } = staticIp; const { static: status, ip } = staticIp;
if (!status) { if (!status) {
@ -89,7 +89,7 @@ class Settings extends Component {
<button <button
type="button" type="button"
className="btn btn-outline-primary btn-sm" className="btn btn-outline-primary btn-sm"
onClick={() => handleStaticIp()} onClick={this.handleStaticIp}
> >
<Trans>set_static_ip</Trans> <Trans>set_static_ip</Trans>
</button> </button>
@ -111,12 +111,48 @@ class Settings extends Component {
); );
}; };
handleAutofix = (type) => {
const {
webIp,
webPort,
dnsIp,
dnsPort,
handleFix,
} = this.props;
const web = { ip: webIp, port: webPort, autofix: false };
const dns = { ip: dnsIp, port: dnsPort, autofix: false };
const set_static_ip = false;
if (type === 'web') {
web.autofix = true;
} else {
dns.autofix = true;
}
handleFix(web, dns, set_static_ip);
};
handleStaticIp = () => {
const {
webIp,
webPort,
dnsIp,
dnsPort,
handleFix,
} = this.props;
const web = { ip: webIp, port: webPort, autofix: false };
const dns = { ip: dnsIp, port: dnsPort, autofix: false };
const set_static_ip = true;
handleFix(web, dns, set_static_ip);
};
render() { render() {
const { const {
handleSubmit, handleSubmit,
handleChange, handleChange,
handleAutofix,
handleStaticIp,
webIp, webIp,
webPort, webPort,
dnsIp, dnsIp,
@ -185,7 +221,7 @@ class Settings extends Component {
<button <button
type="button" type="button"
className="btn btn-secondary btn-sm ml-2" className="btn btn-secondary btn-sm ml-2"
onClick={() => handleAutofix('web', webIp, webPort)} onClick={() => this.handleAutofix('web')}
> >
<Trans>fix</Trans> <Trans>fix</Trans>
</button> </button>
@ -256,7 +292,7 @@ class Settings extends Component {
<button <button
type="button" type="button"
className="btn btn-secondary btn-sm ml-2" className="btn btn-secondary btn-sm ml-2"
onClick={() => handleAutofix('dns', dnsIp, dnsPort)} onClick={() => this.handleAutofix('dns')}
> >
<Trans>fix</Trans> <Trans>fix</Trans>
</button> </button>
@ -300,7 +336,7 @@ class Settings extends Component {
<Trans>static_ip_desc</Trans> <Trans>static_ip_desc</Trans>
</div> </div>
{this.getStaticIpMessage(staticIp, handleStaticIp)} {this.getStaticIpMessage(staticIp)}
</div> </div>
<Controls invalid={invalid} /> <Controls invalid={invalid} />
@ -312,7 +348,7 @@ class Settings extends Component {
Settings.propTypes = { Settings.propTypes = {
handleSubmit: PropTypes.func.isRequired, handleSubmit: PropTypes.func.isRequired,
handleChange: PropTypes.func, handleChange: PropTypes.func,
handleAutofix: PropTypes.func, handleFix: PropTypes.func.isRequired,
validateForm: PropTypes.func, validateForm: PropTypes.func,
webIp: PropTypes.string.isRequired, webIp: PropTypes.string.isRequired,
dnsIp: PropTypes.string.isRequired, dnsIp: PropTypes.string.isRequired,
@ -329,7 +365,6 @@ Settings.propTypes = {
invalid: PropTypes.bool.isRequired, invalid: PropTypes.bool.isRequired,
initialValues: PropTypes.object, initialValues: PropTypes.object,
t: PropTypes.func.isRequired, t: PropTypes.func.isRequired,
handleStaticIp: PropTypes.func.isRequired,
}; };
const selector = formValueSelector('install'); const selector = formValueSelector('install');

View File

@ -44,28 +44,8 @@ class Setup extends Component {
} }
}, DEBOUNCE_TIMEOUT); }, DEBOUNCE_TIMEOUT);
handleAutofix = (type, ip, port) => { handleFix = (web, dns, set_static_ip) => {
const data = { this.props.checkConfig({ web, dns, set_static_ip });
ip,
port,
autofix: true,
};
if (type === 'web') {
this.props.checkConfig({
web: { ...data },
});
} else {
this.props.checkConfig({
dns: { ...data },
});
}
};
handleStaticIp = () => {
this.props.checkConfig({
set_static_ip: true,
});
}; };
openDashboard = (ip, port) => { openDashboard = (ip, port) => {
@ -103,8 +83,7 @@ class Setup extends Component {
onSubmit={this.nextStep} onSubmit={this.nextStep}
onChange={this.handleFormChange} onChange={this.handleFormChange}
validateForm={this.handleFormChange} validateForm={this.handleFormChange}
handleAutofix={this.handleAutofix} handleFix={this.handleFix}
handleStaticIp={this.handleStaticIp}
/> />
); );
case 3: case 3: