You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by le...@apache.org on 2022/03/23 06:05:21 UTC

[incubator-inlong] branch master updated: [INLONG-3314][Dashboard] Support for new inlong stream APIs (#3315)

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


The following commit(s) were added to refs/heads/master by this push:
     new 679ecbf  [INLONG-3314][Dashboard] Support for new inlong stream APIs (#3315)
679ecbf is described below

commit 679ecbf59e67c9fd57f2ce877c767513bf1f3dab
Author: Daniel <le...@outlook.com>
AuthorDate: Wed Mar 23 14:05:14 2022 +0800

    [INLONG-3314][Dashboard] Support for new inlong stream APIs (#3315)
    
    * feat: Support for new data stream API data formats.
    
    * fix: Lack i18n.
    
    * fix: Eslint warning.
---
 .../AccessHelper/DataSourcesEditor/CreateModal.tsx |  7 ++-
 inlong-dashboard/src/locales/cn.json               |  1 +
 inlong-dashboard/src/locales/en.json               |  3 +-
 .../src/pages/AccessCreate/DataStream/helper.ts    | 57 ++++++----------------
 4 files changed, 23 insertions(+), 45 deletions(-)

diff --git a/inlong-dashboard/src/components/AccessHelper/DataSourcesEditor/CreateModal.tsx b/inlong-dashboard/src/components/AccessHelper/DataSourcesEditor/CreateModal.tsx
index e01391e..9c120a6 100644
--- a/inlong-dashboard/src/components/AccessHelper/DataSourcesEditor/CreateModal.tsx
+++ b/inlong-dashboard/src/components/AccessHelper/DataSourcesEditor/CreateModal.tsx
@@ -114,12 +114,15 @@ const Comp: React.FC<Props> = ({ type, id, content = [], record, ...modalProps }
         {
           name: 'sourceName',
           type: 'input',
-          label: '数据源名称',
+          label: t('components.AccessHelper.DataSourcesEditor.CreateModal.DataSourceName'),
           rules: [{ required: true }],
+          props: {
+            disabled: !!id,
+          },
         } as FormItemProps,
       ].concat(config);
     },
-    [type],
+    [type, id, t],
   );
 
   return (
diff --git a/inlong-dashboard/src/locales/cn.json b/inlong-dashboard/src/locales/cn.json
index 90bc84e..a99dd6f 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -14,6 +14,7 @@
   "basic.Yes": "是",
   "basic.No": "否",
   "components.AccessHelper.DataSourcesEditor.NewDataSource": "新建数据源",
+  "components.AccessHelper.DataSourcesEditor.CreateModal.DataSourceName": "数据源名称",
   "components.AccessHelper.DataSourcesEditor.CreateModal.File": "文件",
   "components.AccessHelper.DataSourceMetaData.File.FillInTheAbsolutePath": "填写绝对路径",
   "components.AccessHelper.DataSourceMetaData.File.DataSourceIP": "数据源IP",
diff --git a/inlong-dashboard/src/locales/en.json b/inlong-dashboard/src/locales/en.json
index 692f70c..978be63 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -13,7 +13,8 @@
   "basic.CreateTime": "CreateTime",
   "basic.Yes": "Yes",
   "basic.No": "No",
-  "components.AccessHelper.DataSourcesEditor.NewDataSource": "New data source",
+  "components.AccessHelper.DataSourcesEditor.NewDataSource": "New DataSource",
+  "components.AccessHelper.DataSourcesEditor.CreateModal.DataSourceName": "DataSource Name",
   "components.AccessHelper.DataSourcesEditor.CreateModal.File": "File",
   "components.AccessHelper.DataSourceMetaData.File.FillInTheAbsolutePath": "Fill in the absolute path",
   "components.AccessHelper.DataSourceMetaData.File.DataSourceIP": "Data source IP",
diff --git a/inlong-dashboard/src/pages/AccessCreate/DataStream/helper.ts b/inlong-dashboard/src/pages/AccessCreate/DataStream/helper.ts
index f043fb6..3adb533 100644
--- a/inlong-dashboard/src/pages/AccessCreate/DataStream/helper.ts
+++ b/inlong-dashboard/src/pages/AccessCreate/DataStream/helper.ts
@@ -25,29 +25,23 @@ export const valuesToData = (values, inlongGroupId) => {
       predefinedFields = [],
       rowTypeFields = [],
       dataSourceType,
-      dataSourceBasicId,
       dataSourcesConfig = [],
       streamSink = [],
       ...rest
     } = item;
     const output = {} as any;
-    if (dataSourceType === 'DB' || dataSourceType === 'FILE') {
-      const dstLow = dataSourceType.toLowerCase();
-      output[`${dstLow}BasicInfo`] = {
-        inlongGroupId,
-        inlongStreamId,
-      };
-      if (dataSourceBasicId !== undefined) {
-        output[`${dstLow}BasicInfo`].id = dataSourceBasicId;
-      }
-      output[`${dstLow}DetailInfoList`] = dataSourcesConfig.map(k => ({
-        ...k,
-        inlongGroupId,
-        inlongStreamId,
-      }));
+    if (dataSourceType !== 'AUTO_PUSH') {
+      output.sourceInfo = dataSourcesConfig.map(k => {
+        return {
+          ...k,
+          sourceType: dataSourceType,
+          inlongGroupId,
+          inlongStreamId,
+        };
+      });
     }
 
-    output.streamSink = streamSink.reduce((acc, type) => {
+    output.sinkInfo = streamSink.reduce((acc, type) => {
       if (!type) return acc;
 
       const data = rest[`streamSink${type}`] || [];
@@ -88,32 +82,11 @@ export const valuesToData = (values, inlongGroupId) => {
 // Convert interface data to form data
 export const dataToValues = data => {
   const array = data.map(item => {
-    const {
-      fileBasicInfo,
-      fileDetailInfoList,
-      dbBasicInfo,
-      dbDetailInfoList,
-      sinkInfo,
-      streamInfo,
-    } = item;
-    let output = {} as any;
-    const dataSourceType = fileBasicInfo ? 'FILE' : dbBasicInfo ? 'DB' : '';
-    output.dataSourceType = dataSourceType;
-    if (dataSourceType === 'DB') {
-      output = {
-        ...output,
-        ...dbBasicInfo,
-      };
-      output.dataSourceBasicId = dbBasicInfo.id;
-      output.dataSourcesConfig = dbDetailInfoList;
-    } else if (dataSourceType === 'FILE') {
-      output = {
-        ...output,
-        ...fileBasicInfo,
-      };
-      output.dataSourceBasicId = fileBasicInfo.id;
-      output.dataSourcesConfig = fileDetailInfoList;
-    }
+    const { sourceInfo, sinkInfo, streamInfo } = item;
+    let output = {
+      dataSourceType: sourceInfo[0]?.sourceType || 'AUTO_PUSH',
+      dataSourcesConfig: sourceInfo,
+    } as any;
 
     sinkInfo.forEach(({ sinkType, ...item }) => {
       if (!output[`streamSink${sinkType}`]) output[`streamSink${sinkType}`] = [];