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

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 008217218f437508f1dc6815f2b12032de27932f
Author: 青湛 <[email protected]>
AuthorDate: Wed Mar 27 14:56:38 2024 +1300

    fix: something error for onboard result api interface (#7221)
---
 config-ui/src/api/pipeline/index.ts               |  4 ++-
 config-ui/src/api/pipeline/{index.ts => types.ts} | 42 +++++++++++------------
 config-ui/src/routes/onboard/components/logs.tsx  |  6 ++--
 config-ui/src/routes/onboard/step-4.tsx           | 23 ++++++-------
 4 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/config-ui/src/api/pipeline/index.ts 
b/config-ui/src/api/pipeline/index.ts
index 2d7261d57..0fe0f8a79 100644
--- a/config-ui/src/api/pipeline/index.ts
+++ b/config-ui/src/api/pipeline/index.ts
@@ -19,6 +19,8 @@
 import { IPipeline } from '@/types';
 import { request } from '@/utils';
 
+import { SubTasksRes } from './types';
+
 export const list = (): Promise<{ count: number; pipelines: IPipeline[] }> => 
request('/pipelines');
 
 export const get = (id: ID) => request(`/pipelines/${id}`);
@@ -37,4 +39,4 @@ export const log = (id: ID) => 
request(`/pipelines/${id}/logging.tar.gz`);
 
 export const tasks = (id: ID) => request(`/pipelines/${id}/tasks`);
 
-export const subTasks = (id: ID) => request(`/pipelines/${id}/subtasks`);
+export const subTasks = (id: ID): Promise<SubTasksRes> => 
request(`/pipelines/${id}/subtasks`);
diff --git a/config-ui/src/api/pipeline/index.ts 
b/config-ui/src/api/pipeline/types.ts
similarity index 55%
copy from config-ui/src/api/pipeline/index.ts
copy to config-ui/src/api/pipeline/types.ts
index 2d7261d57..854ac2160 100644
--- a/config-ui/src/api/pipeline/index.ts
+++ b/config-ui/src/api/pipeline/types.ts
@@ -16,25 +16,23 @@
  *
  */
 
-import { IPipeline } from '@/types';
-import { request } from '@/utils';
-
-export const list = (): Promise<{ count: number; pipelines: IPipeline[] }> => 
request('/pipelines');
-
-export const get = (id: ID) => request(`/pipelines/${id}`);
-
-export const remove = (id: ID) =>
-  request(`/pipelines/${id}`, {
-    method: 'delete',
-  });
-
-export const rerun = (id: ID) =>
-  request(`/pipelines/${id}/rerun`, {
-    method: 'post',
-  });
-
-export const log = (id: ID) => request(`/pipelines/${id}/logging.tar.gz`);
-
-export const tasks = (id: ID) => request(`/pipelines/${id}/tasks`);
-
-export const subTasks = (id: ID) => request(`/pipelines/${id}/subtasks`);
+export type SubTasksRes = {
+  completionRate: number;
+  status: string;
+  subtasks: Array<{
+    plugin: string;
+    options: {
+      name: string;
+    };
+    status: string;
+    subtaskDetails: Array<{
+      isCollector: boolean;
+      isFailed: boolean;
+      sequence: number;
+      name: string;
+      beganAt: string;
+      finishedAt: string;
+      finishedRecords: number;
+    }>;
+  }>;
+};
diff --git a/config-ui/src/routes/onboard/components/logs.tsx 
b/config-ui/src/routes/onboard/components/logs.tsx
index 438254b70..1fae57707 100644
--- a/config-ui/src/routes/onboard/components/logs.tsx
+++ b/config-ui/src/routes/onboard/components/logs.tsx
@@ -44,11 +44,11 @@ const Wrapper = styled.div`
   }
 
   span.name {
-    flex: 1;
+    flex: auto;
   }
 
   span.status {
-    flex: 1;
+    flex: 0 0 140px;
     text-align: right;
   }
 
@@ -67,7 +67,7 @@ interface LogsProps {
     tasks: Array<{
       step: number;
       name: string;
-      status: 'pending' | 'running' | 'success' | 'failed';
+      status: string;
       finishedRecords: number;
     }>;
   };
diff --git a/config-ui/src/routes/onboard/step-4.tsx 
b/config-ui/src/routes/onboard/step-4.tsx
index eb1b92d6c..14a250b06 100644
--- a/config-ui/src/routes/onboard/step-4.tsx
+++ b/config-ui/src/routes/onboard/step-4.tsx
@@ -113,8 +113,7 @@ export const Step4 = () => {
 
   const { data } = useAutoRefresh(
     async () => {
-      const taskRes = await API.pipeline.subTasks(record?.pipelineId as 
string);
-      return taskRes.tasks;
+      return await API.pipeline.subTasks(record?.pipelineId as string);
     },
     [],
     {
@@ -133,29 +132,29 @@ export const Step4 = () => {
 
     const collector = {
       plugin: collectorTask.plugin,
-      scopeName: collectorTask.option?.name,
+      scopeName: collectorTask.options?.name,
       status: collectorTask.status,
       tasks: (collectorTask.subtaskDetails ?? [])
-        .filter((it: any) => it.is_collector === '1')
-        .map((it: any) => ({
+        .filter((it) => it.isCollector)
+        .map((it) => ({
           step: it.sequence,
           name: it.name,
-          status: it.is_failed === '1' ? 'failed' : !it.began_at ? 'pending' : 
it.finished_at ? 'success' : 'running',
-          finishedRecords: it.finished_records,
+          status: it.isFailed ? 'failed' : !it.beganAt ? 'pending' : 
it.finishedAt ? 'success' : 'running',
+          finishedRecords: it.finishedRecords,
         })),
     };
 
     const extractor = {
       plugin: extractorTask.plugin,
-      scopeName: extractorTask.option?.name,
+      scopeName: extractorTask.options?.name,
       status: extractorTask.status,
       tasks: (extractorTask.subtaskDetails ?? [])
-        .filter((it: any) => it.is_collector === '1')
-        .map((it: any) => ({
+        .filter((it) => it.isCollector)
+        .map((it) => ({
           step: it.sequence,
           name: it.name,
-          status: it.is_failed === '1' ? 'failed' : !it.began_at ? 'pending' : 
it.finished_at ? 'success' : 'running',
-          finishedRecords: it.finished_records,
+          status: it.isFailed ? 'failed' : !it.beganAt ? 'pending' : 
it.finishedAt ? 'success' : 'running',
+          finishedRecords: it.finishedRecords,
         })),
     };
 

Reply via email to