Major overhaul to the Notes/Issues. Minor tweaks to the UI. Added Profile photos

This commit is contained in:
2026-02-19 06:30:57 +02:00
parent a9a1531d57
commit f09979c653
21 changed files with 988 additions and 308 deletions

View File

@@ -8,9 +8,10 @@ class NoteCreate(BaseModel):
"""Create a new equipment note/log entry."""
title: str
content: str
category: str = "general" # general, maintenance, installation, issue, other
category: str = "general" # general, maintenance, installation, issue, action_item, other
device_id: Optional[str] = None # Firestore doc ID of linked device
user_id: Optional[str] = None # Firestore doc ID of linked user
status: str = "" # "", "completed"
class NoteUpdate(BaseModel):
@@ -20,6 +21,7 @@ class NoteUpdate(BaseModel):
category: Optional[str] = None
device_id: Optional[str] = None
user_id: Optional[str] = None
status: Optional[str] = None
class NoteInDB(BaseModel):
@@ -35,6 +37,7 @@ class NoteInDB(BaseModel):
created_by: str = ""
created_at: str = ""
updated_at: str = ""
status: str = ""
class NoteListResponse(BaseModel):

View File

@@ -50,6 +50,15 @@ async def update_note(
return service.update_note(note_id, body)
@router.patch("/{note_id}/status", response_model=NoteInDB)
async def toggle_note_status(
note_id: str,
body: NoteUpdate,
_user: TokenPayload = Depends(require_permission("equipment", "edit")),
):
return service.update_note(note_id, body)
@router.delete("/{note_id}", status_code=204)
async def delete_note(
note_id: str,

View File

@@ -6,7 +6,7 @@ from equipment.models import NoteCreate, NoteUpdate, NoteInDB
COLLECTION = "equipment_notes"
VALID_CATEGORIES = {"general", "maintenance", "installation", "issue", "other"}
VALID_CATEGORIES = {"general", "maintenance", "installation", "issue", "action_item", "other"}
def _convert_firestore_value(val):
@@ -81,7 +81,10 @@ def list_notes(
if user_id:
query = query.where("user_id", "==", user_id)
query = query.order_by("created_at", direction="DESCENDING")
# Only use order_by when no field filters are applied (avoids composite index requirement)
has_field_filters = bool(category or device_id or user_id)
if not has_field_filters:
query = query.order_by("created_at", direction="DESCENDING")
docs = query.stream()
results = []
@@ -98,6 +101,10 @@ def list_notes(
results.append(note)
# Sort client-side when we couldn't use order_by
if has_field_filters:
results.sort(key=lambda n: n.created_at or "", reverse=True)
return results