Initial commit: Parking Manager

Features:
- Manager-centric parking spot management
- Fair assignment algorithm (parking/presence ratio)
- Presence tracking calendar
- Closing days (specific & weekly recurring)
- Guarantees and exclusions
- Authelia/LLDAP integration for SSO

Stack:
- FastAPI backend
- SQLite database
- Vanilla JS frontend
- Docker deployment
This commit is contained in:
Stefano Manfredi
2025-11-26 23:37:50 +00:00
commit c74a0ed350
49 changed files with 9094 additions and 0 deletions

View File

@@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Users - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>Manage Users</h2>
<div class="header-actions">
<input type="text" id="searchInput" class="form-input" placeholder="Search users...">
</div>
</header>
<div class="content-wrapper">
<div class="card">
<div class="data-table-container">
<table class="data-table" id="usersTable">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Office</th>
<th>Managed Offices</th>
<th>Parking Quota</th>
<th>Spot Prefix</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="usersBody"></tbody>
</table>
</div>
</div>
</div>
</main>
<!-- Edit User Modal -->
<div class="modal" id="userModal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h3 id="userModalTitle">Edit User</h3>
<button class="modal-close" id="closeUserModal">&times;</button>
</div>
<div class="modal-body">
<form id="userForm">
<input type="hidden" id="userId">
<div class="form-group">
<label for="editName">Name</label>
<input type="text" id="editName" required>
</div>
<div class="form-group">
<label for="editEmail">Email</label>
<input type="email" id="editEmail" disabled>
</div>
<div class="form-group">
<label for="editRole">Role</label>
<select id="editRole" required>
<option value="employee">Employee</option>
<option value="manager">Manager</option>
<option value="admin">Admin</option>
</select>
</div>
<div class="form-group">
<label for="editOffice">Office</label>
<select id="editOffice">
<option value="">No office</option>
</select>
</div>
<div class="form-group" id="quotaGroup" style="display: none;">
<label for="editQuota">Parking Quota</label>
<input type="number" id="editQuota" min="0" value="0">
<small class="text-muted">Number of parking spots this manager can assign</small>
</div>
<div class="form-group" id="prefixGroup" style="display: none;">
<label for="editPrefix">Spot Prefix</label>
<input type="text" id="editPrefix" maxlength="2" placeholder="A, B, C...">
<small class="text-muted">Letter prefix for parking spots (e.g., A for spots A1, A2...)</small>
</div>
<div class="form-group" id="managedOfficesGroup" style="display: none;">
<label>Managed Offices</label>
<div id="managedOfficesCheckboxes" class="checkbox-group"></div>
<small class="text-muted">Select offices this manager controls</small>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelUser">Cancel</button>
<button type="submit" class="btn btn-dark">Save</button>
</div>
</form>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script src="/js/admin-users.js"></script>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="auth-container">
<div class="auth-card">
<div class="auth-header">
<h1>Parking Manager</h1>
<p>Manage office presence and parking assignments</p>
</div>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/login" class="btn btn-dark btn-full">Sign In</a>
<a href="/register" class="btn btn-secondary btn-full">Create Account</a>
</div>
</div>
</div>
<script>
// Redirect if already logged in
if (localStorage.getItem('access_token')) {
window.location.href = '/presence';
}
</script>
</body>
</html>

64
frontend/pages/login.html Normal file
View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="auth-container">
<div class="auth-card">
<div class="auth-header">
<h1>Welcome Back</h1>
<p>Sign in to your account</p>
</div>
<div id="errorMessage"></div>
<form id="loginForm">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" required autocomplete="email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" required autocomplete="current-password">
</div>
<button type="submit" class="btn btn-dark btn-full">Sign In</button>
</form>
<div class="auth-footer">
Don't have an account? <a href="/register">Sign up</a>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script>
// Redirect if already logged in
if (api.isAuthenticated()) {
window.location.href = '/presence';
}
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const errorDiv = document.getElementById('errorMessage');
errorDiv.innerHTML = '';
const result = await api.login(email, password);
if (result.success) {
window.location.href = '/presence';
} else {
errorDiv.innerHTML = `<div class="message error">${result.error}</div>`;
}
});
</script>
</body>
</html>

View File

