mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
8.0 KiB
8.0 KiB
Navigation Management System
Overview
Comprehensive navigation management system with admin controls, dropdown menus, social media integration, and full customization capabilities.
Features
1. Dynamic Navigation Management
- Create, edit, delete, and reorder navigation items
- Support for multiple navigation types:
- Page: Links to predefined system pages (Home, About, Calendar, etc.)
- Internal: Custom internal URLs
- External: Links to external websites
- Dropdown: Parent items with child menu items (nested navigation)
- Visibility controls (show/hide items)
- Custom ordering with up/down buttons
- Target controls (_self or _blank for external links)
2. Social Media Integration
- Dedicated social media links management
- Supported platforms:
- YouTube
- TikTok
- Discord
- Twitch
- Automatic icon rendering
- Display in top bar of navigation
- Reorderable and toggleable visibility
3. Admin Interface
- Located at
/admin/navigace - Tab-based interface:
- Navigation Items tab
- Social Links tab
- Features:
- Add new items with modal form
- Edit existing items
- Delete items with confirmation
- Reorder with visual up/down buttons
- Real-time preview of visibility status
Database Schema
navigation_items Table
- id (SERIAL PRIMARY KEY)
- label (VARCHAR) - Display name
- url (TEXT) - Custom URL (optional)
- icon (VARCHAR) - Icon name (optional)
- type (VARCHAR) - internal/external/dropdown/page
- page_type (VARCHAR) - Reference to system page
- page_id (INTEGER) - Optional content ID reference
- visible (BOOLEAN) - Show/hide control
- display_order (INTEGER) - Sort order
- parent_id (INTEGER) - For dropdown children
- target (VARCHAR) - _self/_blank
- css_class (VARCHAR) - Custom styling
- requires_auth (BOOLEAN) - Authentication required
- requires_admin (BOOLEAN) - Admin access required
social_links Table
- id (SERIAL PRIMARY KEY)
- platform (VARCHAR) - facebook/instagram/youtube/etc.
- url (TEXT) - Social media profile URL
- display_order (INTEGER) - Sort order
- visible (BOOLEAN) - Show/hide control
- icon (VARCHAR) - Custom icon override
API Endpoints
Public Endpoints
GET /api/v1/navigation- Get all visible navigation itemsGET /api/v1/social-links- Get all visible social links
Admin Endpoints (require authentication + admin role)
Navigation Management
GET /api/v1/admin/navigation- Get all navigation items (including hidden)POST /api/v1/admin/navigation- Create new navigation itemPUT /api/v1/admin/navigation/:id- Update navigation itemDELETE /api/v1/admin/navigation/:id- Delete navigation itemPOST /api/v1/admin/navigation/reorder- Reorder multiple items
Social Links Management
GET /api/v1/admin/social-links- Get all social links (including hidden)POST /api/v1/admin/social-links- Create new social linkPUT /api/v1/admin/social-links/:id- Update social linkDELETE /api/v1/admin/social-links/:id- Delete social linkPOST /api/v1/admin/social-links/reorder- Reorder multiple links
File Structure
Backend
database/migrations/
- 20251010154600_create_navigation_system.up.sql
- 20251010154600_create_navigation_system.down.sql
internal/models/
- navigation.go (NavigationItem, SocialLink models)
internal/controllers/
- navigation_controller.go (All CRUD operations)
internal/routes/
- routes.go (Added navigation routes)
Frontend
frontend/src/
services/
- navigation.ts (API client functions)
pages/admin/
- NavigationAdminPage.tsx (Admin UI)
components/
- Navbar.tsx (Updated to support dynamic navigation)
Usage
Running Migrations
# Apply migration
make migrate-up
# Or manually with goose
goose -dir database/migrations postgres "your-connection-string" up
Accessing Admin Panel
- Navigate to
/admin/navigace - Use the tabbed interface to manage:
- Navigation Items: Main menu structure
- Social Links: Social media icons
Adding Navigation Items
Page Type (System Pages)
- Click "Přidat položku"
- Enter label (e.g., "Home", "About")
- Select Type: "Stránka (vyberte existující)"
- Choose from predefined pages
- Set visibility and save
External Link
- Click "Přidat položku"
- Enter label
- Select Type: "Externí odkaz"
- Enter full URL (e.g.,
https://example.com) - Choose target (_self or _blank)
- Save
Dropdown Menu
- Create parent item with Type: "Dropdown"
- Create child items with parent_id reference
- Children will appear as dropdown on hover
Adding Social Links
- Switch to "Sociální sítě" tab
- Click "Přidat sociální síť"
- Select platform from dropdown
- Enter profile URL
- Set visibility and save
Frontend Integration
Using Navigation API
import { getNavigationItems, getSocialLinks } from '../services/navigation';
// Fetch navigation
const navItems = await getNavigationItems();
// Fetch social links
const socialLinks = await getSocialLinks();
Navbar Component
The existing Navbar.tsx component already supports:
- Dropdown menus (hover to expand)
- External link indicators
- Social media icons in top bar
- Responsive mobile menu
- Active route highlighting
Predefined Page Types
home→/about→/o-klubucalendar→/kalendarmatches→/zapasyactivities→/aktivityplayers→/hracitables→/tabulkyblog→/blogvideos→/videagallery→/galeriesponsors→/sponzoricontact→/kontaktsearch→/hledat
Default Navigation Items
The migration automatically creates default navigation items on first run:
- Domů (Home)
- O klubu (About)
- Kalendář (Calendar)
- Zápasy (Matches)
- Aktivity (Activities)
- Hráči (Players)
- Tabulky (Tables)
- Články (Blog)
- Videa (Videos)
- Fotogalerie (Gallery)
- Sponzoři (Sponsors)
- Kontakt (Contact)
Best Practices
Ordering
- Use display_order for consistent sorting
- Lower numbers appear first
- Use up/down buttons in admin for easy reordering
Dropdown Menus
- Keep dropdown depth to 1 level (parent → children only)
- Limit children to 5-8 items for best UX
- Use clear, descriptive labels
Social Links
- Order by priority/most used first
- Keep visible count to 3-5 for clean UI
- Use official platform URLs
External Links
- Always use https:// for security
- Set target="_blank" for external sites
- Consider adding icon or indicator
Styling & Customization
CSS Classes
Add custom css_class to navigation items for special styling:
.nav-highlighted {
background: var(--club-primary);
color: white;
}
Icons
Supported React Icons (FaIconName format):
- Navigation: FaHome, FaCalendar, FaUsers, etc.
- Social: FaFacebook, FaInstagram, FaYoutube, etc.
Troubleshooting
Navigation Not Updating
- Check browser console for API errors
- Verify admin authentication
- Clear browser cache
- Check network tab for failed requests
Social Icons Not Showing
- Verify platform name matches supported list
- Check URL format (must start with https://)
- Ensure visibility is set to true
- Check icon import in Navbar component
Dropdown Not Working
- Ensure parent item type is "dropdown"
- Verify children have correct parent_id
- Check both parent and children are visible
- Test hover delay timing
Future Enhancements
- Drag-and-drop reordering (requires react-beautiful-dnd package)
- Multi-level nested dropdowns
- Icon picker UI
- Bulk operations (delete, hide/show)
- Navigation templates/presets
- A/B testing for navigation layouts
- Analytics integration (track clicks)
- Role-based navigation (different menus for different user types)
- Mega menus with rich content
- Breadcrumb generation from navigation structure
Support
For issues or questions, refer to the main project documentation or contact the development team.