diff --git a/app/routes/offices.py b/app/routes/offices.py
index 553d9d1..3aa0a63 100644
--- a/app/routes/offices.py
+++ b/app/routes/offices.py
@@ -26,6 +26,9 @@ router = APIRouter(prefix="/api/offices", tags=["offices"])
class ValidOfficeCreate(BaseModel):
name: str
parking_quota: int = 0
+ booking_window_enabled: bool = True
+ booking_window_end_hour: int = 18
+ booking_window_end_minute: int = 0
class ClosingDayCreate(BaseModel):
@@ -121,6 +124,9 @@ def create_office(data: ValidOfficeCreate, db: Session = Depends(get_db), user=D
name=data.name,
parking_quota=data.parking_quota,
spot_prefix=get_next_available_prefix(db),
+ booking_window_enabled=data.booking_window_enabled,
+ booking_window_end_hour=data.booking_window_end_hour,
+ booking_window_end_minute=data.booking_window_end_minute,
created_at=datetime.utcnow()
)
db.add(office)
@@ -180,12 +186,12 @@ def update_office_settings(office_id: str, data: OfficeSettingsUpdate, db: Sessi
if data.booking_window_end_hour is not None:
if not (0 <= data.booking_window_end_hour <= 23):
- raise HTTPException(status_code=400, detail="Hour must be 0-23")
+ raise HTTPException(status_code=400, detail="Hour must be 0-23")
office.booking_window_end_hour = data.booking_window_end_hour
if data.booking_window_end_minute is not None:
if not (0 <= data.booking_window_end_minute <= 59):
- raise HTTPException(status_code=400, detail="Minute must be 0-59")
+ raise HTTPException(status_code=400, detail="Minute must be 0-59")
office.booking_window_end_minute = data.booking_window_end_minute
office.updated_at = datetime.utcnow()
diff --git a/compose.yml b/compose.yml
index db9b882..555614d 100644
--- a/compose.yml
+++ b/compose.yml
@@ -26,10 +26,10 @@ services:
networks:
- org-network
labels:
- - "caddy=parking.lvh.me"
+ - "caddy=parcheggio.lvh.me"
- "caddy.reverse_proxy={{upstreams 8000}}"
- "caddy.forward_auth=authelia:9091"
- - "caddy.forward_auth.uri=/api/verify?rd=https://parking.lvh.me/"
+ - "caddy.forward_auth.uri=/api/verify?rd=https://parcheggio.lvh.me/"
- "caddy.forward_auth.copy_headers=Remote-User Remote-Groups Remote-Name Remote-Email"
# cambiare l'url delle label per il reverse proxy
diff --git a/database/models.py b/database/models.py
index 76d0494..8eae5cb 100644
--- a/database/models.py
+++ b/database/models.py
@@ -241,15 +241,7 @@ class NotificationLog(Base):
)
- notification_type = Column(Enum(NotificationType, values_callable=lambda obj: [e.value for e in obj]), nullable=False) # parking_change
- subject = Column(Text, nullable=False)
- body = Column(Text, nullable=False)
- created_at = Column(DateTime, default=datetime.utcnow)
- sent_at = Column(DateTime) # null = not sent yet
- __table_args__ = (
- Index('idx_queue_pending', 'sent_at'),
- )
class OfficeSpot(Base):
diff --git a/frontend/assets/parking-map.png b/frontend/assets/parking-map.png
index b4669c3..8793d17 100644
Binary files a/frontend/assets/parking-map.png and b/frontend/assets/parking-map.png differ
diff --git a/frontend/js/admin-offices.js b/frontend/js/admin-offices.js
index 87746d1..d0fda6e 100644
--- a/frontend/js/admin-offices.js
+++ b/frontend/js/admin-offices.js
@@ -17,8 +17,36 @@ document.addEventListener('DOMContentLoaded', async () => {
await loadOffices();
setupEventListeners();
+ populateTimeSelects();
});
+function populateTimeSelects() {
+ const hoursSelect = document.getElementById('officeCutoffHour');
+ const minutesSelect = document.getElementById('officeCutoffMinute');
+
+ // Clear existing
+ hoursSelect.innerHTML = '';
+ minutesSelect.innerHTML = ''; // Re-creating to allow 0-59 range
+
+ // Populate Hours 0-23
+ for (let i = 0; i < 24; i++) {
+ const val = i.toString().padStart(2, '0');
+ const opt = document.createElement('option');
+ opt.value = i;
+ opt.textContent = val;
+ hoursSelect.appendChild(opt);
+ }
+
+ // Populate Minutes 0-59
+ for (let i = 0; i < 60; i++) {
+ const val = i.toString().padStart(2, '0');
+ const opt = document.createElement('option');
+ opt.value = i;
+ opt.textContent = val;
+ minutesSelect.appendChild(opt);
+ }
+}
+
async function loadOffices() {
const response = await api.get('/api/offices');
if (response && response.ok) {
@@ -70,6 +98,11 @@ async function editOffice(officeId) {
document.getElementById('officeName').value = office.name;
document.getElementById('officeQuota').value = office.parking_quota;
+ // Set booking window settings
+ document.getElementById('officeWindowEnabled').checked = office.booking_window_enabled !== false;
+ document.getElementById('officeCutoffHour').value = office.booking_window_end_hour != null ? office.booking_window_end_hour : 18;
+ document.getElementById('officeCutoffMinute').value = office.booking_window_end_minute != null ? office.booking_window_end_minute : 0;
+
openModal('Modifica Ufficio');
}
@@ -123,7 +156,10 @@ async function handleOfficeSubmit(e) {
const officeId = document.getElementById('officeId').value;
const data = {
name: document.getElementById('officeName').value,
- parking_quota: parseInt(document.getElementById('officeQuota').value) || 0
+ parking_quota: parseInt(document.getElementById('officeQuota').value) || 0,
+ booking_window_enabled: document.getElementById('officeWindowEnabled').checked,
+ booking_window_end_hour: parseInt(document.getElementById('officeCutoffHour').value),
+ booking_window_end_minute: parseInt(document.getElementById('officeCutoffMinute').value)
};
console.log('Payload:', data);
diff --git a/frontend/js/parking-settings.js b/frontend/js/parking-settings.js
index d357d0d..b5396a1 100644
--- a/frontend/js/parking-settings.js
+++ b/frontend/js/parking-settings.js
@@ -72,6 +72,15 @@ function populateHourSelect() {
option.textContent = h.toString().padStart(2, '0');
select.appendChild(option);
}
+
+ const minuteSelect = document.getElementById('bookingWindowMinute');
+ minuteSelect.innerHTML = '';
+ for (let m = 0; m < 60; m++) {
+ const option = document.createElement('option');
+ option.value = m;
+ option.textContent = m.toString().padStart(2, '0');
+ minuteSelect.appendChild(option);
+ }
}
async function loadOfficeSettings(id) {
diff --git a/frontend/pages/admin-offices.html b/frontend/pages/admin-offices.html
index f3b9eb4..282fa7b 100644
--- a/frontend/pages/admin-offices.html
+++ b/frontend/pages/admin-offices.html
@@ -93,6 +93,27 @@
Numero totale di posti auto assegnati a questo ufficio
+
+
diff --git a/frontend/pages/parking-settings.html b/frontend/pages/parking-settings.html
index 67f0b18..7e3cc89 100644
--- a/frontend/pages/parking-settings.html
+++ b/frontend/pages/parking-settings.html
@@ -88,10 +88,7 @@
:
Le presenze inserite prima di questo orario saranno messe in
@@ -159,7 +156,8 @@
-