modify system cluster
This commit is contained in:
parent
c675ea0b73
commit
a8b857275a
|
@ -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: {
|
||||
|
|
|
@ -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 (
|
||||
<Card title={editMode === 'NEW' ? '注册集群': '修改集群配置'}>
|
||||
<Card title={editMode === 'NEW' ? '注册集群': '修改集群配置'}
|
||||
extra={[<Button type="primary" onClick={()=>{
|
||||
router.push('/system/cluster');
|
||||
}}>返回</Button>]}
|
||||
>
|
||||
<Form {...formItemLayout}>
|
||||
<Form.Item label="集群名称">
|
||||
{getFieldDecorator('name', {
|
||||
|
@ -131,6 +150,15 @@ class ClusterForm extends React.Component{
|
|||
],
|
||||
})(<Input />)}
|
||||
</Form.Item>
|
||||
<Form.Item label="是否需要身份验证">
|
||||
<Switch
|
||||
defaultChecked={this.state.needAuth}
|
||||
onChange={this.handleAuthChange}
|
||||
checkedChildren={<Icon type="check" />}
|
||||
unCheckedChildren={<Icon type="close" />}
|
||||
/>
|
||||
</Form.Item>
|
||||
{this.state.needAuth === true ? (<div>
|
||||
<Form.Item label="ES 用户名">
|
||||
{getFieldDecorator('username', {
|
||||
initialValue: editValue.basic_auth.username,
|
||||
|
@ -145,6 +173,7 @@ class ClusterForm extends React.Component{
|
|||
],
|
||||
})(<Input.Password />)}
|
||||
</Form.Item>
|
||||
</div>):''}
|
||||
<Form.Item label="排序权重">
|
||||
{getFieldDecorator('order', {
|
||||
initialValue: editValue.order || 0,
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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}) {
|
||||
|
|
Loading…
Reference in New Issue