From 60d85f053105146d786851ef38b7ccaf8cbff008 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 10 Jan 2024 22:14:58 -0600 Subject: [PATCH] Download backend full log. --- src/lib/services/api-endpoints.js | 3 +++ src/lib/services/logging-service.js | 21 +++++++++++++++++++ .../[conversationId]/chat-box.svelte | 12 ++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 src/lib/services/logging-service.js diff --git a/src/lib/services/api-endpoints.js b/src/lib/services/api-endpoints.js index 8d0e1c7e..0874b855 100644 --- a/src/lib/services/api-endpoints.js +++ b/src/lib/services/api-endpoints.js @@ -27,6 +27,9 @@ export const endpoints = { conversationDetailUrl: `${host}/conversation/{conversationId}`, dialogsUrl: `${host}/conversation/{conversationId}/dialogs`, + // logging + loggingFullLogUrl: `${host}/logger/full-log`, + // knowledge base knowledgeBaseUploadUrl: `${host}/knowledge-base/upload`, diff --git a/src/lib/services/logging-service.js b/src/lib/services/logging-service.js new file mode 100644 index 00000000..50c7ee08 --- /dev/null +++ b/src/lib/services/logging-service.js @@ -0,0 +1,21 @@ +import { endpoints } from './api-endpoints.js'; +import axios from 'axios'; + +/** + * Show backend full log + */ +export async function getFullLog() { + axios({ + url: endpoints.loggingFullLogUrl, + method: 'GET', + responseType: 'blob' + }).then((response) => { + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement('a'); + link.href = url; + link.target = "_blank"; + document.body.appendChild(link); + link.click(); + link.remove(); + }) +} \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 72826fcf..52321c5b 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -16,6 +16,7 @@ import { signalr } from '$lib/services/signalr-service.js'; import { webSpeech } from '$lib/services/web-speech.js'; import { sendMessageToHub, GetDialogs } from '$lib/services/conversation-service.js'; + import { getFullLog } from '$lib/services/logging-service'; import { format } from '$lib/helpers/datetime'; import RcText from './rc-text.svelte'; import RcQuickReply from './rc-quick-reply.svelte'; @@ -91,6 +92,10 @@ refresh(); } + async function viewFullLogHandler() { + await getFullLog(); + } + async function sendTextMessage() { await sendMessageToHub(params.agentId, params.conversationId, text); } @@ -140,9 +145,7 @@ - Action - Another action - Something else + View Log @@ -176,9 +179,8 @@ + Eidt Copy - Save - Forward Delete