mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 19:17:56 -05:00
fix(a11y): Analytics and group member tables can be sorted from the keyboard (#33432)
This commit is contained in:
2 files changed
+116
-62
No files matched your search
@@ -159,6 +159,9 @@
|
||||
let userOrderBy = 'total_tokens';
|
||||
let userDirection: 'asc' | 'desc' = 'desc';
|
||||
|
||||
const sortState = (key, orderBy, direction) =>
|
||||
orderBy === key ? (direction === 'asc' ? 'ascending' : 'descending') : 'none';
|
||||
|
||||
const toggleModelSort = (key: string) => {
|
||||
if (modelOrderBy === key) {
|
||||
modelDirection = modelDirection === 'asc' ? 'desc' : 'asc';
|
||||
@@ -563,10 +566,14 @@
|
||||
<th scope="col" class="font-normal px-2.5 py-1.5 w-8">#</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none"
|
||||
on:click={() => toggleModelSort('name')}
|
||||
class="font-normal select-none"
|
||||
aria-sort={sortState('name', modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5"
|
||||
on:click={() => toggleModelSort('name')}
|
||||
>
|
||||
{$i18n.t('Model')}
|
||||
{#if modelOrderBy === 'name'}
|
||||
<span class="font-normal">
|
||||
@@ -577,14 +584,18 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleModelSort('count')}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState('count', modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleModelSort('count')}
|
||||
>
|
||||
{$i18n.t('Messages')}
|
||||
{#if modelOrderBy === 'count'}
|
||||
<span class="font-normal">
|
||||
@@ -595,14 +606,18 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleModelSort('users')}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState('users', modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleModelSort('users')}
|
||||
>
|
||||
{$i18n.t('Users')}
|
||||
{#if modelOrderBy === 'users'}
|
||||
<span class="font-normal">
|
||||
@@ -613,14 +628,18 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleModelSort('chats')}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState('chats', modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleModelSort('chats')}
|
||||
>
|
||||
{$i18n.t('Chats')}
|
||||
{#if modelOrderBy === 'chats'}
|
||||
<span class="font-normal">
|
||||
@@ -631,17 +650,21 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<!-- {$i18n.t('Tokens')} -->
|
||||
{#each tokenColumns as column}
|
||||
<th
|
||||
scope="col"
|
||||
title={`${column.label} ${$i18n.t('tokens')}`}
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleModelSort(column.key)}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState(column.key, modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleModelSort(column.key)}
|
||||
>
|
||||
{column.label}
|
||||
{#if modelOrderBy === column.key}
|
||||
<span class="font-normal">
|
||||
@@ -652,15 +675,19 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
{/each}
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right w-16"
|
||||
on:click={() => toggleModelSort('percentage')}
|
||||
class="font-normal select-none text-right w-16"
|
||||
aria-sort={sortState('percentage', modelOrderBy, modelDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleModelSort('percentage')}
|
||||
>
|
||||
{selectedMetric === 'tokens'
|
||||
? $i18n.t('Token share')
|
||||
: $i18n.t('Message share')}
|
||||
@@ -673,7 +700,7 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -772,10 +799,14 @@
|
||||
<th scope="col" class="font-normal px-2.5 py-1.5 w-8">#</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none"
|
||||
on:click={() => toggleUserSort('name')}
|
||||
class="font-normal select-none"
|
||||
aria-sort={sortState('name', userOrderBy, userDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5"
|
||||
on:click={() => toggleUserSort('name')}
|
||||
>
|
||||
{$i18n.t('User')}
|
||||
{#if userOrderBy === 'name'}
|
||||
<span class="font-normal">
|
||||
@@ -786,14 +817,18 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleUserSort('count')}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState('count', userOrderBy, userDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleUserSort('count')}
|
||||
>
|
||||
{$i18n.t('Messages')}
|
||||
{#if userOrderBy === 'count'}
|
||||
<span class="font-normal">
|
||||
@@ -804,17 +839,21 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
<!-- {$i18n.t('Tokens')} -->
|
||||
{#each tokenColumns as column}
|
||||
<th
|
||||
scope="col"
|
||||
title={`${column.label} ${$i18n.t('tokens')}`}
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right"
|
||||
on:click={() => toggleUserSort(column.key)}
|
||||
class="font-normal select-none text-right"
|
||||
aria-sort={sortState(column.key, userOrderBy, userDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleUserSort(column.key)}
|
||||
>
|
||||
{column.label}
|
||||
{#if userOrderBy === column.key}
|
||||
<span class="font-normal">
|
||||
@@ -825,15 +864,19 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
{/each}
|
||||
<th
|
||||
scope="col"
|
||||
class="font-normal px-2.5 py-1.5 cursor-pointer select-none text-right w-16"
|
||||
on:click={() => toggleUserSort('percentage')}
|
||||
class="font-normal select-none text-right w-16"
|
||||
aria-sort={sortState('percentage', userOrderBy, userDirection)}
|
||||
>
|
||||
<div class="flex gap-1.5 items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full gap-1.5 items-center px-2.5 py-1.5 justify-end"
|
||||
on:click={() => toggleUserSort('percentage')}
|
||||
>
|
||||
{selectedMetric === 'tokens'
|
||||
? $i18n.t('Token share')
|
||||
: $i18n.t('Message share')}
|
||||
@@ -846,7 +889,7 @@
|
||||
{:else}
|
||||
<span class="invisible"><ChevronUp className="size-2" /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in new issue
Block a user