fix mock for cluster

This commit is contained in:
medcl 2021-02-21 10:54:45 +08:00
parent ed1fce4c1b
commit 553d65319a
5 changed files with 13 additions and 11 deletions

View File

@ -12,7 +12,7 @@ type ClusterConfig struct {
} `json:"basic_auth,omitempty" elastic_mapping:"basic_auth:{type:object}"` } `json:"basic_auth,omitempty" elastic_mapping:"basic_auth:{type:object}"`
Order int `json:"order,omitempty" elastic_mapping:"order:{type:integer}"` Order int `json:"order,omitempty" elastic_mapping:"order:{type:integer}"`
Description string `json:"description,omitempty" elastic_mapping:"description:{type:text}"` Description string `json:"description,omitempty" elastic_mapping:"description:{type:text}"`
Enabled bool `json:"enabled,omitempty" elastic_mapping:"enabled:{type:boolean}"` Enabled bool `json:"enabled" elastic_mapping:"enabled:{type:boolean}"`
Created time.Time `json:"created,omitempty" elastic_mapping:"created:{type:date}"` Created time.Time `json:"created,omitempty" elastic_mapping:"created:{type:date}"`
Updated time.Time `json:"updated,omitempty" elastic_mapping:"updated:{type:date}"` Updated time.Time `json:"updated,omitempty" elastic_mapping:"updated:{type:date}"`
} }

View File

@ -65,7 +65,7 @@ export default {
}, },
'POST /_search-center/system/cluster': function(req, res){ 'POST /_search-center/system/cluster': function(req, res){
res.send({ res.send({
"_id": "c0obhd4gq9s7akom0o60", "_id": "c0oc4kkgq9s8qss2uk50",
"_source": { "_source": {
"name": "cluster1", "name": "cluster1",
"endpoint": "http://localhost:9200", "endpoint": "http://localhost:9200",
@ -83,7 +83,7 @@ export default {
}, },
'PUT /_search-center/system/cluster/:id': function(req, res){ 'PUT /_search-center/system/cluster/:id': function(req, res){
res.send({ res.send({
"_id": "c0obhd4gq9s7akom0o60", "_id": "c0oc4kkgq9s8qss2uk50",
"_source": { "_source": {
"basic_auth": { "basic_auth": {
"password": "456", "password": "456",
@ -92,6 +92,7 @@ export default {
"description": "xx业务集群2", "description": "xx业务集群2",
"endpoint": "http://localhost:9201", "endpoint": "http://localhost:9201",
"name": "cluster2", "name": "cluster2",
"enabled": true,
"updated": "2021-02-20T15:25:12.159789+08:00" "updated": "2021-02-20T15:25:12.159789+08:00"
}, },
"result": "updated" "result": "updated"
@ -99,7 +100,7 @@ export default {
}, },
'DELETE /_search-center/system/cluster/:id': function(req, res){ 'DELETE /_search-center/system/cluster/:id': function(req, res){
res.send({ res.send({
"_id": "c0obk7cgq9s7hi05aou0", "_id": "c0oc4kkgq9s8qss2uk50",
"result": "deleted" "result": "deleted"
}); });
} }

View File

@ -159,14 +159,14 @@ class ClusterForm extends React.Component{
/> />
</Form.Item> </Form.Item>
{this.state.needAuth === true ? (<div> {this.state.needAuth === true ? (<div>
<Form.Item label="ES 用户名"> <Form.Item label="用户名">
{getFieldDecorator('username', { {getFieldDecorator('username', {
initialValue: editValue.basic_auth.username, initialValue: editValue.basic_auth.username,
rules: [ rules: [
], ],
})(<Input autoComplete='off' />)} })(<Input autoComplete='off' />)}
</Form.Item> </Form.Item>
<Form.Item label="ES 密码" hasFeedback> <Form.Item label="密码" hasFeedback>
{getFieldDecorator('password', { {getFieldDecorator('password', {
initialValue: editValue.basic_auth.password, initialValue: editValue.basic_auth.password,
rules: [ rules: [

View File

@ -21,7 +21,7 @@ class Index extends React.Component {
dataIndex: 'basic_auth', dataIndex: 'basic_auth',
key: 'username', key: 'username',
render: (val) => { render: (val) => {
console.log(val) //console.log(val)
return (val && typeof val.username !=='undefined' && val.username !== '')? '是': '否'; return (val && typeof val.username !=='undefined' && val.username !== '')? '是': '否';
} }
},{ },{

View File

@ -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; let originalEnabled = data[idx].enabled;
data[idx] = { data[idx] = {
...data[idx], ...data[idx],