You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/11/09 11:25:33 UTC

[inlong] 03/07: [INLONG-6470][Dashboard] Supports management of PostgreSQL source (#6478)

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

dockerzhang pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/inlong.git

commit a5aa182651e41a2d568a4b6fe8b55102d765f1f7
Author: Lizhen <88...@users.noreply.github.com>
AuthorDate: Wed Nov 9 17:38:40 2022 +0800

    [INLONG-6470][Dashboard] Supports management of PostgreSQL source (#6478)
---
 inlong-dashboard/src/locales/cn.json               |  11 +-
 inlong-dashboard/src/locales/en.json               |   9 ++
 .../src/metas/sources/defaults/PostgreSQL.ts       | 154 +++++++++++++++++++++
 .../src/metas/sources/defaults/index.ts            |   5 +
 4 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/inlong-dashboard/src/locales/cn.json b/inlong-dashboard/src/locales/cn.json
index c5ad9c67a..e99371b9c 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -44,11 +44,20 @@
   "meta.Sources.Oracle.Username": "用户",
   "meta.Sources.Oracle.Password": "密码",
   "meta.Sources.Oracle.Database": "数据库名",
-  "meta.Sources.Oracle.SchemaName": "集合名称",
+  "meta.Sources.Oracle.SchemaName": "架构名称",
   "meta.Sources.Oracle.TableName": "表格名称",
   "meta.Sources.Oracle.AllMigration": "是否整库迁移",
   "meta.Sources.Oracle.ScanStartupMode": "扫描启动模式",
   "meta.Sources.Oracle.PrimaryKey": "主键",
+  "meta.Sources.PostgreSQL.Hostname": "服务器主机",
+  "meta.Sources.PostgreSQL.Port": "端口",
+  "meta.Sources.PostgreSQL.Username": "用户",
+  "meta.Sources.PostgreSQL.Password": "密码",
+  "meta.Sources.PostgreSQL.Database": "数据库名",
+  "meta.Sources.PostgreSQL.SchemaName": "架构名称",
+  "meta.Sources.PostgreSQL.TableName": "表格名称",
+  "meta.Sources.PostgreSQL.decodingPluginName": "解码插件名称",
+  "meta.Sources.PostgreSQL.PrimaryKey": "主键",
   "meta.Sinks.SinkName": "名称",
   "meta.Sinks.SinkNameRule": "以英文字母开头,只能包含英文字母、数字、中划线、下划线",
   "meta.Sinks.SinkType": "类型",
diff --git a/inlong-dashboard/src/locales/en.json b/inlong-dashboard/src/locales/en.json
index dc7f103a1..255f56996 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -49,6 +49,15 @@
   "meta.Sources.Oracle.AllMigration": "AllMigration",
   "meta.Sources.Oracle.ScanStartupMode": "Scan startup mode",
   "meta.Sources.Oracle.PrimaryKey": "PrimaryKey",
+  "meta.Sources.PostgreSQL.Hostname": "Hostname",
+  "meta.Sources.PostgreSQL.Port": "Port",
+  "meta.Sources.PostgreSQL.Username": "Username",
+  "meta.Sources.PostgreSQL.Password": "Password",
+  "meta.Sources.PostgreSQL.Database": "Database",
+  "meta.Sources.PostgreSQL.SchemaName": "SchemaName",
+  "meta.Sources.PostgreSQL.TableName": "TableName",
+  "meta.Sources.PostgreSQL.decodingPluginName": "Decoding Plugin Name",
+  "meta.Sources.PostgreSQL.PrimaryKey": "PrimaryKey",
   "meta.Sinks.SinkName": "Name",
   "meta.Sinks.SinkNameRule": "At the beginning of English letters, only English letters, numbers, minus, and underscores",
   "meta.Sinks.SinkType": "Type",
diff --git a/inlong-dashboard/src/metas/sources/defaults/PostgreSQL.ts b/inlong-dashboard/src/metas/sources/defaults/PostgreSQL.ts
new file mode 100644
index 000000000..6bd69cc3f
--- /dev/null
+++ b/inlong-dashboard/src/metas/sources/defaults/PostgreSQL.ts
@@ -0,0 +1,154 @@
+/*
+ * 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 { DataWithBackend } from '@/metas/DataWithBackend';
+import { RenderRow } from '@/metas/RenderRow';
+import { RenderList } from '@/metas/RenderList';
+import { SourceInfo } from '../common/SourceInfo';
+
+const { I18n } = DataWithBackend;
+const { FieldDecorator } = RenderRow;
+const { ColumnDecorator } = RenderList;
+
+export default class PostgreSQLSource
+  extends SourceInfo
+  implements DataWithBackend, RenderRow, RenderList
+{
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @ColumnDecorator()
+  @I18n('meta.Sources.PostgreSQL.Hostname')
+  hostname: string;
+
+  @FieldDecorator({
+    type: 'inputnumber',
+    rules: [{ required: true }],
+    initialValue: 5432,
+    props: values => ({
+      min: 1,
+      max: 65535,
+      disabled: values?.status === 101,
+    }),
+  })
+  @ColumnDecorator()
+  @I18n('meta.Sources.PostgreSQL.Port')
+  port: number;
+
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.Database')
+  database: string;
+
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.SchemaName')
+  schema: string;
+
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @ColumnDecorator()
+  @I18n('meta.Sources.PostgreSQL.Username')
+  username: string;
+
+  @FieldDecorator({
+    type: 'password',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.Password')
+  password: string;
+
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.TableName')
+  tableName: Record<string, unknown>;
+
+  @FieldDecorator({
+    type: 'input',
+    rules: [{ required: true }],
+    props: values => ({
+      disabled: values?.status === 101,
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.PrimaryKey')
+  primaryKey: string;
+
+  @FieldDecorator({
+    type: 'select',
+    initialValue: 'decoderbufs',
+    props: values => ({
+      disabled: values?.status === 101,
+      options: [
+        {
+          label: 'decoderbufs',
+          value: 'decoderbufs',
+        },
+        {
+          label: 'wal2json',
+          value: 'wal2json',
+        },
+        {
+          label: 'wal2json_rds',
+          value: 'wal2json_rds',
+        },
+        {
+          label: 'wal2json_streaming',
+          value: 'wal2json_streaming',
+        },
+        {
+          label: 'wal2json_rds_streaming',
+          value: 'wal2json_rds_streaming',
+        },
+        {
+          label: 'pgoutput',
+          value: 'pgoutput',
+        },
+      ],
+    }),
+  })
+  @I18n('meta.Sources.PostgreSQL.decodingPluginName')
+  decodingPluginName: string;
+}
diff --git a/inlong-dashboard/src/metas/sources/defaults/index.ts b/inlong-dashboard/src/metas/sources/defaults/index.ts
index 881a7ff9a..15e30fcc7 100644
--- a/inlong-dashboard/src/metas/sources/defaults/index.ts
+++ b/inlong-dashboard/src/metas/sources/defaults/index.ts
@@ -51,4 +51,9 @@ export const allDefaultSources: MetaExportWithBackendList<SourceMetaType> = [
     value: 'ORACLE',
     LoadEntity: () => import('./Oracle'),
   },
+  {
+    label: 'PostgreSQL',
+    value: 'POSTGRESQL',
+    LoadEntity: () => import('./PostgreSQL'),
+  },
 ];