profiling + research + download
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="card">
|
||||
<Toast />
|
||||
<ConfirmPopup></ConfirmPopup>
|
||||
<div v-if="loading" class="loading-container">
|
||||
<div v-if="loadingStore.another_loading" class="loading-container">
|
||||
<div class="spinner-container">
|
||||
<ProgressSpinner class="spinner" />
|
||||
<p class="loading-text">Loading data...</p>
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
|
||||
<DataTable v-model:filters="filters" :value="ksdocuments" paginator showGridlines :rows="10" dataKey="id"
|
||||
filterDisplay="menu" :loading="loading"
|
||||
filterDisplay="menu" :loading="loadingStore.another_loading"
|
||||
:globalFilterFields="['ingestionInfo.metadata.KsApplicationName', 'ingestionInfo.metadata.KsFileSources', 'ingestionInfo.metadata.KsDocSource', 'ingestionStatus', 'ingestionDateFormat']">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between gap-4 p-4 ">
|
||||
@@ -103,6 +103,12 @@
|
||||
v-tooltip="'Delete the ingested Record'"
|
||||
:disabled="slotProps.data.ingestionStatus === 'NEW'"
|
||||
:class="{ 'p-button-danger': slotProps.data.ingestionStatus === 'NEW' }" />
|
||||
<Button type="button" icon="pi pi-search" rounded @click="openSimilaritySearch(slotProps.data)"
|
||||
v-tooltip="'Similarity Search'" :disabled="slotProps.data.ingestionStatus === 'NEW'"
|
||||
:class="{ 'p-button-danger': slotProps.data.ingestionStatus === 'NEW' }" />
|
||||
<Button type="button" icon="pi pi-download" rounded @click="downloadFile(slotProps.data)"
|
||||
v-tooltip="'Download file'" :disabled="slotProps.data.ingestionStatus === 'NEW'"
|
||||
:class="{ 'p-button-danger': slotProps.data.ingestionStatus === 'NEW' }" />
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
@@ -120,7 +126,7 @@ import axios from 'axios';
|
||||
import moment from 'moment';
|
||||
import { useConfirm } from "primevue/useconfirm";
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import Button from 'primevue/button';
|
||||
@@ -132,7 +138,10 @@ import InputText from 'primevue/inputtext';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
import Select from 'primevue/select';
|
||||
import Tag from 'primevue/tag';
|
||||
|
||||
import { KsDocumentService } from '../../../service/KsDocumentService';
|
||||
import { KsDocumentStore } from '../../../stores/KsDocumentStore';
|
||||
import { LoadingStore } from '../../../stores/LoadingStore';
|
||||
import { UserPrefStore } from '../../../stores/UserPrefStore';
|
||||
|
||||
const router = useRouter()
|
||||
const ksdocuments = ref(null);
|
||||
@@ -143,6 +152,9 @@ const confirm = useConfirm();
|
||||
const ingestionDialogVisible = ref(false);
|
||||
const ingestionResult = ref('');
|
||||
const filters = ref();
|
||||
const userPrefStore = UserPrefStore();
|
||||
const ksDocumentStore = KsDocumentStore();
|
||||
const loadingStore = LoadingStore();
|
||||
|
||||
const initFilters = () => {
|
||||
filters.value = {
|
||||
@@ -161,14 +173,29 @@ initFilters();
|
||||
const statuses = ref(['NEW', 'INGESTED', 'FAILED']); // Add your statuses here
|
||||
|
||||
onMounted(() => {
|
||||
axios.get('/fe-api/ksdocuments')
|
||||
.then(response => {
|
||||
ksdocuments.value = getCustomDatewithAllResponse(response.data);
|
||||
console.log(ksdocuments.value);
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
userPrefStore.fetchUserData().then(() => {
|
||||
updateDocuments();
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
watch(() => userPrefStore.getSelApp, updateDocuments, { immediate: true });
|
||||
|
||||
function updateDocuments() {
|
||||
//loading.value = true;
|
||||
ksDocumentStore.fetchKsDocument().then(() => {
|
||||
|
||||
ksdocuments.value = getCustomDatewithAllResponse();
|
||||
//loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Computed property to check if all documents are ingested
|
||||
const allDocumentsIngested = computed(() => {
|
||||
return ksdocuments.value && ksdocuments.value.every(doc => doc.ingestionStatus === 'INGESTED');
|
||||
@@ -185,8 +212,8 @@ const getStatus = (data) => {
|
||||
}
|
||||
}
|
||||
|
||||
const getCustomDatewithAllResponse = (data) => {
|
||||
return [...(data || [])].map((d) => {
|
||||
const getCustomDatewithAllResponse = () => {
|
||||
return [...(ksDocumentStore.ksDocument || [])].map((d) => {
|
||||
d.ingestionDateFormat = new Date(d.ingestionDateFormat);
|
||||
return d;
|
||||
});
|
||||
@@ -196,11 +223,69 @@ const updateFilterModel = () => {
|
||||
console.log("updateFilterModel")
|
||||
}
|
||||
|
||||
// Variabile reattiva per il nome del file
|
||||
const filename = ref("");
|
||||
|
||||
// Funzione per scaricare il file
|
||||
const downloadFile = async (doc) => {
|
||||
/*if (!filename.value) {
|
||||
alert("Inserisci il nome del file.");
|
||||
return;
|
||||
}*/
|
||||
console.log("doc", doc)
|
||||
|
||||
try {
|
||||
|
||||
|
||||
//const response = await axios.post('/fe-api/ksdocuments/downloadKSDocument', doc, { responseType: "blob", });
|
||||
const response = await KsDocumentService.downloadKsDocument(doc);
|
||||
|
||||
console.log("response download", response);
|
||||
|
||||
const contentType = response.headers['content-type']; // Tipo MIME dinamico
|
||||
const blob = new Blob([response.data], { type: contentType });
|
||||
|
||||
// Crea un URL temporaneo per il download
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
|
||||
const fileName = doc.fileName;
|
||||
console.log("fileName", fileName)
|
||||
|
||||
// Imposta il nome e avvia il download
|
||||
link.setAttribute('download', fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
// Crea un URL temporaneo per il download del file
|
||||
/*console.log("response download", response);
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.setAttribute("download", filename.value); // Imposta il nome del file
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();*/
|
||||
} catch (error) {
|
||||
console.error("Errore durante il download:", error);
|
||||
alert("Errore durante il download. Controlla il nome del file.");
|
||||
}
|
||||
};
|
||||
|
||||
const editKsDocument = (data) => {
|
||||
console.log(data);
|
||||
router.push({ name: 'ks-document-edit', params: { id: data.id } });
|
||||
}
|
||||
|
||||
const openSimilaritySearch = (doc) => {
|
||||
console.log("doc", doc)
|
||||
ksDocumentStore.setSelectedKsDocument(doc).then(() => {
|
||||
router.push({ name: 'ks_similarity_search' });
|
||||
});
|
||||
}
|
||||
|
||||
const confirmDelete = (id) => {
|
||||
console.log("id", id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user