diff --git a/web/src/models/global.js b/web/src/models/global.js index bd2397e0..fccad9d5 100644 --- a/web/src/models/global.js +++ b/web/src/models/global.js @@ -61,6 +61,18 @@ export default { }) return data; }, + *reloadClusterList({payload}, {call, put, select}){ + yield put({ + type: 'saveData', + payload: { + clusterList: [], + } + }); + yield put({ + type: 'fetchClusterList', + payload: payload + }) + } }, reducers: { diff --git a/web/src/pages/System/Cluster/Form.js b/web/src/pages/System/Cluster/Form.js index 73403107..2223518b 100644 --- a/web/src/pages/System/Cluster/Form.js +++ b/web/src/pages/System/Cluster/Form.js @@ -10,8 +10,17 @@ import {connect} from "dva"; clusterConfig })) class ClusterForm extends React.Component{ - state = { - confirmDirty: false, + constructor(props) { + super(props); + let editValue = this.props.clusterConfig.editValue; + let needAuth = false; + if(editValue.basic_auth && typeof editValue.basic_auth.username !== 'undefined' && editValue.basic_auth.username !== ''){ + needAuth = true; + } + this.state = { + confirmDirty: false, + needAuth: needAuth, + } } componentDidMount() { //console.log(this.props.clusterConfig.editMode) @@ -77,6 +86,12 @@ class ClusterForm extends React.Component{ }) } + handleAuthChange = (val) => { + this.setState({ + needAuth: val, + }) + } + render() { const {getFieldDecorator} = this.props.form; const formItemLayout = { @@ -103,7 +118,11 @@ class ClusterForm extends React.Component{ }; const {editValue, editMode} = this.props.clusterConfig; return ( - + { + router.push('/system/cluster'); + }}>返回]} + >
{getFieldDecorator('name', { @@ -131,6 +150,15 @@ class ClusterForm extends React.Component{ ], })()} + + } + unCheckedChildren={} + /> + + {this.state.needAuth === true ? (
{getFieldDecorator('username', { initialValue: editValue.basic_auth.username, @@ -145,6 +173,7 @@ class ClusterForm extends React.Component{ ], })()} +
):''} {getFieldDecorator('order', { initialValue: editValue.order || 0, diff --git a/web/src/pages/System/Cluster/Index.js b/web/src/pages/System/Cluster/Index.js index d14c3d99..d56d817b 100644 --- a/web/src/pages/System/Cluster/Index.js +++ b/web/src/pages/System/Cluster/Index.js @@ -17,20 +17,13 @@ class Index extends React.Component { dataIndex: 'endpoint', key: 'endpoint', },{ - title: '用户名', - dataIndex: 'basic_auth.username', + title: '是否需要身份验证', + dataIndex: 'basic_auth', key: 'username', - },{ - title: '密码', - dataIndex: 'basic_auth.password', - key: 'password', - render: (val) =>{ - return "******"; + render: (val) => { + console.log(val) + return (val && typeof val.username !=='undefined' && val.username !== '')? '是': '否'; } - },{ - title: '排序权重', - dataIndex: 'order', - key: 'order', },{ title: '描述', dataIndex: 'description', diff --git a/web/src/pages/System/Cluster/models/cluster.js b/web/src/pages/System/Cluster/models/cluster.js index 15090435..04746139 100644 --- a/web/src/pages/System/Cluster/models/cluster.js +++ b/web/src/pages/System/Cluster/models/cluster.js @@ -61,6 +61,7 @@ export default { let idx = data.findIndex((item)=>{ return item.id === res._id; }); + let originalEnabled = data[idx].enabled; data[idx] = { ...data[idx], ...res._source @@ -71,13 +72,34 @@ export default { data } }) - yield put({ - type: 'global/updateCluster', - payload: { - id: res._id, - name: res._source.name, + //handle global cluster logic + if(originalEnabled !== res._source.enabled){ + if(res._source.enabled === true) { + yield put({ + type: 'global/addCluster', + payload: { + id: res._id, + name: res._source.name, + } + }) + }else{ + yield put({ + type: 'global/removeCluster', + payload: { + id: res._id, + } + }) } - }) + }else{ + yield put({ + type: 'global/updateCluster', + payload: { + id: res._id, + name: res._source.name, + } + }) + } + return res; }, *deleteCluster({payload}, {call, put, select}) {