Add list of upstream servers

Closes #344
This commit is contained in:
Ildar Kamalov 2018-09-26 18:38:06 +03:00
parent 3afd8fccc7
commit 2c72035000
5 changed files with 24 additions and 16 deletions

View File

@ -10,3 +10,7 @@
padding-left: 20px; padding-left: 20px;
padding-right: 20px; padding-right: 20px;
} }
.form-control--textarea {
min-height: 110px;
}

View File

@ -34,8 +34,8 @@ export default class Upstream extends Component {
<div className="col"> <div className="col">
<form> <form>
<textarea <textarea
className="form-control" className="form-control form-control--textarea"
value={this.props.upstream} value={this.props.upstreamDns}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<div className="card-actions"> <div className="card-actions">
@ -63,7 +63,7 @@ export default class Upstream extends Component {
} }
Upstream.propTypes = { Upstream.propTypes = {
upstream: PropTypes.string, upstreamDns: PropTypes.string,
processingTestUpstream: PropTypes.bool, processingTestUpstream: PropTypes.bool,
handleUpstreamChange: PropTypes.func, handleUpstreamChange: PropTypes.func,
handleUpstreamSubmit: PropTypes.func, handleUpstreamSubmit: PropTypes.func,

View File

@ -36,16 +36,16 @@ export default class Settings extends Component {
} }
handleUpstreamChange = (value) => { handleUpstreamChange = (value) => {
this.props.handleUpstreamChange({ upstream: value }); this.props.handleUpstreamChange({ upstreamDns: value });
}; };
handleUpstreamSubmit = () => { handleUpstreamSubmit = () => {
this.props.setUpstream(this.props.settings.upstream); this.props.setUpstream(this.props.dashboard.upstreamDns);
}; };
handleUpstreamTest = () => { handleUpstreamTest = () => {
if (this.props.settings.upstream.length > 0) { if (this.props.dashboard.upstreamDns.length > 0) {
this.props.testUpstream(this.props.settings.upstream); this.props.testUpstream(this.props.dashboard.upstreamDns);
} else { } else {
this.props.addErrorToast({ error: 'No servers specified' }); this.props.addErrorToast({ error: 'No servers specified' });
} }
@ -69,7 +69,8 @@ export default class Settings extends Component {
} }
render() { render() {
const { settings, upstream } = this.props; const { settings } = this.props;
const { upstreamDns } = this.props.dashboard;
return ( return (
<Fragment> <Fragment>
<PageTitle title="Settings" /> <PageTitle title="Settings" />
@ -84,7 +85,7 @@ export default class Settings extends Component {
</div> </div>
</Card> </Card>
<Upstream <Upstream
upstream={upstream} upstreamDns={upstreamDns}
processingTestUpstream={settings.processingTestUpstream} processingTestUpstream={settings.processingTestUpstream}
handleUpstreamChange={this.handleUpstreamChange} handleUpstreamChange={this.handleUpstreamChange}
handleUpstreamSubmit={this.handleUpstreamSubmit} handleUpstreamSubmit={this.handleUpstreamSubmit}

View File

@ -3,8 +3,8 @@ import { initSettings, toggleSetting, handleUpstreamChange, setUpstream, testUps
import Settings from '../components/Settings'; import Settings from '../components/Settings';
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { settings } = state; const { settings, dashboard } = state;
const props = { settings }; const props = { settings, dashboard };
return props; return props;
}; };

View File

@ -27,10 +27,6 @@ const settings = handleActions({
[actions.setUpstreamRequest]: state => ({ ...state, processingUpstream: true }), [actions.setUpstreamRequest]: state => ({ ...state, processingUpstream: true }),
[actions.setUpstreamFailure]: state => ({ ...state, processingUpstream: false }), [actions.setUpstreamFailure]: state => ({ ...state, processingUpstream: false }),
[actions.setUpstreamSuccess]: state => ({ ...state, processingUpstream: false }), [actions.setUpstreamSuccess]: state => ({ ...state, processingUpstream: false }),
[actions.handleUpstreamChange]: (state, { payload }) => {
const { upstream } = payload;
return { ...state, upstream };
},
[actions.testUpstreamRequest]: state => ({ ...state, processingTestUpstream: true }), [actions.testUpstreamRequest]: state => ({ ...state, processingTestUpstream: true }),
[actions.testUpstreamFailure]: state => ({ ...state, processingTestUpstream: false }), [actions.testUpstreamFailure]: state => ({ ...state, processingTestUpstream: false }),
@ -39,7 +35,6 @@ const settings = handleActions({
processing: true, processing: true,
processingTestUpstream: false, processingTestUpstream: false,
processingSetUpstream: false, processingSetUpstream: false,
upstream: '',
}); });
const dashboard = handleActions({ const dashboard = handleActions({
@ -52,6 +47,7 @@ const dashboard = handleActions({
dns_port: dnsPort, dns_port: dnsPort,
dns_address: dnsAddress, dns_address: dnsAddress,
querylog_enabled: queryLogEnabled, querylog_enabled: queryLogEnabled,
upstream_dns: upstreamDns,
} = payload; } = payload;
const newState = { const newState = {
...state, ...state,
@ -61,6 +57,7 @@ const dashboard = handleActions({
dnsPort, dnsPort,
dnsAddress, dnsAddress,
queryLogEnabled, queryLogEnabled,
upstreamDns: upstreamDns.join('\n'),
}; };
return newState; return newState;
}, },
@ -141,6 +138,11 @@ const dashboard = handleActions({
const newSetting = { ...state, isFilteringEnabled: !state.isFilteringEnabled }; const newSetting = { ...state, isFilteringEnabled: !state.isFilteringEnabled };
return newSetting; return newSetting;
}, },
[actions.handleUpstreamChange]: (state, { payload }) => {
const { upstreamDns } = payload;
return { ...state, upstreamDns };
},
}, { }, {
processing: true, processing: true,
isCoreRunning: false, isCoreRunning: false,
@ -149,6 +151,7 @@ const dashboard = handleActions({
logStatusProcessing: false, logStatusProcessing: false,
processingVersion: true, processingVersion: true,
processingFiltering: true, processingFiltering: true,
upstreamDns: [],
}); });
const queryLogs = handleActions({ const queryLogs = handleActions({