create dashboard
This commit is contained in:
@@ -6,8 +6,7 @@ import { UserPrefStore } from '../stores/UserPrefStore.js';
|
|||||||
import AppMenuItem from './AppMenuItem.vue';
|
import AppMenuItem from './AppMenuItem.vue';
|
||||||
|
|
||||||
const userPrefStore = UserPrefStore();
|
const userPrefStore = UserPrefStore();
|
||||||
const route = useRouter()
|
const route = useRouter();
|
||||||
|
|
||||||
|
|
||||||
const model = ref([
|
const model = ref([
|
||||||
|
|
||||||
@@ -33,19 +32,22 @@ const model = ref([
|
|||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// onMounted(() => {
|
onMounted(() => {
|
||||||
// if(userPrefStore.user.role == 'ADMIN'){
|
if(userPrefStore.user.role === 'ADMIN'){
|
||||||
// model.value.push({
|
model.value[0].items.push({
|
||||||
// label: 'Chat',
|
label: 'Dashboard',
|
||||||
// items: [{ label: 'Chat', icon: 'pi pi-fw pi-comments', to: '/chat' }]
|
icon: 'pi pi-fw pi-chart-bar',
|
||||||
// });
|
command: () => {
|
||||||
// }
|
route.push({ path: '/dashboard' });
|
||||||
// });
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Funzione per aggiornare la sezione "Your Applications" in base a selectedApp
|
// Funzione per aggiornare la sezione "Your Applications" in base a selectedApp
|
||||||
function updateApplicationsMenu() {
|
function updateApplicationsMenu() {
|
||||||
const selectedApp = userPrefStore.getSelApp;
|
const selectedApp = userPrefStore.getSelApp;
|
||||||
console.log("selectedApp", selectedApp);
|
console.log('selectedApp', selectedApp);
|
||||||
|
|
||||||
if (selectedApp != null) {
|
if (selectedApp != null) {
|
||||||
//Aggiorna il label dell'app
|
//Aggiorna il label dell'app
|
||||||
@@ -58,7 +60,7 @@ function updateApplicationsMenu() {
|
|||||||
const groupedScenarios = {};
|
const groupedScenarios = {};
|
||||||
|
|
||||||
//Raggruppa gli scenari per categoria (solo se type non è null)
|
//Raggruppa gli scenari per categoria (solo se type non è null)
|
||||||
selectedApp.available_scenarios.forEach(app => {
|
selectedApp.available_scenarios.forEach((app) => {
|
||||||
if (app.type) {
|
if (app.type) {
|
||||||
const type = app.type.trim();
|
const type = app.type.trim();
|
||||||
if (!groupedScenarios[type]) {
|
if (!groupedScenarios[type]) {
|
||||||
@@ -72,7 +74,7 @@ function updateApplicationsMenu() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Creazione del menu in base ai gruppi
|
//Creazione del menu in base ai gruppi
|
||||||
Object.keys(groupedScenarios).forEach(type => {
|
Object.keys(groupedScenarios).forEach((type) => {
|
||||||
const scenarios = groupedScenarios[type];
|
const scenarios = groupedScenarios[type];
|
||||||
|
|
||||||
if (scenarios.length >= 2) {
|
if (scenarios.length >= 2) {
|
||||||
@@ -83,7 +85,7 @@ function updateApplicationsMenu() {
|
|||||||
items: []
|
items: []
|
||||||
};
|
};
|
||||||
|
|
||||||
scenarios.forEach(app => {
|
scenarios.forEach((app) => {
|
||||||
typeItem.items.push(createScenarioItem(app));
|
typeItem.items.push(createScenarioItem(app));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,6 +96,7 @@ function updateApplicationsMenu() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Aggiungi "Rev Eng Code" alla fine della lista
|
//Aggiungi "Rev Eng Code" alla fine della lista
|
||||||
model.value[1].items.push({
|
model.value[1].items.push({
|
||||||
label: 'Application Code',
|
label: 'Application Code',
|
||||||
@@ -108,13 +111,9 @@ function updateApplicationsMenu() {
|
|||||||
model.value[1].label = '';
|
model.value[1].label = '';
|
||||||
model.value[1].items = [];
|
model.value[1].items = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createScenarioItem(app) {
|
function createScenarioItem(app) {
|
||||||
|
|
||||||
if (app.associate_exec_list === 'Y') {
|
if (app.associate_exec_list === 'Y') {
|
||||||
return {
|
return {
|
||||||
label: app.label,
|
label: app.label,
|
||||||
@@ -133,7 +132,6 @@ function createScenarioItem(app) {
|
|||||||
route.push({ path: `/home/scenario/exec/${app.scenario_id}` });
|
route.push({ path: `/home/scenario/exec/${app.scenario_id}` });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
label: app.label,
|
label: app.label,
|
||||||
@@ -143,14 +141,8 @@ function createScenarioItem(app) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Monitora i cambiamenti in selectedApp dallo store
|
// Monitora i cambiamenti in selectedApp dallo store
|
||||||
watch(() => userPrefStore.getSelApp, updateApplicationsMenu, { immediate: true });
|
watch(() => userPrefStore.getSelApp, updateApplicationsMenu, { immediate: true });
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -18,14 +18,6 @@ export const ScenarioService = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// getExecScenariosByUser(page = 0, size = 10) {
|
|
||||||
// return axios.get('/executions', {
|
|
||||||
// params: {
|
|
||||||
// page: page,
|
|
||||||
// size: size }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
getExecScenariosByUser(page = 0, size = 10, filters = {}, sortField, sortOrder) {
|
getExecScenariosByUser(page = 0, size = 10, filters = {}, sortField, sortOrder) {
|
||||||
// Filtri potrebbero essere vuoti, quindi rimuoviamoli se non necessari
|
// Filtri potrebbero essere vuoti, quindi rimuoviamoli se non necessari
|
||||||
const requestBody = { page, size, ...filters, sortField, sortOrder };
|
const requestBody = { page, size, ...filters, sortField, sortOrder };
|
||||||
@@ -38,6 +30,10 @@ export const ScenarioService = {
|
|||||||
},
|
},
|
||||||
updateScenarioExecRating(id, rating) {
|
updateScenarioExecRating(id, rating) {
|
||||||
return axios.get('/updateRating?id=' + id + '&rating=' + rating)
|
return axios.get('/updateRating?id=' + id + '&rating=' + rating)
|
||||||
|
},
|
||||||
|
|
||||||
|
getExecScenarioByProject () {
|
||||||
|
return axios.get('/getExecScenarioByProject')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
79
src/service/dashboard/DashboardScenarioService.js
Normal file
79
src/service/dashboard/DashboardScenarioService.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
export const DashboardScenarioService = {
|
||||||
|
|
||||||
|
getExecScenarioByProject (project) {
|
||||||
|
return axios.get('/getExecScenarioByProject', {
|
||||||
|
params: project
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
//funzione per recuperare la lista con TUTTI i progetti
|
||||||
|
getProjects() {
|
||||||
|
return axios.get('/projects');
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getExecutions(filters) {
|
||||||
|
return axios.post('/executions-dash', {
|
||||||
|
dateFrom: filters.dateFrom,
|
||||||
|
dateTo: filters.dateTo,
|
||||||
|
projectNameList: filters.projectNames,
|
||||||
|
scenarioNameList: filters.scenarioNames
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
getExecutionsStats(filters) {
|
||||||
|
return axios.post('/executions-stats-dash', {
|
||||||
|
dateFrom: filters.dateFrom,
|
||||||
|
dateTo: filters.dateTo,
|
||||||
|
projectNameList: filters.projectNames,
|
||||||
|
scenarioNameList: filters.scenarioNames
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getUsers(filters) {
|
||||||
|
return axios.get('/users-by-projects', {
|
||||||
|
params: {
|
||||||
|
projectIdsArr: filters
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getScenarios(filters) {
|
||||||
|
return axios.get('/scenarios-filter', {
|
||||||
|
params: {
|
||||||
|
selectedAccount: filters
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getChats(filters) {
|
||||||
|
return axios.get('/chats', {
|
||||||
|
params: {
|
||||||
|
dateFrom: filters.dateFrom,
|
||||||
|
dateTo: filters.dateTo,
|
||||||
|
projectId: filters.projectId,
|
||||||
|
user: filters.user
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getChatStats(filters) {
|
||||||
|
return axios.post('/dashboard-chat-stats', {
|
||||||
|
dateFrom: filters.dateFrom,
|
||||||
|
dateTo: filters.dateTo,
|
||||||
|
projectNameList: filters.projectNames,
|
||||||
|
scenarioIdList: filters.scenarioId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
@@ -14,18 +14,23 @@ export const UserPrefStore = defineStore('userpref_store', () => {
|
|||||||
const selectedScenario = ref(null)
|
const selectedScenario = ref(null)
|
||||||
|
|
||||||
async function fetchUserData() {
|
async function fetchUserData() {
|
||||||
|
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
loadingStore.user_loading = true;
|
loadingStore.user_loading = true;
|
||||||
await auth.fetch().then((fetchedUser) => {
|
|
||||||
|
try {
|
||||||
|
const fetchedUser = await auth.fetch();
|
||||||
user.value = fetchedUser.data.data;
|
user.value = fetchedUser.data.data;
|
||||||
selectedApp.value = user.value.selectedApplication;
|
selectedApp.value = user.value.selectedApplication;
|
||||||
userLoaded.value = true;
|
userLoaded.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Errore nel recupero dei dati utente:', error);
|
||||||
|
// Puoi anche lanciare un errore se vuoi gestirlo in modo diverso altrove
|
||||||
|
throw error; // Lancia l'errore per gestirlo fuori dalla funzione, se necessario
|
||||||
|
} finally {
|
||||||
loadingStore.user_loading = false;
|
loadingStore.user_loading = false;
|
||||||
}).catch((error) => {
|
}
|
||||||
reject(error);
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
async function updateSelectedProject(project) {
|
async function updateSelectedProject(project) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
166
src/stores/dashboard/DashboardScenarioStore.js
Normal file
166
src/stores/dashboard/DashboardScenarioStore.js
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { DashboardScenarioService } from '../../service/dashboard/DashboardScenarioService'
|
||||||
|
|
||||||
|
import { LoadingStore } from '../../stores/LoadingStore'
|
||||||
|
import { UserPrefStore } from '../../stores/UserPrefStore'
|
||||||
|
|
||||||
|
export const DashboardScenarioStore = defineStore('dashboard_scenario_store', () => {
|
||||||
|
|
||||||
|
const projectScenarios = ref([])
|
||||||
|
const globalScenarios = ref([])
|
||||||
|
const applicationScenarios = ref([])
|
||||||
|
const filterString = ref('')
|
||||||
|
const allScenarios = ref([])
|
||||||
|
const typeFilter = ref({ name: 'All', value: 'all' })
|
||||||
|
const scenariosForRE = ref([])
|
||||||
|
const projects = ref([])
|
||||||
|
const executions = ref([])
|
||||||
|
const chats = ref([])
|
||||||
|
const error = ref(null)
|
||||||
|
const users = ref([])
|
||||||
|
const dashboardResponse = ref(null)
|
||||||
|
const totalExecutions = ref(0);
|
||||||
|
const totalTokens = ref(0);
|
||||||
|
|
||||||
|
|
||||||
|
const userPrefStore = UserPrefStore()
|
||||||
|
const loadingStore = LoadingStore()
|
||||||
|
|
||||||
|
async function fetchExecutionForProject() { //funzione che recupera le esecuzioni dei progetti
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
await DashboardScenarioService.getExecScenarioByProject(userPrefStore.selectedProject).then(resp => {
|
||||||
|
projectScenarios.value = resp.data;
|
||||||
|
allScenarios.value = [...projectScenarios.value]
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//funzioni per la dashboard
|
||||||
|
async function loadProjects() { //carica tutti i progetti
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getProjects(); // prende i progetti dal back
|
||||||
|
projects.value = response.data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento progetti:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento dei progetti';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadExecutions(filters) { //carica i dati per le esecuzioni
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getExecutions(filters);
|
||||||
|
|
||||||
|
console.log("RISPOSTA RAW DA API:", response)
|
||||||
|
|
||||||
|
executions.value = response.data
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento executions:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento delle esecuzioni';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadExecutionsStats (filters) {
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getExecutionsStats(filters);
|
||||||
|
|
||||||
|
console.log("RISPOSTA RAW DA API:", response)
|
||||||
|
|
||||||
|
dashboardResponse.value = response.data
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento executions:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento delle esecuzioni';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadUsers(filters) {
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getUsers(filters);
|
||||||
|
users.value = response.data;
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento users:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento delle esecuzioni';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadChats(filters) { //carica i dati per la tabella della chat
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getChats(filters);
|
||||||
|
chats.value = response.data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento chats:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento delle chat';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadScenarios(filters) {
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getScenarios(filters);
|
||||||
|
allScenarios.value = response.data;
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento scenari:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento degli scenari';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadChatStats(filters) {
|
||||||
|
try {
|
||||||
|
loadingStore.scenario_loading = true;
|
||||||
|
const response = await DashboardScenarioService.getChatStats(filters);
|
||||||
|
|
||||||
|
console.log("RISPOSTA :", response)
|
||||||
|
|
||||||
|
chatStats.value = response.data
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Errore caricamento chat:', err);
|
||||||
|
error.value = err.message || 'Errore durante il caricamento delle chat';
|
||||||
|
} finally {
|
||||||
|
loadingStore.scenario_loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
fetchExecutionForProject,
|
||||||
|
projects,
|
||||||
|
executions,
|
||||||
|
chats,
|
||||||
|
error,
|
||||||
|
loadProjects,
|
||||||
|
loadExecutions,
|
||||||
|
loadChats,
|
||||||
|
loadUsers,
|
||||||
|
loadScenarios,
|
||||||
|
allScenarios,
|
||||||
|
dashboardResponse,
|
||||||
|
totalExecutions,
|
||||||
|
totalTokens,
|
||||||
|
loadExecutionsStats,
|
||||||
|
loadChatStats,
|
||||||
|
chatStats
|
||||||
|
}
|
||||||
|
})
|
||||||
1110
src/views/pages/DashExecution.vue
Normal file
1110
src/views/pages/DashExecution.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user