Skip to content

bitandsolution/stadium-hospitality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 PHASE 4 - ADMIN WEB INTERFACE

πŸ“‹ Overview

Phase 4 implementa l'interfaccia web amministrativa per il sistema Hospitality Manager, utilizzando HTML + Vanilla JavaScript (no frameworks) con Tailwind CSS per lo styling.

πŸ—οΈ Architecture

Frontend Stack

  • HTML5 - Semantic markup
  • Vanilla JavaScript (ES6+) - No frameworks, modular approach
  • Tailwind CSS (CDN) - Rapid styling
  • Lucide Icons - Modern icon set
  • Session Storage - Token management (NO localStorage)

Design Patterns

  • Module Pattern - Ogni file JS Γ¨ un modulo indipendente
  • MVC-like - Separation of concerns (API, Auth, Utils, Controllers)
  • Progressive Enhancement - Base funzionalitΓ  + enhancements
  • Mobile First - Responsive design

πŸ“ File Structure

httpdocs/
β”œβ”€β”€ login.html                 # Login page
β”œβ”€β”€ dashboard.html             # Main dashboard
β”œβ”€β”€ guests.html                # Guest management
β”œβ”€β”€ import.html                # Excel import
β”œβ”€β”€ events.html                # Events CRUD
β”œβ”€β”€ rooms.html                 # Rooms CRUD
β”œβ”€β”€ users.html                 # Users/Hostess management
β”œβ”€β”€ stadiums.html              # Stadiums (super admin)
β”‚
β”œβ”€β”€ js/
β”‚   β”œβ”€β”€ config.js              # Global configuration
β”‚   β”œβ”€β”€ auth.js                # Authentication manager
β”‚   β”œβ”€β”€ api.js                 # API client wrapper
β”‚   β”œβ”€β”€ utils.js               # Utility functions
β”‚   β”œβ”€β”€ dashboard.js           # Dashboard controller
β”‚   β”œβ”€β”€ guests.js              # Guests page controller
β”‚   β”œβ”€β”€ import.js              # Import page controller
β”‚   β”œβ”€β”€ events.js              # Events page controller
β”‚   β”œβ”€β”€ rooms.js               # Rooms page controller
β”‚   β”œβ”€β”€ users.js               # Users page controller
β”‚   └── stadiums.js            # Stadiums page controller
β”‚
└── assets/
    └── icons/                 # PWA icons

πŸ”‘ Key Features

Authentication System (auth.js)

  • Login/Logout flow
  • JWT token management
  • Automatic token refresh
  • Session persistence (sessionStorage)
  • Role-based access control
  • Permission checking

API Client (api.js)

  • Centralized API communication
  • Automatic token injection
  • Token refresh on 401
  • Error handling
  • RESTful endpoints wrapper

Utility Functions (utils.js)

  • Date/time formatting
  • Badge generators (VIP levels, roles, status)
  • Toast notifications
  • Confirmation dialogs
  • File validation
  • HTML escaping
  • Debouncing

Configuration (config.js)

  • API endpoints
  • Session keys
  • Constants (roles, VIP levels, etc.)
  • Validation rules
  • Feature flags

🎨 UI Components

Common Elements

Sidebar Navigation

  • User info with avatar
  • Role-based menu items
  • Active state highlighting
  • Logout button

Header

  • Page title
  • Breadcrumbs
  • Notifications bell
  • Settings icon

Stats Cards

  • Icon + title
  • Main metric (large number)
  • Subtitle description
  • Color-coded by type

Tables

  • Sortable columns
  • Search/filter
  • Pagination
  • Action buttons
  • Row selection

Forms

  • Inline validation
  • Error messages
  • Success feedback
  • File upload with drag & drop

Modals

  • Create/Edit dialogs
  • Confirmation dialogs
  • Loading overlays

Color Palette

Primary: #667eea (Purple)
Secondary: #764ba2 (Dark Purple)
Success: #10b981 (Green)
Warning: #f59e0b (Yellow)
Error: #ef4444 (Red)
Info: #3b82f6 (Blue)
Gray: #6b7280 (Neutral)

Typography

Font Family: 'Inter', sans-serif
Sizes: text-xs, text-sm, text-base, text-lg, text-xl, text-2xl
Weights: 300 (light), 400 (normal), 500 (medium), 600 (semibold), 700 (bold)

πŸ”’ Security

Token Management

  • Tokens stored in sessionStorage (not localStorage)
  • Tokens cleared on logout
  • Tokens cleared on browser close
  • No persistent sessions

API Security

  • All API calls use Authorization header
  • Token automatically refreshed on expiry
  • Failed refresh forces re-login
  • CORS configured properly

XSS Prevention

  • All user input escaped with Utils.escapeHtml()
  • No innerHTML with user data
  • Safe DOM manipulation

CSRF Protection

  • Token-based auth (not cookies)
  • No CSRF vulnerability

πŸš€ Deployment Process

Step 1: Prepare Files Locally

# Create local structure
mkdir -p hospitality-frontend/{js,assets/icons}

