feat: Space Booking System - MVP complet

Sistem web pentru rezervarea de birouri și săli de ședință
cu flux de aprobare administrativă.

Stack: FastAPI + Vue.js 3 + SQLite + TypeScript

Features implementate:
- Autentificare JWT + Self-registration cu email verification
- CRUD Spații, Utilizatori, Settings (Admin)
- Calendar interactiv (FullCalendar) cu drag-and-drop
- Creare rezervări cu validare (durată, program, overlap, max/zi)
- Rezervări recurente (săptămânal)
- Admin: aprobare/respingere/anulare cereri
- Admin: creare directă rezervări (bypass approval)
- Admin: editare orice rezervare
- User: editare/anulare rezervări proprii
- Notificări in-app (bell icon + dropdown)
- Notificări email (async SMTP cu BackgroundTasks)
- Jurnal acțiuni administrative (audit log)
- Rapoarte avansate (utilizare, top users, approval rate)
- Șabloane rezervări (booking templates)
- Atașamente fișiere (upload/download)
- Conflict warnings (verificare disponibilitate real-time)
- Integrare Google Calendar (OAuth2)
- Suport timezone (UTC storage + user preference)
- 225+ teste backend

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-02-09 17:51:29 +00:00
commit df4031d99c
113 changed files with 24491 additions and 0 deletions

389
frontend/src/App.vue Normal file
View File

