You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by ni...@apache.org on 2023/12/27 14:01:28 UTC

(incubator-paimon-webui) branch main updated: [Feature] Support Metadata mock integration (#132)

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

nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-webui.git


The following commit(s) were added to refs/heads/main by this push:
     new c55e968  [Feature] Support Metadata mock integration (#132)
c55e968 is described below

commit c55e96862510521917c56c9535c452c3bff746ae
Author: xiaomo <we...@gmail.com>
AuthorDate: Wed Dec 27 22:01:23 2023 +0800

    [Feature] Support Metadata mock integration (#132)
---
 paimon-web-ui-new/README.md                        |   8 ++
 paimon-web-ui-new/mock/mm.config.js                |  16 ++-
 paimon-web-ui-new/mock/modules/index.js            |   2 +-
 paimon-web-ui-new/mock/modules/metadata.js         | 121 ++++++++++++++++++++-
 .../src/views/metadata/components/schema/index.tsx |   1 +
 5 files changed, 139 insertions(+), 9 deletions(-)

diff --git a/paimon-web-ui-new/README.md b/paimon-web-ui-new/README.md
index 203f387..f0c8e16 100644
--- a/paimon-web-ui-new/README.md
+++ b/paimon-web-ui-new/README.md
@@ -35,10 +35,18 @@ pnpm dev
 
 - If you can't a backend server. You can running project with mock mode
 
+    This will open a mock server service and api document.
+
+    The mock server will in [http://localhost:10088](http://localhost:10088)
+
+    The mock api document will in [http://localhost:10090](http://localhost:10090)
+
 ```sh
 pnpm dev:mock & pnpm run mock
 ```
 
+
+
 ### Type-Check, Compile and Minify for Production
 
 ```sh
diff --git a/paimon-web-ui-new/mock/mm.config.js b/paimon-web-ui-new/mock/mm.config.js
index dba3a5d..eab1dce 100644
--- a/paimon-web-ui-new/mock/mm.config.js
+++ b/paimon-web-ui-new/mock/mm.config.js
@@ -65,11 +65,21 @@ module.exports = util => {
   }
 }
 
-function rename(mockInstance) {
+function rename(mockUtil) {
   const result = {}
   for (const key in mockData) {
-    result[`/mock/api${key}`] = mockInstance(mockData[key])
+    const apiData = mockData[key](mockUtil)
+
+    for (const k in apiData) {
+      const urlGap = k.split(' ')
+
+      if (urlGap.length === 2) {
+        result[`${urlGap[0]} /mock/api${urlGap[1]}`] = apiData[k]
+      } else {
+        result[`/mock/api${k}`] = apiData[k]
+      }
+    }
   }
 
   return result
-}
\ No newline at end of file
+}
diff --git a/paimon-web-ui-new/mock/modules/index.js b/paimon-web-ui-new/mock/modules/index.js
index e642b3e..5895c6b 100644
--- a/paimon-web-ui-new/mock/modules/index.js
+++ b/paimon-web-ui-new/mock/modules/index.js
@@ -18,5 +18,5 @@ under the License. */
 const metadata = require(`./metadata`)
 
 module.exports = {
-  ...metadata
+  metadata
 }
diff --git a/paimon-web-ui-new/mock/modules/metadata.js b/paimon-web-ui-new/mock/modules/metadata.js
index 993e9c4..57ad096 100644
--- a/paimon-web-ui-new/mock/modules/metadata.js
+++ b/paimon-web-ui-new/mock/modules/metadata.js
@@ -15,10 +15,10 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License. */
 
-module.exports = {
-  '/catalog/getAllCatalogs': {
+module.exports = (mockUtil) => ({
+  '/catalog/getAllCatalogs': mockUtil({
     code: 200,
-    message: 'success',
+    msg: 'Successfully',
     'data|5': [
       {
         'id|+1': 1,
@@ -31,5 +31,116 @@ module.exports = {
         hiveConfDir: undefined
       }
     ]
-  }
-}
+  }),
+  'get /database/list': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|5': [
+      {
+        "name": "@name",
+        "catalogId": '1-52',
+        "catalogName": "@title",
+        "description": ""
+      },
+    ]
+  }),
+  'post /table/list': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|5': [
+      {
+        "catalogId": '1-52',
+        "catalogName": "@name",
+        "databaseName": "@name",
+        "name": "@name"
+      },
+    ]
+  }),
+  'post /metadata/query/schema': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|2': [
+      {
+        "schemaId|+1": 0,
+        "fields|10": [
+          {
+            "id|+1": 0,
+            "name": "@id",
+            "type": "@word",
+            "comment": null
+          },
+        ],
+        "partitionKeys": "[]",
+        "primaryKeys": "[\"id\"]",
+        "comment": "",
+        "option|3": [
+          {
+            "key": "@name",
+            "value": "@float"
+          }
+        ],
+        "updateTime": "@datetime"
+      }
+    ]
+  }),
+  'post /metadata/query/snapshot': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|2': [
+      {
+        "snapshotId": "@float",
+        "schemaId": "@float",
+        "commitUser": "@tld",
+        "commitIdentifier": "@tld",
+        "commitKind": "APPEND",
+        "commitTime": "@datetime",
+        "baseManifestList": "@title",
+        "deltaManifestList": "@title",
+        "changelogManifestList": "@title",
+        "totalRecordCount": "@float",
+        "deltaRecordCount": "@float",
+        "changelogRecordCount": "@float",
+        "addedFileCount": "@float",
+        "deletedFileCount": "@float",
+        "watermark": "@float",
+      },
+    ]
+  }),
+  'post /metadata/query/manifest': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|2': [
+      {
+        "fileName": "@title",
+        "fileSize": "@float",
+        "numAddedFiles": "@float",
+        "numDeletedFiles": "@float",
+        "schemaId": "@float"
+      }
+    ]
+  }),
+  'post /metadata/query/dataFile': mockUtil({
+    code: 200,
+    msg: 'Successfully',
+    'data|2': [
+      {
+        "partition": "[]",
+        "bucket": "@float",
+        "filePath": "@title",
+        "fileFormat": "orc",
+        "schemaId": "0",
+        "level": "@float",
+        "recordCount": "4",
+        "fileSizeInBytes": "3999",
+        "minKey": "[152]",
+        "maxKey": "[160]",
+        "nullValueCounts": "{Path=0, Status=0, assetPath=0, cachePath=0, canCreateUser=0, canCreateUserStime=0, dbhost=0, dbname=0, dbport=0, dbpw=0, dbuser=0, groupid=0, host=0, id=0, ifshow=0, ipv6=0, is_review=0, lid=0, mergeServerTime=0, mtime=0, name=0, openDateTime=0, port=0, ready_open_weight=0, recommend_weight=0, server_type=0, sid=0, testflag=0, uncachePath=0, url=0, version=0}",
+        "minValueStats": "{Path=http://static.zuiyouxi.com/game/20120730/, Status=false, assetPath=http://static.zuiyouxi.com/game/20120730/assets/, cachePath=, canCreateUser=true, canCreateUserStime=0, dbhost=192.168.1.1, dbname=pirate5900003, dbport=3306, dbpw=admin, dbuser=rd, groupid=5900002, host=10.0.18.34, id=152, ifshow=false, ipv6=, is_review=0, lid=11, mergeServerTime=0, mtime=1644390163, name=S1-国内测试服, openDateTime=1636077600, port=12002, ready_open_weight=0, recommend_weight= [...]
+        "maxValueStats": "{Path=http://static.zuiyouxi.com/game/20120730/, Status=true, assetPath=http://static.zuiyouxi.com/game/20120730/assets/, cachePath=, canCreateUser=true, canCreateUserStime=0, dbhost=192.168.1.1, dbname=pirate5920001, dbport=3306, dbpw=admin, dbuser=rd, groupid=5920001, host=192.168.2.162, id=160, ifshow=true, ipv6=, is_review=0, lid=13, mergeServerTime=0, mtime=1659498303, name=兼容性测试服, openDateTime=1659492000, port=20009, ready_open_weight=0, recommend_weight=0 [...]
+        "minSequenceNumber": "0",
+        "maxSequenceNumber": "3",
+        "creationTime": "@now"
+      }
+    ]
+  })
+})
diff --git a/paimon-web-ui-new/src/views/metadata/components/schema/index.tsx b/paimon-web-ui-new/src/views/metadata/components/schema/index.tsx
index 170c834..faa2b41 100644
--- a/paimon-web-ui-new/src/views/metadata/components/schema/index.tsx
+++ b/paimon-web-ui-new/src/views/metadata/components/schema/index.tsx
@@ -108,6 +108,7 @@ export default defineComponent({
         {this.loading}
         <n-spin show={this.loading}>
           <n-data-table
+            row-key={(rowData: Schema) => rowData.schemaId}
             columns={this.columns}
             data={this.schemaData?.data || []}
             max-height="calc(100vh - 260px)"