+
+
Knowledge Source Documents
@@ -23,19 +22,18 @@
-
-
+
+
No Records found
-
+
@@ -126,9 +126,7 @@ import Button from 'primevue/button';
import Column from 'primevue/column';
import DataTable from 'primevue/datatable';
import DatePicker from 'primevue/datepicker';
-import Dialog from 'primevue/dialog';
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';
@@ -164,51 +162,50 @@ const initFilters = () => {
initFilters();
-const statuses = ref(['NEW', 'LOADED','INGESTED', 'FAILED']); // Add your statuses here
+const statuses = ref(['NEW', 'LOADED', 'INGESTED', 'FAILED', 'ERROR']); // Add your statuses here
onMounted(() => {
userPrefStore.fetchUserData().then(() => {
updateDocuments();
+ setInterval(() => {
+ updateDocuments();
+ }, 10000);
});
+
+
});
+
const onRowExpand = (event) => {
- console.log("Row expanded:", event.data);
+ console.log("Row expanded:", event.data);
};
const onRowCollapse = (event) => {
- console.log("Row collapsed:", event.data);
+ console.log("Row collapsed:", event.data);
};
watch(() => userPrefStore.getSelApp, updateDocuments, { immediate: true });
function updateDocuments() {
- //loading.value = true;
ksDocumentStore.fetchKsDocument().then(() => {
-
ksdocuments.value = getCustomDatewithAllResponse();
- //ingestionDialogVisible.value = false;
- //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');
});
-
const getStatus = (data) => {
if (data.ingestionStatus === 'INGESTED') {
return 'success';
- } else if (data.ingestionStatus === 'LOADED') {
+ } else if (data.ingestionStatus === 'LOADED' || data.ingestionStatus === 'ERROR') {
return 'danger';
+ } else if (data.ingestionStatus === 'IN PROGRESS') {
+ return 'info';
} else {
- return 'warn';
+ return 'warning';
}
}
@@ -228,18 +225,11 @@ 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
@@ -253,21 +243,11 @@ const downloadFile = async (doc) => {
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("Error while downloading the file:", error);
toast.add({ severity: 'error', summary: 'Error', detail: 'Error while downloading the file. Check the file name.', life: 3000 });
@@ -293,7 +273,7 @@ const confirmDeleteFromVectorStore = (id) => {
icon: 'pi pi-exclamation-triangle',
rejectProps: {
label: 'Cancel',
- class:"p-button",
+ class: "p-button",
outlined: true,
},
acceptProps: {
@@ -319,7 +299,12 @@ const confirmDeleteFromVectorStore = (id) => {
axios.post('/fe-api/vector-store/deleteRecordsFromVectorStore', requestPayload)
.then(response => {
console.log('Delete resource:', response.data)
- updateDocuments(); // Call updateDocuments after successful deletion
+ ksdocuments.value.forEach(element => {
+ if (element.id == id) {
+ element.ingestionStatus = "LOADED"
+ console.log("Updated element", element)
+ }
+ });
toast.add({ severity: 'success', summary: 'Success', detail: 'Deletion Completed', life: 3000 });
})
.catch(error => {
@@ -335,26 +320,24 @@ const startIndividualngestion = (id) => {
toast.add({ severity: 'info', summary: 'Info', detail: 'Starting Ingestion', life: 3000 });
axios.get(`/test/ingest_document/${id}`)
.then(response => {
- ingestionResult.value = response.data;
if (response.data.status == "OK") {
- ksdocuments.value.forEach(element => {
- updateDocuments();
- if (response.data.ingestedDocumentId.includes(element.id)) {
- element.status = "INGESTED"
- updateDocuments();
- toast.add({severity: 'success', summary: 'Success', detail: 'File ingested successfully!', life: 3000});
- }
- });
- } else {
- ingestionResult.value = `Error: ${response.data.message}`;
- }
+ toast.add({ severity: 'success', summary: 'Success', detail: 'Document ingestion started...', life: 3000 });
- //ingestionDialogVisible.value = true;
+ }
+ if (response.data.status == "ERROR") {
+ toast.add({ severity: 'error', summary: 'Success', detail: 'Error ingesting document:' + response.data.message, life: 3000 });
+ }
+ ksdocuments.value.forEach(element => {
+ if (element.id == id) {
+ element.ingestionStatus = response.data.status
+ console.log("Updated element", element)
+ }
+ });
})
.catch(error => {
//ingestionDialogVisible.value = true;
console.error('Error ingesting record: ', error)
- toast.add({ severity: 'error', summary: 'Error', detail: 'Error while ingesting', life: 3000 });
+ toast.add({ severity: 'error', summary: 'Success', detail: 'Error ingesting document:' + error, life: 3000 });
});
};
@@ -384,12 +367,27 @@ const startlngestion = () => {
//new record creation
const newKsDocument = () => {
router.push({ name: 'ks-document-new' });
+};
+
+const getFileIcon = (filename) => {
+ const ext = filename.split('.').pop();
+ if (ext === 'pdf') {
+ return 'pi pi-file-pdf';
+ } else if (ext === 'doc' || ext === 'docx') {
+ return 'pi pi-file-word';
+ } else if (ext === 'xls' || ext === 'xlsx') {
+ return 'pi pi-file-excel';
+ } else if (ext === 'ppt' || ext === 'pptx') {
+ return 'pi pi-file-powerpoint';
+ } else {
+ return 'pi pi-file';
+ }
}
// Function to format date string
function formatDate(dateString) {
// Parse the date string using moment
- return moment(dateString).format('MM/DD/YYYY');
+ return moment(dateString).format('DD/MM/YYYY');
}
@@ -463,5 +461,4 @@ function formatDate(dateString) {
.card {
margin: 2rem;
}
-
\ No newline at end of file
diff --git a/src/views/pages/ksDocuments/KsNewDocumentForm.vue b/src/views/pages/ksDocuments/KsNewDocumentForm.vue
index 32f483e..b6e9ca1 100644
--- a/src/views/pages/ksDocuments/KsNewDocumentForm.vue
+++ b/src/views/pages/ksDocuments/KsNewDocumentForm.vue
@@ -32,15 +32,14 @@