- Add user management system with all CRUD operations - Add promotion statistics dashboard with export - Simplify Trading & Market settings UI - Fix promotion schema (dates now optional) - Add missing API endpoints and PATCH support - Add comprehensive documentation - Fix critical bugs (deletePromotion, duplicate endpoints) All features tested and production-ready.
17 KiB
Admin Panel - Complete Implementation Guide
Overview
The TurboTrades Admin Panel is a comprehensive administrative interface for managing all aspects of the platform. This document outlines all implemented features, their usage, and technical details.
Table of Contents
- Features Overview
- Admin Panel Tabs
- Backend API Endpoints
- Component Architecture
- Usage Guide
- Troubleshooting
Features Overview
✅ Fully Implemented Features
-
Maintenance Mode Management
- Enable/disable site-wide maintenance
- Custom maintenance messages
- Admin bypass with Steam ID whitelist
- Scheduled maintenance with start/end times
-
Announcement System
- Create, edit, and delete announcements
- Multiple announcement types (info, warning, success, error)
- Scheduled announcements with start/end dates
- Dismissible announcements
- Real-time display on frontend
-
Promotion Management
- Create and manage promotional campaigns
- Multiple promotion types (deposit bonus, discount, free item, custom)
- Usage tracking and statistics
- Promo code validation
- User-specific usage limits
- Detailed analytics dashboard
-
Trading & Market Settings
- Enable/disable trading features
- Configure deposit and withdrawal settings
- Set commission rates
- Price limits and auto-update intervals
- Fee management
-
User Management
- Search and filter users
- View detailed user profiles
- Balance adjustments with audit trail
- Ban/unban users with reasons
- Staff level management
- Transaction history viewing
Admin Panel Tabs
1. Maintenance Tab
Purpose: Control site-wide maintenance mode and access restrictions.
Features:
- Toggle maintenance mode on/off
- Custom maintenance message
- Admin Steam ID whitelist for bypass
- Scheduled maintenance windows
- Real-time status indicator
Form Fields:
{
enabled: Boolean,
message: String,
allowedSteamIds: Array<String>,
scheduledStart: Date (optional),
scheduledEnd: Date (optional)
}
API Endpoint: PATCH /api/admin/config/maintenance
2. Announcements Tab
Purpose: Create and manage site-wide announcements displayed to users.
Features:
- Create new announcements with type selection
- Edit existing announcements
- Delete announcements with confirmation modal
- Schedule announcements
- Enable/disable individual announcements
- Set dismissibility
Announcement Types:
info- General information (blue)warning- Important warnings (yellow)success- Success messages (green)error- Critical alerts (red)
Form Fields:
{
type: String (info|warning|success|error),
message: String,
enabled: Boolean,
dismissible: Boolean,
startDate: Date (optional),
endDate: Date (optional)
}
API Endpoints:
POST /api/admin/announcements- CreatePUT /api/admin/announcements/:id- UpdateDELETE /api/admin/announcements/:id- DeleteGET /api/config/announcements- Get active (public)
3. Promotions Tab
Purpose: Manage promotional campaigns and track their performance.
Features:
- Create promotion campaigns
- Edit existing promotions
- Delete promotions
- View detailed statistics
- Track usage and conversions
- Export promotion data
Promotion Types:
deposit_bonus- Bonus on depositsdiscount- Percentage discountfree_item- Free item giveawaycustom- Custom promotion type
Form Fields:
{
name: String,
description: String,
type: String,
enabled: Boolean,
startDate: Date,
endDate: Date,
bonusPercentage: Number,
bonusAmount: Number,
minDeposit: Number,
maxBonus: Number,
discountPercentage: Number,
maxUsesPerUser: Number,
maxTotalUses: Number,
newUsersOnly: Boolean,
code: String (optional),
bannerImage: String (optional)
}
API Endpoints:
POST /api/admin/promotions- CreateGET /api/admin/promotions- List all with statsPUT /api/admin/promotions/:id- UpdateDELETE /api/admin/promotions/:id- DeleteGET /api/admin/promotions/:id/stats- Get statisticsGET /api/admin/promotions/:id/usage- Get usage details
Promotion Statistics Modal:
- Total uses
- Unique users
- Total bonus given
- Average bonus per use
- Usage rate
- Recent usage table with user details
- Export functionality (JSON format)
4. Trading & Market Tab
Purpose: Configure trading and marketplace settings.
Trading Settings:
{
enabled: Boolean,
depositEnabled: Boolean,
withdrawEnabled: Boolean,
minDeposit: Number,
minWithdraw: Number,
withdrawFee: Number (0-1, percentage),
maxItemsPerTrade: Number
}
Market Settings:
{
enabled: Boolean,
commission: Number (0-1, percentage),
minListingPrice: Number,
maxListingPrice: Number,
autoUpdatePrices: Boolean,
priceUpdateInterval: Number (milliseconds)
}
API Endpoints:
PATCH /api/admin/config/trading- Update trading settingsPATCH /api/admin/config/market- Update market settings
5. User Management Tab
Purpose: Manage users, permissions, and account actions.
Features:
- Search users by username, Steam ID, or email
- View detailed user profiles
- Adjust user balances with reasons
- Ban/unban users
- Set staff levels (User, Moderator, Support, Admin, Super Admin)
- View transaction history
- Real-time user statistics
User Actions:
- View Details - Full user profile with statistics
- Adjust Balance - Add or subtract funds with audit trail
- Ban User - Ban with reason and optional duration
- Unban User - Remove ban
- Promote User - Set staff level
Balance Adjustment:
{
type: String (credit|debit),
amount: Number,
reason: String
}
Ban User:
{
banned: Boolean,
reason: String,
duration: Number (hours, 0 = permanent)
}
Staff Levels:
- 0 - Regular User
- 1 - Moderator
- 2 - Support
- 3 - Admin
- 4 - Super Admin
API Endpoints:
GET /api/admin/users/search- Search usersGET /api/admin/users/:id- Get user detailsGET /api/admin/users/:id/stats- Get user statisticsGET /api/admin/users/:id/transactions- Get transactionsPATCH /api/admin/users/:id/balance- Adjust balancePATCH /api/admin/users/:id/ban- Ban/unban userPATCH /api/admin/users/:id/staff-level- Update staff level
Backend API Endpoints
Configuration Endpoints
GET /api/admin/config - Get all configuration
PATCH /api/admin/config/maintenance - Update maintenance settings
PATCH /api/admin/config/trading - Update trading settings
PATCH /api/admin/config/market - Update market settings
Announcement Endpoints
POST /api/admin/announcements - Create announcement
PUT /api/admin/announcements/:id - Update announcement
DELETE /api/admin/announcements/:id - Delete announcement
GET /api/config/announcements - Get active announcements (public)
Promotion Endpoints
POST /api/admin/promotions - Create promotion
GET /api/admin/promotions - List all promotions
PUT /api/admin/promotions/:id - Update promotion
DELETE /api/admin/promotions/:id - Delete promotion
GET /api/admin/promotions/:id/stats - Get promotion statistics
GET /api/admin/promotions/:id/usage - Get promotion usage details
GET /api/config/promotions - Get active promotions (public)
POST /api/config/validate-promo - Validate promo code (public)
User Management Endpoints
GET /api/admin/users/search - Search users
GET /api/admin/users/:id - Get user details
GET /api/admin/users/:id/stats - Get user statistics
GET /api/admin/users/:id/transactions - Get user transactions
PATCH /api/admin/users/:id/balance - Adjust user balance
PATCH /api/admin/users/:id/ban - Ban/unban user
PATCH /api/admin/users/:id/staff-level - Update staff level
Component Architecture
Main Components
-
AdminConfigPanel.vue
- Main container component
- Tab navigation
- State management for all sections
- Integrates all sub-components
-
PromotionStatsModal.vue
- Displays detailed promotion statistics
- Shows usage history with user information
- Export functionality
- Real-time data loading
-
UserManagementTab.vue
- Complete user management interface
- Search and filter functionality
- Multiple modals for different actions
- Real-time user data
-
ConfirmModal.vue
- Reusable confirmation modal
- Used for delete operations
- Customizable messages and styles
-
ToggleSwitch.vue
- Reusable toggle component
- Used for boolean settings
Component Hierarchy
AdminConfigPanel
├── ConfirmModal (delete confirmations)
├── PromotionStatsModal (promotion analytics)
├── Tab: Maintenance
│ ├── ToggleSwitch (enabled)
│ ├── Form fields
│ └── Save button
├── Tab: Announcements
│ ├── Announcement list
│ ├── Create/Edit modal
│ └── Delete with ConfirmModal
├── Tab: Promotions
│ ├── Promotion cards
│ ├── Create/Edit modal
│ ├── Stats button → PromotionStatsModal
│ └── Delete button
├── Tab: Trading & Market
│ ├── Trading form
│ └── Market form
└── Tab: User Management
└── UserManagementTab
├── Search bar
├── User list
├── Details modal
├── Balance adjustment modal
├── Ban modal
└── Promote modal
Usage Guide
Accessing the Admin Panel
- Log in with an admin account (staffLevel >= 3)
- Navigate to the admin section
- Select the desired tab
Creating an Announcement
- Go to Announcements tab
- Click + Create Announcement
- Select announcement type
- Enter message
- Configure settings:
- Enable/disable
- Set dismissibility
- Optional: Schedule with start/end dates
- Click Save
Managing Promotions
- Go to Promotions tab
- Click + Create Promotion
- Fill in promotion details:
- Name and description
- Type (deposit_bonus, discount, etc.)
- Date range
- Bonus/discount settings
- Usage limits
- Optional: Promo code
- Click Save
Viewing Promotion Stats:
- Click the Stats button on any promotion card
- View detailed analytics including:
- Total uses
- Unique users
- Revenue impact
- Recent usage
- Export data for further analysis
Adjusting User Balance
- Go to User Management tab
- Search for user
- Click Balance button
- Select adjustment type (Credit/Debit)
- Enter amount and reason
- Preview new balance
- Confirm adjustment
Banning a User
- Go to User Management tab
- Search for user
- Click Ban button
- Enter ban reason (required)
- Set duration in hours (0 = permanent)
- Confirm ban
Note: Banned users are immediately logged out and cannot access the site until unbanned.
Configuring Maintenance Mode
- Go to Maintenance tab
- Toggle maintenance mode on
- Set custom message
- Add admin Steam IDs for bypass (optional)
- Configure scheduled maintenance (optional)
- Save settings
Admin Bypass: Admins with whitelisted Steam IDs can still access the site during maintenance by logging in through the maintenance page.
Data Models
SiteConfig Model
{
maintenance: {
enabled: Boolean,
message: String,
allowedSteamIds: [String],
scheduledStart: Date,
scheduledEnd: Date
},
announcements: [{
id: String,
type: String,
message: String,
enabled: Boolean,
startDate: Date,
endDate: Date,
dismissible: Boolean,
createdBy: String,
createdAt: Date
}],
promotions: [{
id: String,
name: String,
description: String,
type: String,
enabled: Boolean,
startDate: Date,
endDate: Date,
bonusPercentage: Number,
bonusAmount: Number,
minDeposit: Number,
maxBonus: Number,
discountPercentage: Number,
maxUsesPerUser: Number,
maxTotalUses: Number,
currentUses: Number,
newUsersOnly: Boolean,
code: String,
bannerImage: String,
createdBy: String,
createdAt: Date
}],
trading: {
enabled: Boolean,
depositEnabled: Boolean,
withdrawEnabled: Boolean,
minDeposit: Number,
minWithdraw: Number,
withdrawFee: Number,
maxItemsPerTrade: Number
},
market: {
enabled: Boolean,
commission: Number,
minListingPrice: Number,
maxListingPrice: Number,
autoUpdatePrices: Boolean,
priceUpdateInterval: Number
}
}
PromoUsage Model
{
userId: ObjectId (ref: User),
promoId: String,
promoCode: String,
promoName: String,
promoType: String,
bonusAmount: Number,
discountAmount: Number,
transactionId: ObjectId (ref: Transaction),
depositAmount: Number,
usedAt: Date,
ipAddress: String
}
Troubleshooting
Common Issues
1. Changes not saving
- Check console for error messages
- Verify admin permissions (staffLevel >= 3)
- Ensure all required fields are filled
- Check network connection
2. Announcements not displaying
- Verify announcement is enabled
- Check start/end date range
- Ensure frontend is fetching from correct endpoint
- Clear browser cache
3. Maintenance mode issues
- Verify middleware is properly registered
- Check Steam ID format in whitelist
- Test with non-admin account
- Review maintenance middleware logs
4. Promotion stats not loading
- Verify promotion ID is correct
- Check PromoUsage collection exists
- Ensure stats endpoint is accessible
- Review backend logs for errors
5. User search not working
- Check search query syntax
- Verify database indexes exist
- Ensure proper permissions
- Test with different search terms
Debug Mode
Enable detailed logging:
// Backend (index.js)
console.log('🔍 Debug: Admin action', { user, action, data });
// Frontend (AdminConfigPanel.vue)
console.log('🔍 Debug: Form state', formData);
API Testing
Test endpoints using curl:
# Get config
curl -X GET http://localhost:3000/api/admin/config \
-H "Authorization: Bearer YOUR_TOKEN"
# Update maintenance
curl -X PATCH http://localhost:3000/api/admin/config/maintenance \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"enabled": true, "message": "Maintenance test"}'
# Search users
curl -X GET "http://localhost:3000/api/admin/users/search?query=john" \
-H "Authorization: Bearer YOUR_TOKEN"
Security Considerations
- Authentication Required: All admin endpoints require authentication and admin privileges
- Audit Trail: Balance adjustments and bans are logged with admin information
- Input Validation: All inputs are validated on backend
- Rate Limiting: Consider implementing rate limits for admin actions
- HTTPS Only: Admin panel should only be accessible over HTTPS in production
Future Enhancements
Potential features to add:
-
Audit Log Viewer
- View all admin actions
- Filter by admin, action type, date
- Export audit logs
-
Advanced Analytics
- Revenue charts
- User growth graphs
- Conversion funnels
-
Bulk Operations
- Bulk user actions
- Batch announcement creation
- Mass balance adjustments
-
Email Notifications
- Notify users of promotions
- Send maintenance notifications
- Alert admins of important events
-
Role-Based Permissions
- Fine-grained permission system
- Custom role creation
- Permission templates
-
Scheduled Tasks
- Automatic promotion activation
- Scheduled announcements
- Recurring maintenance windows
Support
For issues or questions:
- Check this documentation
- Review console logs (browser and server)
- Check the troubleshooting section
- Contact development team
Changelog
Version 1.0.0 (Current)
- ✅ Complete maintenance mode system
- ✅ Full announcement management
- ✅ Comprehensive promotion system with analytics
- ✅ Trading and market configuration
- ✅ User management with all CRUD operations
- ✅ Promotion statistics modal with export
- ✅ Real-time data updates
- ✅ Mobile-responsive design
- ✅ Complete API documentation
Last Updated: 2024 Maintained By: TurboTrades Development Team