mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
feat(fe): update task statuses on Dashboard in realtime
Issue: https://github.com/ansible-semaphore/semaphore/issues/621
This commit is contained in:
parent
d417f95273
commit
043b8852aa
@ -106,7 +106,7 @@ export default {
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
socket.addListener((data) => this.onDataReceive(data));
|
||||
socket.addListener((data) => this.onWebsocketDataReceived(data));
|
||||
await this.loadData();
|
||||
},
|
||||
|
||||
@ -117,7 +117,7 @@ export default {
|
||||
this.user = {};
|
||||
},
|
||||
|
||||
onDataReceive(data) {
|
||||
onWebsocketDataReceived(data) {
|
||||
if (data.project_id !== this.projectId || data.task_id !== this.itemId) {
|
||||
return;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
import ItemListPageBase from '@/components/ItemListPageBase';
|
||||
import EventBus from '@/event-bus';
|
||||
import TaskStatus from '@/components/TaskStatus.vue';
|
||||
import socket from '@/socket';
|
||||
|
||||
export default {
|
||||
mixins: [ItemListPageBase],
|
||||
@ -58,6 +59,10 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
socket.addListener((data) => this.onWebsocketDataReceived(data));
|
||||
},
|
||||
|
||||
methods: {
|
||||
showTaskLog(taskId) {
|
||||
EventBus.$emit('i-show-task', {
|
||||
@ -65,6 +70,23 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
async onWebsocketDataReceived(data) {
|
||||
if (data.project_id !== this.projectId || data.type !== 'update') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.items.some((item) => item.id === data.task_id)) {
|
||||
await this.loadItems();
|
||||
}
|
||||
|
||||
const task = this.items.find((item) => item.id === data.task_id);
|
||||
|
||||
Object.assign(task, {
|
||||
...data,
|
||||
type: undefined,
|
||||
});
|
||||
},
|
||||
|
||||
getHeaders() {
|
||||
return [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user