trigger re single class

This commit is contained in:
Florinda
2024-11-12 16:03:38 +01:00
parent 75de230b1f
commit d94d3fa690
4 changed files with 158 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
<template>
<Tabs value="class-code" @update:value="tabUpdate">
<TabList>
<Tab value="class-code">Class Code</Tab>
<Tab value="class-description">Class RE</Tab>
@@ -28,12 +29,29 @@
</TabPanel>
<TabPanel value="class-description">
<div class="flex justify-end">
<Button label="Execute RE Class"
severity="secondary"
rounded @click="doREClass"
v-tooltip.left="'Execute reverse engeenering for the class selected'"
:disabled="loadingStore.re_loading">
</Button>
</div>
<div v-if="loadingStore.re_loading" class="flex justify-center">
<jellyfish-loader :loading="loadingStore.re_loading" scale="1" />
<!--<ProgressSpinner style="width: 30px; height: 30px; margin: 30px" strokeWidth="6" fill="transparent"/>-->
</div>
<div v-if="!loadingStore.re_loading">
<p class="m-0" v-if="classLoaded">
<MdPreview v-if="classDetails.reDescription != null" class="editor" v-model="classDetails.reDescription" language="en-US" />
<p v-else> No Description available for this class</p>
</p>
<Skeleton v-else width="100%" height="10rem"></Skeleton>
</div>
</TabPanel>
<TabPanel v-if="methods != null" value="method-list">
@@ -80,6 +98,9 @@
<script setup>
import { ApplicationCodeService } from '@/service/ApplicationCodeService';
import { LoadingStore } from '@/stores/LoadingStore';
import { UserPrefStore } from '@/stores/UserPrefStore.js';
import axios from 'axios';
import { MdPreview } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
@@ -88,12 +109,17 @@ import TabList from 'primevue/tablist';
import TabPanel from 'primevue/tabpanel';
import TabPanels from 'primevue/tabpanels';
import Tabs from 'primevue/tabs';
import { defineProps, onMounted, ref, toRefs } from 'vue';
import { useToast } from 'primevue/usetoast';
import { defineProps, onMounted, reactive, ref, toRefs } from 'vue';
import { HighCode } from 'vue-highlight-code';
import 'vue-highlight-code/dist/style.css';
import { JellyfishLoader } from "vue3-spinner";
import { useLayout } from './useLayout';
//66f55e4b2894530b1c154f69
const props = defineProps({
className: {
@@ -105,6 +131,7 @@ className: {
const { className } = toRefs(props);
const classDetails = ref(null);
const classLoaded = ref(false);
const loadingStore = LoadingStore();
const nodes = ref(null)
const edges = ref(null)
const dark = ref(false)
@@ -112,13 +139,110 @@ const selectedMethodName = ref(null)
const selectedMethodDetails = ref(null)
const loadingMethod = ref(false)
const methods = ref(null)
let pollingInterval = null;
const userPrefStore = UserPrefStore();
const toast = useToast();
const loading_data = ref(false);
const { graph, layout, previousDirection } = useLayout()
const commonRevRequest = reactive({
repositoryEntityId: '',
applicationName: '',
applicationProjectName: '',
fullClassQualifiedName: '',
applicationVersion: '',
deleteExistingData: true, // Valore booleano
applicationType: 'JAVA',
commitSha: ''
});
onMounted(() => {
loadClassDetails();
console.log("class details: ", classDetails.value);
console.log("class name: ", className.value);
});
const doREClass = () => {
commonRevRequest.fullClassQualifiedName = className.value;
commonRevRequest.applicationName = userPrefStore.getSelApp.internal_name;
commonRevRequest.applicationProjectName = userPrefStore.selectedProject.internal_name;
ApplicationCodeService.doRevEngForSingleClass(commonRevRequest).then(response => {
console.log("RE Class response : ", response.data);
if(response.data != "KO"){
startPolling(response.data);
}else{
toast.add({
severity: 'error', // Tipo di notifica (errore)
summary: 'Errore', // Titolo della notifica
detail: 'Si è verificato un errore. Riprova più tardi.', // Messaggio dettagliato
life: 3000 // Durata della notifica in millisecondi
});
}
})
}
// Function to start polling
function startPolling(processId) {
// Set polling interval (every 5 seconds in this case)
loading_data.value = true;
loadingStore.re_loading = true;
pollingInterval = setInterval(() => pollREBackendAPI(processId), 5000);
console.log("Polling started.");
}
// Function to stop polling
function stopPolling() {
clearInterval(pollingInterval);
loadingStore.re_loading = false;
loading_data.value = false;
loadClassDetails();
console.log("Polling stopped.");
}
const pollREBackendAPI = (processId) => {
axios.get('/java-re-module/getProgressRevSingleClass/'+processId).then(response => {
//console.log("Polling response : ", response);
if(response.data.status === "DONE"){
console.log("status done")
stopPolling();
}else if(response.data.status === "ERROR" || response.status === 404 || response.status === 500){
console.log("status error")
stopPolling();
toast.add({
severity: 'error', // Tipo di notifica (errore)
summary: 'Errore', // Titolo della notifica
detail: 'Si è verificato un errore. Riprova più tardi.', // Messaggio dettagliato
life: 3000 // Durata della notifica in millisecondi
});
}
//stopPolling();
/*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 tabUpdate(value) {
console.log(value);
if ((value === 'class-description' || value ==='class-code') && classLoaded.value === false) {

View File

@@ -4,5 +4,9 @@ export const ApplicationCodeService = {
getApplication(applicationName) {
return axios.get(`/source-viewer/getApplicationTreeNode?applicationName=${applicationName}`);
}
},
doRevEngForSingleClass(data){
return axios.post('/java-re-module/doRevSingleClass', data);
}
};

View File

@@ -9,14 +9,15 @@ export const LoadingStore = defineStore('loading_store', () => {
const user_loading = ref(false)
const another_loading = ref(false)
const exectuion_loading = ref(false)
const re_loading = ref(false)
const isLoading = computed(() => {
return scenario_loading.value || user_loading.value || another_loading.value || exectuion_loading.value
return scenario_loading.value || user_loading.value || another_loading.value || exectuion_loading.value || re_loading.value
})
const loadingType = computed(() => {
if(exectuion_loading.value) return 'ai'
if(re_loading.value) return 'ai'
if(scenario_loading.value) return 'data'
if(user_loading.value) return 'data'
if(another_loading.value) return 'data'
@@ -28,6 +29,7 @@ export const LoadingStore = defineStore('loading_store', () => {
scenario_loading,
another_loading,
exectuion_loading,
re_loading,
loadingType
}
})

View File

@@ -9,9 +9,9 @@
<div class="col-span-4">
<div class="card folder-tree ">
<h5>File Browser</h5>
<Tree :value="nodes" @nodeSelect="onNodeSelect" selectionMode="single" :expandedKeys="expandedKeys" :filter="true" filterMode="lenient" class="w-full"></Tree>
<Tree :value="nodes" @nodeSelect="onNodeSelect" selectionMode="single" :expandedKeys="expandedKeys" @nodeExpand="expandNode" @nodeCollapse="collapseNode" :filter="true" filterMode="lenient" class="w-full"></Tree>
</div>
</div>
<div class="col-span-8">
@@ -72,7 +72,7 @@ function reloadPage() {
fetchApplicationData();
}
watch(() => userPrefStore.getSelApp, reloadPage, { immediate: true });
watch(() => userPrefStore.getSelApp, reloadPage);
function onNodeSelect(e){
if(e.icon == "pi pi-fw pi-file"){
@@ -97,7 +97,7 @@ const collapseAll = () => {
expandedKeys.value = {};
};
const expandNode = (node) => {
/*const expandNode = (node) => {
expandedKeys.value[node.key] = true;
if (node.children && node.children.length) {
@@ -105,6 +105,24 @@ const expandNode = (node) => {
expandNode(child);
}
}
};*/
const expandNode = (node) => {
if (node.children && node.children.length) {
//node.children.forEach(child => {
expandedKeys.value[node.children.key] = true;
// });
}
expandedKeys.value = { ...expandedKeys.value };
};
const collapseNode = (node) => {
if (node.children && node.children.length) {
node.children.forEach(child => {
delete expandedKeys.value[child.key];
});
}
expandedKeys.value = { ...expandedKeys.value };
};
</script>