From 38fa2bd75b46b75ce51691a05a110230a165a3fb Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 16 Mar 2021 20:34:53 +0100 Subject: [PATCH] add notify_history_changed Signed-off-by: Stefan Dej --- src/components/panels/HistoryListPanel.vue | 2 +- src/store/server/history/actions.js | 5 +++++ src/store/server/history/mutations.js | 7 +++++++ src/store/socket/actions.js | 6 +++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index e68d6a60..5511bf05 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -199,7 +199,7 @@ }, getIconColor(status) { switch(status) { - case 'in_progress': return 'white' + case 'in_progress': return 'blue-grey darken-1' case 'completed': return 'green' case 'cancelled': return 'red' diff --git a/src/store/server/history/actions.js b/src/store/server/history/actions.js index c236e79e..aac7bd0e 100644 --- a/src/store/server/history/actions.js +++ b/src/store/server/history/actions.js @@ -12,6 +12,11 @@ export default { commit('addJob', job) } }) + }, + + getChanged({ commit }, payload) { + if (payload.action === 'added') commit('addJob', payload.job) + else if (payload.action === 'finished') commit('updateJob', payload.job) } } \ No newline at end of file diff --git a/src/store/server/history/mutations.js b/src/store/server/history/mutations.js index 2af3c4d5..54e83d4e 100644 --- a/src/store/server/history/mutations.js +++ b/src/store/server/history/mutations.js @@ -7,5 +7,12 @@ export default { addJob(state, payload) { state.jobs.push(payload) + }, + + updateJob(state, payload) { + const index = state.jobs.findIndex(job => job.job_id === payload.job_id) + if (index !== -1) { + state.jobs[index] = payload + } } } \ No newline at end of file diff --git a/src/store/socket/actions.js b/src/store/socket/actions.js index a8f9b7e8..12ca2ce0 100644 --- a/src/store/socket/actions.js +++ b/src/store/socket/actions.js @@ -31,7 +31,7 @@ export default { if (event.wasClean) window.console.log('Socket closed clear') }, - onMessage ({ commit, state }, payload) { + onMessage ({ commit, state, dispatch }, payload) { if (!state.isConnected) commit('setConnected') switch(payload.method) { @@ -99,6 +99,10 @@ export default { commit('server/updateManager/setStatus', payload.params[0], { root: true }) break + case 'notify_history_changed': + dispatch('server/history/getChanged', payload.params[0], { root: true }) + break + default: if (payload.result !== "ok") { if (