feat(api): integrate per-organization resource counts into organization listing
- Added `resource_counts` to the `ListOrganizationsResponse` to include per-organization knowledge base and agent counts, enhancing the sidebar display. - Removed the deprecated `getMeResourceCounts` API endpoint, consolidating resource count retrieval into the organization listing. - Updated the organization store to manage and utilize the new resource counts effectively. - Adjusted UI components to leverage the new resource counts structure, improving data retrieval and display for agents and knowledge bases. This update streamlines resource count management and enhances the user experience by providing relevant data in a single API call.
This commit is contained in:
@@ -159,9 +159,16 @@ export interface ApiResponse<T> {
|
||||
message?: string
|
||||
}
|
||||
|
||||
/** Per-org resource counts (included in list my organizations to avoid extra GET /me/resource-counts) */
|
||||
export interface ResourceCountsByOrg {
|
||||
knowledge_bases: { by_organization: Record<string, number> }
|
||||
agents: { by_organization: Record<string, number> }
|
||||
}
|
||||
|
||||
export interface ListOrganizationsResponse {
|
||||
organizations: Organization[]
|
||||
total: number
|
||||
resource_counts?: ResourceCountsByOrg
|
||||
}
|
||||
|
||||
export interface ListMembersResponse {
|
||||
@@ -642,25 +649,6 @@ export async function listSharedAgents(): Promise<ApiResponse<SharedAgentInfo[]>
|
||||
}
|
||||
}
|
||||
|
||||
/** Response of GET /me/resource-counts: per-org counts for sidebar (one request instead of N). */
|
||||
export interface MeResourceCountsResponse {
|
||||
knowledge_bases: { by_organization: Record<string, number> }
|
||||
agents: { by_organization: Record<string, number> }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get per-organization resource counts for list sidebar (one request).
|
||||
* 全部 total is not included; frontend keeps 全部 = 我的 + 他人共享给我.
|
||||
*/
|
||||
export async function getMeResourceCounts(): Promise<ApiResponse<MeResourceCountsResponse>> {
|
||||
try {
|
||||
const response = await get('/api/v1/me/resource-counts')
|
||||
return response as unknown as ApiResponse<MeResourceCountsResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to get resource counts' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List all agents in an organization (including those shared by current tenant), for list page when a space is selected.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user