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
7 changes: 7 additions & 0 deletions src/lib/helpers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
* @property {number} count - Row count.
*/

/**
* @typedef {Object} KeyValuePair
* @property {string} key - The key.
* @property {string} value - The value.
*/

/**
* @template T
* @typedef {Object} PagedItems<T>
Expand Down Expand Up @@ -179,6 +185,7 @@
* @property {string} [channel] - The conversation channel.
* @property {string} [status] - The conversation status.
* @property {string} [taskId] - The task id.
* @property {KeyValuePair[]} [states] - The conversation status.
*/

/**
Expand Down
36 changes: 33 additions & 3 deletions src/routes/page/conversation/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { utcToLocal } from '$lib/helpers/datetime';
import Swal from 'sweetalert2/dist/sweetalert2.js';
import "sweetalert2/src/sweetalert2.scss";
import lodash from "lodash";

let isLoading = false;
let isComplete = false;
Expand All @@ -45,6 +46,9 @@
/** @type {import('$types').Pagination} */
let pager = filter.pager;

/** @type {string} */
let searchStr = '';

onMount(async () => {
isLoading = true;
getPagedConversations().then(res => {
Expand Down Expand Up @@ -146,12 +150,32 @@
*/
function searchConversations(e) {
e.preventDefault();
const searchStates = handleSearchString();
filter = {
...filter,
pager: { page: firstPage, size: pageSize, count: 0 }
pager: { page: firstPage, size: pageSize, count: 0 },
states: searchStates
};
getPagedConversations();
}

function handleSearchString() {
const splits = searchStr?.split(';') || [];
/** @type {import('$types').KeyValuePair[]} */
const states = [];

splits.forEach(pair => {
const sp = pair?.split('=') || [];
if (sp.length > 0) {
states.push({
key: lodash.trim(sp[0]),
value: lodash.trim(sp[1])
});
}
});

return states;
}
</script>

<HeadTitle title="{$_('Conversation List')}" />
Expand Down Expand Up @@ -186,7 +210,8 @@
type="search"
class="form-control"
id="searchTableList"
placeholder="{$_('Search for ...')}"
bind:value={searchStr}
placeholder="{$_('Search for states, e.g., key1=value1;key2=value2;')}"
/>
</Col>
<Col lg="2">
Expand All @@ -213,7 +238,12 @@
<Input type="date" class="form-control" />
</Col>
<Col lg="1">
<Button type="button" color="secondary" class="btn-soft-secondary w-100">
<Button
type="button"
color="secondary"
class="btn-soft-secondary w-100"
on:click={(e) => searchConversations(e)}
>
<i class="mdi mdi-filter-outline align-middle" /> {$_('Filter')}
</Button>
</Col>
Expand Down