From 4c54153dc8399cc01c786dbeee4d8e2d344aa3bf Mon Sep 17 00:00:00 2001 From: sumedh Date: Thu, 8 Aug 2024 10:34:54 +0530 Subject: [PATCH] delete functionality implemented --- src/components/CodeSnippet.vue | 2 +- src/views/pages/KsDocuments.vue | 100 ++++++++++++++++++--- src/views/pages/KsNewDocumentForm.vue | 118 ++++++------------------- src/views/pages/KsSimilaritySearch.vue | 54 ++++++----- src/views/pages/KsVectorData.vue | 28 +++--- 5 files changed, 155 insertions(+), 147 deletions(-) diff --git a/src/components/CodeSnippet.vue b/src/components/CodeSnippet.vue index 7494626..7d50975 100644 --- a/src/components/CodeSnippet.vue +++ b/src/components/CodeSnippet.vue @@ -55,7 +55,7 @@ function copyToClipboard() { /* Enable positioning of child elements */ } -.class="button-container" { +.button-container { position: sticky; top: 10px; /* Adjust as needed */ diff --git a/src/views/pages/KsDocuments.vue b/src/views/pages/KsDocuments.vue index 5a85a66..aae2406 100644 --- a/src/views/pages/KsDocuments.vue +++ b/src/views/pages/KsDocuments.vue @@ -2,7 +2,7 @@
+ :globalFilterFields="['ingestionInfo.metadata.KsApplicationName', 'ingestionInfo.metadata.KsFileSources', 'ingestionInfo.metadata.KsDocSource', 'ingestionStatus', 'ingestionDateFormat']"> - - - + + + + + - + + + + + @@ -113,12 +135,16 @@ const ingestionDialogVisible = ref(false); const ingestionResult = ref(''); const filters = ref(); +const confirmDialogVisible = ref(false); +const recordToDelete = ref(null); + const initFilters = () => { filters.value = { global: { value: null, matchMode: FilterMatchMode.CONTAINS }, id: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] }, - name: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, - fileName: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, + 'ingestionInfo.metadata.KsApplicationName': { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, + 'ingestionInfo.metadata.KsFileSource': { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, + 'ingestionInfo.metadata.KsDocSource': { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, ingestionDateFormat: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, ingestionStatus: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] } }; @@ -169,6 +195,53 @@ const editKsDocument = (data) => { router.push({ name: 'ks-document-edit', params: { id: data.id } }); } +//delete functionality +function showConfirmDialog(id) { + recordToDelete.value = id; + confirmDialogVisible.value = true; +} + +function confirmDelete() { + if (recordToDelete.value !== null) { + deleteRecordsFromVectorStore(recordToDelete.value); + recordToDelete.value = null; + } + confirmDialogVisible.value = false; +} + +function resetConfirmDialog() { + recordToDelete.value = null; +} + + +const deleteRecordsFromVectorStore = (id) => { + const documentToDelete = ksdocuments.value.find(doc => doc.id === id); + + if (!documentToDelete) { + console.error('Document not found'); + return; + } + + const requestPayload = { + ksDocumentId: id, + ksIngestionInfoId: documentToDelete.ingestionInfo.id, + ksDoctype: documentToDelete.ingestionInfo.metadata.KsDoctype, + ksDocSource: documentToDelete.ingestionInfo.metadata.KsDocSource, + ksFileSource: documentToDelete.ingestionInfo.metadata.KsFileSource, + ksApplicationName: documentToDelete.ingestionInfo.metadata.KsApplicationName, + }; + + axios.post('http://localhost:8082/fe-api/vector-store/deleteRecords', requestPayload) + .then(response => { + console.log('Delete resource:', response.data) + ksdocuments.value = ksdocuments.value.filter(doc => doc.id !== id); + }) + .catch(error => { + console.error('Error deleting records: ', error) + }); +} + +//ingestion const startIndividualngestion = (id) => { axios.get(`http://localhost:8082/test/ingest_document/${id}`) //axios.get('http://localhost:8082/test/ingestion_loop') @@ -212,6 +285,7 @@ const startlngestion = () => { }); }; +//new record creation const newKsDocument = () => { console.log('new'); router.push({ name: 'ks-document-new' }); diff --git a/src/views/pages/KsNewDocumentForm.vue b/src/views/pages/KsNewDocumentForm.vue index 46defb0..688cf5e 100644 --- a/src/views/pages/KsNewDocumentForm.vue +++ b/src/views/pages/KsNewDocumentForm.vue @@ -8,71 +8,81 @@
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
-
@@ -81,81 +91,6 @@
-