fixes and improvements

This commit is contained in:
2026-05-07 12:34:16 +02:00
parent 2ecca84892
commit bba23165ab
14 changed files with 860 additions and 158 deletions
@@ -56,6 +56,47 @@ def get_monitoring_overview(
}
@router.get("/shortcuts")
def get_shortcuts(
store=Depends(get_settings_store),
) -> list[dict[str, Any]]:
"""Return dashboard shortcut records."""
shortcuts = store.list_shortcuts()
logger.info("Dashboard shortcuts count=%s", len(shortcuts))
return shortcuts
@router.post("/shortcuts")
def create_shortcut(
payload: dict[str, Any],
store=Depends(get_settings_store),
) -> dict[str, Any]:
shortcut = store.upsert_shortcut(payload)
logger.info("Created dashboard shortcut id=%s type=%s", shortcut.get("id"), shortcut.get("shortcut_type"))
return shortcut
@router.put("/shortcuts/{shortcut_id}")
def update_shortcut(
shortcut_id: str,
payload: dict[str, Any],
store=Depends(get_settings_store),
) -> dict[str, Any]:
shortcut = store.upsert_shortcut(payload, shortcut_id)
logger.info("Updated dashboard shortcut id=%s type=%s", shortcut.get("id"), shortcut.get("shortcut_type"))
return shortcut
@router.delete("/shortcuts/{shortcut_id}")
def delete_shortcut(
shortcut_id: str,
store=Depends(get_settings_store),
) -> dict[str, str]:
store.delete_shortcut(shortcut_id)
logger.info("Deleted dashboard shortcut id=%s", shortcut_id)
return {"status": "deleted"}
def _map_sessions_to_activity_rows(sessions: list[dict[str, Any]]) -> list[dict[str, Any]]:
"""Normalize Jellyfin sessions into dashboard activity rows."""
results: list[dict[str, Any]] = []
@@ -9,7 +9,7 @@ import paramiko
from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel, Field
from media_library_viewer_api.dependencies import get_settings_store
from media_library_viewer_api.dependencies import get_monitoring_poller, get_settings_store
from media_library_viewer_api.services.db_maintenance import remove_sqlite_database
from media_library_viewer_api.services.media_index import MediaIndex
from media_library_viewer_api.services.settings_store import SettingsStore
@@ -54,7 +54,9 @@ def post_machine(
machine: MonitoringMachineInput,
store: SettingsStore = Depends(get_settings_store),
) -> dict[str, Any]:
return store.upsert_machine(machine.model_dump(exclude_none=True), machine.id)
saved = store.upsert_machine(machine.model_dump(exclude_none=True), machine.id)
get_monitoring_poller().start()
return saved
@router.put("/machines/{machine_id}")
@@ -65,7 +67,9 @@ def put_machine(
) -> dict[str, Any]:
if not store.get_machine(machine_id):
raise HTTPException(status_code=404, detail="Machine not found")
return store.upsert_machine(machine.model_dump(exclude_none=True), machine_id)
saved = store.upsert_machine(machine.model_dump(exclude_none=True), machine_id)
get_monitoring_poller().start()
return saved
@router.delete("/machines/{machine_id}")