From d7882baeab05063f8894531e880f209580806088 Mon Sep 17 00:00:00 2001 From: "andrea.terzani" Date: Fri, 25 Oct 2024 19:41:24 +0200 Subject: [PATCH] Refactor AppMenu and AppTopbar components - Updated the AppMenu component to only add available scenarios to the menu if there are any. - Refactored the AppTopbar component to use the selectedApp value from the UserPrefStore. - Added an updateApplication function to update the selectedApp value in the UserPrefStore and fetch the application scenarios. - Created a watcher to update the selectedApp value when it changes in the UserPrefStore. Fix axios base URL configuration - Updated the axios base URL configuration in the main.js file to use a hardcoded URL instead of the VITE_BACKEND_URL environment variable. Update ProjectService and UserPrefStore - Added an updateSelectedApplication function to the ProjectService to update the selected application. - Updated the UserPrefStore to fetch the selected application from the user data and set it as the selectedApp value. - Added a setSelectedApp function to the UserPrefStore to update the selectedApp value and call the updateSelectedApplication function. Update ScenarioStore - Updated the fetchApplicationScenarios function in the ScenarioStore to use the selectedApp value from the UserPrefStore when fetching scenarios. Remove unused components - Removed the Empty, SeatDemo, PersonalDemo, PaymentDemo, ConfirmationDemo, TreeDoc, and FileDoc components from the project. Fix menu typo - Fixed a typo in the menu component. Revert changes for Canva - Reverted the changes made for Canva. Merge branch 'master' of https://gitlab.gcp.windtre.it/olympus_ai/hermione-fe - Merged the changes from the master branch of the remote repository. --- src/layout/AppMenu.vue | 11 ++++++----- src/layout/AppTopbar.vue | 21 ++++++++++++++++++--- src/main.js | 2 +- src/service/ProjectService.js | 4 ++++ src/stores/ScenarioStore.js | 4 ++-- src/stores/UserPrefStore.js | 9 +++++---- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/layout/AppMenu.vue b/src/layout/AppMenu.vue index f1bcb2e..23fe5b6 100644 --- a/src/layout/AppMenu.vue +++ b/src/layout/AppMenu.vue @@ -7,8 +7,6 @@ import AppMenuItem from './AppMenuItem.vue'; const userPrefStore = UserPrefStore(); - - const model = ref([ { label: '', @@ -41,9 +39,12 @@ function updateApplicationsMenu() { { label: 'Rev Eng Code', icon: 'pi pi-fw pi-id-card', to: '/app-browser' } ]; - selectedApp.available_scenarios.forEach(app => { - model.value[0].items.push({ label: app.label, icon: 'pi pi-fw pi-id-card', to: `/scenario/exec/${app.scenario_id}` }); - }); + if( selectedApp.available_scenarios.length > 0) { + selectedApp.available_scenarios.forEach(app => { + model.value[0].items.push({ label: app.label, icon: 'pi pi-fw pi-id-card', to: `/scenario/exec/${app.scenario_id}` }); + }); + } + } else { // Se selectedApp รจ nullo, svuota gli item diff --git a/src/layout/AppTopbar.vue b/src/layout/AppTopbar.vue index 2fd5814..db31234 100644 --- a/src/layout/AppTopbar.vue +++ b/src/layout/AppTopbar.vue @@ -8,11 +8,11 @@ import { LoadingStore } from '../stores/LoadingStore.js'; import { ScenarioStore } from '../stores/ScenarioStore.js'; import { UserPrefStore } from '../stores/UserPrefStore.js'; +import { ref, watch } from 'vue'; import { useRoute } from 'vue-router'; import AppConfigurator from './AppConfigurator.vue'; import AppProfileMenu from './AppProfileMenu.vue'; - const auth = useAuth(); const route = useRoute(); @@ -23,8 +23,23 @@ const userPrefStore = UserPrefStore(); const scenario_store = ScenarioStore(); const loadingStore = LoadingStore() + +const selectedApp = ref(userPrefStore.getSelApp); + const { onMenuToggle, toggleDarkMode, isDarkTheme } = useLayout(); +async function updateApplication() { + await userPrefStore.setSelectedApp(selectedApp.value); + + scenario_store.fetchApplicationScenarios(); + +} + +function appUpdated() { + selectedApp.value = userPrefStore.getSelApp; +} + +watch(() => userPrefStore.getSelApp, appUpdated, { immediate: true }); @@ -85,12 +100,12 @@ const { onMenuToggle, toggleDarkMode, isDarkTheme } = useLayout();