fix confilcts
This commit is contained in:
parent
28d1abc0ca
commit
71a9e6bc24
|
@ -3,54 +3,173 @@ export default {
|
||||||
res.send({
|
res.send({
|
||||||
".kibana": {
|
".kibana": {
|
||||||
"alias": ".kibana",
|
"alias": ".kibana",
|
||||||
"index": [
|
"indexes": [
|
||||||
".kibana_1"
|
{
|
||||||
|
"index": ".kibana_1",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
".kibana-event-log-7.10.0": {
|
".kibana-event-log-7.10.0": {
|
||||||
"alias": ".kibana-event-log-7.10.0",
|
"alias": ".kibana-event-log-7.10.0",
|
||||||
"index": [
|
"indexes": [
|
||||||
".kibana-event-log-7.10.0-000003",
|
{
|
||||||
".kibana-event-log-7.10.0-000005",
|
"index": ".kibana-event-log-7.10.0-000006",
|
||||||
".kibana-event-log-7.10.0-000004",
|
"filter": null,
|
||||||
".kibana-event-log-7.10.0-000002"
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": ".kibana-event-log-7.10.0-000004",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": ".kibana-event-log-7.10.0-000003",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": ".kibana-event-log-7.10.0-000005",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"write_index": ".kibana-event-log-7.10.0-000005"
|
"write_index": ".kibana-event-log-7.10.0-000006"
|
||||||
},
|
},
|
||||||
".kibana_task_manager": {
|
".kibana_task_manager": {
|
||||||
"alias": ".kibana_task_manager",
|
"alias": ".kibana_task_manager",
|
||||||
"index": [
|
"indexes": [
|
||||||
".kibana_task_manager_1"
|
{
|
||||||
|
"index": ".kibana_task_manager_1",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"custom": {
|
"custom": {
|
||||||
"alias": "custom",
|
"alias": "custom",
|
||||||
"index": [
|
"indexes": [
|
||||||
"test-custom"
|
{
|
||||||
|
"index": "test-custom",
|
||||||
|
"filter": {
|
||||||
|
"match": {
|
||||||
|
"name": "test"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"index_routing": "1",
|
||||||
|
"search_routing": "1",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "test-custom8",
|
||||||
|
"filter": {
|
||||||
|
"match": {
|
||||||
|
"name": "test"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"index_routing": "1",
|
||||||
|
"search_routing": "1",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ilm-history-3": {
|
"ilm-history-3": {
|
||||||
"alias": "ilm-history-3",
|
"alias": "ilm-history-3",
|
||||||
"index": [
|
"indexes": [
|
||||||
"ilm-history-3-000004",
|
{
|
||||||
"ilm-history-3-000005",
|
"index": "ilm-history-3-000004",
|
||||||
"ilm-history-3-000003",
|
"filter": null,
|
||||||
"ilm-history-3-000002"
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": true,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "ilm-history-3-000006",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": true,
|
||||||
|
"is_write_index": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "ilm-history-3-000003",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": true,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "ilm-history-3-000005",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": true,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"write_index": "ilm-history-3-000005"
|
"write_index": "ilm-history-3-000006"
|
||||||
},
|
},
|
||||||
"metricbeat-7.10.0": {
|
"metricbeat-7.10.0": {
|
||||||
"alias": "metricbeat-7.10.0",
|
"alias": "metricbeat-7.10.0",
|
||||||
"index": [
|
"indexes": [
|
||||||
"metricbeat-7.10.0-2021.04.07-000003",
|
{
|
||||||
"metricbeat-7.10.0-2021.02.03-000001",
|
"index": "metricbeat-7.10.0-2021.04.07-000003",
|
||||||
"metricbeat-7.10.0-2021.03.06-000002"
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "metricbeat-7.10.0-2021.02.03-000001",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "metricbeat-7.10.0-2021.03.06-000002",
|
||||||
|
"filter": null,
|
||||||
|
"index_routing": "",
|
||||||
|
"search_routing": "",
|
||||||
|
"is_hidden": false,
|
||||||
|
"is_write_index": false
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"write_index": "metricbeat-7.10.0-2021.04.07-000003"
|
"write_index": "metricbeat-7.10.0-2021.04.07-000003"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
'POST /elasticsearch/:id/alias': function (req, res) {
|
'POST /elasticsearch/:id/alias': function (req, res) {
|
||||||
|
//curl add example
|
||||||
|
// curl -X POST -d '{ "actions" : [{ "add": { "index" : "test-custom", "alias" : "custom" } }]}'
|
||||||
|
//curl delete example
|
||||||
|
// curl -X POST -d '{ "actions" : [{ "remove": { "index" : "test-custom", "alias" : "custom" } }]}'
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
"acknowledged": true
|
"acknowledged": true
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,9 +10,8 @@ import {
|
||||||
Modal,
|
Modal,
|
||||||
message,
|
message,
|
||||||
Divider,
|
Divider,
|
||||||
|
Table, AutoComplete, Switch,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import StandardTable from '@/components/StandardTable';
|
|
||||||
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
|
|
||||||
|
|
||||||
import styles from '../../List/TableList.less';
|
import styles from '../../List/TableList.less';
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ const CreateForm = Form.create()(props => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const UpdateForm = Form.create()(props => {
|
const UpdateForm = Form.create()(props => {
|
||||||
const { updateModalVisible, handleUpdateModalVisible, handleUpdate,values,form } = props;
|
const { updateModalVisible, handleUpdateModalVisible, handleUpdate,values,form, indices } = props;
|
||||||
|
|
||||||
const okHandle = () => {
|
const okHandle = () => {
|
||||||
form.validateFields((err, fieldsValue) => {
|
form.validateFields((err, fieldsValue) => {
|
||||||
|
@ -69,36 +68,67 @@ const UpdateForm = Form.create()(props => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
title="索引设置"
|
title="别名设置"
|
||||||
visible={updateModalVisible}
|
visible={updateModalVisible}
|
||||||
width={640}
|
width={640}
|
||||||
onOk={okHandle}
|
onOk={okHandle}
|
||||||
onCancel={() => handleUpdateModalVisible()}
|
onCancel={() => handleUpdateModalVisible()}
|
||||||
>
|
>
|
||||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="索引名称">
|
<FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} label="别名">
|
||||||
|
{form.getFieldDecorator('alias', {
|
||||||
|
initialValue: values.alias,
|
||||||
|
rules: [{ required: true }],
|
||||||
|
})(<Input placeholder="请输入别名" disabled={!!values.alias} />)}
|
||||||
|
</FormItem>
|
||||||
|
<FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} label="索引">
|
||||||
{form.getFieldDecorator('index', {
|
{form.getFieldDecorator('index', {
|
||||||
initialValue: values.index,
|
initialValue: values.index,
|
||||||
rules: [{ required: true, message: '请输入至少五个字符的名称!', min: 5 }],
|
|
||||||
})(<Input placeholder="请输入名称" />)}
|
|
||||||
</FormItem>
|
|
||||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="索引设置">
|
|
||||||
{form.getFieldDecorator('settings', {
|
|
||||||
initialValue: values.processors,
|
|
||||||
rules: [{ required: true }],
|
rules: [{ required: true }],
|
||||||
|
})(<IndexComplete disabled={!!values.alias} dataSource={indices}/>)}
|
||||||
|
</FormItem>
|
||||||
|
<FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} label="是否为写索引">
|
||||||
|
{form.getFieldDecorator('is_write_index', {
|
||||||
|
valuePropName: 'checked',
|
||||||
|
initialValue: values.is_write_index,
|
||||||
|
rules: [],
|
||||||
|
})(<Switch/>)}
|
||||||
|
</FormItem>
|
||||||
|
<FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} label="过滤查询">
|
||||||
|
{form.getFieldDecorator('filter', {
|
||||||
|
initialValue: values.filter? JSON.stringify(values.filter, '', 2):'',
|
||||||
|
rules: [{ }],
|
||||||
})(<TextArea
|
})(<TextArea
|
||||||
style={{ minHeight: 24 }}
|
style={{ minHeight: 16 }}
|
||||||
placeholder="请输入"
|
placeholder='示例:{"match":{"field_name":"field_value"}}'
|
||||||
rows={9}
|
rows={5}
|
||||||
/>)}
|
/>)}
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<Row>
|
||||||
|
<Col span={12}>
|
||||||
|
<FormItem label="索引路由" labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} >
|
||||||
|
{form.getFieldDecorator('index_routing', {
|
||||||
|
initialValue: values.index_routing,
|
||||||
|
rules: [],
|
||||||
|
})(<Input />)}
|
||||||
|
</FormItem>
|
||||||
|
</Col>
|
||||||
|
<Col span={12} >
|
||||||
|
<FormItem label="搜索路由" labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} >
|
||||||
|
{form.getFieldDecorator('search_routing', {
|
||||||
|
initialValue: values.search_routing,
|
||||||
|
rules: [],
|
||||||
|
})(<Input />)}
|
||||||
|
</FormItem>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* eslint react/no-multi-comp:0 */
|
/* eslint react/no-multi-comp:0 */
|
||||||
@connect(({ pipeline, loading }) => ({
|
@connect(({ global, alias}) => ({
|
||||||
pipeline,
|
selectedClusterID: global.selectedClusterID,
|
||||||
loading: loading.models.pipeline,
|
alias,
|
||||||
}))
|
}))
|
||||||
@Form.create()
|
@Form.create()
|
||||||
class AliasManage extends PureComponent {
|
class AliasManage extends PureComponent {
|
||||||
|
@ -110,201 +140,33 @@ class AliasManage extends PureComponent {
|
||||||
formValues: {},
|
formValues: {},
|
||||||
updateFormValues: {},
|
updateFormValues: {},
|
||||||
};
|
};
|
||||||
datasource = `[
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "blog",
|
|
||||||
"index": "blogs_fixed",
|
|
||||||
"uuid": "Q6zngGf9QVaWqpV0lF-0nw",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "1594",
|
|
||||||
"docs.deleted": "594",
|
|
||||||
"store.size": "17.9mb",
|
|
||||||
"pri.store.size": "8.9mb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "red",
|
|
||||||
"status": "elastic",
|
|
||||||
"index": "elastic_qa",
|
|
||||||
"uuid": "_qkVlQ5LRoOKffV-nFj8Uw",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": null,
|
|
||||||
"docs.deleted": null,
|
|
||||||
"store.size": null,
|
|
||||||
"pri.store.size": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "kibana",
|
|
||||||
"index": ".kibana-event-log-7.9.0-000001",
|
|
||||||
"uuid": "fgTtyl62Tc6F1ddJfPwqHA",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "20",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "25kb",
|
|
||||||
"pri.store.size": "12.5kb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "blog",
|
|
||||||
"index": "blogs",
|
|
||||||
"uuid": "Mb2n4wnNQSKqSToI_QO0Yg",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "1594",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "11mb",
|
|
||||||
"pri.store.size": "5.5mb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "kibana",
|
|
||||||
"index": ".kibana-event-log-7.9.0-000002",
|
|
||||||
"uuid": "8GpbwnDXR2KJUsw6srLnWw",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "9",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "96.9kb",
|
|
||||||
"pri.store.size": "48.4kb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "apm",
|
|
||||||
"index": ".apm-agent-configuration",
|
|
||||||
"uuid": "vIaV9k2VS-W48oUOe2xNWA",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "0",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "416b",
|
|
||||||
"pri.store.size": "208b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "logs",
|
|
||||||
"index": "logs_server1",
|
|
||||||
"uuid": "u56jv2AyR2KOkruOfxIAnA",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "5386",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "5.1mb",
|
|
||||||
"pri.store.size": "2.5mb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "kibana",
|
|
||||||
"index": ".kibana_1",
|
|
||||||
"uuid": "dBCrfVblRPGVlYAIlP_Duw",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "3187",
|
|
||||||
"docs.deleted": "50",
|
|
||||||
"store.size": "24.8mb",
|
|
||||||
"pri.store.size": "12.4mb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "tasks",
|
|
||||||
"index": ".tasks",
|
|
||||||
"uuid": "3RafayGeSNiqglO2BHof9Q",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "3",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "39.9kb",
|
|
||||||
"pri.store.size": "19.9kb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "filebeat",
|
|
||||||
"index": "filebeat-7.9.0-elastic_qa",
|
|
||||||
"uuid": "tktSYU14S3CrsrJb0ybpSQ",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "3009880",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "1.6gb",
|
|
||||||
"pri.store.size": "850.1mb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "analysis",
|
|
||||||
"index": "analysis_test",
|
|
||||||
"uuid": "6ZHEAW1ST_qfg7mo4Bva4w",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "0",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "416b",
|
|
||||||
"pri.store.size": "208b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "open",
|
|
||||||
"index": ".apm-custom-link",
|
|
||||||
"uuid": "Y4N2TeVERrGacEGwY-NPAQ",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "0",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "416b",
|
|
||||||
"pri.store.size": "208b"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"health": "green",
|
|
||||||
"status": "open",
|
|
||||||
"index": "kibana_sample_data_ecommerce",
|
|
||||||
"uuid": "4FIWJKhGSr6bE72R0xEQyA",
|
|
||||||
"pri": "1",
|
|
||||||
"rep": "1",
|
|
||||||
"docs.count": "4675",
|
|
||||||
"docs.deleted": "0",
|
|
||||||
"store.size": "9.2mb",
|
|
||||||
"pri.store.size": "4.6mb"
|
|
||||||
}
|
|
||||||
]`;
|
|
||||||
|
|
||||||
columns = [
|
columns = [
|
||||||
{
|
|
||||||
title: '索引名称',
|
|
||||||
dataIndex: 'index',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '别名',
|
title: '别名',
|
||||||
dataIndex: 'status',
|
dataIndex: 'alias',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '文档数',
|
title: '写索引',
|
||||||
dataIndex: 'docs.count',
|
dataIndex: 'write_index',
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '主分片数',
|
|
||||||
dataIndex: 'pri'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '从分片数',
|
|
||||||
dataIndex: 'rep'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储大小',
|
|
||||||
dataIndex: 'store.size'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<a onClick={() => this.handleUpdateModalVisible(true, record)}>别名设置</a>
|
{/*<a onClick={() => this.handleUpdateModalVisible(true, record)}>别名设置</a>*/}
|
||||||
<Divider type="vertical" />
|
{/*<Divider type="vertical" />*/}
|
||||||
<a onClick={() => {
|
<a onClick={() => {
|
||||||
this.state.selectedRows.push(record);
|
let indices = [];
|
||||||
this.handleDeleteClick();
|
for(let index of record.indexes){
|
||||||
|
indices.push(index.index);
|
||||||
|
}
|
||||||
|
let vals = {
|
||||||
|
alias: record.alias,
|
||||||
|
indices,
|
||||||
|
};
|
||||||
|
this.handleDeleteClick(vals);
|
||||||
}}>删除</a>
|
}}>删除</a>
|
||||||
<Divider type="vertical" />
|
|
||||||
</Fragment>
|
</Fragment>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -312,35 +174,16 @@ class AliasManage extends PureComponent {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
// dispatch({
|
dispatch({
|
||||||
// type: 'pipeline/fetch',
|
type: 'alias/fetchAliasList',
|
||||||
// });
|
payload: {
|
||||||
|
clusterID: this.props.selectedClusterID,
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStandardTableChange = (pagination, filtersArg, sorter) => {
|
handleStandardTableChange = (pagination, filtersArg, sorter) => {
|
||||||
const { dispatch } = this.props;
|
|
||||||
const { formValues } = this.state;
|
|
||||||
|
|
||||||
const filters = Object.keys(filtersArg).reduce((obj, key) => {
|
|
||||||
const newObj = { ...obj };
|
|
||||||
newObj[key] = getValue(filtersArg[key]);
|
|
||||||
return newObj;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
currentPage: pagination.current,
|
|
||||||
pageSize: pagination.pageSize,
|
|
||||||
...formValues,
|
|
||||||
...filters,
|
|
||||||
};
|
|
||||||
if (sorter.field) {
|
|
||||||
params.sorter = `${sorter.field}_${sorter.order}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: 'pipeline/fetch',
|
|
||||||
payload: params,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFormReset = () => {
|
handleFormReset = () => {
|
||||||
|
@ -348,29 +191,21 @@ class AliasManage extends PureComponent {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
this.setState({
|
this.setState({
|
||||||
formValues: {},
|
formValues: {},
|
||||||
});
|
keyword: '',
|
||||||
dispatch({
|
|
||||||
type: 'pipeline/fetch',
|
|
||||||
payload: {},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDeleteClick = e => {
|
handleDeleteClick = (record) => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
const { selectedRows } = this.state;
|
|
||||||
|
|
||||||
if (!selectedRows) return;
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'pipeline/delete',
|
type: 'alias/delete',
|
||||||
payload: {
|
payload: {
|
||||||
key: selectedRows.map(row => row.name),
|
clusterID: this.props.selectedClusterID,
|
||||||
},
|
index: record.index,
|
||||||
callback: () => {
|
alias: record.alias,
|
||||||
this.setState({
|
indices: record.indices,
|
||||||
selectedRows: [],
|
}
|
||||||
});
|
})
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSelectRows = rows => {
|
handleSelectRows = rows => {
|
||||||
|
@ -380,27 +215,10 @@ class AliasManage extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSearch = e => {
|
handleSearch = e => {
|
||||||
e.preventDefault();
|
let values = this.props.form.getFieldsValue();
|
||||||
|
|
||||||
const { dispatch, form } = this.props;
|
|
||||||
|
|
||||||
form.validateFields((err, fieldsValue) => {
|
|
||||||
if (err) return;
|
|
||||||
|
|
||||||
const values = {
|
|
||||||
...fieldsValue,
|
|
||||||
updatedAt: fieldsValue.updatedAt && fieldsValue.updatedAt.valueOf(),
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
formValues: values,
|
keyword: values.keyword,
|
||||||
});
|
})
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: 'rule/fetch',
|
|
||||||
payload: values,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleModalVisible = flag => {
|
handleModalVisible = flag => {
|
||||||
|
@ -410,10 +228,16 @@ class AliasManage extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleUpdateModalVisible = (flag, record) => {
|
handleUpdateModalVisible = (flag, record) => {
|
||||||
this.setState({
|
let values = record || {};
|
||||||
|
let newState = {
|
||||||
updateModalVisible: !!flag,
|
updateModalVisible: !!flag,
|
||||||
updateFormValues: record || {},
|
updateFormValues: values,
|
||||||
});
|
};
|
||||||
|
if(!values.alias){
|
||||||
|
newState.editMode = 'NEW';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState(newState);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleAdd = fields => {
|
handleAdd = fields => {
|
||||||
|
@ -432,13 +256,22 @@ class AliasManage extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleUpdate = fields => {
|
handleUpdate = fields => {
|
||||||
|
let upVals = {}
|
||||||
|
for(let k in fields){
|
||||||
|
if(fields[k]){
|
||||||
|
if(k === 'filter'){
|
||||||
|
upVals[k]=JSON.parse(fields[k]);
|
||||||
|
}else {
|
||||||
|
upVals[k] = fields[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'pipeline/update',
|
type: 'alias/update',
|
||||||
payload: {
|
payload: {
|
||||||
name: fields.name,
|
actionBody: upVals,
|
||||||
desc: fields.desc,
|
clusterID: this.props.selectedClusterID,
|
||||||
processors: fields.processors,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -451,16 +284,16 @@ class AliasManage extends PureComponent {
|
||||||
form: { getFieldDecorator },
|
form: { getFieldDecorator },
|
||||||
} = this.props;
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={this.handleSearch} layout="inline">
|
<Form layout="inline">
|
||||||
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
|
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
|
||||||
<Col md={8} sm={24}>
|
<Col md={8} sm={24}>
|
||||||
<FormItem label="索引名称">
|
<FormItem label="别名">
|
||||||
{getFieldDecorator('name')(<Input placeholder="请输入" />)}
|
{getFieldDecorator('keyword')(<Input placeholder="请输入" />)}
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Col>
|
</Col>
|
||||||
<Col md={8} sm={24}>
|
<Col md={8} sm={24}>
|
||||||
<span className={styles.submitButtons}>
|
<span className={styles.submitButtons}>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" onClick={this.handleSearch}>
|
||||||
查询
|
查询
|
||||||
</Button>
|
</Button>
|
||||||
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
|
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
|
||||||
|
@ -478,28 +311,22 @@ class AliasManage extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const data = {
|
const { selectedRows, updateModalVisible, updateFormValues } = this.state;
|
||||||
list: JSON.parse(this.datasource),
|
|
||||||
pagination: {
|
|
||||||
pageSize: 5,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const { selectedRows, modalVisible, updateModalVisible, updateFormValues } = this.state;
|
|
||||||
const parentMethods = {
|
|
||||||
handleAdd: this.handleAdd,
|
|
||||||
handleModalVisible: this.handleModalVisible,
|
|
||||||
};
|
|
||||||
const updateMethods = {
|
const updateMethods = {
|
||||||
handleUpdateModalVisible: this.handleUpdateModalVisible,
|
handleUpdateModalVisible: this.handleUpdateModalVisible,
|
||||||
handleUpdate: this.handleUpdate,
|
handleUpdate: this.handleUpdate,
|
||||||
};
|
};
|
||||||
|
let aliasList = [...(this.props.alias.aliasList||[])];
|
||||||
|
if(this.state.keyword) {
|
||||||
|
aliasList = aliasList.filter(al=>al.alias.includes(this.state.keyword))
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Card bordered={false}>
|
<Card bordered={false}>
|
||||||
<div className={styles.tableList}>
|
<div className={styles.tableList}>
|
||||||
<div className={styles.tableListForm}>{this.renderForm()}</div>
|
<div className={styles.tableListForm}>{this.renderForm()}</div>
|
||||||
<div className={styles.tableListOperator}>
|
<div className={styles.tableListOperator}>
|
||||||
<Button icon="plus" type="primary" onClick={() => this.handleModalVisible(true)}>
|
<Button icon="plus" type="primary" onClick={() => this.handleUpdateModalVisible(true)}>
|
||||||
新建
|
新建
|
||||||
</Button>
|
</Button>
|
||||||
{selectedRows.length > 0 && (
|
{selectedRows.length > 0 && (
|
||||||
|
@ -508,26 +335,109 @@ class AliasManage extends PureComponent {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<StandardTable
|
<Table
|
||||||
|
size="small"
|
||||||
|
bordered
|
||||||
selectedRows={selectedRows}
|
selectedRows={selectedRows}
|
||||||
data={data}
|
rowKey="alias"
|
||||||
|
dataSource={aliasList}
|
||||||
|
expandedRowRender={record => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<AliasIndexTable rawData={record}
|
||||||
|
handleDeleteClick={this.handleDeleteClick}
|
||||||
|
handleUpdateModalVisible={this.handleUpdateModalVisible} data={record.indexes}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
columns={this.columns}
|
columns={this.columns}
|
||||||
onSelectRow={this.handleSelectRows}
|
onSelectRow={this.handleSelectRows}
|
||||||
onChange={this.handleStandardTableChange}
|
onChange={this.handleStandardTableChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<CreateForm {...parentMethods} modalVisible={modalVisible} />
|
|
||||||
{updateFormValues && Object.keys(updateFormValues).length ? (
|
|
||||||
<UpdateForm
|
<UpdateForm
|
||||||
{...updateMethods}
|
{...updateMethods}
|
||||||
updateModalVisible={updateModalVisible}
|
updateModalVisible={updateModalVisible}
|
||||||
values={updateFormValues}
|
values={updateFormValues}
|
||||||
|
indices={['test-custom', 'dict']}
|
||||||
/>
|
/>
|
||||||
) : null}
|
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AliasManage;
|
export default AliasManage;
|
||||||
|
|
||||||
|
|
||||||
|
class AliasIndexTable extends React.Component {
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
title: '索引',
|
||||||
|
dataIndex: 'index',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '索引路由',
|
||||||
|
dataIndex: 'index_routing'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '搜索路由',
|
||||||
|
dataIndex: 'search_routing'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '过滤查询',
|
||||||
|
dataIndex: 'filter',
|
||||||
|
render:(text)=>{
|
||||||
|
return text ? JSON.stringify(text): '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
render: (text, record) => (
|
||||||
|
<div>
|
||||||
|
<a onClick={() => this.props.handleUpdateModalVisible(true, {
|
||||||
|
...record,
|
||||||
|
alias: this.props.rawData.alias,
|
||||||
|
})}>设置</a>
|
||||||
|
<Divider type="vertical" />
|
||||||
|
<a onClick={() => {
|
||||||
|
this.props.handleDeleteClick({
|
||||||
|
...record,
|
||||||
|
alias: this.props.rawData.alias,
|
||||||
|
});
|
||||||
|
}}>删除</a>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},]
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Table columns={this.columns}
|
||||||
|
size="small"
|
||||||
|
// pagination={false}
|
||||||
|
rowKey="index"
|
||||||
|
dataSource={this.props.data}/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IndexComplete extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
dataSource: [...props.dataSource],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleSearch = v => {
|
||||||
|
let data = this.props.dataSource.filter(d=>d.includes(v));
|
||||||
|
// if(data.length > 0 && v.length >0) {
|
||||||
|
// data.push(v+'*');
|
||||||
|
// }
|
||||||
|
this.setState({
|
||||||
|
dataSource: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
return <AutoComplete style={{width:'100%'}} disabled={this.props.disabled} onChange={this.props.onChange} value={this.props.value} onSearch={this.handleSearch} dataSource={this.state.dataSource} />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
import {getAliasList, doAlias } from '@/services/alias';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespace: 'alias',
|
||||||
|
|
||||||
|
state: {
|
||||||
|
},
|
||||||
|
effects: {
|
||||||
|
*fetchAliasList({ payload }, { call, put }) {
|
||||||
|
const res = yield call(getAliasList, payload);
|
||||||
|
let aliasList = [];
|
||||||
|
for(let k in res){
|
||||||
|
aliasList.push(res[k]);
|
||||||
|
}
|
||||||
|
yield put({
|
||||||
|
type: 'saveData',
|
||||||
|
payload: {
|
||||||
|
aliasList,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
*add({ payload, callback }, { call, put }) {
|
||||||
|
|
||||||
|
},
|
||||||
|
*update({ payload }, { call, put }) {
|
||||||
|
const res = yield call(doAlias, {
|
||||||
|
clusterID: payload.clusterID,
|
||||||
|
data: {
|
||||||
|
actions: [{
|
||||||
|
add: {
|
||||||
|
...payload.actionBody
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if(res.acknowledged){
|
||||||
|
yield put({
|
||||||
|
type:'fetchAliasList',
|
||||||
|
payload: {
|
||||||
|
clusterID: payload.clusterID,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
*delete({ payload }, { call, put }) {
|
||||||
|
let removeBody = {
|
||||||
|
alias: payload.alias,
|
||||||
|
};
|
||||||
|
if(payload.indices){
|
||||||
|
removeBody['indices'] = payload.indices;
|
||||||
|
}else{
|
||||||
|
removeBody['index'] = payload.index;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = yield call(doAlias, {
|
||||||
|
clusterID: payload.clusterID,
|
||||||
|
data: {
|
||||||
|
actions: [{
|
||||||
|
remove: removeBody,
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if(res.acknowledged){
|
||||||
|
yield put({
|
||||||
|
type:'fetchAliasList',
|
||||||
|
payload: {
|
||||||
|
clusterID: payload.clusterID,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
reducers: {
|
||||||
|
saveData(state, { payload }) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
...payload,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,17 @@
|
||||||
|
import request from '@/utils/request';
|
||||||
|
//import {pathPrefix} from './common';
|
||||||
|
|
||||||
|
export async function getAliasList(params){
|
||||||
|
let url = `/elasticsearch/${params.clusterID}/alias`;
|
||||||
|
return request(url,{
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function doAlias(params){
|
||||||
|
let url = `/elasticsearch/${params.clusterID}/alias`;
|
||||||
|
return request(url,{
|
||||||
|
method: 'POST',
|
||||||
|
body: params.data,
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue