diff --git a/CHANGELOG-zh.md b/CHANGELOG-zh.md
index e1961a49..85fc0f19 100644
--- a/CHANGELOG-zh.md
+++ b/CHANGELOG-zh.md
@@ -5,6 +5,7 @@
- **反馈**. 允许用户发送反馈和评分给 Crawlab 开发组.
- **更好的主页指标**. 优化主页上的指标展示.
- **可配置爬虫转化为自定义爬虫**. 用户可以将自己的可配置爬虫转化为 Scrapy 自定义爬虫.
+- **查看定时任务触发的任务**. 允许用户查看定时任务触发的任务. [#648](https://github.com/crawlab-team/crawlab/issues/648)
### Bug 修复
- **CLI 无法在 Windows 上使用**. [#580](https://github.com/crawlab-team/crawlab/issues/580)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b7b0bea..2d69a611 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
- **Feedback**. Allow users to send feedbacks and ratings to Crawlab team.
- **Better Home Page Metrics**. Optimized metrics display on home page.
- **Configurable Spiders Converted to Customized Spiders**. Allow users to convert their configurable spiders into customized spiders which are also Scrapy spiders.
+- **View Tasks Triggered by Schedule**. Allow users to view tasks triggered by a schedule. [#648](https://github.com/crawlab-team/crawlab/issues/648)
### Bug Fixes
- **CLI unable to use on Windows**. [#580](https://github.com/crawlab-team/crawlab/issues/580)
diff --git a/backend/routes/task.go b/backend/routes/task.go
index 2ab1a046..585cf340 100644
--- a/backend/routes/task.go
+++ b/backend/routes/task.go
@@ -13,11 +13,12 @@ import (
)
type TaskListRequestData struct {
- PageNum int `form:"page_num"`
- PageSize int `form:"page_size"`
- NodeId string `form:"node_id"`
- SpiderId string `form:"spider_id"`
- Status string `form:"status"`
+ PageNum int `form:"page_num"`
+ PageSize int `form:"page_size"`
+ NodeId string `form:"node_id"`
+ SpiderId string `form:"spider_id"`
+ ScheduleId string `form:"schedule_id"`
+ Status string `form:"status"`
}
type TaskResultsRequestData struct {
@@ -51,6 +52,9 @@ func GetTaskList(c *gin.Context) {
if data.Status != "" {
query["status"] = data.Status
}
+ if data.ScheduleId != "" {
+ query["schedule_id"] = bson.ObjectIdHex(data.ScheduleId)
+ }
// 获取校验
query = services.GetAuthQuery(query, c)
diff --git a/frontend/src/components/Schedule/ScheduleTaskList.vue b/frontend/src/components/Schedule/ScheduleTaskList.vue
index 854678e4..2d702210 100644
--- a/frontend/src/components/Schedule/ScheduleTaskList.vue
+++ b/frontend/src/components/Schedule/ScheduleTaskList.vue
@@ -15,10 +15,16 @@ export default {
'scheduleForm'
])
},
+ methods: {
+ update () {
+ this.isFilterSpiderDisabled = true
+ this.$set(this.filter, 'spider_id', this.scheduleForm.spider_id)
+ this.filter.schedule_id = this.scheduleForm._id
+ this.$store.dispatch('task/getTaskList')
+ }
+ },
async created () {
- this.isFilterSpiderDisabled = true
- this.filter.spider_id = this.scheduleForm.spider_id
- await this.$store.dispatch('task/getTaskList')
+ this.update()
}
}
diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js
index 5732d990..8c3f41bd 100644
--- a/frontend/src/i18n/zh.js
+++ b/frontend/src/i18n/zh.js
@@ -377,6 +377,7 @@ export default {
'Are you sure to run this spider?': '你确定要运行该爬虫?',
'Are you sure to delete this file/directory?': '你确定要删除该文件/文件夹?',
'Are you sure to convert this spider to customized spider?': '你确定要转化该爬虫为自定义爬虫?',
+ 'Are you sure to delete this task?': '您确定要删除该任务?',
'Added spider successfully': '成功添加爬虫',
'Converted successfully': '成功转化',
'Converted unsuccessfully': '未成功转化',
diff --git a/frontend/src/store/modules/task.js b/frontend/src/store/modules/task.js
index 67f6a153..800c7bce 100644
--- a/frontend/src/store/modules/task.js
+++ b/frontend/src/store/modules/task.js
@@ -15,7 +15,8 @@ const state = {
filter: {
node_id: '',
spider_id: '',
- status: ''
+ status: '',
+ schedule_id: ''
},
// pagination
pageNum: 1,
@@ -122,7 +123,8 @@ const actions = {
page_size: state.pageSize,
node_id: state.filter.node_id || undefined,
spider_id: state.filter.spider_id || undefined,
- status: state.filter.status || undefined
+ status: state.filter.status || undefined,
+ schedule_id: state.filter.schedule_id || undefined
})
.then(response => {
commit('SET_TASK_LIST', response.data.data || [])
diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue
index 96ad76c3..f4f569a2 100644
--- a/frontend/src/views/schedule/ScheduleList.vue
+++ b/frontend/src/views/schedule/ScheduleList.vue
@@ -170,7 +170,7 @@
width="calc(100% - 240px)"
:before-close="() => this.isViewTasksDialogVisible = false"
>
-
+
@@ -618,6 +618,9 @@ export default {
async onViewTasks (row) {
this.isViewTasksDialogVisible = true
this.$store.commit('schedule/SET_SCHEDULE_FORM', row)
+ setTimeout(() => {
+ this.$refs['schedule-task-list'].update()
+ }, 100)
this.$st.sendEv('定时任务', '查看任务列表')
}
},
diff --git a/frontend/src/views/task/TaskList.vue b/frontend/src/views/task/TaskList.vue
index 8f77ad41..e880e075 100644
--- a/frontend/src/views/task/TaskList.vue
+++ b/frontend/src/views/task/TaskList.vue
@@ -353,7 +353,7 @@ export default {
.then(() => {
this.$message({
type: 'success',
- message: 'Deleted successfully'
+ message: this.$t('Deleted successfully')
})
})
this.$st.sendEv('任务列表', '删除任务')