@@ -130,7 +137,8 @@ export default {
...mapState('task', [
'taskForm',
'taskLogTotal',
- 'logKeyword'
+ 'logKeyword',
+ 'isLogFetchLoading'
]),
...mapGetters('task', [
'logData',
@@ -176,6 +184,22 @@ export default {
this.$store.commit('task/SET_IS_LOG_AUTO_SCROLL', value)
}
},
+ isLogAutoFetch: {
+ get () {
+ return this.$store.state.task.isLogAutoFetch
+ },
+ set (value) {
+ this.$store.commit('task/SET_IS_LOG_AUTO_FETCH', value)
+ }
+ },
+ isLogFetchLoading: {
+ get () {
+ return this.$store.state.task.isLogFetchLoading
+ },
+ set (value) {
+ this.$store.commit('task/SET_IS_LOG_FETCH_LOADING', value)
+ }
+ },
filteredLogData () {
return this.logData.filter(d => {
if (!this.searchString) return true
diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js
index 25cf246d..1471c155 100644
--- a/frontend/src/i18n/zh.js
+++ b/frontend/src/i18n/zh.js
@@ -260,6 +260,7 @@ export default {
'Selected Nodes': '指定节点',
'Search Log': '搜索日志',
'Auto-Scroll': '自动滚动',
+ 'Auto-Refresh': '自动刷新',
'Updating log...': '正在更新日志...',
'Error Count': '错误数',
'Log with errors': '日志错误',
diff --git a/frontend/src/store/modules/task.js b/frontend/src/store/modules/task.js
index 3fe46dd7..55a668a0 100644
--- a/frontend/src/store/modules/task.js
+++ b/frontend/src/store/modules/task.js
@@ -6,12 +6,6 @@ const state = {
taskList: [],
taskListTotalCount: 0,
taskForm: {},
- taskLog: [],
- taskLogTotal: 0,
- taskLogPage: 1,
- taskLogPageSize: 5000,
- currentLogIndex: 0,
- isLogAutoScroll: false,
taskResultsData: [],
taskResultsColumns: [],
taskResultsTotalCount: 0,
@@ -26,8 +20,16 @@ const state = {
pageNum: 1,
pageSize: 10,
// log
+ currentLogIndex: 0,
logKeyword: '',
errorLogData: [],
+ isLogAutoScroll: false,
+ isLogAutoFetch: false,
+ isLogFetchLoading: false,
+ taskLog: [],
+ taskLogTotal: 0,
+ taskLogPage: 1,
+ taskLogPageSize: 5000,
// results
resultsPageNum: 1,
resultsPageSize: 10
@@ -133,6 +135,12 @@ const mutations = {
},
SET_IS_LOG_AUTO_SCROLL (state, value) {
state.isLogAutoScroll = value
+ },
+ SET_IS_LOG_AUTO_FETCH (state, value) {
+ state.isLogAutoFetch = value
+ },
+ SET_IS_LOG_FETCH_LOADING (state, value) {
+ state.isLogFetchLoading = value
}
}
diff --git a/frontend/src/views/task/TaskDetail.vue b/frontend/src/views/task/TaskDetail.vue
index 3e298c9f..5a34e2bd 100644
--- a/frontend/src/views/task/TaskDetail.vue
+++ b/frontend/src/views/task/TaskDetail.vue
@@ -15,7 +15,7 @@
-
+
@@ -137,7 +137,8 @@ export default {
'taskResultsData',
'taskResultsTotalCount',
'taskLog',
- 'logKeyword'
+ 'logKeyword',
+ 'isLogAutoFetch'
]),
...mapGetters('task', [
'taskResultsColumns'
@@ -164,6 +165,30 @@ export default {
this.$store.commit('task/SET_RESULTS_PAGE_SIZE', value)
}
},
+ isLogAutoScroll: {
+ get () {
+ return this.$store.state.task.isLogAutoScroll
+ },
+ set (value) {
+ this.$store.commit('task/SET_IS_LOG_AUTO_SCROLL', value)
+ }
+ },
+ isLogAutoFetch: {
+ get () {
+ return this.$store.state.task.isLogAutoFetch
+ },
+ set (value) {
+ this.$store.commit('task/SET_IS_LOG_AUTO_FETCH', value)
+ }
+ },
+ isLogFetchLoading: {
+ get () {
+ return this.$store.state.task.isLogFetchLoading
+ },
+ set (value) {
+ this.$store.commit('task/SET_IS_LOG_FETCH_LOADING', value)
+ }
+ },
isRunning () {
return ['pending', 'running'].includes(this.taskForm.status)
}
@@ -185,21 +210,30 @@ export default {
this.$store.dispatch('task/getTaskResultExcel', this.$route.params.id)
this.$st.sendEv('任务详情', '结果', '下载CSV')
},
- getTaskLog () {
- this.$store.dispatch('task/getTaskLog', { id: this.$route.params.id, keyword: this.logKeyword })
- this.$store.dispatch('task/getTaskErrorLog', this.$route.params.id)
+ async getTaskLog (showLoading) {
+ if (showLoading) {
+ this.isLogFetchLoading = true
+ }
+ await this.$store.dispatch('task/getTaskLog', { id: this.$route.params.id, keyword: this.logKeyword })
+ this.isLogFetchLoading = false
+ await this.$store.dispatch('task/getTaskErrorLog', this.$route.params.id)
}
},
- created () {
- this.$store.dispatch('task/getTaskData', this.$route.params.id)
- this.$store.dispatch('task/getTaskResults', this.$route.params.id)
+ async created () {
+ await this.$store.dispatch('task/getTaskData', this.$route.params.id)
+
+ this.isLogAutoFetch = !!this.isRunning
+ this.isLogAutoScroll = !!this.isRunning
+
+ await this.$store.dispatch('task/getTaskResults', this.$route.params.id)
this.getTaskLog()
this.handle = setInterval(() => {
- if (!this.isRunning) return
- this.$store.dispatch('task/getTaskData', this.$route.params.id)
- this.$store.dispatch('task/getTaskResults', this.$route.params.id)
- this.getTaskLog()
+ if (this.isLogAutoFetch) {
+ this.$store.dispatch('task/getTaskData', this.$route.params.id)
+ this.$store.dispatch('task/getTaskResults', this.$route.params.id)
+ this.getTaskLog()
+ }
}, 5000)
},
mounted () {