@@ -0,0 +1,215 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Office Rules - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>Office Rules</h2>
<div class="header-actions">
<select id="officeSelect" class="form-select">
<option value="">Select Manager</option>
</select>
</div>
</header>
<div class="content-wrapper" id="rulesContent" style="display: none;">
<!-- Weekly Closing Days -->
<div class="card">
<div class="card-header">
<h3>Weekly Closing Days</h3>
</div>
<div class="card-body">
<p class="text-muted" style="margin-bottom: 1rem;">Days of the week the office is regularly closed</p>
<div class="weekday-checkboxes" id="weeklyClosingDays">
<label><input type="checkbox" data-weekday="0"> Sunday</label>
<label><input type="checkbox" data-weekday="1"> Monday</label>
<label><input type="checkbox" data-weekday="2"> Tuesday</label>
<label><input type="checkbox" data-weekday="3"> Wednesday</label>
<label><input type="checkbox" data-weekday="4"> Thursday</label>
<label><input type="checkbox" data-weekday="5"> Friday</label>
<label><input type="checkbox" data-weekday="6"> Saturday</label>
</div>
</div>
</div>
<!-- Specific Closing Days -->
<div class="card">
<div class="card-header">
<h3>Specific Closing Days</h3>
<button class="btn btn-secondary btn-sm" id="addClosingDayBtn">Add</button>
</div>
<div class="card-body">
<p class="text-muted">Specific dates when the office is closed (holidays, etc.)</p>
<div id="closingDaysList" class="rules-list"></div>
</div>
</div>
<!-- Parking Guarantees -->
<div class="card">
<div class="card-header">
<h3>Parking Guarantees</h3>
<button class="btn btn-secondary btn-sm" id="addGuaranteeBtn">Add</button>
</div>
<div class="card-body">
<p class="text-muted">Users guaranteed a parking spot when present</p>
<div id="guaranteesList" class="rules-list"></div>
</div>
</div>
<!-- Parking Exclusions -->
<div class="card">
<div class="card-header">
<h3>Parking Exclusions</h3>
<button class="btn btn-secondary btn-sm" id="addExclusionBtn">Add</button>
</div>
<div class="card-body">
<p class="text-muted">Users excluded from parking assignment</p>
<div id="exclusionsList" class="rules-list"></div>
</div>
</div>
</div>
<div class="content-wrapper" id="noOfficeMessage">
<div class="card">
<div class="card-body text-center">
<p>Select a manager to manage their office rules</p>
</div>
</div>
</div>
</main>
<!-- Add Closing Day Modal -->
<div class="modal" id="closingDayModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3>Add Closing Day</h3>
<button class="modal-close" id="closeClosingDayModal">&times;</button>
</div>
<div class="modal-body">
<form id="closingDayForm">
<div class="form-group">
<label for="closingDate">Date</label>
<input type="date" id="closingDate" required>
</div>
<div class="form-group">
<label for="closingReason">Reason (optional)</label>
<input type="text" id="closingReason" placeholder="e.g., Company holiday">
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelClosingDay">Cancel</button>
<button type="submit" class="btn btn-dark">Add</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Guarantee Modal -->
<div class="modal" id="guaranteeModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3>Add Parking Guarantee</h3>
<button class="modal-close" id="closeGuaranteeModal">&times;</button>
</div>
<div class="modal-body">
<form id="guaranteeForm">
<div class="form-group">
<label for="guaranteeUser">User</label>
<select id="guaranteeUser" required>
<option value="">Select user...</option>
</select>
</div>
<div class="form-group">
<label for="guaranteeStartDate">Start Date (optional)</label>
<input type="date" id="guaranteeStartDate">
<small>Leave empty for no start limit</small>
</div>
<div class="form-group">
<label for="guaranteeEndDate">End Date (optional)</label>
<input type="date" id="guaranteeEndDate">
<small>Leave empty for no end limit</small>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelGuarantee">Cancel</button>
<button type="submit" class="btn btn-dark">Add</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Exclusion Modal -->
<div class="modal" id="exclusionModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3>Add Parking Exclusion</h3>
<button class="modal-close" id="closeExclusionModal">&times;</button>
</div>
<div class="modal-body">
<form id="exclusionForm">
<div class="form-group">
<label for="exclusionUser">User</label>
<select id="exclusionUser" required>
<option value="">Select user...</option>
</select>
</div>
<div class="form-group">
<label for="exclusionStartDate">Start Date (optional)</label>
<input type="date" id="exclusionStartDate">
<small>Leave empty for no start limit</small>
</div>
<div class="form-group">
<label for="exclusionEndDate">End Date (optional)</label>
<input type="date" id="exclusionEndDate">
<small>Leave empty for no end limit</small>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelExclusion">Cancel</button>
<button type="submit" class="btn btn-dark">Add</button>
</div>
</form>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script src="/js/office-rules.js"></script>
</body>
</html>

View File

@@ -0,0 +1,186 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Presence - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>My Presence</h2>
<div class="header-actions">
<button class="btn btn-secondary" id="bulkMarkBtn">Bulk Mark</button>
</div>
</header>
<div class="content-wrapper">
<div class="card presence-card">
<div class="calendar-header">
<button class="btn-icon" id="prevMonth">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</button>
<h3 id="currentMonth">Loading...</h3>
<button class="btn-icon" id="nextMonth">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</button>
</div>
<div class="calendar-grid" id="calendarGrid"></div>
<div class="legend">
<div class="legend-item">
<div class="legend-color status-present"></div>
<span>Present (Office)</span>
</div>
<div class="legend-item">
<div class="legend-color status-remote"></div>
<span>Remote</span>
</div>
<div class="legend-item">
<div class="legend-color status-absent"></div>
<span>Absent</span>
</div>
</div>
</div>
</div>
</main>
<!-- Day Modal -->
<div class="modal" id="dayModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3 id="dayModalTitle">Mark Presence</h3>
<button class="modal-close" id="closeDayModal">&times;</button>
</div>
<div class="modal-body">
<div class="status-buttons">
<button class="status-btn" data-status="present">
<div class="status-icon status-present"></div>
<span>Present</span>
</button>
<button class="status-btn" data-status="remote">
<div class="status-icon status-remote"></div>
<span>Remote</span>
</button>
<button class="status-btn" data-status="absent">
<div class="status-icon status-absent"></div>
<span>Absent</span>
</button>
</div>
<div id="parkingSection" style="display: none; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);">
<div id="parkingInfo" style="margin-bottom: 0.75rem; font-size: 0.9rem;"></div>
<div style="display: flex; gap: 0.5rem;">
<button class="btn btn-secondary" style="flex: 1;" id="reassignParkingBtn">Reassign</button>
<button class="btn btn-secondary" style="flex: 1;" id="releaseParkingBtn">Release</button>
</div>
</div>
<button class="btn btn-secondary btn-full" id="clearDayBtn" style="margin-top: 1rem;">Clear Presence</button>
</div>
</div>
</div>
<!-- Reassign Parking Modal -->
<div class="modal" id="reassignModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3>Reassign Parking Spot</h3>
<button class="modal-close" id="closeReassignModal">&times;</button>
</div>
<div class="modal-body">
<p id="reassignSpotInfo" style="margin-bottom: 1rem; font-size: 0.9rem;"></p>
<div class="form-group">
<label for="reassignUser">Assign to</label>
<select id="reassignUser" required>
<option value="">Select user...</option>
</select>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelReassign">Cancel</button>
<button type="button" class="btn btn-dark" id="confirmReassign">Reassign</button>
</div>
</div>
</div>
</div>
<!-- Bulk Mark Modal -->
<div class="modal" id="bulkMarkModal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h3>Bulk Mark Presence</h3>
<button class="modal-close" id="closeBulkModal">&times;</button>
</div>
<div class="modal-body">
<form id="bulkMarkForm">
<div class="form-group">
<label for="startDate">Start Date</label>
<input type="date" id="startDate" required>
</div>
<div class="form-group">
<label for="endDate">End Date</label>
<input type="date" id="endDate" required>
</div>
<div class="form-group">
<label for="bulkStatus">Status</label>
<select id="bulkStatus" required>
<option value="present">Present (Office)</option>
<option value="remote">Remote</option>
<option value="absent">Absent</option>
</select>
</div>
<div class="form-group checkbox-group">
<label class="checkbox-label">
<input type="checkbox" id="weekdaysOnly">
<span>Weekdays only (Mon-Fri)</span>
</label>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelBulk">Cancel</button>
<button type="submit" class="btn btn-dark">Mark Dates</button>
</div>
</form>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script src="/js/presence.js"></script>
</body>
</html>

188
frontend/pages/profile.html Normal file
View File

