mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
91 lines
2.2 KiB
Markdown
91 lines
2.2 KiB
Markdown
# Dashboard Controller Documentation
|
|
|
|
**File:** `controllers/admin/dashboard.controller.js`
|
|
**Base URL:** `/api/admin/dashboard`
|
|
**Guards:** `authenticate → requireAdmin() → adminLimiter`
|
|
|
|
---
|
|
|
|
## Table of Contents
|
|
- [Users Dashboard](#users-dashboard)
|
|
- [Groups Dashboard](#groups-dashboard)
|
|
|
|
---
|
|
|
|
## Users Dashboard
|
|
|
|
**`GET /api/admin/dashboard/users`**
|
|
|
|
Returns summary stats and breakdowns for all users. All counts run in parallel.
|
|
|
|
### Response `200`
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Users dashboard data fetched.",
|
|
"data": {
|
|
"stats": [
|
|
{ "key": "total", "label": "Total Users", "value": 100 },
|
|
{ "key": "active", "label": "Active Users", "value": 85 },
|
|
{ "key": "inactive", "label": "Inactive Users", "value": 10 },
|
|
{ "key": "verified", "label": "Verified", "value": 80 },
|
|
{ "key": "archived", "label": "Archived", "value": 5 }
|
|
],
|
|
"breakdowns": [
|
|
{
|
|
"key": "acc_type",
|
|
"label": "By Account Type",
|
|
"data": [
|
|
{ "label": "user", "value": 90 },
|
|
{ "label": "staff", "value": 8 },
|
|
{ "label": "admin", "value": 2 }
|
|
]
|
|
},
|
|
{
|
|
"key": "reg_type",
|
|
"label": "By Registration Type",
|
|
"data": [
|
|
{ "label": "system", "value": 75 },
|
|
{ "label": "google", "value": 25 }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Groups Dashboard
|
|
|
|
**`GET /api/admin/dashboard/groups`**
|
|
|
|
Returns summary stats and a top-10 groups-by-member-count breakdown.
|
|
|
|
### Response `200`
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Groups dashboard data fetched.",
|
|
"data": {
|
|
"stats": [
|
|
{ "key": "total", "label": "Total Groups", "value": 20 },
|
|
{ "key": "active", "label": "Active Groups", "value": 18 },
|
|
{ "key": "inactive", "label": "Inactive Groups", "value": 0 },
|
|
{ "key": "archived", "label": "Archived", "value": 2 },
|
|
{ "key": "empty", "label": "Empty Groups", "value": 3 }
|
|
],
|
|
"breakdowns": [
|
|
{
|
|
"key": "top_groups",
|
|
"label": "Top Groups by Members",
|
|
"data": [
|
|
{ "label": "Engineering", "value": 42 },
|
|
{ "label": "Marketing", "value": 30 }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|