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/07/13 11:22:40 UTC

[inlong] branch master updated: [INLONG-5004][Dashboard] Support PostgreSQL sink (#5022)

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/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 57e58d26c [INLONG-5004][Dashboard] Support PostgreSQL sink (#5022)
57e58d26c is described below

commit 57e58d26caccbcadda859eed38cef6a2348cac9a
Author: Lizhen <88...@users.noreply.github.com>
AuthorDate: Wed Jul 13 19:22:34 2022 +0800

    [INLONG-5004][Dashboard] Support PostgreSQL sink (#5022)
---
 .../src/components/MetaData/StorageOracle.tsx      |  4 +-
 .../{StorageOracle.tsx => StoragePostgreSQL.tsx}   | 62 +++++++++++++---------
 inlong-dashboard/src/components/MetaData/index.ts  |  6 +++
 inlong-dashboard/src/locales/cn.json               |  9 ++++
 inlong-dashboard/src/locales/en.json               |  9 ++++
 5 files changed, 64 insertions(+), 26 deletions(-)

diff --git a/inlong-dashboard/src/components/MetaData/StorageOracle.tsx b/inlong-dashboard/src/components/MetaData/StorageOracle.tsx
index 745d8ccac..b502c3506 100644
--- a/inlong-dashboard/src/components/MetaData/StorageOracle.tsx
+++ b/inlong-dashboard/src/components/MetaData/StorageOracle.tsx
@@ -48,7 +48,6 @@ const oracleFieldTypes = [
   'CLOB',
   'RAW',
   'BLOB',
-  // 'interval',
 ].map(item => ({
   label: item,
   value: item,
@@ -65,7 +64,7 @@ const getForm: GetStorageFormFieldsType = (
       name: 'jdbcUrl',
       rules: [{ required: true }],
       props: {
-        placeholder: 'jdbc:oracle:thin://127.0.0.1:3306/write',
+        placeholder: 'jdbc:oracle:thin://127.0.0.1:1521/db_name',
         disabled: isEdit && [110, 130].includes(currentValues?.status),
         style: { width: 500 },
       },
@@ -181,6 +180,7 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
     },
     {
       title: i18n.t('components.AccessHelper.StorageMetaData.Oracle.IsMetaField'),
+      initialValue: 0,
       dataIndex: 'isMetaField',
       type: 'select',
       props: (text, record, idx, isNew) => ({
diff --git a/inlong-dashboard/src/components/MetaData/StorageOracle.tsx b/inlong-dashboard/src/components/MetaData/StoragePostgreSQL.tsx
similarity index 80%
copy from inlong-dashboard/src/components/MetaData/StorageOracle.tsx
copy to inlong-dashboard/src/components/MetaData/StoragePostgreSQL.tsx
index 745d8ccac..d71addd79 100644
--- a/inlong-dashboard/src/components/MetaData/StorageOracle.tsx
+++ b/inlong-dashboard/src/components/MetaData/StoragePostgreSQL.tsx
@@ -27,28 +27,31 @@ import i18n from '@/i18n';
 import { excludeObject } from '@/utils';
 import { sourceDataFields } from './SourceDataFields';
 
-//  oracleFieldTypes
-const oracleFieldTypes = [
-  'BINARY_FLOAT',
-  'BINARY_DOUBLE',
+// postgreSQLFieldTypes
+const postgreSQLFieldTypes = [
   'SMALLINT',
-  'FLOAT',
+  'INT2',
+  'SMALLSERIAL',
+  'SERIAL2',
+  'INTEGER',
+  'SERIAL',
+  'BIGINT',
+  'BIGSERIAL',
+  'REAL',
   'FLOAT4',
   'FLOAT8',
   'DOUBLE',
-  'REAL',
-  'NUMBER',
   'NUMERIC',
-  'DATE',
   'DECIMAL',
   'BOOLEAN',
+  'DATE',
+  'TIME',
   'TIMESTAMP',
   'CHAR',
+  'CHARACTER',
   'VARCHAR',
-  'CLOB',
-  'RAW',
-  'BLOB',
-  // 'interval',
+  'TEXT',
+  'BYTEA',
 ].map(item => ({
   label: item,
   value: item,
@@ -65,14 +68,24 @@ const getForm: GetStorageFormFieldsType = (
       name: 'jdbcUrl',
       rules: [{ required: true }],
       props: {
-        placeholder: 'jdbc:oracle:thin://127.0.0.1:3306/write',
+        placeholder: 'jdbc:postgresql://127.0.0.1:5432/db_name',
         disabled: isEdit && [110, 130].includes(currentValues?.status),
         style: { width: 500 },
       },
     },
     {
       type: 'input',
-      label: i18n.t('components.AccessHelper.StorageMetaData.Oracle.TableName'),
+      label: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.DbName'),
+      name: 'dbName',
+      rules: [{ required: true }],
+      props: {
+        disabled: isEdit && [110, 130].includes(currentValues?.status),
+      },
+      _inTable: true,
+    },
+    {
+      type: 'input',
+      label: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.TableName'),
       name: 'tableName',
       rules: [{ required: true }],
       props: {
@@ -82,7 +95,7 @@ const getForm: GetStorageFormFieldsType = (
     },
     {
       type: 'input',
-      label: i18n.t('components.AccessHelper.StorageMetaData.Oracle.PrimaryKey'),
+      label: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.PrimaryKey'),
       name: 'primaryKey',
       rules: [{ required: true }],
       props: {
@@ -154,14 +167,14 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
   return [
     ...sourceDataFields,
     {
-      title: `ORACLE${i18n.t('components.AccessHelper.StorageMetaData.Oracle.FieldName')}`,
+      title: `POSTGRESQL${i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.FieldName')}`,
       dataIndex: 'fieldName',
       initialValue: '',
       rules: [
         { required: true },
         {
           pattern: /^[a-z][0-9a-z_]*$/,
-          message: i18n.t('components.AccessHelper.StorageMetaData.Oracle.FieldNameRule'),
+          message: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.FieldNameRule'),
         },
       ],
       props: (text, record, idx, isNew) => ({
@@ -169,18 +182,19 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
       }),
     },
     {
-      title: `ORACLE${i18n.t('components.AccessHelper.StorageMetaData.Oracle.FieldType')}`,
+      title: `POSTGRESQL${i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.FieldType')}`,
       dataIndex: 'fieldType',
-      initialValue: oracleFieldTypes[0].value,
+      initialValue: postgreSQLFieldTypes[0].value,
       type: 'select',
       props: (text, record, idx, isNew) => ({
-        options: oracleFieldTypes,
+        options: postgreSQLFieldTypes,
         disabled: [110, 130].includes(currentValues?.status as number) && !isNew,
       }),
       rules: [{ required: true }],
     },
     {
-      title: i18n.t('components.AccessHelper.StorageMetaData.Oracle.IsMetaField'),
+      title: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.IsMetaField'),
+      initialValue: 0,
       dataIndex: 'isMetaField',
       type: 'select',
       props: (text, record, idx, isNew) => ({
@@ -197,7 +211,7 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
       }),
     },
     {
-      title: i18n.t('components.AccessHelper.StorageMetaData.Oracle.FieldFormat'),
+      title: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.FieldFormat'),
       dataIndex: 'fieldFormat',
       initialValue: '',
       type: 'autocomplete',
@@ -211,7 +225,7 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
         ['BIGINT', 'DATE', 'TIMESTAMP'].includes(record.fieldType as string),
     },
     {
-      title: i18n.t('components.AccessHelper.StorageMetaData.Oracle.FieldDescription'),
+      title: i18n.t('components.AccessHelper.StorageMetaData.PostgreSQL.FieldDescription'),
       dataIndex: 'fieldComment',
       initialValue: '',
     },
@@ -220,7 +234,7 @@ const getFieldListColumns: GetStorageColumnsType = (dataType, currentValues) =>
 
 const tableColumns = getForm('col') as ColumnsType;
 
-export const StorageOracle = {
+export const StoragePostgreSQL = {
   getForm,
   getFieldListColumns,
   tableColumns,
diff --git a/inlong-dashboard/src/components/MetaData/index.ts b/inlong-dashboard/src/components/MetaData/index.ts
index a502e3738..66a6bd8a9 100644
--- a/inlong-dashboard/src/components/MetaData/index.ts
+++ b/inlong-dashboard/src/components/MetaData/index.ts
@@ -27,6 +27,7 @@ import { StorageEs } from './StorageEs';
 import { StorageGreenplum } from './StorageGreenplum';
 import { StorageMySQL } from './StorageMySQL';
 import { StorageOracle } from './StorageOracle';
+import { StoragePostgreSQL } from './StoragePostgreSQL';
 
 export interface StoragesType {
   label: string;
@@ -84,4 +85,9 @@ export const Storages: StoragesType[] = [
     value: 'ORACLE',
     ...StorageOracle,
   },
+  {
+    label: 'PostgreSQL',
+    value: 'POSTGRES',
+    ...StoragePostgreSQL,
+  },
 ];
diff --git a/inlong-dashboard/src/locales/cn.json b/inlong-dashboard/src/locales/cn.json
index d0bf3c6f8..e520dc7ee 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -143,6 +143,15 @@
   "components.AccessHelper.StorageMetaData.Oracle.IsMetaField": "是否为元字段",
   "components.AccessHelper.StorageMetaData.Oracle.FieldFormat": "字段格式",
   "components.AccessHelper.StorageMetaData.Oracle.FieldDescription": "字段描述",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.DbName": "DB名称",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.TableName": "表名称",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.PrimaryKey": "主键",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldName": "字段名",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldNameRule": "以英文字母或下划线开头,只能包含英文字母、数字、下划线",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldType": "字段类型",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.IsMetaField": "是否为元字段",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldFormat": "字段格式",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.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 a63530cf3..4076a9ec3 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -143,6 +143,15 @@
   "components.AccessHelper.StorageMetaData.Oracle.IsMetaField": "IsMetaField",
   "components.AccessHelper.StorageMetaData.Oracle.FieldFormat": "FieldFormat",
   "components.AccessHelper.StorageMetaData.Oracle.FieldDescription": "FieldDescription",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.DbName": "DbName",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.TableName": "TableName",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.PrimaryKey": "PrimaryKey",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldName": "FieldName",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldNameRule": "At the beginning of English letters, only English letters, numbers, and underscores",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldType": "FieldType",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.IsMetaField": "IsMetaField",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldFormat": "FieldFormat",
+  "components.AccessHelper.StorageMetaData.PostgreSQL.FieldDescription": "FieldDescription",
   "components.AccessHelper.FieldsConfig.businessFields.Stripe/Second": "Stripe / S",
   "components.AccessHelper.FieldsConfig.businessFields.MessageMiddleware": "Middleware",
   "components.AccessHelper.FieldsConfig.businessFields.AccessSize": "Access Size",