diff --git a/src/service/ScenarioService.js b/src/service/ScenarioService.js
index 9b05834..aeb5bc7 100644
--- a/src/service/ScenarioService.js
+++ b/src/service/ScenarioService.js
@@ -17,10 +17,22 @@ export const ScenarioService = {
return axios.get('/scenariosCross')
},
- getExecScenariosByUser() {
- return axios.get('/scenariosByUser')
+
+ // getExecScenariosByUser(page = 0, size = 10) {
+ // return axios.get('/executions', {
+ // params: {
+ // page: page,
+ // size: size }
+ // });
+ // }
- },
+ getExecScenariosByUser(page = 0, size = 10, filters = {}, sortField, sortOrder) {
+ // Filtri potrebbero essere vuoti, quindi rimuoviamoli se non necessari
+ const requestBody = { page, size, ...filters, sortField, sortOrder };
+ return axios.post('/executions', requestBody);
+ }
+
+ ,
getScenariosForRE(){
return axios.get('/getScenariosForRE')
},
diff --git a/src/stores/ScenarioExecutionStore.js b/src/stores/ScenarioExecutionStore.js
index c050058..759aba4 100644
--- a/src/stores/ScenarioExecutionStore.js
+++ b/src/stores/ScenarioExecutionStore.js
@@ -3,34 +3,76 @@ import { computed, ref } from 'vue';
import { ScenarioService } from '../service/ScenarioService';
import { LoadingStore } from './LoadingStore';
-
export const ScenarioExecutionStore = defineStore('scenario_execution_store', () => {
+ const lstScenarioExecution = ref([]);
+ const selectedExecScenario = ref(null);
+ const loadingStore = LoadingStore();
- const lstScenarioExecution = ref([])
- const selectedExecScenario = ref(null)
- const loadingStore = LoadingStore()
+ const totalRecords = ref(0); // Numero totale di record
+ const currentPage = ref(0); // Pagina corrente
+ const pageSize = ref(10); // Numero di record per pagina
+ const filters = ref({}); // Oggetto per memorizzare i filtri
-
- async function fetchScenariosExecution() {
+ // Funzione per recuperare le esecuzioni con filtri e paginazione
+ async function fetchScenariosExecution(page = 0, size = 10, filters, sortField, sortOrder) {
loadingStore.scenario_loading = true;
- await ScenarioService.getExecScenariosByUser().then(resp => {
- lstScenarioExecution.value = resp.data;
+ try {
+ console.log("Recupero delle esecuzioni con filtri:", page, size, filters, sortField, sortOrder);
+ const resp = await ScenarioService.getExecScenariosByUser(page, size, filters, sortField, sortOrder); // Passiamo anche i filtri
+ lstScenarioExecution.value = resp.data.content;
+ totalRecords.value = resp.data.totalElements;
+ currentPage.value = page;
+ pageSize.value = size;
+ } catch (error) {
+ console.error("Errore nel recupero delle esecuzioni:", error);
+ } finally {
loadingStore.scenario_loading = false;
- });
-
+ }
}
+
const scenariosExecution = computed(() => {
- return lstScenarioExecution.value
- })
+ return lstScenarioExecution.value;
+ });
const getSelectedExecScenario = computed(() => {
- return selectedExecScenario.value
- })
+ return selectedExecScenario.value;
+ });
- async function setSelectedExecScenario(execScenario){
- selectedExecScenario.value = execScenario
- console.log("selectedExecScenario", selectedExecScenario.value);
- }
-
- return { fetchScenariosExecution, selectedExecScenario, lstScenarioExecution, scenariosExecution, getSelectedExecScenario, setSelectedExecScenario}
- })
\ No newline at end of file
+ const getCurrentPage = computed(() => {
+ return currentPage.value;
+ });
+
+ const getPageSize = computed(() => {
+ return pageSize.value;
+ });
+
+ const getTotalRecords = computed(() => {
+ return totalRecords.value;
+ });
+
+ const setSelectedExecScenario = (execScenario) => {
+ selectedExecScenario.value = execScenario;
+ };
+
+ // Funzione per aggiornare i filtri
+ const updateFilters = (newFilters) => {
+ console.log("Nuovi filtri:", newFilters);
+ filters.value = newFilters;
+ filters.value = encodeURIComponent(JSON.stringify(newFilters));
+ fetchScenariosExecution(currentPage.value, pageSize.value, filters.value); // Ricarica con i nuovi filtri
+ };
+
+ return {
+ getCurrentPage,
+ getPageSize,
+ getTotalRecords,
+ fetchScenariosExecution,
+ selectedExecScenario,
+ lstScenarioExecution,
+ scenariosExecution,
+ getSelectedExecScenario,
+ setSelectedExecScenario,
+ updateFilters, // Aggiunto per aggiornare i filtri
+ filters // Rende disponibile i filtri come parte dello store
+ };
+});
diff --git a/src/views/pages/ScenarioExecList.vue b/src/views/pages/ScenarioExecList.vue
index 0542ada..e0bdab2 100644
--- a/src/views/pages/ScenarioExecList.vue
+++ b/src/views/pages/ScenarioExecList.vue
@@ -3,55 +3,46 @@
-
+
Executions List
-
-
-
+ tableStyle="min-width: 70rem"
+ @page="onPage"
+ @sort="onSort"
+ removableSort>
+
+
+
-
+
+
+
+
-
+
{{ slotProps.data.scenario?.name }}
@@ -63,23 +54,13 @@
-
-
+
+
+
+
-
-
-
- {{ slotProps.data.execSharedMap?.user_input?.selected_project }}
-
-
-
-
-
-
-
@@ -87,12 +68,14 @@
-
+
+
+
-
@@ -110,54 +93,47 @@
placeholder="Filter by Date"
/>
-
+ -->
+
+
+ {{ moment(slotProps.data.startDate).format('DD-MM-YYYY HH:mm:ss') }}
+
+
+
-
- {{ slotProps.data.scenario?.aiModel?.apiProvider }}
+ {{ slotProps.data.scenario?.aiModel?.model }}
+
-
-
-
-
-
-
-
- {{ slotProps.data.scenario?.aiModel?.model || 'N/A' }}
-
-
-
-
-
-
-
-
-
- {{ slotProps.data.usedTokens || 'N/A' }}
-
-
-
-
-
+
+ style="min-width: 12rem" :showApplyButton="false" :showAddButton="false" :showClearButton="false">
{{ slotProps.data.executedByUsername || 'N/A' }}
-
+
+
+
@@ -195,7 +171,6 @@ import ProgressSpinner from 'primevue/progressspinner';
import { useToast } from 'primevue/usetoast';
import { onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
-import { ScenarioService } from '../../service/ScenarioService.js';
import { ScenarioExecutionStore } from '../../stores/ScenarioExecutionStore.js';
import { UserPrefStore } from '../../stores/UserPrefStore.js';
@@ -217,38 +192,33 @@ const listScenarios = ref([]);
const scenario_execution_store = ScenarioExecutionStore();
const toast = useToast();
const userPrefStore = UserPrefStore();
+const records = ref(788);
+const actualPage = ref(0);
+const actualPageSize = ref(10);
+const sortField = ref(null);
+const sortOrder = ref(null);
+
const filters = ref({
- global: { value: null, matchMode: FilterMatchMode.CONTAINS },
- 'id': { value: null, matchMode: FilterMatchMode.CONTAINS },
+ '_id': { operator: FilterOperator.AND,
+ constraints: [{ value: null, matchMode: FilterMatchMode.CONTAINS }]
+ },
'scenario.name': {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.CONTAINS }]
},
- 'execSharedMap.user_input.selected_project': {
- operator: FilterOperator.AND,
- constraints: [{value: null, matchMode: FilterMatchMode.CONTAINS }]
- },
'execSharedMap.user_input.selected_application': {
operator: FilterOperator.AND,
constraints: [{
- value: null, matchMode: FilterMatchMode.CONTAINS
+ value: userPrefStore.getSelApp.fe_name, matchMode: FilterMatchMode.CONTAINS
}]
},
- 'scenario.aiModel.apiProvider': {
- operator: FilterOperator.AND,
- constraints: [{ value: null, matchMode: FilterMatchMode.CONTAINS }]
- },
'scenario.aiModel.model': {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.CONTAINS }]
},
- 'usedTokens': {
- operator: FilterOperator.AND,
- constraints: [{ value: null, matchMode: FilterMatchMode.CONTAINS }]
- },
'executedByUsername': {
operator: FilterOperator.AND,
@@ -263,10 +233,17 @@ const filters = ref({
});
onMounted(() => {
- scenario_execution_store.fetchScenariosExecution()
updateFilters();
});
watch(() => route.params.name, updateFilters);
+// watch([() => filters.value], () => {
+// scenario_execution_store.updateFilters(filters.value); // Applica i filtri e carica i dati
+// });
+
+// watch([() => filters.value, () => first.value], () => {
+// fetchData(Math.floor(first.value / scenario_execution_store.getPageSize), scenario_execution_store.getPageSize, filters.value);
+// });
+
function updateFilters() {
const selectedScenario = userPrefStore.getSelScenario;
@@ -274,65 +251,63 @@ function updateFilters() {
if (selectedScenario && route.params.name!=='all') {
console.log('selectedScenario: im in');
filters.value['scenario.name'].constraints[0].value = selectedScenario;
+
}else{
filters.value['scenario.name'].constraints[0].value = null;
}
+ fetchData(0, 10);
}
-async function updateRating(rowData, newRating) {
-
- // Aggiorna il rating nell'oggetto prima di inviarlo
- rowData.rating = newRating.value;
- console.log('data rating:', rowData);
- // Mostra un loader se necessario
- loading_data.value = true;
- ScenarioService.updateScenarioExecRating(rowData).then((response) => {
-
- console.log('response:', response);
- if (response.data === "OK") {
- console.log('Rating aggiornato con successo:', response.data);
- scenario_execution_store.fetchScenariosExecution()
- toast.add({
- severity: 'success', // Tipo di notifica (successo)
- summary: 'Successo', // Titolo della notifica
- detail: 'Rating updated with success.', // Messaggio dettagliato
- life: 3000 // Durata della notifica in millisecondi
- });
- } else {
- console.error('Errore nell\'aggiornamento del rating', response.data);
- toast.add({
- severity: 'error', // Tipo di notifica (errore)
- summary: 'Errore', // Titolo della notifica
- detail: 'Error updating rating. Try later.', // Messaggio dettagliato
- life: 3000 // Durata della notifica in millisecondi
- });
- }
- }).catch((error) => {
- console.error('Errore durante la chiamata al backend:', error);
- }).finally(() => {
- loading_data.value = false;
- });
-
-
+function fetchDataWithFilters(filterCallback) {
+ filterCallback();
+ fetchData(0, actualPageSize.value);
}
+function onSort(event) {
+ console.log('Sorting event:', event);
+
+ sortField.value = event.sortField;
+ sortOrder.value = event.sortOrder;
+
+ fetchData(0,actualPageSize.value);
+}
+
+const fetchData = async (page, size) => {
+ loading_data.value = true;
+
+ try {
+ scenario_execution_store.fetchScenariosExecution(page, size, filters.value, sortField.value, sortOrder.value);
+ //const response = await ScenarioService.getScenarioExecutionList(page, size, filtersForRequest);
+ // aggiorna il store con i risultati della query
+ } catch (error) {
+ console.error('Error fetching data', error);
+ } finally {
+ loading_data.value = false;
+ }
+};
+
const goToScenarioExec = (execScenarioItem) => {
console.log(execScenarioItem);
+
+ router.push({ name: 'scenario-exec-history', query: { id:execScenarioItem.id } });
- scenario_execution_store.setSelectedExecScenario(execScenarioItem).then(() => {
- router.push({ name: 'scenario-exec-history', query: { id:execScenarioItem.id } });
- });
+ // scenario_execution_store.setSelectedExecScenario(execScenarioItem).then(() => {
+ // router.push({ name: 'scenario-exec-history', query: { id:execScenarioItem.id } });
+ // });
};
-function onPage(event) {
- first.value = event.first;
-}
-
-// onBeforeRouteLeave((to, from, next) => {
-// userPrefStore.setSelectedScenario(null);
-// console.log('selectedScenario: im out');
-// });
+ function onPage(event) {
+ actualPage.value = event.page;
+ actualPageSize.value = event.rows;
+ fetchData(event.page, event.rows);
+ console.log('event onpage:', event);
+ //updateFilters();
+ }
+// function onPage(event) {
+// first.value = event.first; // Imposta la pagina corrente
+// fetchData(Math.floor(first.value / scenario_execution_store.getPageSize), scenario_execution_store.getPageSize);
+// }