Sfoglia il codice sorgente

feat: 添加查看产物日志的接口

Jinyao 5 anni fa
parent
commit
f1c2d70477

+ 14 - 0
mock/routers/deployment.js

@@ -1,3 +1,4 @@
+/* eslint-disable max-len */
 /* eslint-disable import/no-extraneous-dependencies */
 /* eslint-disable @typescript-eslint/no-var-requires */
 const router = require('express').Router();
@@ -31,4 +32,17 @@ router.get('/list', (req, res) => {
   ));
 });
 
+router.get('/log', (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
+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`));
+});
+
 module.exports = router;

+ 4 - 0
src/api/devcloud/pipeline.ts

@@ -70,5 +70,9 @@ export const getDeploymentsByProjectId = (projectId: number) => axios.get(`${DEP
   },
 });
 
+export const getDeploymentLog = (pipeline: PipelinePayload) => axios.get(`${DEPLOYMENT_PREFIX}/log`, {
+  params: pipeline,
+});
+
 // STAGE API
 export const getStages = () => axios.get(`${STAGE_PREFIX}`);

+ 41 - 2
src/views/Project/Pipeline.vue

@@ -84,7 +84,7 @@
       </ElTable>
       <ElDialog v-model="showPipelineDetailModal" destroy-on-close>
         <template #title>历史执行结果详情</template>
-        <pre class="pipeline-detail" v-loading="dialogLoading" >{{detail}}</pre>
+        <pre class="log" v-loading="dialogLoading" >{{detail}}</pre>
       </ElDialog>
       <ElDialog v-model="showPipelineHistoryModal" destroy-on-close>
         <template #title>流水线构建历史</template>
@@ -291,6 +291,15 @@
             <ElTag :type="scope.row.status.indexOf('正常') > -1 ? 'success' : 'danger'">{{scope.row.status}}</ElTag>
           </template>
         </ElTableColumn>
+        <ElTableColumn
+          label="运行状态"
+          align="center"
+          width="100"
+        >
+          <template #default="scope">
+            <ElButton type="text" @click="showLog(scope.row.pipelineId)">查看日志</ElButton>
+          </template>
+        </ElTableColumn>
         <ElTableColumn width="60">
           <template #default="scope">
             <ElButton type="text" @click="deleteProduction(scope.row.pipelineId)">
@@ -299,6 +308,15 @@
           </template>
         </ElTableColumn>
       </ElTable>
+      <ElDialog v-model="showProductionLogModal" destroy-on-close>
+        <template #title>
+          产物日志
+        </template>
+        <pre class="log" v-loading="dialogLoading" >{{currentLog}}</pre>
+        <template #footer>
+          <ElButton @click="refreshLog">刷新</ElButton>
+        </template>
+      </ElDialog>
     </ElTabPane>
   </ElTabs>
 </template>
@@ -333,6 +351,9 @@ export default {
       },
       stages: [],
       activeStep: 0,
+      showProductionLogModal: false,
+      currentLogId: -1,
+      currentLog: '',
     };
   },
   computed: {
@@ -474,6 +495,24 @@ export default {
     getStage(stageName) {
       return this.stages.find((stage) => stage.name === stageName);
     },
+    async showLog(pipelineId) {
+      this.currentLogId = pipelineId;
+      this.showProductionLogModal = true;
+      this.dialogLoading = true;
+      this.currentLog = await PipelineAPI.getDeploymentLog({
+        projectId: this.$store.state.workspace.currentProjectId,
+        pipelineId,
+      });
+      this.dialogLoading = false;
+    },
+    async refreshLog() {
+      this.dialogLoading = true;
+      this.currentLog = await PipelineAPI.getDeploymentLog({
+        projectId: this.$store.state.workspace.currentProjectId,
+        pipelineId: this.currentLogId,
+      });
+      this.dialogLoading = false;
+    },
   },
 };
 </script>
@@ -486,7 +525,7 @@ export default {
 .add-button {
   margin-left: 14px;
 }
-.pipeline-detail {
+.log {
   width: 100%;
   word-break: break-word;
   white-space: pre-wrap;