toggle + menù app
This commit is contained in:
@@ -72,13 +72,16 @@
|
||||
<script setup>
|
||||
import { ChevronRightIcon } from '@heroicons/vue/24/solid';
|
||||
import { useAuth } from '@websanova/vue-auth/src/v3.js';
|
||||
import axios from 'axios';
|
||||
import DataView from 'primevue/dataview';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ProjectService } from '../../service/ProjectService.js';
|
||||
import { LoadingStore } from '../../stores/LoadingStore.js';
|
||||
import { UserPrefStore } from '../../stores/UserPrefStore.js';
|
||||
|
||||
|
||||
const loadingStore = LoadingStore()
|
||||
const userPrefStore = UserPrefStore();
|
||||
const auth = useAuth();
|
||||
const user = computed(() => auth.user());
|
||||
|
||||
@@ -89,15 +92,8 @@ const user = computed(() => auth.user());
|
||||
const loading = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
console.log("user:", user);
|
||||
//loading.value = true
|
||||
|
||||
|
||||
data.projects = user.value.lstProjects;
|
||||
/* ProjectService.getUserProjects().then(resp=>{
|
||||
data.projects = resp.data
|
||||
console.log("data projects", data.projects);
|
||||
loading.value = false
|
||||
})*/
|
||||
|
||||
});
|
||||
|
||||
@@ -122,48 +118,20 @@ const user = computed(() => auth.user());
|
||||
}
|
||||
});
|
||||
|
||||
const openProject = (project) => {
|
||||
const openProject = async (project) => {
|
||||
try {
|
||||
// Esegui l'update del progetto
|
||||
await userPrefStore.updateSelectedProject(project);
|
||||
console.log('Progetto aggiornato e dati utente ricaricati');
|
||||
|
||||
console.log("id item", project);
|
||||
ProjectService.updateSelectedProject(project).then(resp=>{
|
||||
//data.projects = resp.data
|
||||
console.info("data selected " + resp.data);
|
||||
|
||||
//auth.fetch();
|
||||
//console.log(auth.user);
|
||||
|
||||
router.push({ name: 'scenario-list' });
|
||||
|
||||
});
|
||||
console.log("user before:", user.value);
|
||||
|
||||
/* try {
|
||||
const response = axios.get('api/auth/fetch-user');
|
||||
console.log("Resp fetch: ", response.data);
|
||||
console.log("auth", auth);
|
||||
|
||||
auth.setUser(response.data); // Aggiorna l'oggetto utente locale
|
||||
} catch (error) {
|
||||
console.error('Errore durante il recupero dei dati utente', error);
|
||||
}*/
|
||||
|
||||
//params: { selProject: project }
|
||||
//router.push({ name: 'scenario-list' });
|
||||
router.push({ name: 'scenario-list' });
|
||||
} catch (error) {
|
||||
console.error('Errore nel cambio progetto:', error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const fetchUserData = async () => {
|
||||
try {
|
||||
const response = await axios.get('api/auth/fetch-user');
|
||||
const fetchedUser = response.data.data;
|
||||
// Aggiorna le informazioni dell'utente in auth
|
||||
//Object.assign(auth.user(), fetchedUser);
|
||||
//user.value = response.data.data; // Aggiorna l'utente con i dati recuperati
|
||||
console.log("fetch response:", response);
|
||||
console.log("user after:", auth.user());
|
||||
} catch (error) {
|
||||
console.error('Error fetching user data:', error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
variant="filled"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="card flex justify-center">
|
||||
<SelectButton v-model="scenario_store.typeFilter" :options="scenarioTypeOp" optionLabel="name" />
|
||||
</div>
|
||||
|
||||
<SelectButton v-model="layout" :options="options" :allowEmpty="false" class="layout-switch">
|
||||
<template #option="{ option }">
|
||||
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
|
||||
@@ -72,15 +77,30 @@ import DataView from 'primevue/dataview';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ScenarioStore } from '../../stores/ScenarioStore.js';
|
||||
import { UserPrefStore } from '../../stores/UserPrefStore.js';
|
||||
|
||||
const router = useRouter()
|
||||
const layout = ref('grid');
|
||||
const options = ref(['list', 'grid']);
|
||||
|
||||
const scenario_store = ScenarioStore();
|
||||
const userPrefStore = UserPrefStore();
|
||||
|
||||
const scenarioTypeOp = ref([
|
||||
{ name: 'All', value: 'all' },
|
||||
{ name: 'Croos', value: 'cross' },
|
||||
{ name: 'Project', value: 'project' },
|
||||
{ name: 'Application', value: 'application' }
|
||||
|
||||
]);
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
scenario_store.fetchScenarios();
|
||||
userPrefStore.fetchUserData().then(() => {
|
||||
|
||||
scenario_store.fetchScenarios();
|
||||
scenario_store.fetchScenariosCross();
|
||||
});
|
||||
});
|
||||
|
||||
const executeScenario = (id) => {
|
||||
|
||||
Reference in New Issue
Block a user