From c6bd35bd026f4df9ee2d8b346e599bec6941d06f Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Mon, 22 Jul 2019 12:32:36 +0800 Subject: [PATCH] updated frontend to adapt changes of golang version --- .gitignore | 2 -- .../Environment/EnvironmentList.vue | 2 +- .../src/components/InfoView/TaskInfoView.vue | 2 +- .../components/TableView/GeneralTableView.vue | 2 +- frontend/src/i18n/zh.js | 1 + frontend/src/store/modules/spider.js | 4 ++-- frontend/src/store/modules/task.js | 16 ++++++------- frontend/src/views/schedule/ScheduleList.vue | 3 +++ frontend/src/views/spider/SpiderList.vue | 23 +++++++++++++++---- frontend/src/views/task/TaskDetail.vue | 8 ++++--- spiders/realestate/realestate/pipelines.py | 6 ++--- 11 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 622a9c22..0afb0ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,6 @@ dist/ downloads/ eggs/ .eggs/ -lib/ -lib64/ parts/ sdist/ var/ diff --git a/frontend/src/components/Environment/EnvironmentList.vue b/frontend/src/components/Environment/EnvironmentList.vue index a46432c0..6858aba4 100644 --- a/frontend/src/components/Environment/EnvironmentList.vue +++ b/frontend/src/components/Environment/EnvironmentList.vue @@ -56,7 +56,7 @@ export default { this.$st.sendEv('爬虫详情-环境', '删除') }, save () { - this.$store.dispatch('spider/updateSpiderEnvs') + this.$store.dispatch('spider/editSpider') .then(() => { this.$message.success(this.$t('Spider info has been saved successfully')) }) diff --git a/frontend/src/components/InfoView/TaskInfoView.vue b/frontend/src/components/InfoView/TaskInfoView.vue index a9c5d534..5eaefb3b 100644 --- a/frontend/src/components/InfoView/TaskInfoView.vue +++ b/frontend/src/components/InfoView/TaskInfoView.vue @@ -66,7 +66,7 @@ export default { onRestart () { }, onStop () { - this.$store.dispatch('task/stopTask', this.$route.params.id) + this.$store.dispatch('task/cancelTask', this.$route.params.id) .then(() => { this.$message.success(`Task "${this.$route.params.id}" has been sent signal to stop`) }) diff --git a/frontend/src/components/TableView/GeneralTableView.vue b/frontend/src/components/TableView/GeneralTableView.vue index 25cd1923..819a0572 100644 --- a/frontend/src/components/TableView/GeneralTableView.vue +++ b/frontend/src/components/TableView/GeneralTableView.vue @@ -5,7 +5,7 @@ :header-cell-style="{background:'rgb(48, 65, 86)',color:'white'}" border> diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index fc6d545c..978f2aea 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -75,6 +75,7 @@ export default { 'Node MAC': '节点MAC', 'Node Port': '节点端口', 'Description': '描述', + 'All Nodes': '所有节点', // 节点列表 'IP': 'IP地址', diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js index 1d603e87..5bb52e77 100644 --- a/frontend/src/store/modules/spider.js +++ b/frontend/src/store/modules/spider.js @@ -110,9 +110,9 @@ const actions = { return request.get(`/spiders/${id}/tasks`) .then(response => { commit('task/SET_TASK_LIST', - response.data.data.map(d => { + response.data.data ? response.data.data.map(d => { return d - }).sort((a, b) => a.create_ts < b.create_ts ? 1 : -1), + }).sort((a, b) => a.create_ts < b.create_ts ? 1 : -1) : [], { root: true }) }) }, diff --git a/frontend/src/store/modules/task.js b/frontend/src/store/modules/task.js index d0520087..545a169b 100644 --- a/frontend/src/store/modules/task.js +++ b/frontend/src/store/modules/task.js @@ -24,7 +24,7 @@ const state = { const getters = { taskResultsColumns (state) { - if (!state.taskResultsData.length) { + if (!state.taskResultsData || !state.taskResultsData.length) { return [] } const keys = [] @@ -80,7 +80,6 @@ const actions = { .then(response => { let data = response.data.data commit('SET_TASK_FORM', data) - console.log(data) dispatch('spider/getSpiderData', data.spider_id, { root: true }) dispatch('node/getNodeData', data.node_id, { root: true }) }) @@ -103,13 +102,8 @@ const actions = { dispatch('getTaskList') }) }, - stopTask ({ state, dispatch }, id) { - return request.post(`/tasks/${id}/stop`) - .then(() => { - dispatch('getTaskList') - }) - }, getTaskLog ({ state, commit }, id) { + commit('SET_TASK_LOG', '') return request.get(`/tasks/${id}/log`) .then(response => { commit('SET_TASK_LOG', response.data.data) @@ -125,6 +119,12 @@ const actions = { // commit('SET_TASK_RESULTS_COLUMNS', response.data.fields) commit('SET_TASK_RESULTS_TOTAL_COUNT', response.data.total) }) + }, + cancelTask ({ state, dispatch }, id) { + return request.post(`/tasks/${id}/cancel`) + .then(() => { + dispatch('getTaskData') + }) } } diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue index e097ff3f..bb65ddac 100644 --- a/frontend/src/views/schedule/ScheduleList.vue +++ b/frontend/src/views/schedule/ScheduleList.vue @@ -104,6 +104,9 @@ :sortable="col.sortable" :align="col.align" :width="col.width"> + diff --git a/frontend/src/views/spider/SpiderList.vue b/frontend/src/views/spider/SpiderList.vue index d5eff01d..fcddbc12 100644 --- a/frontend/src/views/spider/SpiderList.vue +++ b/frontend/src/views/spider/SpiderList.vue @@ -179,6 +179,16 @@ + + + - +