- 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.
267 lines
5.3 KiB
Markdown
267 lines
5.3 KiB
Markdown
# Admin Panel Quick Fix Guide 🚀
|
|
|
|
## 🎯 What Was Fixed
|
|
|
|
### ✅ Issue 1: Toggles Are Now Clear!
|
|
- **NEW:** Green/Red color coding (Green = ON, Red = OFF)
|
|
- **NEW:** "ON" and "OFF" text labels inside toggles
|
|
- **NEW:** Smooth animations and better sizing
|
|
- **Location:** All toggles in Config tab
|
|
|
|
### ✅ Issue 2: Admin Route Debugging Added!
|
|
- **NEW:** Debug tab in admin panel
|
|
- **NEW:** Real-time connectivity tests
|
|
- **NEW:** Comprehensive troubleshooting guide
|
|
|
|
---
|
|
|
|
## 🏃 Quick Start (30 seconds)
|
|
|
|
### Step 1: Build Frontend
|
|
```bash
|
|
cd frontend
|
|
npm run build
|
|
```
|
|
|
|
### Step 2: Make Yourself Admin
|
|
```javascript
|
|
// In MongoDB
|
|
db.users.updateOne(
|
|
{ steamId: "YOUR_STEAM_ID" },
|
|
{ $set: { staffLevel: 5 } }
|
|
)
|
|
```
|
|
|
|
**OR** add to `.env`:
|
|
```
|
|
ADMIN_STEAM_IDS=YOUR_STEAM_ID_HERE
|
|
```
|
|
|
|
### Step 3: Restart & Access
|
|
```bash
|
|
# Restart backend
|
|
npm run dev
|
|
|
|
# Access admin panel
|
|
http://localhost:5173/admin
|
|
```
|
|
|
|
---
|
|
|
|
## 🔍 Troubleshooting (1 minute)
|
|
|
|
### Can't Access /admin?
|
|
|
|
**Option A - Database:**
|
|
```javascript
|
|
db.users.updateOne(
|
|
{ steamId: "YOUR_STEAM_ID" },
|
|
{ $set: { staffLevel: 5 } }
|
|
)
|
|
```
|
|
|
|
**Option B - Environment:**
|
|
```bash
|
|
# Add to .env
|
|
ADMIN_STEAM_IDS=76561198012345678
|
|
# Restart server!
|
|
```
|
|
|
|
**Option C - Check Status:**
|
|
1. Go to `/admin` (it will redirect if not admin)
|
|
2. Check browser console for errors
|
|
3. Verify you're logged in (top right should show username)
|
|
|
|
### Still Not Working?
|
|
|
|
1. **Open Debug Tab:**
|
|
- Navigate to `/admin` (if possible)
|
|
- Click "Debug" tab
|
|
- Click "Run Tests" button
|
|
- Check which test fails
|
|
|
|
2. **Quick Checks:**
|
|
```bash
|
|
# Is backend running?
|
|
curl http://localhost:3000/health
|
|
|
|
# Is frontend running?
|
|
curl http://localhost:5173
|
|
```
|
|
|
|
3. **Nuclear Option:**
|
|
```bash
|
|
# Clear everything
|
|
cd frontend
|
|
rm -rf node_modules/.vite dist
|
|
npm install
|
|
npm run build
|
|
|
|
# Restart both servers
|
|
```
|
|
|
|
---
|
|
|
|
## 📍 File Locations
|
|
|
|
### New Files Created:
|
|
- `frontend/src/components/ToggleSwitch.vue` - New toggle component
|
|
- `frontend/src/components/AdminDebugPanel.vue` - Debug panel
|
|
- `ADMIN_TROUBLESHOOTING.md` - Full troubleshooting guide
|
|
- `ADMIN_IMPROVEMENTS_SUMMARY.md` - Detailed changes
|
|
|
|
### Modified Files:
|
|
- `frontend/src/components/AdminConfigPanel.vue` - Uses new toggles
|
|
- `frontend/src/views/AdminPage.vue` - Added debug tab
|
|
|
|
---
|
|
|
|
## 🎨 Toggle States
|
|
|
|
| State | Color | Label | Meaning |
|
|
|-------|-------|-------|---------|
|
|
| OFF | 🔴 Red | OFF | Feature disabled |
|
|
| ON | 🟢 Green | ON | Feature enabled |
|
|
|
|
---
|
|
|
|
## 🧪 Test Admin Access
|
|
|
|
### Quick Test (Browser):
|
|
1. Open: `http://localhost:5173/admin`
|
|
2. Should see admin dashboard (not redirect to home)
|
|
3. Click "Debug" tab
|
|
4. Click "Run Tests"
|
|
5. All tests should be green ✅
|
|
|
|
### Quick Test (Command Line):
|
|
```bash
|
|
# Test backend health
|
|
curl http://localhost:3000/health
|
|
|
|
# Test admin config (needs auth)
|
|
curl -b cookies.txt http://localhost:3000/api/admin/config
|
|
```
|
|
|
|
---
|
|
|
|
## 💡 Common Mistakes
|
|
|
|
### ❌ Mistake 1: Forgot to Restart Server
|
|
**Fix:** After changing `.env`, ALWAYS restart the backend!
|
|
```bash
|
|
# Stop server (Ctrl+C)
|
|
npm run dev
|
|
```
|
|
|
|
### ❌ Mistake 2: Wrong Staff Level
|
|
**Fix:** Must be staffLevel >= 3 (or in ADMIN_STEAM_IDS)
|
|
```javascript
|
|
// Check your level
|
|
db.users.findOne({ steamId: "YOUR_ID" })
|
|
|
|
// Should see: staffLevel: 5
|
|
```
|
|
|
|
### ❌ Mistake 3: Not Logged In
|
|
**Fix:** Log in via Steam first!
|
|
```
|
|
1. Go to homepage
|
|
2. Click "Login with Steam"
|
|
3. Authorize
|
|
4. Then try /admin
|
|
```
|
|
|
|
### ❌ Mistake 4: Browser Cache
|
|
**Fix:** Hard refresh!
|
|
```
|
|
Windows/Linux: Ctrl + Shift + R
|
|
Mac: Cmd + Shift + R
|
|
```
|
|
|
|
---
|
|
|
|
## 📱 Visual Guide
|
|
|
|
### Before (Old Toggles):
|
|
```
|
|
[ ] Enable Feature ← Hard to see state
|
|
```
|
|
|
|
### After (New Toggles):
|
|
```
|
|
[🟢 ON ◉] Enable Feature ← Green = ON
|
|
[🔴 ◉OFF] Disable Feature ← Red = OFF
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 Success Checklist
|
|
|
|
- [ ] Frontend builds without errors
|
|
- [ ] Can access `/admin` route
|
|
- [ ] See new colored toggles in Config tab
|
|
- [ ] Toggle animations are smooth
|
|
- [ ] Debug tab is visible
|
|
- [ ] Debug tests show green checkmarks
|
|
- [ ] Can save config changes
|
|
- [ ] No errors in browser console
|
|
|
|
---
|
|
|
|
## 📚 Full Documentation
|
|
|
|
- **Troubleshooting:** `ADMIN_TROUBLESHOOTING.md`
|
|
- **Detailed Changes:** `ADMIN_IMPROVEMENTS_SUMMARY.md`
|
|
- **Implementation:** `ADMIN_IMPLEMENTATION.md`
|
|
- **System Overview:** `ADMIN_SYSTEM.md`
|
|
|
|
---
|
|
|
|
## 🆘 Still Stuck?
|
|
|
|
### Checklist:
|
|
1. [ ] Backend is running on port 3000
|
|
2. [ ] Frontend is running on port 5173
|
|
3. [ ] MongoDB is running
|
|
4. [ ] User has staffLevel >= 3
|
|
5. [ ] User is logged in via Steam
|
|
6. [ ] `.env` file has ADMIN_STEAM_IDS (if using)
|
|
7. [ ] Server was restarted after `.env` changes
|
|
8. [ ] Browser cache was cleared
|
|
9. [ ] No errors in backend console
|
|
10. [ ] No errors in browser console (F12)
|
|
|
|
### Get Help:
|
|
1. Open browser console (F12)
|
|
2. Copy any error messages
|
|
3. Check backend logs
|
|
4. Check MongoDB is accessible
|
|
5. Try the Debug panel tests
|
|
|
|
---
|
|
|
|
## ⚡ TL;DR
|
|
|
|
```bash
|
|
# 1. Build
|
|
cd frontend && npm run build
|
|
|
|
# 2. Make admin
|
|
# In MongoDB: db.users.updateOne({steamId: "ID"}, {$set: {staffLevel: 5}})
|
|
# OR add to .env: ADMIN_STEAM_IDS=YOUR_ID
|
|
|
|
# 3. Restart
|
|
npm run dev
|
|
|
|
# 4. Visit
|
|
http://localhost:5173/admin
|
|
```
|
|
|
|
**New toggles are in Config tab. Debug panel is in Debug tab. Done! ✅**
|
|
|
|
---
|
|
|
|
**Last Updated:** 2024
|
|
**Version:** 2.0
|
|
**Status:** ✅ Ready to Use |