mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac
This commit is contained in:
parent
ee60c3e92a
commit
662f3cd1b3
1 changed files with 24 additions and 23 deletions
|
|
@ -27,8 +27,7 @@
|
||||||
password: ''
|
password: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
let _user_groups: any[] = [];
|
let userGroups: any[] | null = null;
|
||||||
let loadingGroups = false;
|
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
const res = await updateUserById(localStorage.token, selectedUser.id, _user).catch((error) => {
|
const res = await updateUserById(localStorage.token, selectedUser.id, _user).catch((error) => {
|
||||||
|
|
@ -43,14 +42,12 @@
|
||||||
|
|
||||||
const loadUserGroups = async () => {
|
const loadUserGroups = async () => {
|
||||||
if (!selectedUser?.id) return;
|
if (!selectedUser?.id) return;
|
||||||
loadingGroups = true;
|
userGroups = null;
|
||||||
try {
|
|
||||||
_user_groups = await getUserGroupsById(localStorage.token, selectedUser.id);
|
userGroups = await getUserGroupsById(localStorage.token, selectedUser.id).catch((error) => {
|
||||||
} catch (error) {
|
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
} finally {
|
return null;
|
||||||
loadingGroups = false;
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|
@ -122,6 +119,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if userGroups}
|
||||||
|
<div class="flex flex-col w-full text-sm">
|
||||||
|
<div class="mb-1 text-xs text-gray-500">{$i18n.t('User Groups')}</div>
|
||||||
|
|
||||||
|
{#if userGroups.length}
|
||||||
|
<div class="flex flex-wrap gap-1 my-0.5 -mx-1">
|
||||||
|
{#each userGroups as userGroup}
|
||||||
|
<span class="px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-850 text-xs">
|
||||||
|
{userGroup.name}
|
||||||
|
</span>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<span>-</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs text-gray-500">{$i18n.t('Email')}</div>
|
<div class=" mb-1 text-xs text-gray-500">{$i18n.t('Email')}</div>
|
||||||
|
|
||||||
|
|
@ -168,20 +183,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col w-full">
|
|
||||||
<div class="mb-1 text-xs text-gray-500">{$i18n.t('Groups')}</div>
|
|
||||||
|
|
||||||
{#if loadingGroups}
|
|
||||||
<div class="text-sm font-medium text-white">{$i18n.t('Loading groups...')}</div>
|
|
||||||
{:else if _user_groups.length === 0}
|
|
||||||
<div class="text-sm font-medium text-white">{$i18n.t('No groups assigned')}</div>
|
|
||||||
{:else}
|
|
||||||
<div class="text-sm font-medium text-white">
|
|
||||||
{_user_groups.map(g => g.name).join(', ')}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex justify-end pt-3 text-sm font-medium">
|
<div class="flex justify-end pt-3 text-sm font-medium">
|
||||||
<button
|
<button
|
||||||
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
|
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue