diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index faab88a7..c580d2f1 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -236,6 +236,12 @@ export default { 'collect.proc.type.name': 'Process Name', 'collect.proc.type.input.pattern.msg': 'Cannot contain Chinese', + 'collect.plugin': 'Plugin', + 'collect.plugin.name.placeholder': 'Description of the collection', + 'collect.plugin.filepath': 'FilePath', + 'collect.plugin.params': 'Params', + 'collect.plugin.filepath.placeholder': 'The absolute path of the plugin', + 'graph.subscribe': 'Subscribe', 'graph.subscribe.node': 'Node', 'graph.subscribe.screen': 'Screen', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 18b5418c..83a1a64d 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -237,6 +237,12 @@ export default { 'collect.proc.type.name': '进程名', 'collect.proc.type.input.pattern.msg': '不能包含中文', + 'collect.plugin': '插件', + 'collect.plugin.name.placeholder': '对采集配置的说明', + 'collect.plugin.filepath': '文件路径', + 'collect.plugin.params': '参数', + 'collect.plugin.filepath.placeholder': '待执行插件所在的绝对路径', + 'graph.subscribe': '订阅图表', 'graph.subscribe.node': '所属节点', 'graph.subscribe.screen': '选择大盘', diff --git a/web/src/pages/Monitor/Collect/CollectForm/PLUGINForm.tsx b/web/src/pages/Monitor/Collect/CollectForm/PLUGINForm.tsx new file mode 100644 index 00000000..de67966a --- /dev/null +++ b/web/src/pages/Monitor/Collect/CollectForm/PLUGINForm.tsx @@ -0,0 +1,145 @@ +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; +import _ from 'lodash'; +import { Button, Form, Select, Input, TreeSelect } from 'antd'; +import { injectIntl, FormattedMessage } from 'react-intl'; +import { renderTreeNodes } from '@cpts/Layout/utils'; +import { nameRule, interval } from '../config'; + + +const FormItem = Form.Item; +const { Option } = Select; +const formItemLayout = { + labelCol: { span: 6 }, + wrapperCol: { span: 14 }, +}; +const defaultFormData = { + collect_type: 'plugin', + timeout: 3, + step: 10, +}; + +const getInitialValues = (initialValues: any) => { + return _.assignIn({}, defaultFormData, _.cloneDeep(initialValues)); +} + +const CollectForm = (props: any) => { + const initialValues = getInitialValues(props.initialValues); + const { getFieldProps, getFieldDecorator } = props.form; + + getFieldDecorator('collect_type', { + initialValue: initialValues.collect_type, + }); + + const [submitLoading, setSubmitLoading] = useState(false); + + const handleSubmit = (e: any) => { + e.preventDefault(); + props.form.validateFields((errors: any, values: any) => { + if (errors) { + console.error(errors); + return; + } + setSubmitLoading(true); + props.onSubmit(values).catch(() => { + setSubmitLoading(false); + }); + }); + } + + return ( +
+ ); +} + +export default Form.create()(injectIntl(CollectForm)); diff --git a/web/src/pages/Monitor/Collect/CollectForm/PORTForm.tsx b/web/src/pages/Monitor/Collect/CollectForm/PORTForm.tsx index 08167f0e..ab755b2c 100644 --- a/web/src/pages/Monitor/Collect/CollectForm/PORTForm.tsx +++ b/web/src/pages/Monitor/Collect/CollectForm/PORTForm.tsx @@ -61,7 +61,7 @@ class CollectForm extends Component