Skip to content

Commit

Permalink
Merge pull request #16 from iceljc/features/refine-conversation-elements
Browse files Browse the repository at this point in the history
Features/refine conversation elements
  • Loading branch information
Oceania2018 authored Jan 23, 2024
2 parents 2d24627 + e93fb99 commit 0383b97
Show file tree
Hide file tree
Showing 14 changed files with 246 additions and 79 deletions.
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"chart.js": "^4.4.0",
"drawflow": "^0.0.59",
"fullcalendar": "^6.1.9",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"overlayscrollbars": "^2.4.4",
"overlayscrollbars-svelte": "^0.5.2",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Col,
Row,
} from '@sveltestrap/sveltestrap';
import { afterUpdate } from 'svelte';
/** @type {import('$lib/helpers/types').Pagination} */
export let pagination = { page: 1, size: 10, count: 0 };
Expand All @@ -23,9 +22,9 @@
/** @type {number[]} */
$: pages = Array.from({ length: maxPage - minPage + 1 }, (_, i) => minPage + i);
/** @type {boolean} */
$: disableBackward = pagination.page === firstPage;
$: disableBackward = pagination.page === firstPage || pagination.count === 0;
/** @type {boolean} */
$: disableForward = pagination.page === totalPages;
$: disableForward = pagination.page === totalPages || pagination.count === 0;
/**
* @param {any} e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/** @type {number} */
$: totalPages = Math.ceil(pagination.count / pagination.size);
/** @type {number} */
$: start = (pagination.page - 1) * pagination.size + 1;
$: start = pagination.count <= 0 ? 0 : (pagination.page - 1) * pagination.size + 1;
/** @type {number} */
$: end = Math.min(pagination.page * pagination.size, pagination.count);
/** @type {number} */
Expand All @@ -23,9 +23,9 @@
/** @type {number[]} */
$: pages = Array.from({ length: maxPage - minPage + 1 }, (_, i) => minPage + i);
/** @type {boolean} */
$: disableBackward = pagination.page === firstPage;
$: disableBackward = pagination.page === firstPage || pagination.count === 0;
/** @type {boolean} */
$: disableForward = pagination.page === totalPages;
$: disableForward = pagination.page === totalPages || pagination.count === 0;
/**
* @param {any} e
Expand Down
1 change: 1 addition & 0 deletions src/lib/helpers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

/**
* @typedef {Object} AgentFilter
* @property {Pagination} pager - Pagination
* @property {boolean} [isRouter]
* @property {boolean} [isEvaluator]
* @property {boolean} [allowRouting]
Expand Down
12 changes: 8 additions & 4 deletions src/lib/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ export async function getSettings() {
return response.data;
}

/**
* Get conversation list
* @param {import('$types').ConversationFilter} filter
* @returns {Promise<import('$types').PagedItems<import('$types').ConversationModel>>}
*/

/**
* Get agent list
* @param {import('$types').AgentFilter} filter
* @returns {Promise<import('$types').AgentModel[]>}
* @returns {Promise<import('$types').PagedItems<import('$types').AgentModel>>}
*/
export async function getAgents(filter) {
let url = endpoints.agentListUrl;
const response = await axios.get(url, {
params: filter
});
const response = await axios.post(url, { ...filter });
return response.data;
}