@@ -0,0 +1,389 @@
<template>
<div id="app">
<header v-if="authStore.isAuthenticated" class="header">
<div class="container">
<h1>Space Booking</h1>
<nav>
<router-link to="/dashboard">Dashboard</router-link>
<router-link to="/spaces">Spaces</router-link>
<router-link to="/my-bookings">My Bookings</router-link>
<router-link v-if="authStore.isAdmin" to="/admin">Spaces Admin</router-link>
<router-link v-if="authStore.isAdmin" to="/users">Users Admin</router-link>
<router-link v-if="authStore.isAdmin" to="/admin/pending">Pending Requests</router-link>
<router-link v-if="authStore.isAdmin" to="/admin/settings">Settings</router-link>
<router-link v-if="authStore.isAdmin" to="/admin/reports">Reports</router-link>
<router-link v-if="authStore.isAdmin" to="/admin/audit-log">Audit Log</router-link>
<!-- Notification Bell -->
<div class="notification-wrapper">
<button @click="toggleNotifications" class="notification-bell" aria-label="Notifications">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path>
<path d="M13.73 21a2 2 0 0 1-3.46 0"></path>
</svg>
<span v-if="unreadCount > 0" class="badge">{{ unreadCount }}</span>
</button>
<!-- Notification Dropdown -->
<div v-if="showNotifications" class="notification-dropdown" ref="dropdownRef">
<div class="notification-header">
<h3>Notifications</h3>
<button @click="closeNotifications" class="close-btn">&times;</button>
</div>
<div v-if="loading" class="notification-loading">Loading...</div>
<div v-else-if="notifications.length === 0" class="notification-empty">
No new notifications
</div>
<div v-else class="notification-list">
<div
v-for="notification in notifications"
:key="notification.id"
:class="['notification-item', { unread: !notification.is_read }]"
@click="handleNotificationClick(notification)"
>
<div class="notification-title">{{ notification.title }}</div>
<div class="notification-message">{{ notification.message }}</div>
<div class="notification-time">{{ formatTime(notification.created_at) }}</div>
</div>
</div>
</div>
</div>
<button @click="logout" class="btn-logout">Logout ({{ authStore.user?.email }})</button>
</nav>
</div>
</header>
<main class="main">
<router-view />
</main>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { useAuthStore } from '@/stores/auth'
import { useRouter } from 'vue-router'
import { notificationsApi } from '@/services/api'
import type { Notification } from '@/types'
const authStore = useAuthStore()
const router = useRouter()
const notifications = ref<Notification[]>([])
const showNotifications = ref(false)
const loading = ref(false)
const dropdownRef = ref<HTMLElement | null>(null)
let refreshInterval: number | null = null
const unreadCount = computed(() => {
return notifications.value.filter((n) => !n.is_read).length
})
const logout = () => {
authStore.logout()
router.push('/login')
}
const fetchNotifications = async () => {
if (!authStore.isAuthenticated) return
try {
loading.value = true
// Get all notifications, sorted by created_at DESC (from API)
notifications.value = await notificationsApi.getAll()
} catch (error) {
console.error('Failed to fetch notifications:', error)
} finally {
loading.value = false
}
}
const toggleNotifications = () => {
showNotifications.value = !showNotifications.value
if (showNotifications.value) {
fetchNotifications()
}
}
const closeNotifications = () => {
showNotifications.value = false
}
const handleNotificationClick = async (notification: Notification) => {
// Mark as read
if (!notification.is_read) {
try {
await notificationsApi.markAsRead(notification.id)
// Update local state
notification.is_read = true
} catch (error) {
console.error('Failed to mark notification as read:', error)
}
}
// Navigate to booking if available
if (notification.booking_id) {
closeNotifications()
router.push('/my-bookings')
}
}
const formatTime = (dateStr: string): string => {
const date = new Date(dateStr)
const now = new Date()
const diffMs = now.getTime() - date.getTime()
const diffMins = Math.floor(diffMs / 60000)
const diffHours = Math.floor(diffMs / 3600000)
const diffDays = Math.floor(diffMs / 86400000)
if (diffMins < 1) return 'Just now'
if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? 's' : ''} ago`
if (diffHours < 24) return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`
if (diffDays < 7) return `${diffDays} day${diffDays > 1 ? 's' : ''} ago`
return date.toLocaleDateString()
}
// Click outside to close
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownRef.value &&
!dropdownRef.value.contains(event.target as Node) &&
!(event.target as HTMLElement).closest('.notification-bell')
) {
closeNotifications()
}
}
onMounted(() => {
// Initial fetch
fetchNotifications()
// Auto-refresh every 30 seconds
refreshInterval = window.setInterval(fetchNotifications, 30000)
// Add click outside listener
document.addEventListener('click', handleClickOutside)
})
onUnmounted(() => {
if (refreshInterval) {
clearInterval(refreshInterval)
}
document.removeEventListener('click', handleClickOutside)
})
</script>
<style scoped>
.header {
background: #2c3e50;
color: white;
padding: 1rem 0;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
h1 {
margin: 0;
font-size: 1.5rem;
}
nav {
display: flex;
gap: 1.5rem;
align-items: center;
}
nav a {
color: white;
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 4px;
transition: background 0.2s;
}
nav a:hover,
nav a.router-link-active {
background: rgba(255,255,255,0.1);
}
.btn-logout {
background: #e74c3c;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
font-size: 0.9rem;
}
.btn-logout:hover {
background: #c0392b;
}
.main {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
}
/* Notifications */
.notification-wrapper {
position: relative;
}
.notification-bell {
background: transparent;
border: none;
color: white;
cursor: pointer;
padding: 0.5rem;
border-radius: 4px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s;
}
.notification-bell:hover {
background: rgba(255, 255, 255, 0.1);
}
.notification-bell .badge {
position: absolute;
top: 2px;
right: 2px;
background: #e74c3c;
color: white;
border-radius: 10px;
padding: 2px 6px;
font-size: 0.7rem;
font-weight: bold;
min-width: 18px;
text-align: center;
}
.notification-dropdown {
position: absolute;
top: calc(100% + 10px);
right: 0;
background: white;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
width: 360px;
max-height: 400px;
overflow: hidden;
z-index: 1000;
display: flex;
flex-direction: column;
}
.notification-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
border-bottom: 1px solid #e0e0e0;
background: #f8f9fa;
}
.notification-header h3 {
margin: 0;
font-size: 1rem;
color: #2c3e50;
}
.close-btn {
background: none;
border: none;
font-size: 1.5rem;
color: #7f8c8d;
cursor: pointer;
padding: 0;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
}
.close-btn:hover {
background: #e0e0e0;
color: #2c3e50;
}
.notification-loading,
.notification-empty {
padding: 2rem;
text-align: center;
color: #7f8c8d;
}
.notification-list {
overflow-y: auto;
max-height: 340px;
}
.notification-item {
padding: 1rem;
border-bottom: 1px solid #e0e0e0;
cursor: pointer;
transition: background 0.2s;
}
.notification-item:hover {
background: #f8f9fa;
}
.notification-item.unread {
background: #e8f4fd;
border-left: 3px solid #3498db;
}
.notification-item.unread:hover {
background: #d6ebfa;
}
.notification-title {
font-weight: 600;
color: #2c3e50;
margin-bottom: 0.25rem;
font-size: 0.9rem;
}
.notification-item.unread .notification-title {
font-weight: 700;
}
.notification-message {
color: #555;
font-size: 0.85rem;
margin-bottom: 0.5rem;
line-height: 1.4;
}
.notification-time {
color: #95a5a6;
font-size: 0.75rem;
}
/* Responsive */
@media (max-width: 768px) {
.notification-dropdown {
width: 320px;
}
}
</style>