fix admin portal cannot see org issue

This commit is contained in:
Kohaku-Blueleaf
2025-10-20 01:51:33 +08:00
parent ae09f94b91
commit bdf23de657
4 changed files with 30 additions and 19 deletions

View File

@@ -12,8 +12,6 @@ declare module 'vue' {
ChartCard: typeof import('./components/ChartCard.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAside: typeof import('element-plus/es')['ElAside']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElContainer: typeof import('element-plus/es')['ElContainer']
@@ -26,23 +24,12 @@ declare module 'vue' {
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElResult: typeof import('element-plus/es')['ElResult']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
FileTree: typeof import('./components/FileTree.vue')['default']
GlobalSearch: typeof import('./components/GlobalSearch.vue')['default']

View File

@@ -22,9 +22,10 @@ const dialogVisible = ref(false);
const userDialogVisible = ref(false);
const selectedUser = ref(null);
// Search
// Search and filters
const searchQuery = ref("");
const searchDebounceTimer = ref(null);
const showOrgs = ref(true); // Toggle to show/hide organizations
// Pagination
const currentPage = ref(1);
@@ -105,6 +106,7 @@ async function loadUsers() {
search: searchQuery.value || undefined,
limit: pageSize.value,
offset: (currentPage.value - 1) * pageSize.value,
include_orgs: showOrgs.value,
});
users.value = response.users;
} catch (error) {
@@ -302,7 +304,7 @@ onMounted(() => {
<!-- Search Bar -->
<el-card class="mb-4">
<div class="flex gap-4 items-center">
<div class="flex gap-4 items-center flex-wrap">
<el-input
v-model="searchQuery"
placeholder="Search users by username or email..."
@@ -315,6 +317,12 @@ onMounted(() => {
<div class="i-carbon-search text-gray-400" />
</template>
</el-input>
<el-switch
v-model="showOrgs"
@change="loadUsers"
active-text="Show Organizations"
inactive-text="Users Only"
/>
<span v-if="searchQuery" class="text-sm text-gray-500">
Searching for: "{{ searchQuery }}"
</span>
@@ -341,7 +349,16 @@ onMounted(() => {
label="Username"
min-width="150"
sortable="custom"
/>
>
<template #default="{ row }">
<div class="flex items-center gap-2">
<span>{{ row.username }}</span>
<el-tag v-if="row.is_org" size="small" type="warning"
>ORG</el-tag
>
</div>
</template>
</el-table-column>
<el-table-column prop="email" label="Email" min-width="200" />
<el-table-column
prop="private_used"

View File

@@ -32,11 +32,11 @@ function createAdminClient(token) {
*/
export async function listUsers(
token,
{ search, limit = 100, offset = 0 } = {},
{ search, limit = 100, offset = 0, include_orgs = false } = {},
) {
const client = createAdminClient(token);
const response = await client.get("/users", {
params: { search, limit, offset },
params: { search, limit, offset, include_orgs },
});
return response.data;
}

View File

@@ -88,6 +88,7 @@ async def list_users(
search: str | None = None,
limit: int = 100,
offset: int = 0,
include_orgs: bool = False,
_admin: bool = Depends(verify_admin_token),
):
"""List all users with quota information.
@@ -96,13 +97,18 @@ async def list_users(
search: Search by username or email (optional)
limit: Maximum number of users to return
offset: Offset for pagination
include_orgs: Include organizations in results (default: False)
_admin: Admin authentication (dependency)
Returns:
List of users with quota information
"""
users_query = User.select().where(User.is_org == False)
# Filter by type
if include_orgs:
users_query = User.select() # Include both users and orgs
else:
users_query = User.select().where(User.is_org == False) # Users only
# Add search filter if provided
if search:
@@ -119,6 +125,7 @@ async def list_users(
"email": u.email,
"email_verified": u.email_verified,
"is_active": u.is_active,
"is_org": u.is_org, # Add org flag
"private_quota_bytes": u.private_quota_bytes,
"public_quota_bytes": u.public_quota_bytes,
"private_used_bytes": u.private_used_bytes,