Create document picklist and refactor axios call
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { ScenarioExecutionService } from '../service/ScenarioExecutionService';
|
||||
import { ScenarioService } from '../service/ScenarioService';
|
||||
import { LoadingStore } from './LoadingStore';
|
||||
|
||||
export const ScenarioExecutionStore = defineStore('scenario_execution_store', () => {
|
||||
const lstScenarioExecution = ref([]);
|
||||
const selectedExecScenario = ref(null);
|
||||
const currentScenario = ref({});
|
||||
const currentExecution = ref(null);
|
||||
const executionProgress = ref(null);
|
||||
const loadingStore = LoadingStore();
|
||||
|
||||
const totalRecords = ref(0); // Numero totale di record
|
||||
@@ -30,6 +34,53 @@ export const ScenarioExecutionStore = defineStore('scenario_execution_store', ()
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione per recuperare un singolo scenario
|
||||
async function fetchScenario(id) {
|
||||
try {
|
||||
const response = await ScenarioService.getScenarioById(id);
|
||||
currentScenario.value = response.data;
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching scenario:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione per eseguire uno scenario
|
||||
async function executeScenario(data) {
|
||||
try {
|
||||
const response = await ScenarioService.executeScenarioAsync(data);
|
||||
currentExecution.value = response.data;
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error executing scenario:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione per recuperare i dettagli di esecuzione
|
||||
async function getScenarioExecution(execId) {
|
||||
try {
|
||||
const response = await ScenarioService.getScenarioExecution(execId);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error getting scenario execution:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione per recuperare il progresso di esecuzione
|
||||
async function getExecutionProgress(execId) {
|
||||
try {
|
||||
const response = await ScenarioService.getExecutionProgress(execId);
|
||||
executionProgress.value = response.data;
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error getting execution progress:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFile(filePath, executionId) {
|
||||
loadingStore.scenario_loading = true;
|
||||
try {
|
||||
@@ -80,6 +131,18 @@ export const ScenarioExecutionStore = defineStore('scenario_execution_store', ()
|
||||
return totalRecords.value;
|
||||
});
|
||||
|
||||
const getCurrentScenario = computed(() => {
|
||||
return currentScenario.value;
|
||||
});
|
||||
|
||||
const getCurrentExecution = computed(() => {
|
||||
return currentExecution.value;
|
||||
});
|
||||
|
||||
const getExecutionProgressData = computed(() => {
|
||||
return executionProgress.value;
|
||||
});
|
||||
|
||||
const setSelectedExecScenario = (execScenario) => {
|
||||
selectedExecScenario.value = execScenario;
|
||||
};
|
||||
@@ -96,6 +159,9 @@ export const ScenarioExecutionStore = defineStore('scenario_execution_store', ()
|
||||
const resetStore = () => {
|
||||
lstScenarioExecution.value = [];
|
||||
selectedExecScenario.value = null;
|
||||
currentScenario.value = {};
|
||||
currentExecution.value = null;
|
||||
executionProgress.value = null;
|
||||
totalRecords.value = 0;
|
||||
currentPage.value = 0;
|
||||
pageSize.value = 10;
|
||||
@@ -106,15 +172,22 @@ export const ScenarioExecutionStore = defineStore('scenario_execution_store', ()
|
||||
getCurrentPage,
|
||||
getPageSize,
|
||||
getTotalRecords,
|
||||
getCurrentScenario,
|
||||
getCurrentExecution,
|
||||
getExecutionProgressData,
|
||||
fetchScenariosExecution,
|
||||
fetchScenario,
|
||||
executeScenario,
|
||||
getScenarioExecution,
|
||||
getExecutionProgress,
|
||||
downloadFile,
|
||||
selectedExecScenario,
|
||||
lstScenarioExecution,
|
||||
scenariosExecution,
|
||||
getSelectedExecScenario,
|
||||
setSelectedExecScenario,
|
||||
updateFilters, // Aggiunto per aggiornare i filtri
|
||||
updateFilters,
|
||||
filters,
|
||||
resetStore // Rende disponibile i filtri come parte dello store
|
||||
resetStore
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user