From 688f0252a1ce18404ead5aa93f8190b2848b7bd3 Mon Sep 17 00:00:00 2001 From: wea_ondara Date: Tue, 28 May 2024 17:33:39 +0200 Subject: [PATCH] refresh displayed ai in dashboard when store is reloaded --- frontend/src/components/dashboard/AiInstanceTabs.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/components/dashboard/AiInstanceTabs.vue b/frontend/src/components/dashboard/AiInstanceTabs.vue index dcec71b..3c4532d 100644 --- a/frontend/src/components/dashboard/AiInstanceTabs.vue +++ b/frontend/src/components/dashboard/AiInstanceTabs.vue @@ -4,6 +4,7 @@ import AiInstanceComponent from '@/components/dashboard/AiInstanceComponent.vue' import Alert from '@/components/Bootstrap/Alert.vue'; import {AiInstanceVmV1} from 'ai-oas'; import {AiInstanceStore} from '@/stores/AiInstanceStore'; +import {Watch} from 'vue-property-decorator'; @Options({ name: 'AiInstanceTabs', @@ -16,6 +17,13 @@ export default class AiInstanceTabs extends Vue { mounted(): void { this.aiInstanceStore.loadIfAbsent(); } + + @Watch('aiInstanceStore.aiInstances', {deep: true}) + private onAiInstancesChanged(newValue: AiInstanceVmV1[]): void { + if (this.selectedAiInstance && !newValue.find(e => e === this.selectedAiInstance)) { + this.selectedAiInstance = newValue.find(e => e.configuration.id === this.selectedAiInstance?.configuration.id) ?? null; + } + } }