refresh displayed ai in dashboard when store is reloaded

This commit is contained in:
wea_ondara
2024-05-28 17:33:39 +02:00
parent fa6f901fe2
commit 688f0252a1

View File

@@ -4,6 +4,7 @@ import AiInstanceComponent from '@/components/dashboard/AiInstanceComponent.vue'
import Alert from '@/components/Bootstrap/Alert.vue'; import Alert from '@/components/Bootstrap/Alert.vue';
import {AiInstanceVmV1} from 'ai-oas'; import {AiInstanceVmV1} from 'ai-oas';
import {AiInstanceStore} from '@/stores/AiInstanceStore'; import {AiInstanceStore} from '@/stores/AiInstanceStore';
import {Watch} from 'vue-property-decorator';
@Options({ @Options({
name: 'AiInstanceTabs', name: 'AiInstanceTabs',
@@ -16,6 +17,13 @@ export default class AiInstanceTabs extends Vue {
mounted(): void { mounted(): void {
this.aiInstanceStore.loadIfAbsent(); 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;
}
}
} }
</script> </script>