From 99915aea25889a4dd5368ae8aac8d9f0d5e45f27 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Wed, 12 Feb 2020 18:30:45 +0800 Subject: [PATCH 1/3] fixed docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 976e5968..9d5acbb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: redis: image: redis:latest restart: always - # command: redis --requirepass "password" # set redis password 设置 Redis 密码 + # command: redis-server --requirepass "password" # set redis password 设置 Redis 密码 # volumes: # - "/opt/crawlab/redis/data:/data" # make data persistent 持久化 # ports: From a7cf7fd298990545e83ad0c31ac29413f017cb84 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Thu, 13 Feb 2020 11:15:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8C=E9=94=99=E8=AF=AF=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/InfoView/TaskInfoView.vue | 25 +- .../src/components/Overview/TaskOverview.vue | 2 +- .../src/components/ScrollView/LogItem.vue | 50 ++-- .../src/components/ScrollView/LogView.vue | 250 ++++++++++++++---- frontend/src/i18n/zh.js | 2 + frontend/src/store/modules/task.js | 31 +++ frontend/src/utils/index.js | 4 +- frontend/src/utils/log.js | 5 + frontend/src/views/task/TaskDetail.vue | 14 +- 9 files changed, 298 insertions(+), 85 deletions(-) create mode 100644 frontend/src/utils/log.js diff --git a/frontend/src/components/InfoView/TaskInfoView.vue b/frontend/src/components/InfoView/TaskInfoView.vue index 34318d84..d55945b0 100644 --- a/frontend/src/components/InfoView/TaskInfoView.vue +++ b/frontend/src/components/InfoView/TaskInfoView.vue @@ -11,6 +11,15 @@ + + + {{$t('Log with errors')}} + + @@ -28,7 +37,7 @@ - + @@ -37,7 +46,7 @@ - + @@ -59,7 +68,8 @@ diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index 2dcb46d2..5dbf2919 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -211,6 +211,8 @@ export default { 'Search Log': '搜索日志', 'Auto-Scroll': '自动滚动', 'Updating log...': '正在更新日志...', + 'Error Count': '错误数', + 'Log with errors': '日志错误', // 任务列表 'Node': '节点', diff --git a/frontend/src/store/modules/task.js b/frontend/src/store/modules/task.js index 95153be5..563fc907 100644 --- a/frontend/src/store/modules/task.js +++ b/frontend/src/store/modules/task.js @@ -1,4 +1,5 @@ import request from '../../api/request' +import utils from '../../utils' const state = { // TaskList @@ -6,6 +7,7 @@ const state = { taskListTotalCount: 0, taskForm: {}, taskLog: '', + currentLogIndex: 0, taskResultsData: [], taskResultsColumns: [], taskResultsTotalCount: 0, @@ -36,6 +38,32 @@ const getters = { } } return keys + }, + logData (state) { + const data = state.taskLog.split('\n') + .map((d, i) => { + return { + index: i + 1, + data: d, + active: state.currentLogIndex === i + 1 + } + }) + if (state.taskForm && state.taskForm.status === 'running') { + data.push({ + index: data.length + 1, + data: '###LOG_END###' + }) + data.push({ + index: data.length + 1, + data: '' + }) + } + return data + }, + errorLogData (state, getters) { + return getters.logData.filter(d => { + return d.data.match(utils.log.errorRegex) + }) } } @@ -49,6 +77,9 @@ const mutations = { SET_TASK_LOG (state, value) { state.taskLog = value }, + SET_CURRENT_LOG_INDEX (state, value) { + state.currentLogIndex = value + }, SET_TASK_RESULTS_DATA (state, value) { state.taskResultsData = value }, diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index ab33114f..9867c812 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -1,9 +1,11 @@ import stats from './stats' import encrypt from './encrypt' import tour from './tour' +import log from './log' export default { stats, encrypt, - tour + tour, + log } diff --git a/frontend/src/utils/log.js b/frontend/src/utils/log.js new file mode 100644 index 00000000..8b1ea0ab --- /dev/null +++ b/frontend/src/utils/log.js @@ -0,0 +1,5 @@ +const regexToken = ' :,.' + +export default { + errorRegex: new RegExp(`(?:[${regexToken}]|^)((?:error|exception|traceback)s?)(?:[${regexToken}]|$)`, 'gi') +} diff --git a/frontend/src/views/task/TaskDetail.vue b/frontend/src/views/task/TaskDetail.vue index d5d1fd04..8af32049 100644 --- a/frontend/src/views/task/TaskDetail.vue +++ b/frontend/src/views/task/TaskDetail.vue @@ -12,10 +12,10 @@ - + - +
@@ -55,7 +55,6 @@ export default { return { activeTabName: 'overview', handle: undefined, - taskLog: '', // tutorial tourSteps: [ @@ -137,7 +136,8 @@ export default { ...mapState('task', [ 'taskForm', 'taskResultsData', - 'taskResultsTotalCount' + 'taskResultsTotalCount', + 'taskLog' ]), ...mapGetters('task', [ 'taskResultsColumns' @@ -186,11 +186,7 @@ export default { this.$st.sendEv('任务详情', '结果', '下载CSV') }, getTaskLog () { - if (this.$route.params.id) { - request.get(`/tasks/${this.$route.params.id}/log`).then(response => { - this.taskLog = response.data.data - }) - } + this.$store.dispatch('task/getTaskLog', this.$route.params.id) } }, created () { From 8aae4b631bdf517e9919ec640ccf0aa62b117b53 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Thu, 13 Feb 2020 11:44:28 +0800 Subject: [PATCH 3/3] code cleanup --- frontend/src/components/ScrollView/LogView.vue | 4 +++- frontend/src/views/task/TaskDetail.vue | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/ScrollView/LogView.vue b/frontend/src/components/ScrollView/LogView.vue index d1edd60d..04905cb8 100644 --- a/frontend/src/components/ScrollView/LogView.vue +++ b/frontend/src/components/ScrollView/LogView.vue @@ -212,11 +212,12 @@ export default { } }, mounted () { + this.currentLogIndex = 0 this.handle = setInterval(() => { if (this.isToBottom) { this.toBottom() } - }, 500) + }, 200) }, destroyed () { clearInterval(this.handle) @@ -269,6 +270,7 @@ export default { border-bottom: 1px solid #DCDFE6; height: calc(100vh - 240px); font-size: 16px; + overflow: auto; } .errors-wrapper.collapsed { diff --git a/frontend/src/views/task/TaskDetail.vue b/frontend/src/views/task/TaskDetail.vue index 8af32049..11051ed0 100644 --- a/frontend/src/views/task/TaskDetail.vue +++ b/frontend/src/views/task/TaskDetail.vue @@ -42,7 +42,6 @@ import { import TaskOverview from '../../components/Overview/TaskOverview' import GeneralTableView from '../../components/TableView/GeneralTableView' import LogView from '../../components/ScrollView/LogView' -import request from '../../api/request' export default { name: 'TaskDetail',