hermione scenarios
This commit is contained in:
@@ -1,6 +1,81 @@
|
||||
<template>
|
||||
<div className="card">
|
||||
<h5>Empty Page</h5>
|
||||
<p>Use this page to start from scratch and place your custom content.</p>
|
||||
<div v-if="loading">Loading...</div>
|
||||
<div v-else>
|
||||
<div v-for="input in scenario.inputs" :key="input.name" class="input-container">
|
||||
<label :for="input.name"><b>{{ input.name }}</b></label>
|
||||
<div class="input-wrapper">
|
||||
<InputText :id="input.name" v-model="value" :placeholder="`Type ${input.name}`" class="full-width-input"/>
|
||||
<Button label="Send" severity="info" @click="execScenario(input)" class="send-button"></Button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ scenario_output }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import axios from 'axios';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const value = ref('');
|
||||
const scenario = ref(null);
|
||||
const inputs = ref([]);
|
||||
const scenario_output = ref('');
|
||||
const loading = ref(false);
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
const id = route.params.id;
|
||||
axios.get('http://localhost:8081/scenarios/' + id )
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
loading.value = false
|
||||
scenario.value = response.data
|
||||
});
|
||||
});
|
||||
|
||||
const execScenario = (input) => {
|
||||
const data = {
|
||||
scenario_id: scenario.value.id,
|
||||
inputs: {
|
||||
[input.name]: value.value
|
||||
}
|
||||
}
|
||||
|
||||
console.log(data)
|
||||
|
||||
axios.post('http://localhost:8081/scenarios/execute', data)
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
scenario_output.value = response.data.stringOutput
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.input-container {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.send-button {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.full-width-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
87
src/views/pages/ScenarioList.vue
Normal file
87
src/views/pages/ScenarioList.vue
Normal 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>
|
||||
Reference in New Issue
Block a user