feat/perf: Add ENABLE_PUBLIC_ACTIVE_USERS_COUNT environment variable (#20027)
* Merge pull request open-webui#19030 from open-webui/dev (#115) Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: Claude <noreply@anthropic.com> Resolves #13026 * Claude/find active user count 1ct t1 (#116) Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: Claude <noreply@anthropic.com> Resolves #13026 * Claude/find active user count 1ct t1 (#117) Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: Claude <noreply@anthropic.com> Resolves #13026 --------- Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
import { getUsage } from '$lib/apis';
|
||||
import { getSessionUser, userSignOut } from '$lib/apis/auths';
|
||||
|
||||
import { showSettings, mobile, showSidebar, showShortcuts, user } from '$lib/stores';
|
||||
import { showSettings, mobile, showSidebar, showShortcuts, user, config } from '$lib/stores';
|
||||
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
|
||||
@@ -59,9 +59,14 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: if (show) {
|
||||
getUsageInfo();
|
||||
}
|
||||
const handleDropdownChange = (state: boolean) => {
|
||||
dispatch('change', state);
|
||||
|
||||
// Fetch usage info when dropdown opens, if user has permission
|
||||
if (state && ($config?.features?.enable_public_active_users_count || role === 'admin')) {
|
||||
getUsageInfo();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<ShortcutsModal bind:show={$showShortcuts} />
|
||||
@@ -75,9 +80,7 @@
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<DropdownMenu.Root
|
||||
bind:open={show}
|
||||
onOpenChange={(state) => {
|
||||
dispatch('change', state);
|
||||
}}
|
||||
onOpenChange={handleDropdownChange}
|
||||
>
|
||||
<DropdownMenu.Trigger>
|
||||
<slot />
|
||||
@@ -352,7 +355,7 @@
|
||||
<div class=" self-center truncate">{$i18n.t('Sign Out')}</div>
|
||||
</DropdownMenu.Item>
|
||||
|
||||
{#if showActiveUsers && usage}
|
||||
{#if showActiveUsers && ($config?.features?.enable_public_active_users_count || role === 'admin') && usage}
|
||||
{#if usage?.user_count}
|
||||
<hr class=" border-gray-50/30 dark:border-gray-800/30 my-1 p-0" />
|
||||
|
||||
@@ -364,7 +367,9 @@
|
||||
<div
|
||||
class="flex rounded-xl py-1 px-3 text-xs gap-2.5 items-center"
|
||||
on:mouseenter={() => {
|
||||
getUsageInfo();
|
||||
if ($config?.features?.enable_public_active_users_count || role === 'admin') {
|
||||
getUsageInfo();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class=" flex items-center">
|
||||
|
||||
Reference in New Issue
Block a user