diff --git a/frontend/src/components/Common/BatchCrawlDialog.vue b/frontend/src/components/Common/BatchCrawlDialog.vue new file mode 100644 index 00000000..c7a0cd7f --- /dev/null +++ b/frontend/src/components/Common/BatchCrawlDialog.vue @@ -0,0 +1,284 @@ + + + + + diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index 68667d2d..14a08293 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -234,6 +234,8 @@ export default { 'Overwrite': '覆盖', 'Ignore': '忽略', 'De-Duplication': '去重', + 'Same Above': '同上', + 'Batch Run': '批量运行', // 爬虫列表 'Name': '名称', @@ -659,6 +661,7 @@ export default { 'Please enter Web Hook URL': '请输入 Web Hook URL', 'Are you sure to download this spider?': '您确定要下载该爬虫?', 'Downloaded successfully': '下载成功', + 'Unable to submit because of some errors': '有错误,无法提交', // 其他 'Star crawlab-team/crawlab on GitHub': '在 GitHub 上为 Crawlab 加星吧' diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js index 7ec71fe0..e393f03a 100644 --- a/frontend/src/store/modules/spider.js +++ b/frontend/src/store/modules/spider.js @@ -4,10 +4,13 @@ import request from '../../api/request' const state = { // list of spiders spiderList: [], - allSpiderList: [], + // total number of spiders spiderTotal: 0, + // list of all spiders + allSpiderList: [], + // active spider data spiderForm: {}, diff --git a/frontend/src/store/modules/task.js b/frontend/src/store/modules/task.js index 8f4b6c90..61653045 100644 --- a/frontend/src/store/modules/task.js +++ b/frontend/src/store/modules/task.js @@ -32,7 +32,9 @@ const state = { activeErrorLogItem: {}, // results resultsPageNum: 1, - resultsPageSize: 10 + resultsPageSize: 10, + // batch crawl + batchCrawlList: [] } const getters = { @@ -144,6 +146,12 @@ const mutations = { }, SET_ACTIVE_ERROR_LOG_ITEM(state, value) { state.activeErrorLogItem = value + }, + SET_BATCH_CRAWL_LIST(state, value) { + state.batchCrawlList = value + }, + SET_IS_BATCH_CRAWL_DIALOG_VISIBLE(state, value) { + state.isBatchCrawlDialogVisible = value } } diff --git a/frontend/src/views/spider/SpiderList.vue b/frontend/src/views/spider/SpiderList.vue index f9c0e0c4..80317a47 100644 --- a/frontend/src/views/spider/SpiderList.vue +++ b/frontend/src/views/spider/SpiderList.vue @@ -315,6 +315,14 @@ /> + + + +
@@ -379,15 +387,14 @@
- {{ $t('Run') }} + {{ $t('Batch Run') }} { + this.getList() + }, 1000) + }, onCopy(row, ev) { ev.stopPropagation() this.copyDialogVisible = true @@ -1297,10 +1318,36 @@ this.crawlConfirmDialogVisible = true this.isMultiple = true }, + onBatchCrawl() { + this.$store.commit('task/SET_BATCH_CRAWL_LIST', this.selectedSpiders.map(d => { + return { + spider_id: d._id, + run_type: 'random', + param: '', + scrapy_log_level: 'INFO' + } + })) + if (this.batchCrawlList.length < 10) { + for (let i = this.batchCrawlList.length; i < 10; i++) { + this.batchCrawlList.push({ + spider_id: '', + run_type: 'random', + param: '', + scrapy_log_level: 'INFO' + }) + } + } + this.batchCrawlDialogVisible = true + this.isMultiple = true + }, onCrawlConfirmDialogClose() { this.crawlConfirmDialogVisible = false this.isMultiple = false }, + onBatchCrawlDialogClose() { + this.batchCrawlDialogVisible = false + this.isMultiple = false + }, isDisabled(row) { return row.is_public && row.username !== this.userInfo.username && this.userInfo.role !== 'admin' }