Skip to content

Commit b94de4f

Browse files
committed
refac
1 parent 039a1e1 commit b94de4f

File tree

6 files changed

+101
-17
lines changed

6 files changed

+101
-17
lines changed

backend/open_webui/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ async def get_app_config(request: Request):
11911191
{
11921192
"default_models": app.state.config.DEFAULT_MODELS,
11931193
"default_prompt_suggestions": app.state.config.DEFAULT_PROMPT_SUGGESTIONS,
1194+
"user_count": user_count,
11941195
"code": {
11951196
"engine": app.state.config.CODE_EXECUTION_ENGINE,
11961197
},
@@ -1214,11 +1215,10 @@ async def get_app_config(request: Request):
12141215
"api_key": GOOGLE_DRIVE_API_KEY.value,
12151216
},
12161217
"onedrive": {"client_id": ONEDRIVE_CLIENT_ID.value},
1218+
"license_metadata": app.state.LICENSE_METADATA,
12171219
**(
12181220
{
1219-
"record_count": user_count,
12201221
"active_entries": app.state.USER_COUNT,
1221-
"license_metadata": app.state.LICENSE_METADATA,
12221222
}
12231223
if user.role == "admin"
12241224
else {}

src/lib/components/admin/Settings/General.svelte

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import DOMPurify from 'dompurify';
3+
24
import { getBackendConfig, getVersionUpdates, getWebhookUrl, updateWebhookUrl } from '$lib/apis';
35
import {
46
getAdminConfig,
@@ -220,15 +222,44 @@
220222
<div class="">
221223
{$i18n.t('License')}
222224
</div>
223-
<a
224-
class=" text-xs text-gray-500 hover:underline"
225-
href="https://docs.openwebui.com/enterprise"
226-
target="_blank"
227-
>
228-
{$i18n.t(
229-
'Upgrade to a licensed plan for enhanced capabilities, including custom theming and branding, and dedicated support.'
230-
)}
231-
</a>
225+
226+
{#if $config?.license_metadata}
227+
<a
228+
href="https://docs.openwebui.com/enterprise"
229+
target="_blank"
230+
class="text-gray-500 mt-0.5"
231+
>
232+
<span class=" capitalize text-black dark:text-white"
233+
>{$config?.license_metadata?.type}
234+
license</span
235+
>
236+
registered to
237+
<span class=" capitalize text-black dark:text-white"
238+
>{$config?.license_metadata?.organization_name}</span
239+
>
240+
for
241+
<span class=" font-medium text-black dark:text-white"
242+
>{$config?.license_metadata?.seats ?? 'Unlimited'} users.</span
243+
>
244+
</a>
245+
{#if $config?.license_metadata?.html}
246+
<div class="mt-0.5">
247+
{@html DOMPurify.sanitize($config?.license_metadata?.html)}
248+
</div>
249+
{/if}
250+
{:else}
251+
<a
252+
class=" text-xs hover:underline"
253+
href="https://docs.openwebui.com/enterprise"
254+
target="_blank"
255+
>
256+
<span class="text-gray-500">
257+
{$i18n.t(
258+
'Upgrade to a licensed plan for enhanced capabilities, including custom theming and branding, and dedicated support.'
259+
)}
260+
</span>
261+
</a>
262+
{/if}
232263
</div>
233264

234265
<!-- <button

src/lib/components/admin/Users/UserList.svelte

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import ChevronUp from '$lib/components/icons/ChevronUp.svelte';
2929
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
3030
import About from '$lib/components/chat/Settings/About.svelte';
31+
import Banner from '$lib/components/common/Banner.svelte';
3132
3233
const i18n = getContext('i18n');
3334
@@ -124,12 +125,43 @@
124125
/>
125126
<UserChatsModal bind:show={showUserChatsModal} user={selectedUser} />
126127

128+
{#if ($config?.license_metadata?.seats ?? null) !== null && users.length > $config?.license_metadata?.seats}
129+
<div class=" mt-1 mb-2 text-xs text-red-500">
130+
<Banner
131+
className="mx-0"
132+
banner={{
133+
type: 'error',
134+
title: 'License Error',
135+
content:
136+
'Exceeded the number of seats in your license. Please contact support to increase the number of seats.',
137+
dismissable: true
138+
}}
139+
/>
140+
</div>
141+
{/if}
142+
127143
<div class="mt-0.5 mb-2 gap-1 flex flex-col md:flex-row justify-between">
128144
<div class="flex md:self-center text-lg font-medium px-0.5">
129-
{$i18n.t('Users')}
145+
<div class="flex-shrink-0">
146+
{$i18n.t('Users')}
147+
</div>
130148
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
131149

132-
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{users.length}</span>
150+
{#if ($config?.license_metadata?.seats ?? null) !== null}
151+
{#if users.length > $config?.license_metadata?.seats}
152+
<span class="text-lg font-medium text-red-500"
153+
>{users.length} of {$config?.license_metadata?.seats}
154+
<span class="text-sm font-normal">available users</span></span
155+
>
156+
{:else}
157+
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
158+
>{users.length} of {$config?.license_metadata?.seats}
159+
<span class="text-sm font-normal">available users</span></span
160+
>
161+
{/if}
162+
{:else}
163+
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{users.length}</span>
164+
{/if}
133165
</div>
134166

135167
<div class="flex gap-1">

src/lib/components/chat/Chat.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,18 @@
19401940
{#if $banners.length > 0 && !history.currentId && !$chatId && selectedModels.length <= 1}
19411941
<div class="absolute top-12 left-0 right-0 w-full z-30">
19421942
<div class=" flex flex-col gap-1 w-full">
1943+
{#if ($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats}
1944+
<Banner
1945+
banner={{
1946+
type: 'error',
1947+
title: 'License Error',
1948+
content: $i18n.t(
1949+
'Exceeded the number of seats in your license. Please contact support to increase the number of seats.'
1950+
)
1951+
}}
1952+
/>
1953+
{/if}
1954+
19431955
{#each $banners.filter( (b) => (b.dismissible ? !JSON.parse(localStorage.getItem('dismissedBannerIds') ?? '[]').includes(b.id) : true) ) as banner}
19441956
<Banner
19451957
{banner}

src/lib/components/chat/Settings/About.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@
136136
</div>
137137

138138
<div>
139+
{#if $config?.license_metadata}
140+
<div class="mb-2 text-xs">
141+
{#if !$WEBUI_NAME.includes('Open WebUI')}
142+
<span class=" text-gray-500 dark:text-gray-300 font-medium">{$WEBUI_NAME}</span> -
143+
{/if}
144+
145+
<span class=" capitalize">{$config?.license_metadata?.type}</span> license purchased by
146+
<span class=" capitalize">{$config?.license_metadata?.organization_name}</span>
147+
</div>
148+
{/if}
149+
139150
<pre
140151
class="text-xs text-gray-400 dark:text-gray-500">Copyright (c) {new Date().getFullYear()} <a
141152
href="https://openwebui.com"
@@ -172,9 +183,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
172183
</div>
173184

174185
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
175-
{#if !$WEBUI_NAME.includes('Open WebUI')}
176-
<span class=" text-gray-500 dark:text-gray-300 font-medium">{$WEBUI_NAME}</span> -
177-
{/if}
178186
{$i18n.t('Created by')}
179187
<a
180188
class=" text-gray-500 dark:text-gray-300 font-medium"

src/lib/components/common/Banner.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
dismissable: true,
1717
timestamp: Math.floor(Date.now() / 1000)
1818
};
19+
export let className = 'mx-4';
1920
2021
export let dismissed = false;
2122
@@ -41,7 +42,7 @@
4142
{#if !dismissed}
4243
{#if mounted}
4344
<div
44-
class=" top-0 left-0 right-0 p-2 mx-4 px-3 flex justify-center items-center relative rounded-xl border border-gray-100 dark:border-gray-850 text-gray-800 dark:text-gary-100 bg-white dark:bg-gray-900 backdrop-blur-xl z-30"
45+
class="{className} top-0 left-0 right-0 p-2 px-3 flex justify-center items-center relative rounded-xl border border-gray-100 dark:border-gray-850 text-gray-800 dark:text-gary-100 bg-white dark:bg-gray-900 backdrop-blur-xl z-30"
4546
transition:fade={{ delay: 100, duration: 300 }}
4647
>
4748
<div class=" flex flex-col md:flex-row md:items-center flex-1 text-sm w-fit gap-1.5">

0 commit comments

Comments
 (0)