mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
added batch restart tasks
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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) // 批量重试任务
|
||||
}
|
||||
// 定时任务
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -56,6 +56,16 @@
|
||||
>
|
||||
{{ $t('Cancel') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedTasks.length > 0"
|
||||
icon="el-icon-refresh"
|
||||
class="btn-restart"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="onRestartMultipleTask"
|
||||
>
|
||||
{{ $t('Restart') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedTasks.length > 0"
|
||||
icon="el-icon-delete"
|
||||
@@ -392,6 +402,31 @@
|
||||
this.$store.dispatch('task/getTaskList')
|
||||
this.$st.sendEv('任务列表', '搜索')
|
||||
},
|
||||
onRestartMultipleTask() {
|
||||
this.$confirm(this.$t('Are you sure to restart these tasks'), this.$t('Notification'), {
|
||||
confirmButtonText: this.$t('Confirm'),
|
||||
cancelButtonText: this.$t('Cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
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'),
|
||||
|
||||
Reference in New Issue
Block a user