Added Cia Scenario Viewer
This commit is contained in:
246
src/views/pages/CiaScenarioExec.vue
Normal file
246
src/views/pages/CiaScenarioExec.vue
Normal file
@@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<div v-if="loading" class="flex justify-center">
|
||||
<ProgressSpinner style="width: 50px; height: 50px; margin-top: 50px" strokeWidth="3" fill="transparent"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="flex items-center justify-between p-2">
|
||||
<h1>
|
||||
{{ scenario.name }}
|
||||
</h1>
|
||||
<Button
|
||||
@click="back()"
|
||||
label="Load"
|
||||
class="flex items-center text-sm">
|
||||
<ChevronLeftIcon name="chevron-left" class="w-4 h-5 text-white"/>
|
||||
<span>Back to Scenarios</span>
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex mt-6">
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<template v-if="scenario.inputs && scenario.inputs.length === 1">
|
||||
<div class="input-container flex items-center">
|
||||
<div class="flex-grow">
|
||||
<label :for="scenario.inputs[0].name"><h2>{{ scenario.inputs[0].label }}</h2></label>
|
||||
<div class="input-wrapper">
|
||||
<component
|
||||
:is="getInputComponent(scenario.inputs[0].type)"
|
||||
:id="scenario.inputs[0].name"
|
||||
v-model="formData[scenario.inputs[0].name]"
|
||||
:options="scenario.inputs[0].options"
|
||||
class="full-width-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<Button label="Send" @click="execScenario" class="mt-9 ml-4"/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div v-for="input in scenario.inputs" :key="input.name" class="input-container">
|
||||
<label :for="input.name"><b>{{ input.label }}</b></label>
|
||||
<div class="input-wrapper">
|
||||
<component
|
||||
:is="getInputComponent(input.type)"
|
||||
:id="input.name"
|
||||
v-model="formData[input.name]"
|
||||
:options="input.options"
|
||||
class="full-width-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<Button label="Submit" @click="execScenario" class=""/>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading_data" class="flex justify-center">
|
||||
<ProgressSpinner style="width: 30px; height: 30px; margin: 30px" strokeWidth="6" fill="transparent"/>
|
||||
</div>
|
||||
<div v-if="data_loaded">
|
||||
<Panel class="mt-6">
|
||||
<template #header>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="font-bold">Hermione Response</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #icons>
|
||||
<div class="flex justify-end">
|
||||
<Button severity="secondary" rounded @click="openDebug" v-tooltip.left="'View code'">
|
||||
<i class="pi pi-code"></i>
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<div v-if="scenario_output != null">
|
||||
<ChangeImpactOutputViewer :scenario_output="scenario_output" />
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
<Dialog v-model:visible="debug_modal" maximizable modal :header="scenario.name" :style="{ width: '75%' }" :breakpoints="{ '1199px': '75vw', '575px': '90vw' }">
|
||||
|
||||
<div class="flex">
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<JsonEditorVue
|
||||
v-model="exec_scenario"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import { ChevronLeftIcon } from '@heroicons/vue/24/solid';
|
||||
import axios from 'axios';
|
||||
import JsonEditorVue from 'json-editor-vue';
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
import Select from 'primevue/select';
|
||||
import Textarea from 'primevue/textarea';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const value = ref('');
|
||||
const scenario = ref({});
|
||||
const scenario_output = ref(null);
|
||||
const loading = ref(false);
|
||||
const data_loaded = ref(false);
|
||||
const loading_data = ref(false);
|
||||
const formData = ref({});
|
||||
const exec_id = ref(null);
|
||||
const exec_scenario = ref({});
|
||||
const debug_modal = ref(false)
|
||||
// Variable to hold the interval ID
|
||||
let pollingInterval = null;
|
||||
|
||||
onMounted(() => {
|
||||
loading.value = true
|
||||
const id = '66f4ff309766132cadc97ebf' //TODO: Remove fixed scenario id route.params.id;
|
||||
|
||||
axios.get('/scenarios/' + id )
|
||||
.then(response => {
|
||||
loading.value = false
|
||||
scenario.value = response.data
|
||||
});
|
||||
});
|
||||
|
||||
const getInputComponent = (type) => {
|
||||
switch (type) {
|
||||
case 'text':
|
||||
return InputText;
|
||||
case 'textarea':
|
||||
return Textarea;
|
||||
case 'select':
|
||||
return Select;
|
||||
default:
|
||||
return InputText;
|
||||
}
|
||||
};
|
||||
|
||||
const execScenario = () => {
|
||||
loading_data.value = true;
|
||||
data_loaded.value = false;
|
||||
|
||||
const data = {
|
||||
scenario_id: scenario.value.id,
|
||||
inputs: { ...formData.value }
|
||||
};
|
||||
|
||||
axios.post('/scenarios/execute-async', data)
|
||||
.then(response => {
|
||||
scenario_output.value = response.data.stringOutput;
|
||||
exec_id.value = response.data.scenarioExecution_id
|
||||
// Start polling
|
||||
startPolling();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error executing scenario:', error);
|
||||
});
|
||||
};
|
||||
|
||||
const back = () => {
|
||||
router.push({ name: 'scenario-list'});
|
||||
}
|
||||
|
||||
const openDebug = () => {
|
||||
|
||||
axios.get('/scenarios/execute/'+ exec_id.value).then(resp =>{
|
||||
exec_scenario.value = resp.data
|
||||
debug_modal.value = true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const pollBackendAPI = () => {
|
||||
|
||||
axios.get('/scenarios/getExecutionProgress/'+exec_id.value).then(response => {
|
||||
if (response.data.status == 'OK' || response.data.status == 'ERROR') {
|
||||
console.log("Condition met, stopping polling.");
|
||||
stopPolling();
|
||||
|
||||
loading_data.value = false;
|
||||
data_loaded.value = true;
|
||||
scenario_output.value = response.data.stringOutput;
|
||||
exec_id.value = response.data.scenarioExecution_id
|
||||
|
||||
} else {
|
||||
console.log("Condition not met, polling continues.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function to start polling
|
||||
function startPolling() {
|
||||
// Set polling interval (every 5 seconds in this case)
|
||||
pollingInterval = setInterval(pollBackendAPI, 2500);
|
||||
console.log("Polling started.");
|
||||
}
|
||||
|
||||
// Function to stop polling
|
||||
function stopPolling() {
|
||||
clearInterval(pollingInterval);
|
||||
console.log("Polling stopped.");
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.input-container {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.full-width-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.editor ol {
|
||||
list-style-type: decimal !important;
|
||||
}
|
||||
|
||||
.editor ul {
|
||||
list-style-type: disc !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -1,87 +0,0 @@
|
||||
<template>
|
||||
<div className="card">
|
||||
<h5>Ks document</h5>
|
||||
<form @submit.prevent="submitForm">
|
||||
<div class="p-field">
|
||||
<label for="description">Description</label>
|
||||
<InputText id="description" v-model="ksdocument.description" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="fileName">File Name</label>
|
||||
<InputText id="fileName" v-model="ksdocument.fileName" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="filePath">File Path</label>
|
||||
<InputText id="filePath" v-model="ksdocument.filePath" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="ingestionDate">Ingestion Date</label>
|
||||
<InputText id="ingestionDate" v-model="ksdocument.ingestionDate" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="defaultChunkSize">Default Chunk Size</label>
|
||||
<InputNumber id="defaultChunkSize" v-model="ksdocument.ingestionInfo.defaultChunkSize" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="maxNumberOfChunks">Max Number of Chunks</label>
|
||||
<InputNumber id="maxNumberOfChunks" v-model="ksdocument.ingestionInfo.maxNumberOfChunks" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="minChunkSize">Min Chunk Size</label>
|
||||
<InputNumber id="minChunkSize" v-model="ksdocument.ingestionInfo.minChunkSize" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="minChunkSizeToEmbed">Min Chunk Size To Embed</label>
|
||||
<InputNumber id="minChunkSizeToEmbed" v-model="ksdocument.ingestionInfo.minChunkSizeToEmbed" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="type">Type</label>
|
||||
<InputText id="type" v-model="ksdocument.ingestionInfo.type" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="ingestionStatus">Ingestion Status</label>
|
||||
<InputText id="ingestionStatus" v-model="ksdocument.ingestionStatus" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="name">Name</label>
|
||||
<InputText id="name" v-model="ksdocument.name" />
|
||||
</div>
|
||||
<div class="p-field">
|
||||
<label for="metadata">Metadata</label>
|
||||
<InputTextarea id="metadata" v-model="ksdocument.ingestionInfo.metadata" />
|
||||
</div>
|
||||
<Button label="Submit" type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onMounted } from 'vue'
|
||||
import axios from 'axios';
|
||||
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { data } from 'autoprefixer';
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const ksdocument = ref({ingestionInfo:{}});
|
||||
|
||||
onMounted(() => {
|
||||
axios.get('http://localhost:8082/ksdocuments/'+route.params.id)
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
ksdocument.value = response.data;
|
||||
});
|
||||
});
|
||||
|
||||
const getStatus = (data) => {
|
||||
if (data.ingestionStatus === 'INGESTED') {
|
||||
return 'success';
|
||||
} else if (data.ingestionStatus === 'NEW') {
|
||||
return 'danger';
|
||||
} else {
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,74 +0,0 @@
|
||||
<template>
|
||||
<div className="card">
|
||||
|
||||
<DataTable
|
||||
:value="ksdocuments"
|
||||
:paginator="true"
|
||||
:rows="10"
|
||||
dataKey="id"
|
||||
:rowHover="true"
|
||||
showGridlines
|
||||
>
|
||||
<template #header>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-xl font-bold">KS Documents</span>
|
||||
<Button icon="pi pi-plus" rounded raised @click="newKsDocument()" />
|
||||
</div>
|
||||
</template>
|
||||
<Column field="name" header="Name"></Column>
|
||||
<Column field="fileName" header="File Name"></Column>
|
||||
<Column field="ingestionStatus" header="Status">
|
||||
<template #body="slotProps">
|
||||
<Tag :value="slotProps.data.ingestionStatus" :severity="getStatus(slotProps.data)" />
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="ingestionDate" header="Ingestion Date"></Column>
|
||||
<Column headerStyle="width: 5rem; text-align: center" bodyStyle="text-align: center; overflow: visible">
|
||||
<template #body="slotProps">
|
||||
<Button type="button" icon="pi pi-pencil" rounded @click="editKsDocument(slotProps.data)"/>
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onMounted } from 'vue'
|
||||
import axios from 'axios';
|
||||
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
const ksdocuments = ref(null);
|
||||
const scenario = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
axios.get('http://localhost:8082/fe-api/ksdocuments')
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
ksdocuments.value = response.data;
|
||||
});
|
||||
});
|
||||
|
||||
const getStatus = (data) => {
|
||||
if (data.ingestionStatus === 'INGESTED') {
|
||||
return 'success';
|
||||
} else if (data.ingestionStatus === 'NEW') {
|
||||
return 'danger';
|
||||
} else {
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
|
||||
const editKsDocument = (data) => {
|
||||
console.log(data);
|
||||
router.push({ name: 'ks-document-edit', params: { id: data.id } });
|
||||
}
|
||||
|
||||
const newKsDocument = () => {
|
||||
console.log('new');
|
||||
router.push({ name: 'ks-document-new'});
|
||||
|
||||
}
|
||||
</script>
|
||||
154
src/views/pages/OldScenarioExec.vue
Normal file
154
src/views/pages/OldScenarioExec.vue
Normal file
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<div v-if="loading" class="flex justify-center">
|
||||
<ProgressSpinner style="width: 50px; height: 50px; margin-top: 50px" strokeWidth="3" fill="transparent"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="flex items-center justify-between p-2">
|
||||
|
||||
<Button
|
||||
@click="back()"
|
||||
label="Load"
|
||||
class="flex items-center text-sm">
|
||||
<ChevronLeftIcon name="chevron-left" class="w-4 h-5 text-white"/>
|
||||
<span>Back to Scenarios</span>
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex mt-6">
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<div class="input-container flex items-center" v-if="!data_loaded">
|
||||
<div class="flex-grow">
|
||||
<label ><h2>Execution Id</h2></label>
|
||||
<div class="input-wrapper">
|
||||
<InputText v-model="execution_id" class="full-width-input" />
|
||||
</div>
|
||||
</div>
|
||||
<Button label="Find" @click="retrieveScenarioExec" class="mt-9 ml-4" />
|
||||
</div>
|
||||
<h1>
|
||||
{{ scenario.name }}
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading_data" class="flex justify-center">
|
||||
<ProgressSpinner style="width: 30px; height: 30px; margin: 30px" strokeWidth="6" fill="transparent"/>
|
||||
</div>
|
||||
<div v-if="data_loaded">
|
||||
<Panel class="mt-6">
|
||||
<template #header>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="font-bold">Hermione Response</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #icons>
|
||||
<div class="flex justify-end">
|
||||
<Button severity="secondary" rounded @click="openDebug" v-tooltip.left="'View code'">
|
||||
<i class="pi pi-code"></i>
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<div v-if="scenario_output != null">
|
||||
<!--<MdPreview class="editor" v-model="scenario_output" language="en-US" />-->
|
||||
<ChangeImpactOutputViewer :scenario_output="scenario_output" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
<Dialog v-model:visible="debug_modal" maximizable modal :header="scenario.name" :style="{ width: '75%' }" :breakpoints="{ '1199px': '75vw', '575px': '90vw' }">
|
||||
|
||||
<div class="flex">
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<JsonEditorVue
|
||||
v-model="exec_scenario"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import ChangeImpactOutputViewer from '@/components/ChangeImpactOutputViewer.vue';
|
||||
import { ChevronLeftIcon } from '@heroicons/vue/24/solid';
|
||||
import axios from 'axios';
|
||||
import JsonEditorVue from 'json-editor-vue';
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
import { ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const value = ref('');
|
||||
const scenario = ref({});
|
||||
const scenario_output = ref(null);
|
||||
const loading = ref(false);
|
||||
const data_loaded = ref(false);
|
||||
const loading_data = ref(false);
|
||||
const formData = ref({});
|
||||
const exec_id = ref(null);
|
||||
const exec_scenario = ref({});
|
||||
const debug_modal = ref(false)
|
||||
const execution_id=ref("");
|
||||
|
||||
|
||||
const retrieveScenarioExec = () => {
|
||||
const id = execution_id.value
|
||||
loading.value = true
|
||||
|
||||
axios.get('/execution?id=' + id )
|
||||
.then(response => {
|
||||
loading.value = false
|
||||
scenario.value = response.data.scenario
|
||||
exec_scenario.value = response.data
|
||||
data_loaded.value = true;
|
||||
scenario_output.value = response.data.execSharedMap.scenario_output;
|
||||
exec_id.value = response.data.scenarioExecution_id
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
const back = () => {
|
||||
router.push({ name: 'scenario-list'});
|
||||
}
|
||||
|
||||
const openDebug = () => {
|
||||
debug_modal.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.input-container {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.full-width-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.editor ol {
|
||||
list-style-type: decimal !important;
|
||||
}
|
||||
|
||||
.editor ul {
|
||||
list-style-type: disc !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user