From 691fcef7ba588904ccbd8feed0b3559a8023d9d7 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Thu, 19 Sep 2024 16:44:51 -0500 Subject: [PATCH] add adv search --- src/lib/helpers/enums.js | 3 +- src/lib/helpers/http.js | 2 +- src/lib/scss/custom/pages/_knowledgebase.scss | 63 +++++++- src/lib/services/api-endpoints.js | 4 +- src/lib/services/knowledge-base-service.js | 18 +-- .../common/search/advanced-search.svelte | 148 ++++++++++++++++++ .../common/vector-table/vector-item.svelte | 145 +++++++++-------- .../knowledge-base/documents/+page.svelte | 41 +++-- .../knowledge-document-upload.svelte | 6 +- .../question-answer/+page.svelte | 22 +-- static/images/icons/html_icon.png | Bin 25373 -> 18824 bytes 11 files changed, 345 insertions(+), 107 deletions(-) create mode 100644 src/routes/page/knowledge-base/common/search/advanced-search.svelte diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 1c4a5e2..3573690 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -80,7 +80,8 @@ const knowledgePayloadName = { DataSource: 'dataSource', FileId: 'fileId', FileName: 'fileName', - FileSource: 'fileSource' + FileSource: 'fileSource', + FileUrl: 'fileUrl' }; export const KnowledgePayloadName = Object.freeze(knowledgePayloadName); diff --git a/src/lib/helpers/http.js b/src/lib/helpers/http.js index 637703d..0372761 100644 --- a/src/lib/helpers/http.js +++ b/src/lib/helpers/http.js @@ -60,7 +60,7 @@ function skipLoader(config) { new RegExp('http(s*)://(.*?)/knowledge/vector/(.*?)/page', 'g'), new RegExp('http(s*)://(.*?)/knowledge/(.*?)/search', 'g'), new RegExp('http(s*)://(.*?)/knowledge/vector/(.*?)/create', 'g'), - new RegExp('http(s*)://(.*?)/knowledge/document/(.*?)/list', 'g') + new RegExp('http(s*)://(.*?)/knowledge/document/(.*?)/page', 'g') ]; const putRegexes = [ diff --git a/src/lib/scss/custom/pages/_knowledgebase.scss b/src/lib/scss/custom/pages/_knowledgebase.scss index f7229ea..651a899 100644 --- a/src/lib/scss/custom/pages/_knowledgebase.scss +++ b/src/lib/scss/custom/pages/_knowledgebase.scss @@ -173,6 +173,16 @@ white-space: wrap !important; } + .more-detail-item { + .link { + color: var(--bs-primary); + + &:hover { + text-decoration: underline; + } + } + } + .more-detail { margin: 2px 0px; padding-left: 2rem; @@ -297,4 +307,55 @@ border-radius: 10px; padding: 10px; background-color: var(--bs-light); -} \ No newline at end of file +} + +.knowledge-adv-search-container { + .knowledge-adv-search-btn { + display: flex; + justify-content: flex-start; + gap: 10px; + font-size: 18px; + + input { + outline: none !important; + box-shadow: none !important; + } + } + + .knowledge-adv-search-items { + margin-top: 15px; + display: flex; + flex-direction: column; + gap: 10px; + + .knowledge-adv-search-item { + display: flex; + gap: 10px; + + .search-item-cb { + flex: 0 0 20px; + + .form-check { + font-size: 15px; + margin-bottom: 0.125rem; + } + + input[type="checkbox"] { + outline: none !important; + box-shadow: none !important; + } + } + + .search-item-name { + font-size: 15px; + flex: 0 0 100px; + } + + .search-item-content { + flex: 0.3; + min-width: 150px; + max-width: 350px; + } + } + } +} diff --git a/src/lib/services/api-endpoints.js b/src/lib/services/api-endpoints.js index caf7b19..9797210 100644 --- a/src/lib/services/api-endpoints.js +++ b/src/lib/services/api-endpoints.js @@ -60,7 +60,7 @@ export const endpoints = { // knowledge base vectorKnowledgeCollectionsUrl: `${host}/knowledge/vector/collections`, - vectorKnowledgePageDataUrl: `${host}/knowledge/vector/{collection}/page`, + vectorKnowledgePageListUrl: `${host}/knowledge/vector/{collection}/page`, vectorKnowledgeSearchUrl: `${host}/knowledge/vector/{collection}/search`, vectorKnowledgeCreateUrl: `${host}/knowledge/vector/{collection}/create`, vectorKnowledgeUpdateUrl: `${host}/knowledge/vector/{collection}/update`, @@ -74,7 +74,7 @@ export const endpoints = { knowledgeDocumentUploadUrl: `${host}/knowledge/document/{collection}/upload`, knowledgeDocumentDeleteUrl: `${host}/knowledge/document/{collection}/delete/{fileId}`, - knowledgeDocumentListUrl: `${host}/knowledge/document/{collection}/list`, + knowledgeDocumentPageListUrl: `${host}/knowledge/document/{collection}/page`, // chathub chatHubUrl: `${host}/chatHub`, diff --git a/src/lib/services/knowledge-base-service.js b/src/lib/services/knowledge-base-service.js index 624d5a2..386b63d 100644 --- a/src/lib/services/knowledge-base-service.js +++ b/src/lib/services/knowledge-base-service.js @@ -17,11 +17,11 @@ export async function getVectorKnowledgeCollections(type) { } /** - * @param {import('$knowledgeTypes').SearchKnowledgeRequest} request * @param {string} collection + * @param {import('$knowledgeTypes').SearchKnowledgeRequest} request * @returns {Promise} */ -export async function searchVectorKnowledge(request, collection) { +export async function searchVectorKnowledge(collection, request) { const url = replaceUrl(endpoints.vectorKnowledgeSearchUrl, { collection: collection }); @@ -31,12 +31,12 @@ export async function searchVectorKnowledge(request, collection) { } /** - * @param {import('$knowledgeTypes').KnowledgeFilter} filter * @param {string} collection + * @param {import('$knowledgeTypes').KnowledgeFilter} filter * @returns {Promise} */ -export async function getPagedVectorKnowledgeData(filter, collection) { - const url = replaceUrl(endpoints.vectorKnowledgePageDataUrl, { +export async function getVectorKnowledgePageList(collection, filter) { + const url = replaceUrl(endpoints.vectorKnowledgePageListUrl, { collection: collection }); @@ -96,11 +96,11 @@ export async function updateVectorKnowledgeData(id, collection, text, dataSource /** - * @param {string} id * @param {string} collection + * @param {string} id * @returns {Promise} */ -export async function deleteVectorKnowledgeData(id, collection) { +export async function deleteVectorKnowledgeData(collection, id) { const url = replaceUrl(endpoints.vectorKnowledgeDeleteUrl, { collection: collection, id: id @@ -160,8 +160,8 @@ export async function deleteKnowledgeDocument(collection, fileId) { * @param {import('$knowledgeTypes').KnowledgeDocRequest} request * @returns {Promise} */ -export async function getKnowledgeDocuments(collection, request) { - const url = replaceUrl(endpoints.knowledgeDocumentListUrl, { +export async function getKnowledgeDocumentPageList(collection, request) { + const url = replaceUrl(endpoints.knowledgeDocumentPageListUrl, { collection: collection }); diff --git a/src/routes/page/knowledge-base/common/search/advanced-search.svelte b/src/routes/page/knowledge-base/common/search/advanced-search.svelte new file mode 100644 index 0000000..4a828d8 --- /dev/null +++ b/src/routes/page/knowledge-base/common/search/advanced-search.svelte @@ -0,0 +1,148 @@ + + + +
+
+ toggleAdvSearch(e)} + /> +
+
{'Advance Search'}
+
+ {#if showAdvSearch} +
+ +
+ +
    +
  • {'Select the checkbox to enable seaching in each field.'}
  • +
  • {'Empty value will not be used to search.'}
  • +
+
+ {/if} +
+ + {#if showAdvSearch} +
+ {#each innerItems as item, idx (idx)} +
+
+ toggleItemCheckbox(idx, e)} + /> +
+
+
{`${item.displayName}:`}
+
+
+ changeItemValue(idx, e)} + /> +
+
+ {/each} +
+ {/if} +
diff --git a/src/routes/page/knowledge-base/common/vector-table/vector-item.svelte b/src/routes/page/knowledge-base/common/vector-table/vector-item.svelte index 82ef3ab..e30c4b6 100644 --- a/src/routes/page/knowledge-base/common/vector-table/vector-item.svelte +++ b/src/routes/page/knowledge-base/common/vector-table/vector-item.svelte @@ -73,9 +73,9 @@
{item?.data?.question || item?.data?.text || ''}
{#if isQuestionAnswerCollection} - -
{item?.data?.answer || ''}
- + +
{item?.data?.answer || ''}
+ {/if}