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
16c95991
Unverified
Commit
16c95991
authored
Jun 16, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 16, 2024
Browse files
Merge pull request #3145 from ricky-davis/sortable-chats
feat: Sortable chats in admin panel
parents
f3bd8107
b0d9aa38
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
5 deletions
+48
-5
src/lib/components/admin/UserChatsModal.svelte
src/lib/components/admin/UserChatsModal.svelte
+48
-5
No files found.
src/lib/components/admin/UserChatsModal.svelte
View file @
16c95991
...
@@ -31,6 +31,17 @@
...
@@ -31,6 +31,17 @@
}
}
})();
})();
}
}
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';
}
}
</script>
</script>
<Modal size="lg" bind:show>
<Modal size="lg" bind:show>
...
@@ -69,18 +80,45 @@
...
@@ -69,18 +80,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('Title')}
{#if sortKey === 'title'}
{sortOrder === 'asc' ? '▲' : '▼'}
{:else}
<span class="invisible">▲</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 class="invisible">▲</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 class="invisible">▲</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 +126,16 @@
...
@@ -88,11 +126,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