From 4c2a2617a1c3ecd253418d645478d095c1f2e24c Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Wed, 25 Oct 2023 16:19:18 +0200 Subject: [PATCH] Adapt Project component to Vuex use for fetching data. The Project component is now responsible for fetching and updating the data used by most project tabs, with the exception of ProjectSummary, QC, Graphs and Map. It is also the only one listening for server events and reacting to them. Individual tabs are still responsible for sending data to the server, at least for the time being. --- lib/www/client/source/src/views/Project.vue | 27 +++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/www/client/source/src/views/Project.vue b/lib/www/client/source/src/views/Project.vue index e7ba96c..4cb982e 100644 --- a/lib/www/client/source/src/views/Project.vue +++ b/lib/www/client/source/src/views/Project.vue @@ -37,7 +37,7 @@ export default { return this.loading || this.projectId; }, - ...mapGetters(["loading", "projectId", "serverEvent"]) + ...mapGetters(["loading", "projectId", "projectSchema", "serverEvent"]) }, watch: { @@ -45,16 +45,39 @@ export default { if (event.channel == "project" && event.payload?.operation == "DELETE" && event.payload?.schema == "public") { // Project potentially deleted await this.getProject(this.$route.params.project); + } else if (event.payload?.schema == this.projectSchema) { + if (event.channel == "event") { + this.refreshEvents(); + } else if (event.channel == "planned_lines") { + this.refreshPlan(); + } else if (["raw_lines", "final_lines", "final_shots"].includes(event.channel)) { + this.refreshSequences(); + } else if (["preplot_lines", "preplot_points"].includes(event.channel)) { + this.refreshLines(); + } else if (event.channel == "info") { + if ((event.payload?.new ?? event.payload?.old)?.key == "plan") { + this.refreshPlan(); + } + } else if (event.channel == "project") { + this.getProject(this.$route.params.project); + } } } }, methods: { - ...mapActions(["getProject"]) + ...mapActions(["getProject", "refreshLines", "refreshSequences", "refreshEvents", "refreshLabels", "refreshPlan"]) }, async mounted () { await this.getProject(this.$route.params.project); + if (this.projectFound) { + this.refreshLines(); + this.refreshSequences(); + this.refreshEvents(); + this.refreshLabels(); + this.refreshPlan(); + } } }