@@ -91,8 +112,10 @@ import JsonEditorVue from 'json-editor-vue';
import { MdPreview } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
import ProgressSpinner from 'primevue/progressspinner';
+import { useToast } from 'primevue/usetoast';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
+import { ScenarioService } from '../../service/ScenarioService.js';
import { ScenarioExecutionStore } from '../../stores/ScenarioExecutionStore.js';
const router = useRouter();
@@ -107,10 +130,12 @@ const formData = ref({});
const exec_id = ref(null);
const exec_scenario = ref({});
const debug_modal = ref(false);
+const rating = ref(null);
const scenario_execution_store = ScenarioExecutionStore();
const execution = scenario_execution_store.getSelectedExecScenario;
const execution_id = ref(null)
const inputs = ref(null);
+const toast = useToast();
onMounted(() => {
@@ -136,12 +161,46 @@ const retrieveScenarioExec = (id) => {
scenario.value = response.data.scenario
exec_scenario.value = response.data
data_loaded.value = true;
+ rating.value = response.data.rating
scenario_output.value = response.data.execSharedMap.scenario_output;
exec_id.value = response.data.scenarioExecution_id
inputs.value = response.data.scenarioExecutionInput.inputs
});
};
+async function updateRating(newRating) {
+
+ loading_data.value = true;
+ ScenarioService.updateScenarioExecRating(execution_id.value,newRating.value).then((response) => {
+
+ console.log('response:', response);
+ if (response.data === "OK") {
+ rating.value = newRating.value;
+ console.log('Rating aggiornato con successo:', response.data);
+ 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;
+ });
+
+
+}
+
diff --git a/src/views/pages/ScenarioExec.vue b/src/views/pages/ScenarioExec.vue
index 17083b2..fdf4f84 100644
--- a/src/views/pages/ScenarioExec.vue
+++ b/src/views/pages/ScenarioExec.vue
@@ -71,8 +71,18 @@
+