Add comprehensive demo data loading logic and .env.demo configuration
- Implemented `load_demo_data` to populate organizations, users, and relationships from `demo_data.json`. - Refactored database initialization to handle demo-specific passwords and multi-entity creation in demo mode. - Added `demo_data.json` with sample organizations and users for better demo showcase. - Introduced `.env.demo` to simplify environment setup for demo scenarios. - Updated `.gitignore` to include `.env.demo` while keeping other `.env` files excluded.
This commit is contained in:
45
frontend/src/lib/api/admin.ts
Normal file
45
frontend/src/lib/api/admin.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { apiClient } from './client';
|
||||
import type { Options } from './generated/sdk.gen';
|
||||
|
||||
export interface UserGrowthData {
|
||||
date: string;
|
||||
totalUsers: number;
|
||||
activeUsers: number;
|
||||
}
|
||||
|
||||
export interface OrgDistributionData {
|
||||
name: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface UserStatusData {
|
||||
name: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface AdminStatsResponse {
|
||||
user_growth: UserGrowthData[];
|
||||
organization_distribution: OrgDistributionData[];
|
||||
user_status: UserStatusData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin: Get Dashboard Stats
|
||||
*
|
||||
* Get aggregated statistics for the admin dashboard (admin only)
|
||||
*/
|
||||
export const getAdminStats = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<any, ThrowOnError>
|
||||
) => {
|
||||
return (options?.client ?? apiClient).get<AdminStatsResponse, any, ThrowOnError>({
|
||||
responseType: 'json',
|
||||
security: [
|
||||
{
|
||||
scheme: 'bearer',
|
||||
type: 'http',
|
||||
},
|
||||
],
|
||||
url: '/api/v1/admin/stats',
|
||||
...options,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user