From c9a8cab8feca9863ca4b677b669f026c9231a85e Mon Sep 17 00:00:00 2001 From: Jont828 Date: Tue, 15 Aug 2023 16:43:12 -0400 Subject: [PATCH] Fetch version using mixin on page load to avoid lag --- web/src/components/SettingsCard.vue | 18 +++------- web/src/mixins/setVersion.js | 24 +++++++++++++ web/src/views/DescribeCluster.vue | 53 ++++++++++++++++------------- web/src/views/ManagementCluster.vue | 24 +++++++------ 4 files changed, 70 insertions(+), 49 deletions(-) create mode 100644 web/src/mixins/setVersion.js diff --git a/web/src/components/SettingsCard.vue b/web/src/components/SettingsCard.vue index f6f39d2..6e40ee9 100644 --- a/web/src/components/SettingsCard.vue +++ b/web/src/components/SettingsCard.vue @@ -31,7 +31,7 @@ Version - {{ gitVersion }} + {{ version }} @@ -84,6 +85,7 @@ import AlertError from "../components/AlertError.vue"; import SettingsCard from "../components/SettingsCard.vue"; import { useSettingsStore } from "../stores/settings.js"; +import { setVersion } from "../mixins/setVersion.js"; import _ from "lodash"; import colors from "vuetify/lib/util/colors"; @@ -97,12 +99,39 @@ export default { CustomResourceDefinition, AlertError, }, + mixins: [setVersion], + data() { + return { + showSettingsOverlay: false, + showAboutOverlay: false, + alert: false, + errorMessage: "", + treeIsReady: false, + resourceIsReady: false, + resource: {}, + selected: {}, + treeData: {}, + cachedTreeString: "", + treeConfig: { nodeWidth: 180, nodeHeight: 50, levelHeight: 120 }, + scale: 1, + legend: { + cluster: "Cluster API", + bootstrap: "Bootstrap Provider", + controlplane: "Control Plane Provider", + infrastructure: "Infrastructure Provider", + addons: "Add-ons", + virtual: "None", + }, + gitVersion: "" + }; + }, setup() { const store = useSettingsStore(); return { store }; }, async beforeMount() { await this.fetchCluster(); + await this.fetchVersion(); }, computed: { theme() { @@ -306,30 +335,6 @@ export default { ); }, }, - data() { - return { - showSettingsOverlay: false, - showAboutOverlay: false, - alert: false, - errorMessage: "", - treeIsReady: false, - resourceIsReady: false, - resource: {}, - selected: {}, - treeData: {}, - cachedTreeString: "", - treeConfig: { nodeWidth: 180, nodeHeight: 50, levelHeight: 120 }, - scale: 1, - legend: { - cluster: "Cluster API", - bootstrap: "Bootstrap Provider", - controlplane: "Control Plane Provider", - infrastructure: "Infrastructure Provider", - addons: "Add-Ons", - virtual: "None", - }, - }; - }, }; diff --git a/web/src/views/ManagementCluster.vue b/web/src/views/ManagementCluster.vue index fb716b1..f3bde11 100644 --- a/web/src/views/ManagementCluster.vue +++ b/web/src/views/ManagementCluster.vue @@ -37,7 +37,9 @@ import Vue from "vue"; import ManagementClusterTree from "../components/ManagementClusterTree.vue"; import SettingsCard from "../components/SettingsCard.vue"; import AppBar from "../components/AppBar.vue"; + import { useSettingsStore } from "../stores/settings.js"; +import { setVersion } from "../mixins/setVersion.js"; export default { name: "ManagementCluster", @@ -46,6 +48,17 @@ export default { SettingsCard, AppBar, }, + mixins: [setVersion], + data() { + return { + showSettingsOverlay: false, + treeConfig: { nodeWidth: 300, nodeHeight: 140, levelHeight: 275 }, + treeData: {}, + cachedTreeString: "", + treeIsReady: false, + scale: 1, + }; + }, setup() { const store = useSettingsStore(); return { store }; @@ -66,17 +79,6 @@ export default { this.selected = {}; clearInterval(this.polling); }, - data() { - return { - showSettingsOverlay: false, - treeConfig: { nodeWidth: 300, nodeHeight: 140, levelHeight: 275 }, - treeData: {}, - cachedTreeString: "", - treeIsReady: false, - scale: 1, - gitVersion: "", - }; - }, watch: { "store.selectedInterval": function (val) { console.log("Overview store.selectedInterval: " + val);