# Copy files to local folder
cp login.html dashboard.html hospitality-frontend/
cp js/*.js hospitality-frontend/js/

Step 2: Deploy to Server

# Upload files via SCP
scp -r hospitality-frontend/* checkindigitale@checkindigitale.cloud:/var/www/vhosts/checkindigitale.cloud/httpdocs/

# Or use SFTP client (FileZilla, Cyberduck, etc.)

Step 3: Set Permissions

ssh checkindigitale@checkindigitale.cloud
cd /var/www/vhosts/checkindigitale.cloud/httpdocs
chmod 644 *.html
chmod 644 js/*.js
chmod 755 js/

Step 4: Test

  1. Open https://checkindigitale.cloud/login.html
  2. Test login with credentials
  3. Verify dashboard loads
  4. Check browser console for errors
  5. Test logout

πŸ§ͺ Testing Strategy

Manual Testing Checklist

Login Flow

  • Login page loads
  • Valid credentials work
  • Invalid credentials show error
  • Token saved in sessionStorage
  • Redirect to dashboard after login

Dashboard

  • User info displays correctly
  • Stats cards show data
  • Menu items visible based on role
  • Quick actions work
  • Upcoming events list
  • Logout works

Navigation

  • All menu links work
  • Active state highlights current page
  • Back button works
  • Breadcrumbs accurate

Responsive Design

  • Mobile (< 640px) works
  • Tablet (640-1024px) works
  • Desktop (> 1024px) works
  • Touch interactions work

Browser Compatibility

  • βœ… Chrome 90+
  • βœ… Firefox 88+
  • βœ… Safari 14+
  • βœ… Edge 90+
  • ⚠️ IE11 NOT SUPPORTED

πŸ“Š Performance Targets

Metric Target Status
Login API < 500ms βœ…
Dashboard Load < 1s βœ…
Page Transitions < 200ms βœ…
API Calls < 200ms avg βœ…
Bundle Size < 50KB (JS) βœ…

πŸ› Common Issues & Solutions

Issue: Login doesn't work

Solution:

  1. Check API endpoint in config.js
  2. Verify CORS headers in .htaccess
  3. Check browser console for errors
  4. Test API with curl

Issue: Token not sent in requests

Solution:

  1. Check sessionStorage has token
  2. Verify Auth.getAuthHeader() returns correct format
  3. Clear sessionStorage and login again

Issue: Dashboard shows loading forever

Solution:

  1. Check API endpoints respond correctly
  2. Verify token is valid
  3. Check stadium_id for non-super-admin users
  4. Review browser console errors

Issue: Styles not loading

Solution:

  1. Check Tailwind CDN loads
  2. Verify internet connection
  3. Check browser console for CSP errors
  4. Clear browser cache

πŸ”„ Development Workflow

Local Development

# Use local dev server
python3 -m http.server 8000

# Or use PHP built-in server
php -S localhost:8000

# Open browser
open http://localhost:8000/login.html

Production Deployment

# Build (nothing to build, just copy files)
cp src/* dist/

# Deploy
rsync -avz dist/ user@server:/path/to/httpdocs/

# Test
curl https://checkindigitale.cloud/login.html

πŸ“ Code Style Guide

JavaScript

// Use const for immutable, let for mutable
const API_URL = 'https://api.example.com';
let counter = 0;

// Use arrow functions
const fetchData = async () => {
    // ...
};

// Use template literals
const message = `Hello, ${userName}!`;

// Use destructuring
const { id, name } = user;

// Use async/await (not .then())
const data = await API.get('/endpoint');

// Add comments for complex logic
// Calculate total price with tax
const totalPrice = basePrice * (1 + taxRate);

HTML

<!-- Use semantic HTML5 tags -->
<header></header>
<main></main>
<footer></footer>
<nav></nav>
<article></article>

<!-- Use data attributes for JavaScript hooks -->
<button data-action="delete" data-id="123">Delete</button>

<!-- Use ARIA labels for accessibility -->
<button aria-label="Close modal">Γ—</button>

CSS (Tailwind)

<!-- Use Tailwind utility classes -->
<div class="flex items-center justify-between p-4 bg-white rounded-lg shadow">

<!-- Group related utilities -->
<div class="w-full md:w-1/2 lg:w-1/3">

<!-- Use hover, focus, active states -->
<button class="hover:bg-blue-600 focus:outline-none focus:ring-2">

πŸ“š Resources

Documentation

Tools

  • Browser DevTools (F12)
  • Postman (API testing)
  • VS Code (development)

🎯 Sprint Plan

βœ… Sprint 1: Core Infrastructure (COMPLETED)

  • Login page
  • Dashboard
  • Auth system
  • API client
  • Utils

πŸ”„ Sprint 2: Guest Management (CURRENT)

  • Guest list page
  • Guest search
  • Guest edit
  • Excel import

⏳ Sprint 3: Admin Features

  • Events CRUD
  • Rooms CRUD
  • Users management
  • Room assignments

⏳ Sprint 4: Analytics

  • Dashboard charts
  • Room statistics
  • Event reports
  • Export functionality

🀝 Contributing

Adding a New Page

  1. Create HTML file: newpage.html
  2. Create JS controller: js/newpage.js
  3. Add menu item in all pages
  4. Add route protection if needed
  5. Test all user roles
  6. Deploy

Adding a New Feature

  1. Update config.js if needed
  2. Add API endpoint in api.js
  3. Implement UI in HTML
  4. Add controller logic in JS
  5. Test thoroughly
  6. Deploy

Version: 1.3.0
Status: Sprint 1 Complete, Sprint 2 In Progress
Last Updated: 2025-09-29
Maintainer: Antonio Tartaglia - bitAND solution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published