added batch restart tasks

This commit is contained in:
marvzhang
2020-07-18 11:43:34 +08:00
parent 478fbd1759
commit 4e4807a6a4
5 changed files with 48 additions and 7 deletions

View File

@@ -212,6 +212,7 @@
scrapy_log_level: 'INFO'
})
}
this.$st.sendEv('批量运行', '重置')
},
getSpiderById(id) {
return this.allSpiderList.filter(d => d._id === id)[0] || {}
@@ -225,6 +226,7 @@
this.$set(row, 'scrapy_spider_name', this.scrapySpidersNamesDict[id][0])
}
}
this.$st.sendEv('批量运行', '选择爬虫')
},
getScrapySpiderNames(id) {
if (!this.scrapySpidersNamesDict[id]) return []
@@ -241,6 +243,7 @@
}))
this.reset()
this.$emit('close')
this.$st.sendEv('批量运行', '确认批量运行')
},
async fetchScrapySpiderNames(id) {
if (!this.scrapySpidersNamesDict[id]) {
@@ -269,9 +272,11 @@
param: '',
scrapy_log_level: 'INFO'
})
this.$st.sendEv('批量运行', '添加')
},
onRemove(rowIndex) {
this.batchCrawlList.splice(rowIndex, 1)
this.$st.sendEv('批量运行', '删除')
}
}
}

View File

@@ -668,6 +668,9 @@ export default {
'Are you sure to stop these tasks': '确认停止这些任务?',
'Are you sure to delete these tasks': '确认删除这些任务?',
'Stopped successfully': '成功停止',
'Are you sure to restart these tasks': '确认重新运行这些任务?',
'Restarted successfully': '成功重新运行',
'Are you sure to stop this task?': '确认停止这个任务?',
// 其他
'Star crawlab-team/crawlab on GitHub': ' GitHub 上为 Crawlab 加星吧'

View File

@@ -259,6 +259,11 @@ const actions = {
return await request.post(`/tasks-cancel`, {
ids
})
},
async restartTaskMultiple({ dispatch }, ids) {
return await request.post(`/tasks-restart`, {
ids
})
}
}

View File

@@ -1310,6 +1310,7 @@
this.$message.success(`Task "${row._id}" has been sent signal to stop`)
this.getList()
}
this.$st.sendEv('爬虫列表', '任务列表', '停止任务')
},
onIsScrapy(value) {
if (value) {
@@ -1331,7 +1332,7 @@
spider_ids: this.selectedSpiders.map(d => d._id)
})
if (!res.data.error) {
this.$message.success('Delete successfully')
this.$message.success('Deleted successfully')
this.$refs['table'].clearSelection()
await this.getList()
}
@@ -1359,13 +1360,9 @@
} finally {
this.isStopLoading = false
}
this.$st.sendEv('爬虫列表', '批量删除爬虫')
this.$st.sendEv('爬虫列表', '批量停止爬虫')
})
},
onCrawlSelectedSpiders() {
this.crawlConfirmDialogVisible = true
this.isMultiple = true
},
onBatchCrawl() {
this.$store.commit('task/SET_BATCH_CRAWL_LIST', this.selectedSpiders.map(d => {
return {
@@ -1387,6 +1384,7 @@
}
this.batchCrawlDialogVisible = true
this.isMultiple = true
this.$st.sendEv('爬虫列表', '点击批量运行')
},
onCrawlConfirmDialogClose() {
this.crawlConfirmDialogVisible = false
@@ -1415,6 +1413,7 @@
this.isMultiple = false
await this.getList()
})
this.$st.sendEv('爬虫列表', '批量设置项目')
}
}
}

View File

@@ -203,7 +203,7 @@
:width="col.width"
/>
</template>
<el-table-column :label="$t('Action')" align="left" fixed="right" width="150px">
<el-table-column :label="$t('Action')" align="left" fixed="right" width="200px">
<template slot-scope="scope">
<el-tooltip :content="$t('View')" placement="top">
<el-button type="primary" icon="el-icon-search" size="mini" @click="onView(scope.row)" />
@@ -224,6 +224,14 @@
@click="onRemove(scope.row, $event)"
/>
</el-tooltip>
<el-tooltip v-if="['pending', 'running'].includes(scope.row.status)" :content="$t('Stop')" placement="top">
<el-button
type="info"
icon="el-icon-video-pause"
size="mini"
@click="onStop(scope.row, $event)"
/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
@@ -424,6 +432,7 @@
message: resp.data.error
})
})
this.$st.sendEv('任务列表', '批量重启任务')
}).catch(() => {
})
},
@@ -449,6 +458,7 @@
message: resp.data.error
})
})
this.$st.sendEv('任务列表', '批量删除任务')
}).catch(() => {
})
},
@@ -474,6 +484,7 @@
message: resp.data.error
})
})
this.$st.sendEv('任务列表', '批量停止任务')
}).catch(() => {
})
},
@@ -511,6 +522,24 @@
this.$st.sendEv('任务列表', '重新开始任务')
})
},
onStop(row, ev) {
ev.stopPropagation()
this.$confirm(this.$t('Are you sure to stop this task?'), this.$t('Notification'), {
confirmButtonText: this.$t('Confirm'),
cancelButtonText: this.$t('Cancel'),
type: 'warning'
}).then(() => {
this.$store.dispatch('task/cancelTask', row._id)
.then(() => {
this.$message({
type: 'success',
message: this.$t('Stopped successfully')
})
this.$store.dispatch('task/getTaskList')
})
this.$st.sendEv('任务列表', '停止任务')
})
},
onView(row) {
this.$router.push(`/tasks/${row._id}`)
this.$st.sendEv('任务列表', '查看任务')