Sfoglia il codice sorgente

Merge branch 'hotfix/zhouweilu' into develop

soleil 7 anni fa
parent
commit
e4380daa85

+ 2 - 2
src/api/codehw.js

@@ -66,9 +66,9 @@ export const getLatestBuildInfoList = (projectId, limit = 5) => {
  * @param {string|number} projectId
  * @return {Promise<{id:string,data:DeploySerializerType[]}>}
  */
-export const getLatestDeployInfoList = (projectId, limit = 5) => {
+export const getLatestDeployInfoList = (projectId, limit = 5, success = 1) => {
   return request(
-    `${CODE_HOMEWORK_MODULE}/project/deploy/record/${projectId}?limit=${limit}`
+    `${CODE_HOMEWORK_MODULE}/project/deploy/record/${projectId}?limit=${limit}&success=${success}`
   );
 };
 

+ 54 - 33
src/views/student/Code/ProjectDetail/DeployDetail.vue

@@ -94,7 +94,7 @@
 </template>
 <script>
 import {
-  getDeployDetail,
+  // getDeployDetail,
   getDeployLogInfo,
   getLatestBuildInfoList,
   makeDeploy,
@@ -108,14 +108,15 @@ export default {
       isRunning: false,
       deployStatus: "",
       deployInfo: {},
-      haveDeployRecord: false,
+      // haveDeployRecord: false,
       deployLog: "",
       unfoldDeployLogInfo: false,
       latestBuildList: [],
       latestDeployList: [],
       latestMirrorIdList: [],
       radio: -1,
-      isfetchLog: false
+      isfetchLog: false,
+      latestDeployId: 0
     };
   },
   props: {
@@ -129,46 +130,42 @@ export default {
     }
   },
   watch: {
-    projectDetail: function(newVal) {
-      console.log(newVal);
+    projectDetail: function() {
+      // console.log(newVal);
       //获取最新一次部署详细信息
-      if (newVal.latestDeploy && newVal.latestDeploy.id) {
-        this.haveDeployRecord = true;
-        this.getLatestDeployInfo(newVal.latestDeploy.id);
-        // this.getDeployLogInfo(this.projectDetail.latestDeploy.id);
-      }
+      // if (newVal.latestDeploy && newVal.latestDeploy.id) {
+      //   // this.haveDeployRecord = true;
+      //
+      //   // this.getDeployLogInfo(this.projectDetail.latestDeploy.id);
+      // }
+      this.getLatestDeployInfo();
       this.getLatestBuildInfo(this.projectDetail && this.projectDetail.id, 5);
       this.getLastNDeployInfoList(
         this.projectDetail && this.projectDetail.id,
-        5
+        5,
+        1
       );
     }
   },
   mounted() {
-    if (this.projectDetail.latestDeploy) {
-      this.getLatestDeployInfo(this.projectDetail.latestDeploy.id);
-      // this.getDeployLogInfo(this.projectDetail.latestDeploy.id);
-    }
     if (this.projectDetail.id) {
       this.getLatestBuildInfo(this.projectDetail.id, 5);
-      this.getLastNDeployInfoList(this.projectDetail.id, 5);
+      this.getLastNDeployInfoList(this.projectDetail.id, 5, 1);
+      this.getLatestDeployInfo();
     }
   },
   methods: {
-    //获取部署日志
-    // checkDeployLog(){
-    //     if(this.projectDetail.latestDeploy){
-    //         this.getDeployLogInfo(this.projectDetail.latestDeploy.id);
-    //     }
-    // },
-    //获取最新一次部署详细信息
-    getLatestDeployInfo(deployId) {
-      getDeployDetail(deployId)
+    //获取最新一次部署信息
+    getLatestDeployInfo() {
+      getLatestDeployInfoList(this.projectDetail.id, 1, 0)
         .then(res => {
-          this.deployInfo = res.data;
-          this.deployStatus = res.data.status;
-          let isRunning = this.deployStatus == "RUNNING" ? true : false;
-          this.isRunning = isRunning;
+          if (res.data && res.data.length > 0) {
+            this.latestDeployId = res.data[0].id;
+            this.deployInfo = res.data[0];
+            this.deployStatus = res.data[0].status;
+            let isRunning = this.deployStatus == "RUNNING" ? true : false;
+            this.isRunning = isRunning;
+          }
         })
         .catch(e => {
           this.$toast.open({
@@ -177,6 +174,22 @@ export default {
           });
         });
     },
+    //获取最新一次部署详细信息
+    // getLatestDeployInfo(deployId) {
+    //   getDeployDetail(deployId)
+    //     .then(res => {
+    //       this.deployInfo = res.data;
+    //       this.deployStatus = res.data.status;
+    //       let isRunning = this.deployStatus == "RUNNING" ? true : false;
+    //       this.isRunning = isRunning;
+    //     })
+    //     .catch(e => {
+    //       this.$toast.open({
+    //         message: e.message || "服务器未知错误",
+    //         type: "is-danger"
+    //       });
+    //     });
+    // },
     //处理时间格式
     handleTime(time) {
       if (!time) {
@@ -201,12 +214,20 @@ export default {
           replicas: 1
         })
           .then(res => {
-            console.log(res);
+            if (res.data.status == "SUCCESS") {
+              this.$toast.open({
+                message: "不要重复部署哦~",
+                type: "is-warning"
+              });
+              return;
+            }
+            // console.log(res);
             this.$toast.open({
               message: "开始部署",
               type: "is-success"
             });
             this.isRunning = true;
+            this.deployInfo = res.data;
             // setTimeout(() => {
             //   this.getLatestDeployInfo(this.projectDetail.latestDeploy.id);
             // }, 1000);
@@ -220,8 +241,8 @@ export default {
       }
     },
     //获取最近n次部署成功记录
-    getLastNDeployInfoList(projectId, limit) {
-      getLatestDeployInfoList(projectId, limit)
+    getLastNDeployInfoList(projectId, limit, success) {
+      getLatestDeployInfoList(projectId, limit, success)
         .then(res => {
           this.latestDeployList = res.data;
           // this.latestMirrorIdList = this.latestMirrorIdList.concat(res.data);
@@ -252,7 +273,7 @@ export default {
       if (this.unfoldDeployLogInfo) {
         this.unfoldDeployLogInfo = false;
       } else {
-        let deployId = this.projectDetail.latestDeploy.id;
+        let deployId = this.latestDeployId;
         this.isfetchLog = true;
         getDeployLogInfo(deployId)
           .then(res => {

+ 1 - 1
src/views/student/Document/docContent.vue

@@ -17,7 +17,7 @@
       <template slot="content">
         题目名称:{{ contentResult.name }} <br />
         <br />
-      commit: <b-tag type="is-primary">{{contentResult.gitCommit ? contentResult.gitCommit.substring(0,8) : '暂无commit记录' }}</b-tag>
+      对应提交: <b-tag type="is-primary">{{contentResult.gitCommit ? contentResult.gitCommit.substring(0,8) : '暂无commit记录' }}</b-tag>
           <a class="button is-small" v-clipboard:copy="message"
                   v-clipboard:success="onCopy"
                   v-clipboard:error="onError" style="margin-left:10px;">复制</a>

+ 1 - 1
src/views/teacher/Document/docContent.vue

@@ -17,7 +17,7 @@
       <template slot="content">
         题目名称:{{ contentResult.name }} <br />
         <br />
-        commit: <b-tag type="is-primary">{{contentResult.gitCommit ? contentResult.gitCommit.substring(0,8) : '暂无commit记录' }}</b-tag>
+        对应提交: <b-tag type="is-primary">{{contentResult.gitCommit ? contentResult.gitCommit.substring(0,8) : '暂无commit记录' }}</b-tag>
         <br/>
         <br/>
         小组成员:<span