You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/06/15 10:32:42 UTC

[incubator-inlong] branch master updated: [INLONG-4668][Dashboard] Support the config management of the Elasticsearch sink (#4669)

This is an automated email from the ASF dual-hosted git repository.

healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new aeeffeef5 [INLONG-4668][Dashboard] Support the config management of the Elasticsearch sink (#4669)
aeeffeef5 is described below

commit aeeffeef5f46e16eb26aa30e20f5f893c06eab30
Author: Daniel <le...@outlook.com>
AuthorDate: Wed Jun 15 18:32:37 2022 +0800

    [INLONG-4668][Dashboard] Support the config management of the Elasticsearch sink (#4669)
---
 .../src/components/MetaData/StorageEs.tsx          | 257 +++++++++++++++++++++
 inlong-dashboard/src/components/MetaData/index.ts  |   6 +
 inlong-dashboard/src/locales/cn.json               |  17 +-
 inlong-dashboard/src/locales/en.json               |  17 +-
 4 files changed, 293 insertions(+), 4 deletions(-)

diff --git a/inlong-dashboard/src/components/MetaData/StorageEs.tsx b/inlong-dashboard/src/components/MetaData/StorageEs.tsx
new file mode 100644
index 000000000..0f555f455
--- /dev/null
+++ b/inlong-dashboard/src/components/MetaData/StorageEs.tsx
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+  getColsFromFields,
+  GetStorageColumnsType,
+  GetStorageFormFieldsType,
+} from '@/utils/metaData';
+import i18n from '@/i18n';
+import { ColumnsType } from 'antd/es/table';
+import EditableTable, { ColumnsItemProps } from '@/components/EditableTable';
+import { excludeObject } from '@/utils';
+import { sourceDataFields } from './SourceDataFields';
+
+const esTypes = [
+  'text',
+  'keyword',
+  'date',
+  'boolean',
+  'long',
+  'integer',
+  'short',
+  'byte',
+  'double',
+  'float',
+  'half_float',
+  'scaled_float',
+].map(item => ({
+  label: item,
+  value: item,
+}));
+
+const getForm: GetStorageFormFieldsType = (
+  type: 'form' | 'col' = 'form',
+  { currentValues, inlongGroupId, isEdit, dataType } = {} as any,
+) => {
+  const fileds = [
+    {
+      name: 'indexName',
+      type: 'input',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.IndexName'),
+      rules: [{ required: true }],
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      _inTable: true,
+    },
+    {
+      name: 'enableCreateResource',
+      type: 'radio',
+      label: i18n.t('components.AccessHelper.StorageMetaData.EnableCreateResource'),
+      rules: [{ required: true }],
+      initialValue: 1,
+      tooltip: i18n.t('components.AccessHelper.StorageMetaData.EnableCreateResourceHelp'),
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+        options: [
+          {
+            label: i18n.t('basic.Yes'),
+            value: 1,
+          },
+          {
+            label: i18n.t('basic.No'),
+            value: 0,
+          },
+        ],
+      },
+    },
+    {
+      name: 'username',
+      type: 'input',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Username'),
+      rules: [{ required: true }],
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      _inTable: true,
+    },
+    {
+      name: 'password',
+      type: 'password',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Password'),
+      rules: [{ required: true }],
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+        style: {
+          maxWidth: 500,
+        },
+      },
+    },
+    {
+      type: 'input',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.Host'),
+      name: 'host',
+      rules: [{ required: true }],
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+    },
+    {
+      name: 'port',
+      type: 'inputnumber',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.Port'),
+      initialValue: 1,
+      props: {
+        min: 1,
+        max: 65535,
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      rules: [{ required: true }],
+    },
+    {
+      name: 'flushInterval',
+      type: 'inputnumber',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.FlushInterval'),
+      initialValue: 1,
+      props: {
+        min: 1,
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      rules: [{ required: true }],
+      suffix: i18n.t('components.AccessHelper.StorageMetaData.Es.FlushIntervalUnit'),
+    },
+    {
+      name: 'flushRecord',
+      type: 'inputnumber',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.FlushRecord'),
+      initialValue: 1000,
+      props: {
+        min: 1,
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      rules: [{ required: true }],
+      suffix: i18n.t('components.AccessHelper.StorageMetaData.Es.FlushRecordUnit'),
+    },
+    {
+      name: 'retryTime',
+      type: 'inputnumber',
+      label: i18n.t('components.AccessHelper.StorageMetaData.Es.RetryTimes'),
+      initialValue: 3,
+      props: {
+        min: 1,
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      rules: [{ required: true }],
+      suffix: i18n.t('components.AccessHelper.StorageMetaData.Es.RetryTimesUnit'),
+    },
+    {
+      name: 'fieldList',
+      type: EditableTable,
+      props: {
+        size: 'small',
+        editing: ![110, 130].includes(currentValues?.status),
+        columns: getFieldListColumns(dataType, currentValues),
+      },
+    },
+  ];
+
+  return type === 'col'
+    ? getColsFromFields(fileds)
+    : fileds.map(item => excludeObject(['_inTable'], item));
+};
+
+const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) => {
+  return [
+    ...sourceDataFields,
+    {
+      title: `ES ${i18n.t('components.AccessHelper.StorageMetaData.Es.FieldName')}`,
+      dataIndex: 'fieldName',
+      rules: [
+        { required: true },
+        {
+          pattern: /^[a-zA-Z][a-zA-Z0-9_]*$/,
+          message: i18n.t('components.AccessHelper.StorageMetaData.Es.FieldNameRule'),
+        },
+      ],
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+    },
+    {
+      title: `ES ${i18n.t('components.AccessHelper.StorageMetaData.Es.FieldType')}`,
+      dataIndex: 'fieldType',
+      initialValue: esTypes[0].value,
+      type: 'select',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+        options: esTypes,
+      }),
+      rules: [{ required: true }],
+    },
+    {
+      title: 'Analyzer',
+      dataIndex: 'analyzer',
+      type: 'input',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+      visible: (text, record) => record.fieldType === 'text',
+    },
+    {
+      title: 'SearchAnalyzer',
+      dataIndex: 'searchAnalyzer',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+      visible: (text, record) => record.fieldType === 'text',
+    },
+    {
+      title: i18n.t('components.AccessHelper.StorageMetaData.Es.DateFormat'),
+      dataIndex: 'format',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+      visible: (text, record) => record.fieldType === 'date',
+    },
+    {
+      title: 'ScalingFactor',
+      dataIndex: 'scalingFactor',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+      visible: (text, record) => record.fieldType === 'scaled_float',
+    },
+    {
+      title: `ES ${i18n.t('components.AccessHelper.StorageMetaData.Es.FieldDescription')}`,
+      dataIndex: 'fieldComment',
+      props: (text, record, idx, isNew) => ({
+        disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
+      }),
+    },
+  ] as ColumnsItemProps[];
+};
+
+const tableColumns = getForm('col') as ColumnsType;
+
+export const StorageEs = {
+  getForm,
+  getFieldListColumns,
+  tableColumns,
+};
diff --git a/inlong-dashboard/src/components/MetaData/index.ts b/inlong-dashboard/src/components/MetaData/index.ts
index a6105a601..9d98cbb2c 100644
--- a/inlong-dashboard/src/components/MetaData/index.ts
+++ b/inlong-dashboard/src/components/MetaData/index.ts
@@ -23,6 +23,7 @@ import { StorageHive } from './StorageHive';
 import { StorageClickhouse } from './StorageClickhouse';
 import { StorageKafka } from './StorageKafka';
 import { StorageIceberg } from './StorageIceberg';
+import { StorageEs } from './StorageEs';
 
 export interface StoragesType {
   label: string;
@@ -60,4 +61,9 @@ export const Storages: StoragesType[] = [
     value: 'KAFKA',
     ...StorageKafka,
   },
+  {
+    label: 'Elasticsearch',
+    value: 'ELASTICSEARCH',
+    ...StorageEs,
+  },
 ];
diff --git a/inlong-dashboard/src/locales/cn.json b/inlong-dashboard/src/locales/cn.json
index b4219a24b..fb50381f3 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -89,6 +89,20 @@
   "components.AccessHelper.StorageMetaData.Clickhouse.PrimaryKey": "主键",
   "components.AccessHelper.StorageMetaData.Clickhouse.CompressionCode": "压缩格式",
   "components.AccessHelper.StorageMetaData.Clickhouse.TtlExpr": "生命周期",
+  "components.AccessHelper.StorageMetaData.Es.IndexName": "索引名称",
+  "components.AccessHelper.StorageMetaData.Es.FlushInterval": "刷新的间隔",
+  "components.AccessHelper.StorageMetaData.Es.FlushIntervalUnit": "秒",
+  "components.AccessHelper.StorageMetaData.Es.FlushRecord": "刷新的数据条数",
+  "components.AccessHelper.StorageMetaData.Es.FlushRecordUnit": "条",
+  "components.AccessHelper.StorageMetaData.Es.RetryTimes": "重试次数",
+  "components.AccessHelper.StorageMetaData.Es.RetryTimesUnit": "次",
+  "components.AccessHelper.StorageMetaData.Es.Host": "主机地址",
+  "components.AccessHelper.StorageMetaData.Es.Port": "端口",
+  "components.AccessHelper.StorageMetaData.Es.FieldName": "字段名",
+  "components.AccessHelper.StorageMetaData.Es.FieldNameRule": "以英文字母开头,只能包含英文字母、数字、下划线",
+  "components.AccessHelper.StorageMetaData.Es.FieldType": "字段类型",
+  "components.AccessHelper.StorageMetaData.Es.FieldDescription": "字段描述",
+  "components.AccessHelper.StorageMetaData.Es.DateFormat": "日期格式",
   "components.AccessHelper.StorageMetaData.Kafka.Server": "服务器地址",
   "components.AccessHelper.StorageMetaData.Kafka.SerializationType": "序列化类型",
   "components.AccessHelper.StorageMetaData.Kafka.PartitionNum": "Topic分区数",
@@ -183,8 +197,6 @@
   "components.Layout.NavWidget.Logout": "退出登录",
   "components.StaffSelect.Placeholder": "请输入关键字搜索",
   "configs.pagination.Total": "共{{total}}项",
-  "pages.AccessCreate.Business.config.BusinessInformation": "分组信息",
-  "pages.AccessCreate.Business.config.AccessRequirements": "接入要求",
   "pages.AccessCreate.Business.config.AccessScale": "接入规模",
   "pages.AccessCreate.DataStream.config.Basic": "基础信息",
   "pages.AccessCreate.DataStream.config.DataInfo": "数据信息",
@@ -194,6 +206,7 @@
   "pages.AccessCreate.DataStreams": "数据流",
   "pages.AccessCreate.Submit": "提交审批",
   "pages.AccessCreate.SubmittedSuccessfully": "提交成功",
+  "pages.AccessCreate.CheckMsg": "请检查表单",
   "pages.AccessCreate.BusinessInfo": "分组信息",
   "pages.AccessCreate.Previous": "上一步",
   "pages.AccessCreate.NewAccess": "新建接入",
diff --git a/inlong-dashboard/src/locales/en.json b/inlong-dashboard/src/locales/en.json
index 5756da64c..5977a2918 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -89,6 +89,20 @@
   "components.AccessHelper.StorageMetaData.Clickhouse.PrimaryKey": "PrimaryKey",
   "components.AccessHelper.StorageMetaData.Clickhouse.CompressionCode": "CompressionCode",
   "components.AccessHelper.StorageMetaData.Clickhouse.TtlExpr": "TtlExpr",
+  "components.AccessHelper.StorageMetaData.Es.IndexName": "IndexName",
+  "components.AccessHelper.StorageMetaData.Es.FlushInterval": "FlushInterval",
+  "components.AccessHelper.StorageMetaData.Es.FlushIntervalUnit": "S",
+  "components.AccessHelper.StorageMetaData.Es.FlushRecord": "FlushRecord",
+  "components.AccessHelper.StorageMetaData.Es.FlushRecordUnit": "items",
+  "components.AccessHelper.StorageMetaData.Es.RetryTimes": "RetryTimes",
+  "components.AccessHelper.StorageMetaData.Es.RetryTimesUnit": "items",
+  "components.AccessHelper.StorageMetaData.Es.Host": "Host",
+  "components.AccessHelper.StorageMetaData.Es.Port": "Port",
+  "components.AccessHelper.StorageMetaData.Es.FieldName": "FieldName",
+  "components.AccessHelper.StorageMetaData.Es.FieldNameRule": "At the beginning of English letters, only English letters, numbers, and underscores",
+  "components.AccessHelper.StorageMetaData.Es.FieldType": "FieldType",
+  "components.AccessHelper.StorageMetaData.Es.FieldDescription": "FieldDescription",
+  "components.AccessHelper.StorageMetaData.Es.DateFormat": "DateFormat",
   "components.AccessHelper.StorageMetaData.Kafka.Server": "Server",
   "components.AccessHelper.StorageMetaData.Kafka.SerializationType": "SerializationType",
   "components.AccessHelper.StorageMetaData.Kafka.PartitionNum": "PartitionNum",
@@ -183,8 +197,6 @@
   "components.Layout.NavWidget.Logout": "Logout",
   "components.StaffSelect.Placeholder": "Please enter a keyword search",
   "configs.pagination.Total": "Total {{total}} items",
-  "pages.AccessCreate.Business.config.BusinessInformation": "Group information",
-  "pages.AccessCreate.Business.config.AccessRequirements": "Access requirements",
   "pages.AccessCreate.Business.config.AccessScale": "Access scale",
   "pages.AccessCreate.DataStream.config.Basic": "Basic Info",
   "pages.AccessCreate.DataStream.config.DataInfo": "Data Info",
@@ -194,6 +206,7 @@
   "pages.AccessCreate.DataStreams": "Data streams",
   "pages.AccessCreate.Submit": "Submit",
   "pages.AccessCreate.SubmittedSuccessfully": "Submitted successfully",
+  "pages.AccessCreate.CheckMsg": "Please check the form",
   "pages.AccessCreate.BusinessInfo": "Group information",
   "pages.AccessCreate.Previous": "Previous",
   "pages.AccessCreate.NewAccess": "Access Create",