hermione scenarios

This commit is contained in:
paola.trabucco
2024-08-01 15:36:09 +02:00
parent e466ff879e
commit fa96add05b
7 changed files with 195 additions and 150 deletions

View File

@@ -0,0 +1,87 @@
<template>
<div v-if="loading">Loading...</div>
<div v-else>
<DataView :value="scenarios" :layout="layout" paginator :rows="5">
<template #header>
<div class="flex justify-end">
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
<template #option="{ option }">
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
</template>
</SelectButton>
</div>
</template>
<template #list="slotProps">
<div class="flex flex-col">
<div v-for="(item, index) in slotProps.items" :key="index">
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
<div>
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.description }}</span>
</div>
</div>
<div class="flex flex-col md:items-end gap-8">
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button @click="executeScenario(item.id)" label="Load" class="flex-auto md:flex-initial whitespace-nowrap"></Button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid="slotProps">
<div class="grid grid-cols-12 gap-4">
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.description }}</span>
<div class="pt-6">
<div class="flex flex-col gap-6 mt-6">
<div class="flex gap-2">
<Button @click="executeScenario(item.id)" label="Load" class="flex-auto whitespace-nowrap"></Button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script setup>
import DataView from 'primevue/dataview';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { ScenarioService } from '../../service/ScenarioService.js';
const router = useRouter()
const layout = ref('grid');
const options = ref(['list', 'grid']);
const scenarios = ref([])
const loading = ref(false)
onMounted(() => {
loading.value = true
ScenarioService.getScenarios().then(resp=>{
scenarios.value = resp.data
loading.value = false
console.log(scenarios.value)
})
});
const executeScenario = (id) => {
console.log(id);
router.push({ name: 'scenario-exec', params: { id: id } });
}
</script>