modify system cluster
This commit is contained in:
parent
c675ea0b73
commit
a8b857275a
|
@ -61,6 +61,18 @@ export default {
|
||||||
})
|
})
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
*reloadClusterList({payload}, {call, put, select}){
|
||||||
|
yield put({
|
||||||
|
type: 'saveData',
|
||||||
|
payload: {
|
||||||
|
clusterList: [],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
yield put({
|
||||||
|
type: 'fetchClusterList',
|
||||||
|
payload: payload
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reducers: {
|
reducers: {
|
||||||
|
|
|
@ -10,8 +10,17 @@ import {connect} from "dva";
|
||||||
clusterConfig
|
clusterConfig
|
||||||
}))
|
}))
|
||||||
class ClusterForm extends React.Component{
|
class ClusterForm extends React.Component{
|
||||||
state = {
|
constructor(props) {
|
||||||
confirmDirty: false,
|
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() {
|
componentDidMount() {
|
||||||
//console.log(this.props.clusterConfig.editMode)
|
//console.log(this.props.clusterConfig.editMode)
|
||||||
|
@ -77,6 +86,12 @@ class ClusterForm extends React.Component{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleAuthChange = (val) => {
|
||||||
|
this.setState({
|
||||||
|
needAuth: val,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {getFieldDecorator} = this.props.form;
|
const {getFieldDecorator} = this.props.form;
|
||||||
const formItemLayout = {
|
const formItemLayout = {
|
||||||
|
@ -103,7 +118,11 @@ class ClusterForm extends React.Component{
|
||||||
};
|
};
|
||||||
const {editValue, editMode} = this.props.clusterConfig;
|
const {editValue, editMode} = this.props.clusterConfig;
|
||||||
return (
|
return (
|
||||||
<Card title={editMode === 'NEW' ? '注册集群': '修改集群配置'}>
|
<Card title={editMode === 'NEW' ? '注册集群': '修改集群配置'}
|
||||||
|
extra={[<Button type="primary" onClick={()=>{
|
||||||
|
router.push('/system/cluster');
|
||||||
|
}}>返回</Button>]}
|
||||||
|
>
|
||||||
<Form {...formItemLayout}>
|
<Form {...formItemLayout}>
|
||||||
<Form.Item label="集群名称">
|
<Form.Item label="集群名称">
|
||||||
{getFieldDecorator('name', {
|
{getFieldDecorator('name', {
|
||||||
|
@ -131,6 +150,15 @@ class ClusterForm extends React.Component{
|
||||||
],
|
],
|
||||||
})(<Input />)}
|
})(<Input />)}
|
||||||
</Form.Item>
|
</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 用户名">
|
<Form.Item label="ES 用户名">
|
||||||
{getFieldDecorator('username', {
|
{getFieldDecorator('username', {
|
||||||
initialValue: editValue.basic_auth.username,
|
initialValue: editValue.basic_auth.username,
|
||||||
|
@ -145,6 +173,7 @@ class ClusterForm extends React.Component{
|
||||||
],
|
],
|
||||||
})(<Input.Password />)}
|
})(<Input.Password />)}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</div>):''}
|
||||||
<Form.Item label="排序权重">
|
<Form.Item label="排序权重">
|
||||||
{getFieldDecorator('order', {
|
{getFieldDecorator('order', {
|
||||||
initialValue: editValue.order || 0,
|
initialValue: editValue.order || 0,
|
||||||
|
|
|
@ -17,20 +17,13 @@ class Index extends React.Component {
|
||||||
dataIndex: 'endpoint',
|
dataIndex: 'endpoint',
|
||||||
key: 'endpoint',
|
key: 'endpoint',
|
||||||
},{
|
},{
|
||||||
title: '用户名',
|
title: '是否需要身份验证',
|
||||||
dataIndex: 'basic_auth.username',
|
dataIndex: 'basic_auth',
|
||||||
key: 'username',
|
key: 'username',
|
||||||
},{
|
render: (val) => {
|
||||||
title: '密码',
|
console.log(val)
|
||||||
dataIndex: 'basic_auth.password',
|
return (val && typeof val.username !=='undefined' && val.username !== '')? '是': '否';
|
||||||
key: 'password',
|
|
||||||
render: (val) =>{
|
|
||||||
return "******";
|
|
||||||
}
|
}
|
||||||
},{
|
|
||||||
title: '排序权重',
|
|
||||||
dataIndex: 'order',
|
|
||||||
key: 'order',
|
|
||||||
},{
|
},{
|
||||||
title: '描述',
|
title: '描述',
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
|
|
|
@ -61,6 +61,7 @@ export default {
|
||||||
let idx = data.findIndex((item)=>{
|
let idx = data.findIndex((item)=>{
|
||||||
return item.id === res._id;
|
return item.id === res._id;
|
||||||
});
|
});
|
||||||
|
let originalEnabled = data[idx].enabled;
|
||||||
data[idx] = {
|
data[idx] = {
|
||||||
...data[idx],
|
...data[idx],
|
||||||
...res._source
|
...res._source
|
||||||
|
@ -71,13 +72,34 @@ export default {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
yield put({
|
//handle global cluster logic
|
||||||
type: 'global/updateCluster',
|
if(originalEnabled !== res._source.enabled){
|
||||||
payload: {
|
if(res._source.enabled === true) {
|
||||||
id: res._id,
|
yield put({
|
||||||
name: res._source.name,
|
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;
|
return res;
|
||||||
},
|
},
|
||||||
*deleteCluster({payload}, {call, put, select}) {
|
*deleteCluster({payload}, {call, put, select}) {
|
||||||
|
|
Loading…
Reference in New Issue