diff --git a/backend/conf/config.yml b/backend/conf/config.yml index 80653ce5..cfb74881 100644 --- a/backend/conf/config.yml +++ b/backend/conf/config.yml @@ -39,7 +39,7 @@ task: workers: 16 other: tmppath: "/tmp" -version: 0.4.10 +version: 0.5.0 setting: crawlabLogToES: "N" # Send crawlab runtime log to ES, open this option "Y", remember to set esClient crawlabLogIndex: "crawlab-log" diff --git a/backend/main.go b/backend/main.go index 6aa755e7..ea040e0c 100644 --- a/backend/main.go +++ b/backend/main.go @@ -252,6 +252,7 @@ func main() { authGroup.GET("/tasks/:id/results/download", routes.DownloadTaskResultsCsv) // 下载任务结果 authGroup.POST("/tasks/:id/restart", routes.RestartTask) // 重新开始任务 authGroup.POST("/tasks-cancel", routes.CancelSelectedTask) // 批量取消任务 + authGroup.POST("/tasks-restart", routes.RestartSelectedTask) // 批量重试任务 } // 定时任务 { diff --git a/backend/routes/task.go b/backend/routes/task.go index ac30935f..d8ea39a1 100644 --- a/backend/routes/task.go +++ b/backend/routes/task.go @@ -380,6 +380,22 @@ func CancelSelectedTask(c *gin.Context) { HandleSuccess(c) } +func RestartSelectedTask(c *gin.Context) { + ids := make(map[string][]string) + if err := c.ShouldBindJSON(&ids); err != nil { + HandleError(http.StatusBadRequest, c, err) + return + } + list := ids["ids"] + for _, id := range list { + if err := services.RestartTask(id, services.GetCurrentUserId(c)); err != nil { + HandleError(http.StatusInternalServerError, c, err) + return + } + } + HandleSuccess(c) +} + // @Summary Get task log // @Description Get task log // @Tags task diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 203154a5..4c98fd3f 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -219,25 +219,25 @@ export const constantRouterMap = [ } ] }, - { - path: '/challenges', - component: Layout, - meta: { - title: 'ChallengeList', - icon: 'fa fa-flash' - }, - children: [ - { - path: '', - name: 'ChallengeList', - component: () => import('../views/challenge/ChallengeList'), - meta: { - title: 'Challenges', - icon: 'fa fa-flash' - } - } - ] - }, + // { + // path: '/challenges', + // component: Layout, + // meta: { + // title: 'ChallengeList', + // icon: 'fa fa-flash' + // }, + // children: [ + // { + // path: '', + // name: 'ChallengeList', + // component: () => import('../views/challenge/ChallengeList'), + // meta: { + // title: 'Challenges', + // icon: 'fa fa-flash' + // } + // } + // ] + // }, { path: '/feedback', component: Layout, diff --git a/frontend/src/views/task/TaskList.vue b/frontend/src/views/task/TaskList.vue index 4c7639a8..02121446 100644 --- a/frontend/src/views/task/TaskList.vue +++ b/frontend/src/views/task/TaskList.vue @@ -56,6 +56,16 @@ > {{ $t('Cancel') }} + + {{ $t('Restart') }} + { + const ids = this.selectedTasks.map(item => item._id) + this.$store.dispatch('task/restartTaskMultiple', ids).then((resp) => { + if (resp.data.status === 'ok') { + this.$message({ + type: 'success', + message: this.$t('Restarted successfully') + }) + this.$store.dispatch('task/getTaskList') + this.$refs['table'].clearSelection() + return + } + this.$message({ + type: 'error', + message: resp.data.error + }) + }) + }).catch(() => { + }) + }, onRemoveMultipleTask() { this.$confirm(this.$t('Are you sure to delete these tasks'), this.$t('Notification'), { confirmButtonText: this.$t('Confirm'),