Explorar el Código

feat: details改为lazyload避免过长详情影响列表加载速度,同步后端接口。

Jinyao hace 5 años
padre
commit
2211bd6d5c
Se han modificado 4 ficheros con 32 adiciones y 26 borrados
  1. 10 17
      mock/routers/pipeline.js
  2. 10 1
      src/api/pipeline.ts
  3. 4 0
      src/api/prefix.ts
  4. 8 8
      src/views/Project/Pipeline.vue

+ 10 - 17
mock/routers/pipeline.js

@@ -42,16 +42,6 @@ router.get('/history/list', (req, res) => {
     Mock.mock(
       {
         'data|10': [{
-          details: `2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
-2021-03-16 00:01:58.622  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
-2021-03-16 00:01:58.634  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
-2021-03-16 00:01:58.641  INFO 20584 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
-2021-03-16 00:01:58.974  INFO 20584 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
-2021-03-16 00:01:58.975  INFO 20584 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
-2021-03-16 00:01:58.993  INFO 20584 --- [           main] s.devcloud.web.DevcloudWebApplication    : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
-2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
-2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
-2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`,
           'id|+5': 101,
           pipelineId: 100,
           'result|1': ['成功', '失败', '执行中'],
@@ -74,12 +64,8 @@ router.get('/history/list', (req, res) => {
   ));
 });
 
-router.get('/list', (req, res) => {
-  res.json(wrapper(
-    Mock.mock(
-      {
-        'data|10': [{
-          details: `2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
+router.get('/history/details', (req, res) => {
+  res.json(wrapper(`2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
 2021-03-16 00:01:58.622  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
 2021-03-16 00:01:58.634  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
 2021-03-16 00:01:58.641  INFO 20584 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
@@ -88,7 +74,14 @@ router.get('/list', (req, res) => {
 2021-03-16 00:01:58.993  INFO 20584 --- [           main] s.devcloud.web.DevcloudWebApplication    : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
-2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`,
+2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`));
+});
+
+router.get('/list', (req, res) => {
+  res.json(wrapper(
+    Mock.mock(
+      {
+        'data|10': [{
           'id|+1': 100,
           name: Random.cname(),
           'result|1': ['成功', '失败', '执行中'],

+ 10 - 1
src/api/pipeline.ts

@@ -1,6 +1,6 @@
 import axios from '@/utils/axios';
 
-import { PIPELINE_PREFIX, DEPLOYMENT_PREFIX } from './prefix';
+import { PIPELINE_PREFIX, DEPLOYMENT_PREFIX, STAGE_PREFIX } from './prefix';
 
 interface PipelinePayload {
   projectId: number;
@@ -31,6 +31,12 @@ export const updatePipeline = (updatePipelinePayload: UpdatePipelinePayload) =>
 
 export const getPipelineTemplates = () => axios.get(`${PIPELINE_PREFIX}/templates`);
 
+export const getPipelineHistoryDetail = (historyId: number) => axios.get(`${PIPELINE_PREFIX}/history/details`, {
+  params: {
+    historyId,
+  },
+});
+
 export const getPipelineHistory = (pipeline: PipelinePayload) => axios.get(`${PIPELINE_PREFIX}/history/list`, {
   params: pipeline,
 });
@@ -56,3 +62,6 @@ export const getDeploymentsByProjectId = (projectId: number) => axios.get(`${DEP
     projectId,
   },
 });
+
+// STAGE API
+export const getStages = () => axios.get(`${STAGE_PREFIX}`);

+ 4 - 0
src/api/prefix.ts

@@ -3,3 +3,7 @@ export const DEPLOYMENT_PREFIX = '/deployments';
 export const USER_PREFIX = '/users';
 export const TREE_PREFIX = '/tree';
 export const PROJECT_PREFIX = '/project';
+export const GROUP_PREFIX = '/groups';
+export const BUGLIST_PREFIX = '/bug_list';
+export const APITEST_PREFIX = '/test';
+export const STAGE_PREFIX = '/stages';

+ 8 - 8
src/views/Project/Pipeline.vue

@@ -57,7 +57,7 @@
         >
           <template #default="scope">
             <ElButton
-              @click="handleClick('detail', scope.row.id)"
+              @click="handleClick('detail', scope.row.historyId)"
               type="text"
               size="small"
               :disabled="scope.row.result==='执行中'"
@@ -80,7 +80,7 @@
         </ElTableColumn>
       </ElTable>
       <ElDialog v-model="showPipelineDetailModal" destroy-on-close>
-        <template #title>最近一次流水线构建的执行结果详情</template>
+        <template #title>历史执行结果详情</template>
         <pre class="pipeline-detail">{{detail}}</pre>
       </ElDialog>
       <ElDialog v-model="showPipelineHistoryModal" destroy-on-close>
@@ -90,11 +90,6 @@
           :default-sort="{prop: 'id', order: 'descending'}"
           height="400"
         >
-          <ElTableColumn type="expand">
-            <template #default="scope">
-              <pre class="pipeline-detail">{{scope.row.details}}</pre>
-            </template>
-          </ElTableColumn>
           <ElTableColumn
             prop="id"
             label="构建ID"
@@ -118,6 +113,11 @@
             align="center"
             :formatter="(row) => timeFormatter(row, 'startTime')"
           ></ElTableColumn>
+          <ElTableColumn>
+            <template #default="scope">
+              <ElButton @click="handleClick('detail', scope.row.id)" type="text" size="small">查看详情</ElButton>
+            </template>
+          </ElTableColumn>
         </ElTable>
       </ElDialog>
       <ElDialog
@@ -300,7 +300,7 @@ export default {
         }
         case 'detail': {
           this.showPipelineDetailModal = true;
-          this.detail = Array.prototype.find.call(this.pipelines, (pipeline) => pipeline.id === id).details;
+          this.detail = await PipelineAPI.getPipelineHistoryDetail(id);
           break;
         }
         case 'history': {