Expand Down
6 changes: 6 additions & 0 deletions src/routes/VerticalLayout/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { page } from '$app/stores';
import { browser } from '$app/environment';
import { _ } from 'svelte-i18n'
import { isMenuButton } from 'svelte-jsoneditor';
/** @type {import('$types').PluginMenuDefModel[]} */
export let menu
Expand Down Expand Up @@ -131,6 +132,11 @@
};
const removeActiveDropdown = () => {
document.querySelectorAll('.vertical-menu .mm-active').forEach((menu) => {
menu.querySelectorAll('.active').forEach(child => child.classList.remove('active'));
menu.classList.remove('mm-active');
});
document.querySelectorAll('.vertical-menu .has-arrow').forEach((menu) => {
if (menu.nextElementSibling) {
menu.nextElementSibling.classList.add('mm-collapse');
Expand Down
12 changes: 7 additions & 5 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import Swal from 'sweetalert2/dist/sweetalert2.js';
import "sweetalert2/src/sweetalert2.scss";
import { replaceNewLine } from '$lib/helpers/http';
import _ from "lodash";
const options = {
scrollbars: {
Expand Down Expand Up @@ -203,7 +204,7 @@
</div>
</div>
<div class="scrollbar" style="height: 75vh">
<div class="scrollbar" style="height: 80vh">
<div class="chat-conversation p-3">
<ul class="list-unstyled mb-0">
<li>
Expand Down Expand Up @@ -269,7 +270,7 @@
</div>
</div>
<div class="p-3 chat-input-section" style="height: 15vh">
<div class="p-3 chat-input-section" style="height: 10vh">
<div class="row">
<div class="col-auto">
<button
Expand All @@ -280,8 +281,8 @@
</button>
</div>
<div class="col">
<div class="position-relative">
<textarea rows={3} maxlength={500} class="form-control chat-input" bind:value={text} on:keydown={e => onSendMessage(e)} placeholder="Enter Message..." />
<div class="position-relative">
<textarea rows={1} maxlength={500} class="form-control chat-input" bind:value={text} on:keydown={e => onSendMessage(e)} placeholder="Enter Message..." />
<div class="chat-input-links" id="tooltip-container">
<ul class="list-inline mb-0">
<li class="list-inline-item">
Expand All @@ -295,8 +296,9 @@
<button
type="submit"
class="btn btn-primary btn-rounded chat-send waves-effect waves-light"
disabled={!!!_.trim(text)}
on:click={sendTextMessage}
><span class="d-none d-sm-inline-block me-2">Send</span>
><span class="d-none d-sm-inline-block me-2">Send</span>
<i class="mdi mdi-send" />
</button>
</div>
Expand Down
74 changes: 66 additions & 8 deletions src/routes/page/agent/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,79 @@
import CardAgent from './card-agent.svelte';
import { getAgents } from '$lib/services/agent-service.js';
import { onMount } from 'svelte';
import PlainPagination from '$lib/common/PlainPagination.svelte';
/** @type {import('$types').AgentModel[]} */
let agents = [];
const firstPage = 1;
const pageSize = 12;
/** @type {import('$types').PagedItems<import('$types').AgentModel>} */
let agents = { items: [], count: 0 };
/** @type {import('$types').AgentFilter} */
const initFilter = {
pager: { page: firstPage, size: pageSize, count: 0 },
isEvaluator: false
};
/** @type {import('$types').AgentFilter} */
let filter = { ... initFilter };
/** @type {import('$types').Pagination} */
let pager = filter.pager;
onMount(async () => {
agents = await getAgents({
isEvaluator: false
});
await getPagedAgents();
});
async function getPagedAgents() {
agents = await getAgents(filter);
refresh();
}
function refresh() {
refreshAgents();
refreshPager(agents.count, filter.pager.page, filter.pager.size);
}
function refreshAgents() {
agents = {
items: agents?.items?.map(t => { return { ...t }; }) || [],
count: agents?.count || 0
};
}
/** @param {number} totalItemsCount */
function refreshPager(totalItemsCount, page = firstPage, pageCount = pageSize) {
pager = {
page: page,
size: pageCount || 0,
count: totalItemsCount || 0
};
}
/**
* @param {number} pageNum
*/
function pageTo(pageNum) {
pager = {
...pager,
page: pageNum
};
filter = {
...filter,
pager: pager
};
getPagedAgents();
}
</script>
<HeadTitle title="Agent List" />

<Breadcrumb title="Agent" pagetitle="List" />
<Row>
<CardAgent agents={agents} />
</Row>
<CardAgent agents={agents.items} />
</Row>
<PlainPagination pagination={pager} pageTo={pageTo} />
74 changes: 66 additions & 8 deletions src/routes/page/agent/evaluator/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,77 @@
import { Col, Row } from '@sveltestrap/sveltestrap';
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
import HeadTitle from '$lib/common/HeadTitle.svelte';
import { getAgents } from '$lib/services/agent-service.js';
import { onMount } from 'svelte';
import { getAgents } from '$lib/services/agent-service.js';
import { onMount } from 'svelte';
import PlainPagination from '$lib/common/PlainPagination.svelte';
/** @type {import('$types').AgentModel[]} */
let agents = [];
const firstPage = 1;
const pageSize = 12;
/** @type {import('$types').PagedItems<import('$types').AgentModel>} */
let agents = { items: [], count: 0 };
/** @type {import('$types').AgentFilter} */
const initFilter = {
pager: { page: firstPage, size: pageSize, count: 0 },
isEvaluator: true
};
/** @type {import('$types').AgentFilter} */
let filter = { ... initFilter };
/** @type {import('$types').Pagination} */
let pager = filter.pager;
onMount(async () => {
agents = await getAgents({
isEvaluator: true
});
await getPagedAgents();
});
async function getPagedAgents() {
agents = await getAgents(filter);
refresh();
}
function refresh() {
refreshAgents();
refreshPager(agents.count, filter.pager.page, filter.pager.size);
}
function refreshAgents() {
agents = {
items: agents?.items?.map(t => { return { ...t }; }) || [],
count: agents?.count || 0
};
}
/** @param {number} totalItemsCount */
function refreshPager(totalItemsCount, page = firstPage, pageCount = pageSize) {
pager = {
page: page,
size: pageCount || 0,
count: totalItemsCount || 0
};
}
/**
* @param {number} pageNum
*/
function pageTo(pageNum) {
pager = {
...pager,
page: pageNum
};
filter = {
...filter,
pager: pager
};
getPagedAgents();
}
</script>
<HeadTitle title="Evaluator" />
<Breadcrumb title="Agent" pagetitle="Evaluator" />
<Breadcrumb title="Agent" pagetitle="Evaluator" />
<PlainPagination pagination={pager} pageTo={pageTo} />
Loading

0 comments on commit 0383b97

Please sign in to comment.