diff --git a/src/layout/AppProfileMenu.vue b/src/layout/AppProfileMenu.vue index d3e347b..5b7facb 100644 --- a/src/layout/AppProfileMenu.vue +++ b/src/layout/AppProfileMenu.vue @@ -6,7 +6,9 @@ {{ user.name + " " + user.surname }} - + + + @@ -16,14 +18,26 @@ import { useAuth } from '@websanova/vue-auth/src/v3.js'; import { computed } from 'vue'; import { useRouter } from 'vue-router'; +import { ScenarioStore } from '@/stores/ScenarioStore'; const auth = useAuth(); const user = computed(() => auth.user()); const router = useRouter(); +const scenario_store = ScenarioStore(); + function redirectProject() { router.push('/projects'); // Specifica il percorso per la pagina "Projects" } +function logout() { + auth.logout().then(() => { + scenario_store.resetStore(); + router.push('/auth/login'); + }).catch(err => { + console.error("Errore durante il logout:", err); + }); +} + diff --git a/src/stores/ScenarioStore.js b/src/stores/ScenarioStore.js index aa0c9e4..44d2565 100644 --- a/src/stores/ScenarioStore.js +++ b/src/stores/ScenarioStore.js @@ -6,7 +6,6 @@ import { UserPrefStore } from './UserPrefStore' export const ScenarioStore = defineStore('scenario_store', () => { - const projectScenarios = ref([]) const globalScenarios = ref([]) const applicationScenarios = ref([]) @@ -18,7 +17,6 @@ export const ScenarioStore = defineStore('scenario_store', () => { const userPrefStore = UserPrefStore() const loadingStore = LoadingStore() - async function fetchScenarios() { loadingStore.scenario_loading = true; await ScenarioService.getScenariosProject(userPrefStore.selectedProject).then(resp => { @@ -26,7 +24,6 @@ export const ScenarioStore = defineStore('scenario_store', () => { allScenarios.value = [...projectScenarios.value] loadingStore.scenario_loading = false; }); - } async function fetchScenariosForRE() { @@ -35,7 +32,6 @@ export const ScenarioStore = defineStore('scenario_store', () => { scenariosForRE.value = resp.data; loadingStore.scenario_loading = false; }); - } async function fetchScenariosCross() { @@ -45,19 +41,16 @@ export const ScenarioStore = defineStore('scenario_store', () => { allScenarios.value = [...globalScenarios.value] loadingStore.scenario_loading = false; }); - } - async function fetchApplicationScenarios() { loadingStore.scenario_loading = true; - console.log("fetchApplicationScenarios >= selectedApp", userPrefStore.selectedApp) ; - await ScenarioService.getScenariosApplication(userPrefStore.selectedApp).then(resp=>{ + console.log("fetchApplicationScenarios >= selectedApp", userPrefStore.selectedApp); + await ScenarioService.getScenariosApplication(userPrefStore.selectedApp).then(resp => { console.log("response scenari", resp); applicationScenarios.value = resp.data allScenarios.value = [...projectScenarios.value, ...applicationScenarios.value] loadingStore.scenario_loading = false; - }) } @@ -65,7 +58,6 @@ export const ScenarioStore = defineStore('scenario_store', () => { return allScenarios.value }) - const filteredScenarios = computed(() => { console.log("scenarios", allScenarios.value); var filteredScenario = [] @@ -91,12 +83,43 @@ export const ScenarioStore = defineStore('scenario_store', () => { }); }) + const filteredScenariosCanvas = computed(() => { + console.log("scenarios", allScenarios.value); + var filteredScenario = [] - return {filteredScenarios, - projectScenarios, - applicationScenarios, - fetchScenarios, - fetchApplicationScenarios, - scenarios, - filterString , typeFilter, fetchScenariosCross, globalScenarios, fetchScenariosForRE, scenariosForRE} - }) \ No newline at end of file + if(userPrefStore.getSelApp != null) { + filteredScenario = [...globalScenarios.value,...projectScenarios.value, ...applicationScenarios.value] + } else { + filteredScenario = [...globalScenarios.value,...projectScenarios.value] + } + + return filteredScenario + }) + + function resetStore() { + projectScenarios.value = [] + globalScenarios.value = [] + applicationScenarios.value = [] + filterString.value = '' + allScenarios.value = [] + typeFilter.value = { name: 'All', value: 'all' } + scenariosForRE.value = [] + } + + return { + filteredScenarios, + filteredScenariosCanvas, + projectScenarios, + applicationScenarios, + fetchScenarios, + fetchApplicationScenarios, + scenarios, + filterString, + typeFilter, + fetchScenariosCross, + globalScenarios, + fetchScenariosForRE, + scenariosForRE, + resetStore + } +}) \ No newline at end of file diff --git a/src/views/pages/ScenarioExec.vue b/src/views/pages/ScenarioExec.vue index 3461e99..39d70b1 100644 --- a/src/views/pages/ScenarioExec.vue +++ b/src/views/pages/ScenarioExec.vue @@ -1,262 +1,199 @@