Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
91d53530
Commit
91d53530
authored
Jun 13, 2024
by
rdavis
Browse files
Added the ability to sort chats in the admin panel chats modal
Added "Updated at" column to the admin panel chats modal.
parent
4727e5cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
5 deletions
+51
-5
src/lib/components/admin/UserChatsModal.svelte
src/lib/components/admin/UserChatsModal.svelte
+51
-5
No files found.
src/lib/components/admin/UserChatsModal.svelte
View file @
91d53530
...
@@ -31,6 +31,20 @@
...
@@ -31,6 +31,20 @@
}
}
})();
})();
}
}
let sortKey = 'updated_at'; // default sort key
let sortOrder = 'desc'; // default sort order
function setSortKey(key) {
if (sortKey === key) {
sortOrder = sortOrder === 'asc' ? 'desc' : 'asc';
} else {
sortKey = key;
sortOrder = 'asc';
}
}
$: {
console.log(chats);
}
</script>
</script>
<Modal size="lg" bind:show>
<Modal size="lg" bind:show>
...
@@ -69,18 +83,45 @@
...
@@ -69,18 +83,45 @@
class="text-xs text-gray-700 uppercase bg-transparent dark:text-gray-200 border-b-2 dark:border-gray-800"
class="text-xs text-gray-700 uppercase bg-transparent dark:text-gray-200 border-b-2 dark:border-gray-800"
>
>
<tr>
<tr>
<th scope="col" class="px-3 py-2"> {$i18n.t('Name')} </th>
<th scope="col" class="px-3 py-2 cursor-pointer select-none" on:click={() => setSortKey('title')}>
<th scope="col" class="px-3 py-2 hidden md:flex"> {$i18n.t('Created at')} </th>
{$i18n.t('Name')}
{#if sortKey === 'title'}
{sortOrder === 'asc' ? '▲' : '▼'}
{:else}
<span style="visibility:hidden">▲</span>
{/if}
</th>
<th scope="col" class="px-3 py-2 cursor-pointer select-none" on:click={() => setSortKey('created_at')}>
{$i18n.t('Created at')}
{#if sortKey === 'created_at'}
{sortOrder === 'asc' ? '▲' : '▼'}
{:else}
<span style="visibility:hidden">▲</span>
{/if}
</th>
<th scope="col" class="px-3 py-2 hidden md:flex cursor-pointer select-none" on:click={() => setSortKey('updated_at')}>
{$i18n.t('Updated at')}
{#if sortKey === 'updated_at'}
{sortOrder === 'asc' ? '▲' : '▼'}
{:else}
<span style="visibility:hidden">▲</span>
{/if}
</th>
<th scope="col" class="px-3 py-2 text-right" />
<th scope="col" class="px-3 py-2 text-right" />
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
{#each chats as chat, idx}
{#each chats
.sort((a, b) => {
if (a[sortKey] < b[sortKey]) return sortOrder === 'asc' ? -1 : 1;
if (a[sortKey] > b[sortKey]) return sortOrder === 'asc' ? 1 : -1;
return 0;
}) as chat, idx}
<tr
<tr
class="bg-transparent {idx !== chats.length - 1 &&
class="bg-transparent {idx !== chats.length - 1 &&
'border-b'} dark:bg-gray-900 dark:border-gray-850 text-xs"
'border-b'} dark:bg-gray-900 dark:border-gray-850 text-xs"
>
>
<td class="px-3 py-1
w-2/3
">
<td class="px-3 py-1">
<a href="/s/{chat.id}" target="_blank">
<a href="/s/{chat.id}" target="_blank">
<div class=" underline line-clamp-1">
<div class=" underline line-clamp-1">
{chat.title}
{chat.title}
...
@@ -88,11 +129,16 @@
...
@@ -88,11 +129,16 @@
</a>
</a>
</td>
</td>
<td class=" px-3 py-1
hidden md:flex
h-[2.5rem]">
<td class=" px-3 py-1 h-[2.5rem]">
<div class="my-auto">
<div class="my-auto">
{dayjs(chat.created_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
{dayjs(chat.created_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
</div>
</div>
</td>
</td>
<td class=" px-3 py-1 hidden md:flex h-[2.5rem]">
<div class="my-auto">
{dayjs(chat.updated_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
</div>
</td>
<td class="px-3 py-1 text-right">
<td class="px-3 py-1 text-right">
<div class="flex justify-end w-full">
<div class="flex justify-end w-full">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment