From 04c66bdf9cdd1ae48d8f4041dc3d14d193f4af6a Mon Sep 17 00:00:00 2001 From: serversdwn Date: Mon, 12 Jan 2026 23:07:25 +0000 Subject: [PATCH] Refactor project dashboard and device list templates; add modals for editing projects and locations - Updated project_dashboard.html to conditionally display NRLs or Locations based on project type, and added a button to open a modal for adding locations. - Enhanced slm_device_list.html with a configuration button for each unit, allowing users to open a modal for device configuration. - Modified detail.html to include an edit project modal with a form for updating project details, including client name, status, and dates. - Improved sound_level_meters.html by restructuring the layout and adding a configuration modal for SLM devices. - Implemented JavaScript functions for handling modal interactions, including opening, closing, and submitting forms for project and location management. --- .gitignore | 1 + backend/routers/project_locations.py | 2 + backend/routers/slm_dashboard.py | 8 +- .../partials/projects/assignment_list.html | 30 + .../partials/projects/location_list.html | 66 +++ .../partials/projects/project_dashboard.html | 65 +-- templates/partials/slm_device_list.html | 10 +- templates/projects/detail.html | 537 +++++++++++++++++- templates/sound_level_meters.html | 212 +------ 9 files changed, 705 insertions(+), 226 deletions(-) create mode 100644 templates/partials/projects/assignment_list.html create mode 100644 templates/partials/projects/location_list.html diff --git a/.gitignore b/.gitignore index b697ede..fd12ceb 100644 --- a/.gitignore +++ b/.gitignore @@ -211,3 +211,4 @@ __marimo__/ *.db *.db-journal data/ +.aider* diff --git a/backend/routers/project_locations.py b/backend/routers/project_locations.py index 0f999c9..37312e2 100644 --- a/backend/routers/project_locations.py +++ b/backend/routers/project_locations.py @@ -152,6 +152,8 @@ async def update_location( location.name = data["name"] if "description" in data: location.description = data["description"] + if "location_type" in data: + location.location_type = data["location_type"] if "coordinates" in data: location.coordinates = data["coordinates"] if "address" in data: diff --git a/backend/routers/slm_dashboard.py b/backend/routers/slm_dashboard.py index d2e4408..9107b3c 100644 --- a/backend/routers/slm_dashboard.py +++ b/backend/routers/slm_dashboard.py @@ -61,13 +61,9 @@ async def get_slm_stats(request: Request, db: Session = Depends(get_db)): async def get_slm_units( request: Request, db: Session = Depends(get_db), -<<<<<<< Updated upstream - search: str = Query(None) -======= search: str = Query(None), project: str = Query(None), include_measurement: bool = Query(False), ->>>>>>> Stashed changes ): """ Get list of SLM units for the sidebar. @@ -75,6 +71,10 @@ async def get_slm_units( """ query = db.query(RosterUnit).filter_by(device_type="sound_level_meter") + # Filter by project if provided + if project: + query = query.filter(RosterUnit.project_id == project) + # Filter by search term if provided if search: search_term = f"%{search}%" diff --git a/templates/partials/projects/assignment_list.html b/templates/partials/projects/assignment_list.html new file mode 100644 index 0000000..8b75c7a --- /dev/null +++ b/templates/partials/projects/assignment_list.html @@ -0,0 +1,30 @@ + +{% if assignments %} +
+ {% for item in assignments %} +
+
+
+

{{ item.unit.id if item.unit else item.assignment.unit_id }}

+ {% if item.location %} +

Location: {{ item.location.name }}

+ {% endif %} +

+ Assigned: {% if item.assignment.assigned_at %}{{ item.assignment.assigned_at.strftime('%Y-%m-%d %H:%M') }}{% else %}Unknown{% endif %} +

+
+ +
+
+ {% endfor %} +
+{% else %} +
+ + + +

No active assignments

+
+{% endif %} diff --git a/templates/partials/projects/location_list.html b/templates/partials/projects/location_list.html new file mode 100644 index 0000000..dfb3ef8 --- /dev/null +++ b/templates/partials/projects/location_list.html @@ -0,0 +1,66 @@ + +{% if locations %} +
+ {% for item in locations %} +
+
+
+
+

{{ item.location.name }}

+ {% if item.location.location_type %} + + {{ item.location.location_type|capitalize }} + + {% endif %} +
+ {% if item.location.description %} +

{{ item.location.description }}

+ {% endif %} + {% if item.location.address %} +

{{ item.location.address }}

+ {% endif %} + {% if item.location.coordinates %} +

{{ item.location.coordinates }}

+ {% endif %} +
+ +
+ {% if item.assignment %} + + {% else %} + + {% endif %} + + +
+
+ +
+ Sessions: {{ item.session_count }} + {% if item.assignment and item.assigned_unit %} + Assigned: {{ item.assigned_unit.id }} + {% else %} + No active assignment + {% endif %} +
+
+ {% endfor %} +
+{% else %} +
+ + + +

No locations added yet

+
+{% endif %} diff --git a/templates/partials/projects/project_dashboard.html b/templates/partials/projects/project_dashboard.html index 9fbe084..8fc70d1 100644 --- a/templates/partials/projects/project_dashboard.html +++ b/templates/partials/projects/project_dashboard.html @@ -44,47 +44,34 @@ -
+
-

Locations

- {% if locations %} -
- {% for location in locations %} -
-

{{ location.name }}

- {% if location.address %} -

{{ location.address }}

- {% endif %} - {% if location.coordinates %} -

{{ location.coordinates }}

- {% endif %} -
- {% endfor %} +
+

+ {% if project_type and project_type.id == 'sound_monitoring' %} + NRLs + {% else %} + Locations + {% endif %} +

+ +
+
+
+
+
+
- {% else %} -

No locations added yet.

- {% endif %} -
- -
-

Assigned Units

- {% if assigned_units %} - - {% else %} -

No units assigned yet.

- {% endif %} +
diff --git a/templates/partials/slm_device_list.html b/templates/partials/slm_device_list.html index 6b883cc..0908861 100644 --- a/templates/partials/slm_device_list.html +++ b/templates/partials/slm_device_list.html @@ -1,7 +1,15 @@ {% if units %} {% for unit in units %} - + + + + + + + + + + + + + {% endblock %} diff --git a/templates/sound_level_meters.html b/templates/sound_level_meters.html index 91b2151..b31bdf6 100644 --- a/templates/sound_level_meters.html +++ b/templates/sound_level_meters.html @@ -21,46 +21,12 @@
-<<<<<<< Updated upstream -
- -
-
-

Active Units

- - -
- -
- - -
- -
-
-
-
-
-
-=======

Projects

View all ->>>>>>> Stashed changes
Manage roster
-<<<<<<< Updated upstream -
- -
-
-
-
-=======
->>>>>>> Stashed changes
-<<<<<<< Updated upstream + + + -======= ->>>>>>> Stashed changes {% endblock %}