From 8cfab0216e992515ad69caf4977a18777b3c20f3 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 12 Nov 2024 20:33:22 -0800 Subject: [PATCH] refac --- .../components/admin/Settings/Users.svelte | 4 +- src/lib/components/admin/Users.svelte | 463 +++++++++++++++++ src/routes/(app)/admin/+page.svelte | 490 +----------------- 3 files changed, 468 insertions(+), 489 deletions(-) create mode 100644 src/lib/components/admin/Users.svelte diff --git a/src/lib/components/admin/Settings/Users.svelte b/src/lib/components/admin/Settings/Users.svelte index 532553ea6..60c480f0f 100644 --- a/src/lib/components/admin/Settings/Users.svelte +++ b/src/lib/components/admin/Settings/Users.svelte @@ -323,7 +323,7 @@ -
+
diff --git a/src/lib/components/admin/Users.svelte b/src/lib/components/admin/Users.svelte new file mode 100644 index 000000000..761ab92bf --- /dev/null +++ b/src/lib/components/admin/Users.svelte @@ -0,0 +1,463 @@ + + + { + 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/routes/(app)/admin/+page.svelte b/src/routes/(app)/admin/+page.svelte index e9e650f8c..fcc5d39a2 100644 --- a/src/routes/(app)/admin/+page.svelte +++ b/src/routes/(app)/admin/+page.svelte @@ -1,489 +1,5 @@ - - { - 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} - - +