Skip to content

Commit

Permalink
Merge pull request #264 from iceljc/features/refine-chat-window
Browse files Browse the repository at this point in the history
add plugin search
  • Loading branch information
iceljc authored Nov 5, 2024
2 parents 20b0d03 + 615050c commit 75114ea
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/lib/helpers/types/pluginTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/**
* @typedef {Object} PluginFilter
* @property {import('$commonTypes').Pagination} pager - Pagination
* @property {string[]} [names] - The plugin names
*/

export default {};
2 changes: 2 additions & 0 deletions src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
flex: 0 0 fit-content;
flex-direction: column;
height: 100%;
gap: 5px;

.chat-head-agent {
flex: 0.5;
Expand All @@ -108,6 +109,7 @@
display: flex;
gap: 5px;
width: fit-content;
font-size: 12px;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/services/plugin-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export async function getPlugins(filter) {
let url = endpoints.pluginListUrl;
const response = await axios.get(url, { params: filter,
paramsSerializer: {
dots: true
dots: true,
indexes: null
}
});
return response.data;
Expand Down
9 changes: 4 additions & 5 deletions src/routes/VerticalLayout/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@
return path?.startsWith('/') ? path.substring(1) : path;
};
/** @param {string} link */
const goToPage = (link) => {
const goToPage = () => {
globalEventStore.reset();
}
</script>
Expand Down Expand Up @@ -231,19 +230,19 @@
</Link>
<ul class="sub-menu mm-collapse">
{#each subMenu.childItems as childItem}
<li><Link href={childItem.link} on:click={() => goToPage(childItem.link)}>{$_(childItem.label)}</Link></li>
<li><Link href={childItem.link} on:click={() => goToPage()}>{$_(childItem.label)}</Link></li>
{/each}
</ul>
</li>
{:else}
<li><Link href={subMenu.link} on:click={() => goToPage(subMenu.link)}>{$_(subMenu.label)}</Link></li>
<li><Link href={subMenu.link} on:click={() => goToPage()}>{$_(subMenu.label)}</Link></li>
{/if}
{/each}
</ul>
</li>
{:else}
<li>
<Link class="waves-effect" href={item.link} on:click={() => goToPage(item.link)} >
<Link class="waves-effect" href={item.link} on:click={() => goToPage()} >
<i class={item.icon} /> <span>{$_(item.label)}</span>
</Link>
</li>
Expand Down
22 changes: 21 additions & 1 deletion src/routes/page/plugin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
import HeadTitle from '$lib/common/HeadTitle.svelte';
import Plugins from './plugin-list.svelte';
import { onMount } from 'svelte';
import { onDestroy, onMount } from 'svelte';
import { getPlugins } from '$lib/services/plugin-service';
import { PUBLIC_PLUGIN_DEFAULT_ICON } from '$env/static/public';
import PlainPagination from '$lib/common/PlainPagination.svelte';
import { _ } from 'svelte-i18n';
import { globalEventStore } from '$lib/helpers/store';
import { GlobalEvent } from '$lib/helpers/enums';
const firstPage = 1;
const pageSize = 12;
Expand All @@ -25,10 +27,28 @@
/** @type {import('$commonTypes').Pagination} */
let pager = filter.pager;
/** @type {any} */
let unsubscriber;
onMount(async () => {
await getPagedPlugins();
unsubscriber = globalEventStore.subscribe((/** @type {import('$commonTypes').GlobalEvent} */ event) => {
if (event.name !== GlobalEvent.Search) return;
const names = event.payload ? [event.payload] : undefined;
filter = {
pager: { page: firstPage, size: pageSize, count: 0 },
names: names
};
getPagedPlugins();
});
});
onDestroy(() => {
unsubscriber?.();
});
async function getPagedPlugins() {
plugins = await getPlugins(filter);
refresh();
Expand Down

0 comments on commit 75114ea

Please sign in to comment.