diff --git a/src/lib/components/admin/Users.svelte b/src/lib/components/admin/Users.svelte index 761ab92bf..7c094b082 100644 --- a/src/lib/components/admin/Users.svelte +++ b/src/lib/components/admin/Users.svelte @@ -1,463 +1,60 @@ - { - deleteUserHandler(selectedUser.id); - }} -/> - -{#key selectedUser} - { - users = await getUsers(localStorage.token); - }} - /> -{/key} - - { - users = await getUsers(localStorage.token); - }} -/> - - -{#if loaded} -
-
- {$i18n.t('Users')} -
- - {users.length} -
- -
-
-
-
- - - -
- -
- -
- - - -
-
-
-
- +
- { + selectedTab = 'overview'; + }} > - - - - - - - - - - - - - - - {#each filteredUsers as user, userIdx} - - - - - - - - - - - - - - {/each} - -
setSortKey('role')} - > -
- {$i18n.t('Role')} +
{$i18n.t('Overview')}
+ - {#if sortKey === 'role'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
setSortKey('name')} - > -
- {$i18n.t('Name')} - - {#if sortKey === 'name'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
setSortKey('email')} - > -
- {$i18n.t('Email')} - - {#if sortKey === 'email'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
setSortKey('last_active_at')} - > -
- {$i18n.t('Last Active')} - - {#if sortKey === 'last_active_at'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
setSortKey('created_at')} - > -
- {$i18n.t('Created at')} - {#if sortKey === 'created_at'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
setSortKey('oauth_sub')} - > -
- {$i18n.t('OAuth ID')} - - {#if sortKey === 'oauth_sub'} - {#if sortOrder === 'asc'} - - {:else} - - {/if} - - {:else} - - {/if} -
-
-
- - -
- user - -
{user.name}
-
-
{user.email} - {dayjs(user.last_active_at * 1000).fromNow()} - - {dayjs(user.created_at * 1000).format($i18n.t('MMMM DD, YYYY'))} - {user.oauth_sub ?? ''} -
- {#if $config.features.enable_admin_chat_access && user.role !== 'admin'} - - - - {/if} - - - - - - {#if user.role !== 'admin'} - - - - {/if} -
-
+
-
- ⓘ {$i18n.t("Click on the user role button to change a user's role.")} +
+ {#if selectedTab === 'overview'} + + {:else if selectedTab === 'groups'} + + {/if}
- - -{/if} +
diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib/components/admin/Users/UserList.svelte b/src/lib/components/admin/Users/UserList.svelte new file mode 100644 index 000000000..1c82eab0a --- /dev/null +++ b/src/lib/components/admin/Users/UserList.svelte @@ -0,0 +1,465 @@ + + + { + deleteUserHandler(selectedUser.id); + }} +/> + +{#key selectedUser} + { + users = await getUsers(localStorage.token); + }} + /> +{/key} + + { + users = await getUsers(localStorage.token); + }} +/> + + +{#if loaded} +
+
+ {$i18n.t('Users')} +
+ + {users.length} +
+ +
+
+
+
+ + + +
+ +
+ +
+ + + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + {#each filteredUsers as user, userIdx} + + + + + + + + + + + + + + {/each} + +
setSortKey('role')} + > +
+ {$i18n.t('Role')} + + {#if sortKey === 'role'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
setSortKey('name')} + > +
+ {$i18n.t('Name')} + + {#if sortKey === 'name'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
setSortKey('email')} + > +
+ {$i18n.t('Email')} + + {#if sortKey === 'email'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
setSortKey('last_active_at')} + > +
+ {$i18n.t('Last Active')} + + {#if sortKey === 'last_active_at'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
setSortKey('created_at')} + > +
+ {$i18n.t('Created at')} + {#if sortKey === 'created_at'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
setSortKey('oauth_sub')} + > +
+ {$i18n.t('OAuth ID')} + + {#if sortKey === 'oauth_sub'} + {#if sortOrder === 'asc'} + + {:else} + + {/if} + + {:else} + + {/if} +
+
+
+ + +
+ user + +
{user.name}
+
+
{user.email} + {dayjs(user.last_active_at * 1000).fromNow()} + + {dayjs(user.created_at * 1000).format($i18n.t('MMMM DD, YYYY'))} + {user.oauth_sub ?? ''} +
+ {#if $config.features.enable_admin_chat_access && user.role !== 'admin'} + + + + {/if} + + + + + + {#if user.role !== 'admin'} + + + + {/if} +
+
+
+ +
+ ⓘ {$i18n.t("Click on the user role button to change a user's role.")} +
+ + +{/if} diff --git a/src/lib/components/admin/AddUserModal.svelte b/src/lib/components/admin/Users/UserList/AddUserModal.svelte similarity index 99% rename from src/lib/components/admin/AddUserModal.svelte rename to src/lib/components/admin/Users/UserList/AddUserModal.svelte index eea77fce5..c29a39e82 100644 --- a/src/lib/components/admin/AddUserModal.svelte +++ b/src/lib/components/admin/Users/UserList/AddUserModal.svelte @@ -4,9 +4,10 @@ import { onMount, getContext } from 'svelte'; import { addUser } from '$lib/apis/auths'; - import Modal from '../common/Modal.svelte'; import { WEBUI_BASE_URL } from '$lib/constants'; + import Modal from '$lib/components/common/Modal.svelte'; + const i18n = getContext('i18n'); const dispatch = createEventDispatcher(); diff --git a/src/lib/components/admin/EditUserModal.svelte b/src/lib/components/admin/Users/UserList/EditUserModal.svelte similarity index 98% rename from src/lib/components/admin/EditUserModal.svelte rename to src/lib/components/admin/Users/UserList/EditUserModal.svelte index dcaff95b6..2b01e4fe5 100644 --- a/src/lib/components/admin/EditUserModal.svelte +++ b/src/lib/components/admin/Users/UserList/EditUserModal.svelte @@ -5,7 +5,8 @@ import { onMount, getContext } from 'svelte'; import { updateUserById } from '$lib/apis/users'; - import Modal from '../common/Modal.svelte'; + + import Modal from '$lib/components/common/Modal.svelte'; const i18n = getContext('i18n'); const dispatch = createEventDispatcher(); diff --git a/src/lib/components/admin/UserChatsModal.svelte b/src/lib/components/admin/Users/UserList/UserChatsModal.svelte similarity index 99% rename from src/lib/components/admin/UserChatsModal.svelte rename to src/lib/components/admin/Users/UserList/UserChatsModal.svelte index 45c17f4f0..4c8447829 100644 --- a/src/lib/components/admin/UserChatsModal.svelte +++ b/src/lib/components/admin/Users/UserList/UserChatsModal.svelte @@ -5,8 +5,9 @@ const dispatch = createEventDispatcher(); - import Modal from '$lib/components/common/Modal.svelte'; import { getChatListByUserId, deleteChatById, getArchivedChatList } from '$lib/apis/chats'; + + import Modal from '$lib/components/common/Modal.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; const i18n = getContext('i18n'); diff --git a/src/routes/(app)/admin/+layout.svelte b/src/routes/(app)/admin/+layout.svelte index 2ad600150..f209e1946 100644 --- a/src/routes/(app)/admin/+layout.svelte +++ b/src/routes/(app)/admin/+layout.svelte @@ -52,12 +52,10 @@ class="flex gap-1 scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-full bg-transparent py-1" > {$i18n.t('Dashboard')}{$i18n.t('Users')} - import Users from '$lib/components/admin/Users.svelte'; - + import { goto } from '$app/navigation'; + import { onMount } from 'svelte'; - + onMount(() => { + goto('/admin/users'); + }); + diff --git a/src/routes/(app)/admin/users/+page.svelte b/src/routes/(app)/admin/users/+page.svelte new file mode 100644 index 000000000..028cfd7fe --- /dev/null +++ b/src/routes/(app)/admin/users/+page.svelte @@ -0,0 +1,5 @@ + + +