From 9ddb1523d00da5e6ee73b33a9ad10e13b95a025c Mon Sep 17 00:00:00 2001 From: Joris-k Date: Fri, 6 Dec 2024 17:40:13 +0100 Subject: [PATCH] feat(xo-lite): add host network tab and pif table / status component and pif store --- .../lite/src/components/host/HostTabBar.vue | 2 +- .../components/host/network/HostPifStatus.vue | 44 ++++ .../components/host/network/HostPifTable.vue | 228 ++++++++++++++++++ @xen-orchestra/lite/src/locales/en.json | 7 + @xen-orchestra/lite/src/locales/fr.json | 7 + .../lite/src/stores/xen-api/pif.store.ts | 34 +++ .../lite/src/views/host/HostNetworkView.vue | 17 +- .../lib/components/ui/checkbox/UiCheckbox.vue | 2 +- .../lib/components/ui/input/UiInput.vue | 1 + 9 files changed, 338 insertions(+), 4 deletions(-) create mode 100644 @xen-orchestra/lite/src/components/host/network/HostPifStatus.vue create mode 100644 @xen-orchestra/lite/src/components/host/network/HostPifTable.vue create mode 100644 @xen-orchestra/lite/src/stores/xen-api/pif.store.ts diff --git a/@xen-orchestra/lite/src/components/host/HostTabBar.vue b/@xen-orchestra/lite/src/components/host/HostTabBar.vue index e918ee34e70..d64d5cf2626 100644 --- a/@xen-orchestra/lite/src/components/host/HostTabBar.vue +++ b/@xen-orchestra/lite/src/components/host/HostTabBar.vue @@ -6,7 +6,7 @@ {{ $t('console') }} - + {{ $t('network') }} diff --git a/@xen-orchestra/lite/src/components/host/network/HostPifStatus.vue b/@xen-orchestra/lite/src/components/host/network/HostPifStatus.vue new file mode 100644 index 00000000000..1590f46082d --- /dev/null +++ b/@xen-orchestra/lite/src/components/host/network/HostPifStatus.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/@xen-orchestra/lite/src/components/host/network/HostPifTable.vue b/@xen-orchestra/lite/src/components/host/network/HostPifTable.vue new file mode 100644 index 00000000000..2ff5b292c5c --- /dev/null +++ b/@xen-orchestra/lite/src/components/host/network/HostPifTable.vue @@ -0,0 +1,228 @@ + + + + + diff --git a/@xen-orchestra/lite/src/locales/en.json b/@xen-orchestra/lite/src/locales/en.json index a9217ed7ae1..1dde1a40903 100644 --- a/@xen-orchestra/lite/src/locales/en.json +++ b/@xen-orchestra/lite/src/locales/en.json @@ -35,6 +35,7 @@ "close": "Close", "community": "Community", "community-name": "{name} community", + "connected": "Connected", "configuration": "Configuration", "confirm-cancel": "Are you sure you want to cancel?", "confirm-delete": "You're about to delete {0}", @@ -60,11 +61,14 @@ "descending": "descending", "description": "Description", "dhcp": "DHCP", + "disconnected": "Disconnected", + "disconnected-from-physical-device": "Disconnected from physical device", "disabled": "Disabled", "display": "Display", "dns": "DNS", "do-you-have-needs": "You have needs and/or expectations? Let us know", "documentation": "Documentation", + "edit": "Edit", "edit-config": "Edit config", "enabled": "Enabled", "error-occurred": "An error has occurred", @@ -186,6 +190,7 @@ "new-features-are-coming": "New features are coming soon!", "news": "News", "news-name": "{name} news", + "none": "None", "no-alarm-triggered": "No alarm triggered", "no-result": "No result", "no-selected-vm-can-be-exported": "No selected VM can be exported", @@ -199,6 +204,7 @@ "password": "Password", "password-invalid": "Password invalid", "pause": "Pause", + "pifs": "PIFs", "please-confirm": "Please confirm", "pool-cpu-usage": "Pool CPU Usage", "pool-ram-usage": "Pool RAM Usage", @@ -220,6 +226,7 @@ "resume": "Resume", "save": "Save", + "scan-pifs": "Scan PIFs", "select-compression": "Select a compression", "select-destination-host": "Select a destination host", "selected-vms-in-execution": "Some selected VMs are running", diff --git a/@xen-orchestra/lite/src/locales/fr.json b/@xen-orchestra/lite/src/locales/fr.json index d9f86ea546e..a7ac3f46e1f 100644 --- a/@xen-orchestra/lite/src/locales/fr.json +++ b/@xen-orchestra/lite/src/locales/fr.json @@ -36,6 +36,7 @@ "community": "Communauté", "community-name": "Communauté {name}", "configuration": "Configuration", + "connected": "Connecté", "confirm-cancel": "Êtes-vous sûr de vouloir annuler ?", "confirm-delete": "Vous êtes sur le point de supprimer {0}", "console-unavailable": "Console indisponible", @@ -60,11 +61,14 @@ "descending": "descendant", "description": "Description", "dhcp": "DHCP", + "disconnected": "Déconnecté", + "disconnected-from-physical-device": "Déconnecté de l'appareil physique", "dns": "DNS", "disabled": "Désactivé", "display": "Affichage", "do-you-have-needs": "Vous avez des besoins et/ou des attentes ? Faites le nous savoir", "documentation": "Documentation", + "edit": "Modifier", "edit-config": "Modifier config", "enabled": "Activé", "error-occurred": "Une erreur est survenue", @@ -186,6 +190,7 @@ "new-features-are-coming": "De nouvelles fonctionnalités arrivent bientôt !", "news": "Actualités", "news-name": "Actualités {name}", + "none": "Aucun", "no-alarm-triggered": "Aucune alarme déclenchée", "no-result": "Aucun résultat", "no-selected-vm-can-be-exported": "Aucune VM sélectionnée ne peut être exportée", @@ -199,6 +204,7 @@ "password": "Mot de passe", "password-invalid": "Mot de passe incorrect", "pause": "Pause", + "pifs": "PIFs", "please-confirm": "Veuillez confirmer", "pool-cpu-usage": "Utilisation CPU du Pool", "pool-ram-usage": "Utilisation RAM du Pool", @@ -220,6 +226,7 @@ "resume": "Reprendre", "save": "Enregistrer", + "scan-pifs": "Scanner les PIFs", "select-compression": "Sélectionnez une compression", "select-destination-host": "Sélectionnez un hôte de destination", "selected-vms-in-execution": "Certaines VMs sélectionnées sont en cours d'exécution", diff --git a/@xen-orchestra/lite/src/stores/xen-api/pif.store.ts b/@xen-orchestra/lite/src/stores/xen-api/pif.store.ts new file mode 100644 index 00000000000..b0e11880f15 --- /dev/null +++ b/@xen-orchestra/lite/src/stores/xen-api/pif.store.ts @@ -0,0 +1,34 @@ +import type { XenApiHost } from '@/libs/xen-api/xen-api.types' +import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config' +import { useHostStore } from '@/stores/xen-api/host.store' +import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util' +import { defineStore } from 'pinia' +import { computed } from 'vue' +import { useRoute } from 'vue-router' + +export const usePifStore = defineStore('xen-api-pif', () => { + const route = useRoute() + + const deps = { + hostStore: useHostStore(), + } + const { context: baseContext, ...configRest } = createXapiStoreConfig('pif') + + const hostContext = deps.hostStore.getContext() + + const currentHostPifs = computed(() => { + const currentHostUuid = route.params.uuid as XenApiHost['uuid'] + + return baseContext.records.value.filter(pif => { + const host = hostContext.getByOpaqueRef(pif.host) + return host?.uuid === currentHostUuid + }) + }) + + const context = { + ...baseContext, + currentHostPifs, + } + + return createSubscribableStoreContext({ context, ...configRest }, deps) +}) diff --git a/@xen-orchestra/lite/src/views/host/HostNetworkView.vue b/@xen-orchestra/lite/src/views/host/HostNetworkView.vue index 4a52297b68a..60cba06b207 100644 --- a/@xen-orchestra/lite/src/views/host/HostNetworkView.vue +++ b/@xen-orchestra/lite/src/views/host/HostNetworkView.vue @@ -1,11 +1,24 @@ + + diff --git a/@xen-orchestra/web-core/lib/components/ui/checkbox/UiCheckbox.vue b/@xen-orchestra/web-core/lib/components/ui/checkbox/UiCheckbox.vue index 8b1bdaf05b3..2092b8a2d93 100644 --- a/@xen-orchestra/web-core/lib/components/ui/checkbox/UiCheckbox.vue +++ b/@xen-orchestra/web-core/lib/components/ui/checkbox/UiCheckbox.vue @@ -43,7 +43,7 @@ const props = withDefaults( { disabled: undefined } ) -const checkboxModel = defineModel({ default: undefined }) +const checkboxModel = defineModel({ default: undefined }) const slots = defineSlots<{ default?(): any diff --git a/@xen-orchestra/web-core/lib/components/ui/input/UiInput.vue b/@xen-orchestra/web-core/lib/components/ui/input/UiInput.vue index 03b1c8cb5d5..d72eed42c28 100644 --- a/@xen-orchestra/web-core/lib/components/ui/input/UiInput.vue +++ b/@xen-orchestra/web-core/lib/components/ui/input/UiInput.vue @@ -88,6 +88,7 @@ const id = computed(() => uniqueId('input-')) /* IMPLEMENTATION */ .ui-input { position: relative; + flex: 1; .before + .input { padding-inline-start: 4.8rem;