From cd1011066f7459479ce88aa4ef337158e7ad10dd Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Thu, 13 Jul 2023 10:58:44 -0700 Subject: [PATCH 1/6] Retrieve current Flamenco version --- web/app/src/views/JobsView.vue | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/web/app/src/views/JobsView.vue b/web/app/src/views/JobsView.vue index ed04e62d..f34905f6 100644 --- a/web/app/src/views/JobsView.vue +++ b/web/app/src/views/JobsView.vue @@ -39,7 +39,9 @@ import { useJobs } from '@/stores/jobs'; import { useTasks } from '@/stores/tasks'; import { useNotifs } from '@/stores/notifications' import { useTaskLog } from '@/stores/tasklog' -import { getAPIClient } from "@/api-client"; +import { getAPIClient } from '@/api-client'; +import { apiClient } from '@/stores/api-query-count'; +import { MetaApi } from '@/manager-api'; import FooterPopup from '@/components/footer/FooterPopup.vue' import GetTheAddon from '@/components/GetTheAddon.vue' @@ -271,9 +273,28 @@ export default { // SocketIO connection event handlers: onSIOReconnected() { + this.$refs.jobsTable.onReconnected(); if (this.$refs.tasksTable) this.$refs.tasksTable.onReconnected(); + + /*Grab Flamenco version from backend + Compare with previous version + If different than before log a notification about the upgrade, + and actually refresh the entire page to ensure the new version is loaded properly. */ + const metaAPI = new MetaApi(apiClient); + let currVersion; + metaAPI.getVersion() + .then((version) => { + this.flamencoName = version.name; + this.flamencoVersion = version.version; + + currVersion = this.flamencoVersion + }) + .catch((error) => { + console.log("Error getting the Flamenco version:", error); + }) + }, onSIODisconnected(reason) { }, -- 2.30.2 From 7fec95587318ba2eba0db23f5fdd3431e86f6dd1 Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Wed, 19 Jul 2023 10:24:09 -0700 Subject: [PATCH 2/6] Revert changes of JobsView to original --- web/app/src/views/JobsView.vue | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/web/app/src/views/JobsView.vue b/web/app/src/views/JobsView.vue index f34905f6..b88b8bc1 100644 --- a/web/app/src/views/JobsView.vue +++ b/web/app/src/views/JobsView.vue @@ -277,24 +277,6 @@ export default { this.$refs.jobsTable.onReconnected(); if (this.$refs.tasksTable) this.$refs.tasksTable.onReconnected(); - - /*Grab Flamenco version from backend - Compare with previous version - If different than before log a notification about the upgrade, - and actually refresh the entire page to ensure the new version is loaded properly. */ - const metaAPI = new MetaApi(apiClient); - let currVersion; - metaAPI.getVersion() - .then((version) => { - this.flamencoName = version.name; - this.flamencoVersion = version.version; - - currVersion = this.flamencoVersion - }) - .catch((error) => { - console.log("Error getting the Flamenco version:", error); - }) - }, onSIODisconnected(reason) { }, -- 2.30.2 From eaf6fd3148c206fd63a6c1ea5e043dd661f84e52 Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Wed, 19 Jul 2023 13:18:30 -0700 Subject: [PATCH 3/6] Add SocketIO reconnection and version check --- web/app/src/App.vue | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/web/app/src/App.vue b/web/app/src/App.vue index 6f9016d4..12af4404 100644 --- a/web/app/src/App.vue +++ b/web/app/src/App.vue @@ -14,7 +14,7 @@ - + add-on | API @@ -28,8 +28,11 @@ import * as API from '@/manager-api'; import { getAPIClient } from "@/api-client"; import { backendURL } from '@/urls'; +import { useSocketStatus } from '@/stores/socket-status'; -import ApiSpinner from '@/components/ApiSpinner.vue' +import ApiSpinner from '@/components/ApiSpinner.vue'; +import UpdateListener from '@/components/UpdateListener.vue'; +import ConnectionStatus from '@/components/ConnectionStatus.vue'; const DEFAULT_FLAMENCO_NAME = "Flamenco"; const DEFAULT_FLAMENCO_VERSION = "unknown"; @@ -38,6 +41,8 @@ export default { name: 'App', components: { ApiSpinner, + UpdateListener, + ConnectionStatus }, data: () => ({ flamencoName: DEFAULT_FLAMENCO_NAME, @@ -47,6 +52,14 @@ export default { mounted() { window.app = this; this.fetchManagerInfo(); + + const sockStatus = useSocketStatus(); + this.$watch(() => sockStatus.isConnected, (isConnected) => { + if (isConnected) { + this.socketIOReconnect(); + } + }); + }, methods: { // TODO: also call this when SocketIO reconnects. @@ -57,6 +70,16 @@ export default { this.flamencoVersion = version.version; }) }, + + socketIOReconnect() { + this.fetchManagerInfo() + if (this.flamencoVersion !== DEFAULT_FLAMENCO_VERSION || this.flamencoName !== DEFAULT_FLAMENCO_NAME ) { + console.log(`Upgraded Flamenco Version: ${this.flamencoVersion}`); + + // Reload the page + location.reload(); + } + } }, } -- 2.30.2 From 2f286504e8557f6241ce5ce7419eba9b06cc77e6 Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Fri, 21 Jul 2023 07:21:41 -0700 Subject: [PATCH 4/6] Revert accidental changes --- web/app/src/views/JobsView.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/app/src/views/JobsView.vue b/web/app/src/views/JobsView.vue index b88b8bc1..134d8500 100644 --- a/web/app/src/views/JobsView.vue +++ b/web/app/src/views/JobsView.vue @@ -39,9 +39,7 @@ import { useJobs } from '@/stores/jobs'; import { useTasks } from '@/stores/tasks'; import { useNotifs } from '@/stores/notifications' import { useTaskLog } from '@/stores/tasklog' -import { getAPIClient } from '@/api-client'; -import { apiClient } from '@/stores/api-query-count'; -import { MetaApi } from '@/manager-api'; +import { getAPIClient } from "@/api-client"; import FooterPopup from '@/components/footer/FooterPopup.vue' import GetTheAddon from '@/components/GetTheAddon.vue' @@ -273,10 +271,10 @@ export default { // SocketIO connection event handlers: onSIOReconnected() { - this.$refs.jobsTable.onReconnected(); if (this.$refs.tasksTable) this.$refs.tasksTable.onReconnected(); + }, onSIODisconnected(reason) { }, -- 2.30.2 From 09333db822c8bf4a69e88e258e4279b269716eb0 Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Fri, 21 Jul 2023 07:52:01 -0700 Subject: [PATCH 5/6] Update socket reconnection status --- web/app/src/App.vue | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/web/app/src/App.vue b/web/app/src/App.vue index 12af4404..83768a69 100644 --- a/web/app/src/App.vue +++ b/web/app/src/App.vue @@ -49,15 +49,16 @@ export default { flamencoVersion: DEFAULT_FLAMENCO_VERSION, backendURL: backendURL, }), + mounted() { window.app = this; this.fetchManagerInfo(); const sockStatus = useSocketStatus(); this.$watch(() => sockStatus.isConnected, (isConnected) => { - if (isConnected) { - this.socketIOReconnect(); - } + if (!isConnected) return; + if (!sockStatus.wasEverDisconnected) return; + this.socketIOReconnect(); }); }, @@ -72,14 +73,14 @@ export default { }, socketIOReconnect() { - this.fetchManagerInfo() - if (this.flamencoVersion !== DEFAULT_FLAMENCO_VERSION || this.flamencoName !== DEFAULT_FLAMENCO_NAME ) { - console.log(`Upgraded Flamenco Version: ${this.flamencoVersion}`); - - // Reload the page + const metaAPI = new API.MetaApi(getAPIClient()) + metaAPI.getVersion().then((version) => { + if (version.name === this.flamencoName && version.version == this.flamencoVersion) + return; + console.log(`Updated from ${this.flamencoVersion} to ${version.version}`); location.reload(); - } - } + }); + }, }, } -- 2.30.2 From 821e375a8bee12ccd6874edc87fc858b4be1ade6 Mon Sep 17 00:00:00 2001 From: Eveline Anderson Date: Fri, 21 Jul 2023 08:15:02 -0700 Subject: [PATCH 6/6] Clean up code --- web/app/src/App.vue | 7 +------ web/app/src/views/JobsView.vue | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/web/app/src/App.vue b/web/app/src/App.vue index 83768a69..07b37290 100644 --- a/web/app/src/App.vue +++ b/web/app/src/App.vue @@ -14,7 +14,7 @@ - + add-on | API @@ -31,8 +31,6 @@ import { backendURL } from '@/urls'; import { useSocketStatus } from '@/stores/socket-status'; import ApiSpinner from '@/components/ApiSpinner.vue'; -import UpdateListener from '@/components/UpdateListener.vue'; -import ConnectionStatus from '@/components/ConnectionStatus.vue'; const DEFAULT_FLAMENCO_NAME = "Flamenco"; const DEFAULT_FLAMENCO_VERSION = "unknown"; @@ -41,15 +39,12 @@ export default { name: 'App', components: { ApiSpinner, - UpdateListener, - ConnectionStatus }, data: () => ({ flamencoName: DEFAULT_FLAMENCO_NAME, flamencoVersion: DEFAULT_FLAMENCO_VERSION, backendURL: backendURL, }), - mounted() { window.app = this; this.fetchManagerInfo(); diff --git a/web/app/src/views/JobsView.vue b/web/app/src/views/JobsView.vue index 134d8500..ed04e62d 100644 --- a/web/app/src/views/JobsView.vue +++ b/web/app/src/views/JobsView.vue @@ -274,7 +274,6 @@ export default { this.$refs.jobsTable.onReconnected(); if (this.$refs.tasksTable) this.$refs.tasksTable.onReconnected(); - }, onSIODisconnected(reason) { }, -- 2.30.2