This is an automated email from the ASF dual-hosted git repository.
leezng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 1c43cf808 [INLONG-4888][Dashboard] Support MySQL sink (#4904)
1c43cf808 is described below
commit 1c43cf8080d02eeee4fe1f53c64155ce96182072
Author: Lizhen <[email protected]>
AuthorDate: Thu Jul 7 14:08:19 2022 +0800
[INLONG-4888][Dashboard] Support MySQL sink (#4904)
---
.../src/components/MetaData/StorageMySQL.tsx | 238 +++++++++++++++++++++
inlong-dashboard/src/components/MetaData/index.ts | 6 +
inlong-dashboard/src/locales/cn.json | 11 +
inlong-dashboard/src/locales/en.json | 11 +
4 files changed, 266 insertions(+)
diff --git a/inlong-dashboard/src/components/MetaData/StorageMySQL.tsx
b/inlong-dashboard/src/components/MetaData/StorageMySQL.tsx
new file mode 100644
index 000000000..a4993f8db
--- /dev/null
+++ b/inlong-dashboard/src/components/MetaData/StorageMySQL.tsx
@@ -0,0 +1,238 @@
+/*
+ * 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 React from 'react';
+import {
+ getColsFromFields,
+ GetStorageColumnsType,
+ GetStorageFormFieldsType,
+} from '@/utils/metaData';
+import { ColumnsType } from 'antd/es/table';
+import EditableTable, { ColumnsItemProps } from '@/components/EditableTable';
+import i18n from '@/i18n';
+import { excludeObject } from '@/utils';
+import { sourceDataFields } from './SourceDataFields';
+
+// mysqlFieldTypes
+const mysqlFieldTypes = [
+ 'string',
+ 'varchar',
+ 'char',
+ 'tinyint',
+ 'smallint',
+ 'int',
+ 'bigint',
+ 'float',
+ 'double',
+ 'decimal',
+ 'numeric',
+ 'boolean',
+ 'binary',
+ 'timestamp',
+ 'date',
+ // 'interval',
+].map(item => ({
+ label: item,
+ value: item,
+}));
+
+const getForm: GetStorageFormFieldsType = (
+ type,
+ { currentValues, inlongGroupId, isEdit, dataType, form } = {} as any,
+) => {
+ const fileds = [
+ {
+ type: 'input',
+ label: 'JDBC URL',
+ name: 'jdbcUrl',
+ rules: [{ required: true }],
+ props: {
+ placeholder: 'jdbc:mysql://127.0.0.1:3306/write',
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ style: { width: 500 },
+ },
+ },
+ {
+ type: 'input',
+ label: i18n.t('components.AccessHelper.StorageMetaData.MySQL.TableName'),
+ name: 'tableName',
+ rules: [{ required: true }],
+ props: {
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ },
+ _inTable: true,
+ },
+ {
+ type: 'radio',
+ label:
i18n.t('components.AccessHelper.StorageMetaData.EnableCreateResource'),
+ name: '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,
+ },
+ ],
+ },
+ },
+ {
+ type: 'input',
+ label: i18n.t('components.AccessHelper.StorageMetaData.Username'),
+ name: 'username',
+ rules: [{ required: true }],
+ props: {
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ },
+ _inTable: true,
+ },
+ {
+ type: 'password',
+ label: i18n.t('components.AccessHelper.StorageMetaData.Password'),
+ name: 'password',
+ rules: [{ required: true }],
+ props: {
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ style: {
+ maxWidth: 500,
+ },
+ },
+ },
+ {
+ name: 'flushInterval',
+ type: 'inputnumber',
+ label:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.FlushInterval'),
+ initialValue: 1,
+ props: {
+ min: 1,
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ },
+ rules: [{ required: true }],
+ suffix:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.FlushIntervalUnit'),
+ },
+ {
+ name: 'retryTime',
+ type: 'inputnumber',
+ label:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.RetryTimes'),
+ initialValue: 3,
+ props: {
+ min: 1,
+ disabled: isEdit && [110, 130].includes(currentValues?.status),
+ },
+ rules: [{ required: true }],
+ suffix:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.RetryTimesUnit'),
+ },
+ {
+ type: (
+ <EditableTable
+ size="small"
+ columns={getFieldListColumns(dataType, currentValues)}
+ canDelete={(record, idx, isNew) => !isEdit || isNew}
+ />
+ ),
+ name: 'sinkFieldList',
+ },
+ ];
+
+ return type === 'col'
+ ? getColsFromFields(fileds)
+ : fileds.map(item => excludeObject(['_inTable'], item));
+};
+
+const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues)
=> {
+ return [
+ ...sourceDataFields,
+ {
+ title:
`MYSQL${i18n.t('components.AccessHelper.StorageMetaData.MySQL.FieldName')}`,
+ dataIndex: 'fieldName',
+ initialValue: '',
+ rules: [
+ { required: true },
+ {
+ pattern: /^[a-z][0-9a-z_]*$/,
+ message:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.FieldNameRule'),
+ },
+ ],
+ props: (text, record, idx, isNew) => ({
+ disabled: [110, 130].includes(currentValues?.status as number) &&
!isNew,
+ }),
+ },
+ {
+ title:
`MYSQL${i18n.t('components.AccessHelper.StorageMetaData.MySQL.FieldType')}`,
+ dataIndex: 'fieldType',
+ initialValue: mysqlFieldTypes[0].value,
+ type: 'select',
+ props: (text, record, idx, isNew) => ({
+ options: mysqlFieldTypes,
+ disabled: [110, 130].includes(currentValues?.status as number) &&
!isNew,
+ }),
+ rules: [{ required: true }],
+ },
+ {
+ title:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.IsMetaField'),
+ dataIndex: 'isMetaField',
+ initialValue: 0,
+ type: 'select',
+ props: (text, record, idx, isNew) => ({
+ options: [
+ {
+ label: i18n.t('basic.Yes'),
+ value: 1,
+ },
+ {
+ label: i18n.t('basic.No'),
+ value: 0,
+ },
+ ],
+ }),
+ },
+ {
+ title:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.FieldFormat'),
+ dataIndex: 'fieldFormat',
+ initialValue: 0,
+ type: 'autocomplete',
+ props: (text, record, idx, isNew) => ({
+ options: ['MICROSECONDS', 'MILLISECONDS', 'SECONDS', 'SQL',
'ISO_8601'].map(item => ({
+ label: item,
+ value: item,
+ })),
+ }),
+ visible: (text, record) =>
+ ['bigint', 'date', 'timestamp'].includes(record.fieldType as string),
+ },
+ {
+ title:
i18n.t('components.AccessHelper.StorageMetaData.MySQL.FieldDescription'),
+ dataIndex: 'fieldComment',
+ initialValue: '',
+ },
+ ] as ColumnsItemProps[];
+};
+
+const tableColumns = getForm('col') as ColumnsType;
+
+export const StorageMySQL = {
+ getForm,
+ getFieldListColumns,
+ tableColumns,
+};
diff --git a/inlong-dashboard/src/components/MetaData/index.ts
b/inlong-dashboard/src/components/MetaData/index.ts
index 60637d83b..87d9ec9a7 100644
--- a/inlong-dashboard/src/components/MetaData/index.ts
+++ b/inlong-dashboard/src/components/MetaData/index.ts
@@ -25,6 +25,7 @@ import { StorageKafka } from './StorageKafka';
import { StorageIceberg } from './StorageIceberg';
import { StorageEs } from './StorageEs';
import { StorageGreenplum } from './StorageGreenplum';
+import { StorageMySQL } from './StorageMySQL';
export interface StoragesType {
label: string;
@@ -72,4 +73,9 @@ export const Storages: StoragesType[] = [
value: 'GREENPLUM',
...StorageGreenplum,
},
+ {
+ label: 'MySQL',
+ value: 'MYSQL',
+ ...StorageMySQL,
+ },
];
diff --git a/inlong-dashboard/src/locales/cn.json
b/inlong-dashboard/src/locales/cn.json
index 696883ce0..74dcde9c2 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -130,6 +130,17 @@
"components.AccessHelper.StorageMetaData.Greenplum.IsMetaField": "是否为元字段",
"components.AccessHelper.StorageMetaData.Greenplum.FieldFormat": "字段格式",
"components.AccessHelper.StorageMetaData.Greenplum.FieldDescription": "字段描述",
+ "components.AccessHelper.StorageMetaData.MySQL.TableName": "表名称",
+ "components.AccessHelper.StorageMetaData.MySQL.FlushInterval": "刷新的间隔",
+ "components.AccessHelper.StorageMetaData.MySQL.FlushIntervalUnit": "秒",
+ "components.AccessHelper.StorageMetaData.MySQL.RetryTimes": "重试次数",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldName": "字段名",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldNameRule":
"以英文字母或下划线开头,只能包含英文字母、数字、下划线",
+ "components.AccessHelper.StorageMetaData.MySQL.RetryTimesUnit": "次",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldType": "字段类型",
+ "components.AccessHelper.StorageMetaData.MySQL.IsMetaField": "是否为元字段",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldFormat": "字段格式",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldDescription": "字段描述",
"components.AccessHelper.FieldsConfig.businessFields.Stripe/Second": "条/秒",
"components.AccessHelper.FieldsConfig.businessFields.MessageMiddleware":
"消息中间件",
"components.AccessHelper.FieldsConfig.businessFields.AccessSize": "按天接入大小",
diff --git a/inlong-dashboard/src/locales/en.json
b/inlong-dashboard/src/locales/en.json
index 98668d456..b0de10721 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -130,6 +130,17 @@
"components.AccessHelper.StorageMetaData.Greenplum.IsMetaField":
"IsMetaField",
"components.AccessHelper.StorageMetaData.Greenplum.FieldFormat":
"FieldFormat",
"components.AccessHelper.StorageMetaData.Greenplum.FieldDescription":
"FieldDescription",
+ "components.AccessHelper.StorageMetaData.MySQL.TableName": "TableName",
+ "components.AccessHelper.StorageMetaData.MySQL.FlushInterval":
"FlushInterval",
+ "components.AccessHelper.StorageMetaData.MySQL.FlushIntervalUnit": "S",
+ "components.AccessHelper.StorageMetaData.MySQL.RetryTimes": "RetryTimes",
+ "components.AccessHelper.StorageMetaData.MySQL.RetryTimesUnit": "times",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldName": "FieldName",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldNameRule": "At the
beginning of English letters, only English letters, numbers, and underscores",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldType": "FieldType",
+ "components.AccessHelper.StorageMetaData.MySQL.IsMetaField": "IsMetaField",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldFormat": "FieldFormat",
+ "components.AccessHelper.StorageMetaData.MySQL.FieldDescription":
"FieldDescription",
"components.AccessHelper.FieldsConfig.businessFields.Stripe/Second": "Stripe
/ S",
"components.AccessHelper.FieldsConfig.businessFields.MessageMiddleware":
"Middleware",
"components.AccessHelper.FieldsConfig.businessFields.AccessSize": "Access
Size",