@@ -0,0 +1,188 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>Profile</h2>
</header>
<div class="content-wrapper">
<div class="card">
<div class="card-header">
<h3>Personal Information</h3>
</div>
<div class="card-body">
<form id="profileForm">
<div class="form-group">
<label for="name">Full Name</label>
<input type="text" id="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" disabled>
<small class="text-muted">Email cannot be changed</small>
</div>
<div class="form-group">
<label for="office">Office</label>
<select id="office">
<option value="">No office</option>
</select>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-dark">Save Changes</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h3>Change Password</h3>
</div>
<div class="card-body">
<form id="passwordForm">
<div class="form-group">
<label for="currentPassword">Current Password</label>
<input type="password" id="currentPassword" required>
</div>
<div class="form-group">
<label for="newPassword">New Password</label>
<input type="password" id="newPassword" required minlength="8">
<small>Minimum 8 characters</small>
</div>
<div class="form-group">
<label for="confirmPassword">Confirm New Password</label>
<input type="password" id="confirmPassword" required>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-dark">Change Password</button>
</div>
</form>
</div>
</div>
</div>
</main>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script>
let currentUser = null;
document.addEventListener('DOMContentLoaded', async () => {
if (!api.requireAuth()) return;
currentUser = await api.getCurrentUser();
if (!currentUser) return;
await loadOffices();
populateForm();
setupEventListeners();
});
async function loadOffices() {
const response = await api.get('/api/offices');
if (response && response.ok) {
const offices = await response.json();
const select = document.getElementById('office');
offices.forEach(office => {
const option = document.createElement('option');
option.value = office.id;
option.textContent = office.name;
select.appendChild(option);
});
}
}
function populateForm() {
document.getElementById('name').value = currentUser.name || '';
document.getElementById('email').value = currentUser.email;
document.getElementById('office').value = currentUser.office_id || '';
}
function setupEventListeners() {
// Profile form
document.getElementById('profileForm').addEventListener('submit', async (e) => {
e.preventDefault();
const data = {
name: document.getElementById('name').value,
office_id: document.getElementById('office').value || null
};
const response = await api.put('/api/users/me/profile', data);
if (response && response.ok) {
utils.showMessage('Profile updated successfully', 'success');
currentUser = await api.getCurrentUser();
} else {
const error = await response.json();
utils.showMessage(error.detail || 'Failed to update profile', 'error');
}
});
// Password form
document.getElementById('passwordForm').addEventListener('submit', async (e) => {
e.preventDefault();
const newPassword = document.getElementById('newPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (newPassword !== confirmPassword) {
utils.showMessage('Passwords do not match', 'error');
return;
}
const data = {
current_password: document.getElementById('currentPassword').value,
new_password: newPassword
};
const response = await api.post('/api/users/me/change-password', data);
if (response && response.ok) {
utils.showMessage('Password changed successfully', 'success');
document.getElementById('passwordForm').reset();
} else {
const error = await response.json();
utils.showMessage(error.detail || 'Failed to change password', 'error');
}
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="auth-container">
<div class="auth-card">
<div class="auth-header">
<h1>Create Account</h1>
<p>Sign up for a new account</p>
</div>
<div id="errorMessage"></div>
<form id="registerForm">
<div class="form-group">
<label for="name">Full Name</label>
<input type="text" id="name" required autocomplete="name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" required autocomplete="email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" required autocomplete="new-password" minlength="8">
<small>Minimum 8 characters</small>
</div>
<div class="form-group">
<label for="office">Office (optional)</label>
<select id="office">
<option value="">Select an office...</option>
</select>
</div>
<button type="submit" class="btn btn-dark btn-full">Create Account</button>
</form>
<div class="auth-footer">
Already have an account? <a href="/login">Sign in</a>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script>
// Redirect if already logged in
if (api.isAuthenticated()) {
window.location.href = '/presence';
}
// Load offices
async function loadOffices() {
try {
const response = await fetch('/api/offices');
if (response.ok) {
const offices = await response.json();
const select = document.getElementById('office');
offices.forEach(office => {
const option = document.createElement('option');
option.value = office.id;
option.textContent = office.name;
select.appendChild(option);
});
}
} catch (error) {
console.error('Failed to load offices:', error);
}
}
loadOffices();
document.getElementById('registerForm').addEventListener('submit', async (e) => {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const officeId = document.getElementById('office').value || null;
const errorDiv = document.getElementById('errorMessage');
errorDiv.innerHTML = '';
const result = await api.register(email, password, name, officeId);
if (result.success) {
window.location.href = '/presence';
} else {
errorDiv.innerHTML = `<div class="message error">${result.error}</div>`;
}
});
</script>
</body>
</html>

View File

@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>Settings</h2>
</header>
<div class="content-wrapper">
<div class="card">
<div class="card-header">
<h3>Preferences</h3>
</div>
<div class="card-body">
<form id="settingsForm">
<div class="form-group">
<label for="weekStartDay">Week Starts On</label>
<select id="weekStartDay">
<option value="0">Sunday</option>
<option value="1">Monday</option>
</select>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-dark">Save Settings</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h3>Parking Notifications</h3>
</div>
<div class="card-body">
<form id="notificationForm">
<div class="form-group">
<label class="toggle-label">
<span>Weekly Summary</span>
<label class="toggle-switch">
<input type="checkbox" id="notifyWeeklyParking">
<span class="toggle-slider"></span>
</label>
</label>
<small class="text-muted">Receive weekly parking assignments summary every Friday at 12:00</small>
</div>
<div class="form-group">
<label class="toggle-label">
<span>Daily Reminder</span>
<label class="toggle-switch">
<input type="checkbox" id="notifyDailyParking">
<span class="toggle-slider"></span>
</label>
</label>
<small class="text-muted">Receive daily parking reminder on working days</small>
</div>
<div class="form-group" id="dailyTimeGroup" style="margin-left: 1rem;">
<label>Reminder Time</label>
<div style="display: flex; gap: 0.5rem; align-items: center;">
<select id="notifyDailyHour" style="width: 80px;">
<!-- Hours populated by JS -->
</select>
<span>:</span>
<select id="notifyDailyMinute" style="width: 80px;">
<option value="0">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
</div>
</div>
<div class="form-group">
<label class="toggle-label">
<span>Assignment Changes</span>
<label class="toggle-switch">
<input type="checkbox" id="notifyParkingChanges">
<span class="toggle-slider"></span>
</label>
</label>
<small class="text-muted">Receive immediate notifications when your parking assignment changes</small>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-dark">Save Notifications</button>
</div>
</form>
</div>
</div>
</div>
</main>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script>
let currentUser = null;
document.addEventListener('DOMContentLoaded', async () => {
if (!api.requireAuth()) return;
currentUser = await api.getCurrentUser();
if (!currentUser) return;
populateHourSelect();
populateForm();
setupEventListeners();
});
function populateHourSelect() {
const select = document.getElementById('notifyDailyHour');
for (let h = 0; h < 24; h++) {
const option = document.createElement('option');
option.value = h;
option.textContent = h.toString().padStart(2, '0');
select.appendChild(option);
}
}
function populateForm() {
document.getElementById('weekStartDay').value = currentUser.week_start_day || 0;
// Notification settings
document.getElementById('notifyWeeklyParking').checked = currentUser.notify_weekly_parking !== 0;
document.getElementById('notifyDailyParking').checked = currentUser.notify_daily_parking !== 0;
document.getElementById('notifyDailyHour').value = currentUser.notify_daily_parking_hour || 8;
document.getElementById('notifyDailyMinute').value = currentUser.notify_daily_parking_minute || 0;
document.getElementById('notifyParkingChanges').checked = currentUser.notify_parking_changes !== 0;
updateDailyTimeVisibility();
}
function updateDailyTimeVisibility() {
const enabled = document.getElementById('notifyDailyParking').checked;
document.getElementById('dailyTimeGroup').style.display = enabled ? 'block' : 'none';
}
function setupEventListeners() {
// Settings form
document.getElementById('settingsForm').addEventListener('submit', async (e) => {
e.preventDefault();
const data = {
week_start_day: parseInt(document.getElementById('weekStartDay').value)
};
const response = await api.put('/api/users/me/settings', data);
if (response && response.ok) {
utils.showMessage('Settings saved successfully', 'success');
currentUser = await api.getCurrentUser();
} else {
const error = await response.json();
utils.showMessage(error.detail || 'Failed to save settings', 'error');
}
});
// Notification form
document.getElementById('notificationForm').addEventListener('submit', async (e) => {
e.preventDefault();
const data = {
notify_weekly_parking: document.getElementById('notifyWeeklyParking').checked ? 1 : 0,
notify_daily_parking: document.getElementById('notifyDailyParking').checked ? 1 : 0,
notify_daily_parking_hour: parseInt(document.getElementById('notifyDailyHour').value),
notify_daily_parking_minute: parseInt(document.getElementById('notifyDailyMinute').value),
notify_parking_changes: document.getElementById('notifyParkingChanges').checked ? 1 : 0
};
const response = await api.put('/api/users/me/settings', data);
if (response && response.ok) {
utils.showMessage('Notification settings saved', 'success');
currentUser = await api.getCurrentUser();
} else {
const error = await response.json();
utils.showMessage(error.detail || 'Failed to save notifications', 'error');
}
});
// Toggle daily time visibility
document.getElementById('notifyDailyParking').addEventListener('change', updateDailyTimeVisibility);
}
</script>
</body>
</html>

View File

@@ -0,0 +1,157 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Team Calendar - Parking Manager</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<aside class="sidebar">
<div class="sidebar-header">
<h1>Parking Manager</h1>
</div>
<nav class="sidebar-nav"></nav>
<div class="sidebar-footer">
<div class="user-menu">
<button class="user-button" id="userMenuButton">
<div class="user-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
</div>
<div class="user-info">
<div class="user-name" id="userName">Loading...</div>
<div class="user-role" id="userRole">-</div>
</div>
</button>
<div class="user-dropdown" id="userDropdown" style="display: none;">
<a href="/profile" class="dropdown-item">Profile</a>
<a href="/settings" class="dropdown-item">Settings</a>
<hr class="dropdown-divider">
<button class="dropdown-item" id="logoutButton">Logout</button>
</div>
</div>
</div>
</aside>
<main class="main-content">
<header class="page-header">
<h2>Team Calendar</h2>
<div class="header-actions">
<select id="viewToggle" class="form-select" style="min-width: 100px;">
<option value="week">Week</option>
<option value="month">Month</option>
</select>
<select id="managerFilter" class="form-select">
<option value="">All Managers</option>
</select>
</div>
</header>
<div class="content-wrapper">
<div class="card">
<div class="calendar-header">
<button class="btn-icon" id="prevWeek">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</button>
<h3 id="currentWeek">Loading...</h3>
<button class="btn-icon" id="nextWeek">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</button>
</div>
<div class="team-calendar-container">
<table class="team-calendar-table" id="teamCalendarTable">
<thead>
<tr id="calendarHeader"></tr>
</thead>
<tbody id="calendarBody"></tbody>
</table>
</div>
<div class="legend">
<div class="legend-item">
<div class="legend-color status-present"></div>
<span>Present</span>
</div>
<div class="legend-item">
<div class="legend-color status-remote"></div>
<span>Remote</span>
</div>
<div class="legend-item">
<div class="legend-color status-absent"></div>
<span>Absent</span>
</div>
</div>
</div>
</div>
</main>
<!-- Day Status Modal -->
<div class="modal" id="dayModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3 id="dayModalTitle">Mark Presence</h3>
<button class="modal-close" id="closeDayModal">&times;</button>
</div>
<div class="modal-body">
<p id="dayModalUser" style="margin-bottom: 1rem; font-weight: 500;"></p>
<div class="status-buttons">
<button class="status-btn" data-status="present">
<div class="status-icon status-present"></div>
<span>Present</span>
</button>
<button class="status-btn" data-status="remote">
<div class="status-icon status-remote"></div>
<span>Remote</span>
</button>
<button class="status-btn" data-status="absent">
<div class="status-icon status-absent"></div>
<span>Absent</span>
</button>
</div>
<div id="parkingSection" style="display: none; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);">
<div id="parkingInfo" style="margin-bottom: 0.75rem; font-size: 0.9rem;"></div>
<button class="btn btn-secondary btn-full" id="reassignParkingBtn">Reassign Spot</button>
</div>
<button class="btn btn-secondary btn-full" id="clearDayBtn" style="margin-top: 1rem;">Clear Presence</button>
</div>
</div>
</div>
<!-- Reassign Parking Modal -->
<div class="modal" id="reassignModal" style="display: none;">
<div class="modal-content modal-small">
<div class="modal-header">
<h3>Reassign Parking Spot</h3>
<button class="modal-close" id="closeReassignModal">&times;</button>
</div>
<div class="modal-body">
<p id="reassignSpotInfo" style="margin-bottom: 1rem; font-size: 0.9rem;"></p>
<div class="form-group">
<label for="reassignUser">Assign to</label>
<select id="reassignUser" required>
<option value="">Select user...</option>
</select>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancelReassign">Cancel</button>
<button type="button" class="btn btn-dark" id="confirmReassign">Reassign</button>
</div>
</div>
</div>
</div>
<script src="/js/api.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/nav.js"></script>
<script src="/js/team-calendar.js"></script>
</body>
</html>