create dashboard

This commit is contained in:
mariapia.lorusso
2025-06-09 16:55:06 +02:00
parent 8b8843ee14
commit 3796213b7b
6 changed files with 1403 additions and 55 deletions

View File

@@ -6,8 +6,7 @@ import { UserPrefStore } from '../stores/UserPrefStore.js';
import AppMenuItem from './AppMenuItem.vue';
const userPrefStore = UserPrefStore();
const route = useRouter()
const route = useRouter();
const model = ref([
@@ -18,7 +17,7 @@ const model = ref([
{ label: 'Execution List', icon: 'pi pi-fw pi-list', command: () => {
route.push({path: '/executions/all'});
} },
] },
] },
{
label: '',
items: [] } ,
@@ -30,22 +29,25 @@ const model = ref([
label: 'Chat',
items: [{ label: 'Chat', icon: 'pi pi-fw pi-comments', to: '/chat' }]
}
]);
// onMounted(() => {
// if(userPrefStore.user.role == 'ADMIN'){
// model.value.push({
// label: 'Chat',
// items: [{ label: 'Chat', icon: 'pi pi-fw pi-comments', to: '/chat' }]
// });
// }
// });
onMounted(() => {
if(userPrefStore.user.role === 'ADMIN'){
model.value[0].items.push({
label: 'Dashboard',
icon: 'pi pi-fw pi-chart-bar',
command: () => {
route.push({ path: '/dashboard' });
}
});
}
});
// Funzione per aggiornare la sezione "Your Applications" in base a selectedApp
function updateApplicationsMenu() {
const selectedApp = userPrefStore.getSelApp;
console.log("selectedApp", selectedApp);
console.log('selectedApp', selectedApp);
if (selectedApp != null) {
//Aggiorna il label dell'app
@@ -58,7 +60,7 @@ function updateApplicationsMenu() {
const groupedScenarios = {};
//Raggruppa gli scenari per categoria (solo se type non è null)
selectedApp.available_scenarios.forEach(app => {
selectedApp.available_scenarios.forEach((app) => {
if (app.type) {
const type = app.type.trim();
if (!groupedScenarios[type]) {
@@ -70,30 +72,31 @@ function updateApplicationsMenu() {
model.value[1].items.push(createScenarioItem(app));
}
});
//Creazione del menu in base ai gruppi
Object.keys(groupedScenarios).forEach(type => {
//Creazione del menu in base ai gruppi
Object.keys(groupedScenarios).forEach((type) => {
const scenarios = groupedScenarios[type];
if (scenarios.length >= 2) {
//Se ci sono almeno 2 scenari nella stessa categoria, creiamo un gruppo
//Se ci sono almeno 2 scenari nella stessa categoria, creiamo un gruppo
const typeItem = {
label: type,
icon: 'pi pi-fw pi-folder',
items: []
};
scenarios.forEach(app => {
scenarios.forEach((app) => {
typeItem.items.push(createScenarioItem(app));
});
model.value[1].items.push(typeItem);
}else {
} else {
//Se c'è solo un elemento, lo aggiungiamo direttamente
model.value[1].items.push(createScenarioItem(scenarios[0]));
}
});
//Aggiungi "Rev Eng Code" alla fine della lista
model.value[1].items.push({
label: 'Application Code',
@@ -108,14 +111,10 @@ function updateApplicationsMenu() {
model.value[1].label = '';
model.value[1].items = [];
}
}
function createScenarioItem(app) {
if(app.associate_exec_list === 'Y'){
if (app.associate_exec_list === 'Y') {
return {
label: app.label,
icon: 'pi pi-fw pi-wrench',
@@ -133,8 +132,7 @@ function createScenarioItem(app) {
route.push({ path: `/home/scenario/exec/${app.scenario_id}` });
}
};
}else{
} else {
return {
label: app.label,
icon: 'pi pi-fw pi-wrench',
@@ -143,14 +141,8 @@ function createScenarioItem(app) {
}
};
}
}
// Monitora i cambiamenti in selectedApp dallo store
watch(() => userPrefStore.getSelApp, updateApplicationsMenu, { immediate: true });
</script>