Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,11 @@
}

.chat-input-section {
padding: 2vmin 2%;
padding: 0 2%;
height: 8%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
}

.chat-input-hide {
Expand Down Expand Up @@ -361,6 +364,35 @@
flex: 2%;
}

.instant-log-body {
display: flex;
flex-direction: column;
gap: 20px;
overflow-y: scroll;
scrollbar-width: none;

.instant-log-section {
border-radius: 10px;
background-color: var(--bs-primary) !important;
margin: 0px 60px;
flex: 0 0 500px;
display: flex;
flex-direction: column;
height: 500px;
min-height: 500px;

.close-icon {
font-size: 20px;
color: red;
padding: 0 5px;

i {
cursor: pointer;
}
}
}
}

.nav-group {
margin: 0px 3px;
}
Expand Down Expand Up @@ -440,7 +472,7 @@
padding-left: 10px;

.state-key {
color: var(--bs-primary);
// color: var(--bs-primary);
}

.state-source {
Expand All @@ -463,8 +495,8 @@
}

.queue-change-container {
margin-top: 0px;
margin-bottom: 0px;
margin-top: 10px;
margin-bottom: 10px;
padding: 0px 10px;

.log-content {
Expand Down
136 changes: 70 additions & 66 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { onMount, setContext, tick } from 'svelte';
import Viewport from 'svelte-viewport-info';
import { PUBLIC_LIVECHAT_ENTRY_ICON } from '$env/static/public';
import { BOT_SENDERS, FILE_EDITORS, TEXT_EDITORS, USER_SENDERS } from '$lib/helpers/constants';
import { BOT_SENDERS, TEXT_EDITORS, USER_SENDERS } from '$lib/helpers/constants';
import { signalr } from '$lib/services/signalr-service.js';
import { webSpeech } from '$lib/services/web-speech.js';
import { newConversation } from '$lib/services/conversation-service';
Expand All @@ -37,17 +37,17 @@
import { utcToLocal } from '$lib/helpers/datetime';
import { replaceNewLine } from '$lib/helpers/http';
import { EditorType, FileSourceType, SenderAction, UserRole } from '$lib/helpers/enums';
import { loadFileGallery, loadLocalFiles } from '$lib/helpers/utils/gallery';
import { loadFileGallery } from '$lib/helpers/utils/gallery';
import RichContent from './rich-content/rich-content.svelte';
import RcMessage from "./rich-content/rc-message.svelte";
import RcDisclaimer from './rich-content/rc-disclaimer.svelte';
import MessageImageGallery from '$lib/common/MessageImageGallery.svelte';
import ChatImageUploader from './chat-image/chat-image-uploader.svelte';
import ChatImageGallery from './chat-image/chat-image-gallery.svelte';
import ContentLog from './content-log/content-log.svelte';
import PersistLog from './persist-log/persist-log.svelte';
import InstantLog from './instant-log/instant-log.svelte';
import _ from "lodash";
import { Pane, Splitpanes } from 'svelte-splitpanes';
import StateLog from './state-log/state-log.svelte';
import Swal from 'sweetalert2/dist/sweetalert2.js';
import "sweetalert2/src/sweetalert2.scss";
import moment from 'moment';
Expand Down Expand Up @@ -114,10 +114,10 @@
let conversationUser;

/** @type {boolean} */
let isLoadContentLog = false;
let isLoadStateLog = false;
let isContentLogClosed = false; // initial condition
let isStateLogClosed = false; // initial condition
let isLoadPersistLog = false;
let isLoadInstantLog = false;
let isPersistLogClosed = false; // initial condition
let isInstantLogClosed = false; // initial condition
let isOpenEditMsgModal = false;
let isOpenUserAddStateModal = false;
let isSendingMsg = false;
Expand Down Expand Up @@ -172,11 +172,11 @@
function resizeChatWindow() {
isLite = Viewport.Width <= screenWidthThreshold;
if (!isLite) {
isLoadContentLog = !isContentLogClosed;
isLoadStateLog = !isStateLogClosed;
isLoadPersistLog = !isPersistLogClosed;
isLoadInstantLog = !isInstantLogClosed;
} else {
isLoadContentLog = false;
isLoadStateLog = false;
isLoadPersistLog = false;
isLoadInstantLog = false;
isOpenEditMsgModal = false;
isOpenUserAddStateModal = false;
}
Expand All @@ -185,8 +185,8 @@
function initChatView() {
isFrame = $page.url.searchParams.get('isFrame') === 'true';
// initial condition
isContentLogClosed = false;
isStateLogClosed = false;
isPersistLogClosed = false;
isInstantLogClosed = false;
resizeChatWindow();
}

Expand Down Expand Up @@ -351,30 +351,30 @@

/** @param {import('$types').ConversationContentLogModel} log */
function onConversationContentLogGenerated(log) {
if (!isLoadContentLog) return;
if (!isLoadPersistLog) return;
contentLogs.push({ ...log });
contentLogs = contentLogs.map(x => { return { ...x }; });
}

/** @param {import('$types').ConversationStateLogModel} log */
function onConversationStateLogGenerated(log) {
if (!isLoadStateLog) return;
if (!isLoadPersistLog) return;

convStateLogs.push({ ...log });
convStateLogs = convStateLogs.map(x => { return { ...x }; });
}

/** @param {import('$types').MessageStateLogModel} log */
function onStateChangeGenerated(log) {
if (!isLoadStateLog || log == null) return;
if (!isLoadInstantLog || log == null) return;

msgStateLogs.push({ ...log });
msgStateLogs = msgStateLogs.map(x => { return { ...x }; });
}

/** @param {import('$types').AgentQueueLogModel} log */
function onAgentQueueChanged(log) {
if (!isLoadContentLog || log == null) return;
if (!isLoadInstantLog || log == null) return;

agentQueueLogs.push({ ...log });
agentQueueLogs = agentQueueLogs.map(x => { return { ...x }; });
Expand Down Expand Up @@ -577,34 +577,40 @@
}
}

function toggleContentLog() {
isLoadContentLog = !isLoadContentLog;
if (!isLoadContentLog) {
contentLogs = [];
agentQueueLogs = [];
isContentLogClosed = true;
} else {
isContentLogClosed = false;
function openLogs() {
if (!isLoadPersistLog) {
isLoadPersistLog = true;
isPersistLogClosed = false;
}

if (!isLoadInstantLog) {
isLoadInstantLog = true;
isInstantLogClosed = false;
}
}

function closePersistLog() {
isLoadPersistLog = false;
contentLogs = [];
convStateLogs = [];
isPersistLogClosed = true;
}

function cleanContentLogScreen() {
function cleanPersistLogScreen() {
contentLogs = [];
convStateLogs = [];
}

function toggleStateLog() {
isLoadStateLog = !isLoadStateLog;
if (!isLoadStateLog) {
convStateLogs = [];
msgStateLogs = [];
isStateLogClosed = true;
} else {
isStateLogClosed = false;
}
function closeInstantLog() {
isLoadInstantLog = false;
msgStateLogs = [];
agentQueueLogs = [];
isInstantLogClosed = true;
}

function cleanStateLogScreen() {
convStateLogs = [];
function cleanInstantLogScreen() {
msgStateLogs = [];
agentQueueLogs = [];
}

function toggleUserAddStateModal() {
Expand Down Expand Up @@ -758,13 +764,11 @@

/** @param {string} messageId */
function truncateLogs(messageId) {
if (isLoadContentLog) {
const targetIdx = contentLogs.findIndex(x => x.message_id === messageId);
if (isLoadPersistLog) {
let targetIdx = contentLogs.findIndex(x => x.message_id === messageId);
contentLogs = contentLogs.filter((x, idx) => idx < targetIdx);
}

if (isLoadStateLog) {
const targetIdx = convStateLogs.findIndex(x => x.message_id === messageId);

targetIdx = convStateLogs.findIndex(x => x.message_id === messageId);
convStateLogs = convStateLogs.filter((x, idx) => idx < targetIdx);
}
}
Expand Down Expand Up @@ -793,7 +797,7 @@

/** @param {string} messageId */
function highlightStateLog(messageId) {
if (!isLoadStateLog) return;
if (!isLoadInstantLog) return;

const targets = document.querySelectorAll('.state-log-item');
targets.forEach(elm => {
Expand All @@ -815,15 +819,15 @@
const stateLogWrapper = '.conv-state-log-scrollbar';
const elements = [];
const contentLogElm = document.querySelector(`#content-log-${messageId}`);
if (isLoadContentLog && !!contentLogElm) {
if (isLoadPersistLog && !!contentLogElm) {
elements.push({
elm: contentLogElm,
wrapperName: contentLogWrapper
});
}

const stateLogElm = document.querySelector(`#state-log-${messageId}`);
if (isLoadStateLog && !!stateLogElm) {
if (isLoadPersistLog && !!stateLogElm) {
elements.push({
elm: stateLogElm,
wrapperName: stateLogWrapper
Expand Down Expand Up @@ -882,14 +886,14 @@
<HeadTitle title="Chat" addOn='' />
<div class="d-lg-flex">
<Splitpanes>
{#if isLoadStateLog}
{#if isLoadInstantLog}
<Pane size={30} minSize={20} maxSize={50} >
<StateLog
bind:convStateLogs={convStateLogs}
<InstantLog
bind:msgStateLogs={msgStateLogs}
bind:agentQueueLogs={agentQueueLogs}
autoScroll={autoScrollLog}
closeWindow={toggleStateLog}
cleanScreen={cleanStateLogScreen}
closeWindow={closeInstantLog}
cleanScreen={cleanInstantLogScreen}
/>
</Pane>
{/if}
Expand All @@ -899,9 +903,9 @@
<div class="border-bottom chat-head">
<div class="row">
<div class="col-md-4 col-7 head-left">
<div class="m-1">{agent?.name}</div>
<div class="m-1">{agent?.name || 'Unkown'}</div>
<div class="text-muted mb-0">
<i class="mdi mdi-circle text-success align-middle me-1" /> {conversationUser?.full_name || ''}
<i class="mdi mdi-circle text-success align-middle me-1" /> {conversationUser?.full_name || conversationUser?.user_name || ''}
</div>
</div>

Expand All @@ -923,23 +927,23 @@
<i class="bx bx-dots-horizontal-rounded" />
</DropdownToggle>
<DropdownMenu class="dropdown-menu-end">
{#if !isLite && !isLoadContentLog}
<DropdownItem on:click={() => toggleContentLog()}>View Log</DropdownItem>
{#if !isLite && (!isLoadPersistLog || !isLoadInstantLog)}
<DropdownItem on:click={() => openLogs()}>View Log</DropdownItem>
{/if}
{#if !isLite && (!isLoadStateLog || !isOpenUserAddStateModal)}
{#if !isLite && (!isLoadInstantLog || !isOpenUserAddStateModal)}
<li>
<Dropdown direction="right" class="state-menu">
<DropdownToggle caret class="dropdown-item">
States
</DropdownToggle>
<DropdownMenu>
{#if !isLoadStateLog}
<!-- {#if !isLoadInstantLog}
<DropdownItem
on:click={() => toggleStateLog()}
on:click={() => toggleInstantLog()}
>
View States
</DropdownItem>
{/if}
{/if} -->
{#if !isOpenUserAddStateModal}
<DropdownItem
disabled={disableAction}
Expand Down Expand Up @@ -993,7 +997,7 @@
<div class="msg-container">
<div
class="ctext-wrap user-msg"
class:clickable={!isLite && (isLoadContentLog || isLoadStateLog)}
class:clickable={!isLite && (isLoadPersistLog || isLoadInstantLog)}
id={`user-msg-${message.message_id}`}
tabindex="0"
aria-label="user-msg-to-log"
Expand Down Expand Up @@ -1126,14 +1130,14 @@
</div>
</div>
</Pane>
{#if isLoadContentLog}
{#if isLoadPersistLog}
<Pane size={30} minSize={20} maxSize={50}>
<ContentLog
<PersistLog
bind:contentLogs={contentLogs}
bind:agentQueueLogs={agentQueueLogs}
bind:convStateLogs={convStateLogs}
autoScroll={autoScrollLog}
closeWindow={toggleContentLog}
cleanScreen={cleanContentLogScreen}
closeWindow={closePersistLog}
cleanScreen={cleanPersistLogScreen}
/>
</Pane>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

<div class="log-element queue-change-container">
<div class="log-content">
<span class="text-danger">{data?.log}</span>
<span class="text-warning">{data?.log}</span>
</div>
</div>
Loading