fixes and improvements

This commit is contained in:
2026-05-11 17:00:46 +02:00
parent 67a619e148
commit 80d38ed86d
6 changed files with 40 additions and 25 deletions
@@ -43,7 +43,7 @@ def get_monitoring_overview(
store=Depends(get_settings_store),
) -> dict[str, Any]:
"""Return one lightweight monitoring row per configured machine."""
machines = store.list_machines()
machines = [m for m in store.list_machines() if m.get("enabled")]
rows: list[dict[str, Any]] = []
for machine in machines:
try:
@@ -53,8 +53,8 @@ def _resolve_machine(store: SettingsStore, machine_id: str | None) -> dict[str,
@router.get("/machines")
def get_machines(store: SettingsStore = Depends(get_settings_store)) -> list[dict[str, Any]]:
"""Return monitoring machines for the UI."""
return store.list_machines()
"""Return enabled monitoring machines for the UI."""
return [m for m in store.list_machines() if m.get("enabled")]
@router.get("/poller")
@@ -318,9 +318,6 @@ def reset_local_database(
media_index = MediaIndex()
media_removed = remove_sqlite_database(media_index.db_path)
# Recreate the default local machine immediately so the UI remains usable.
store.ensure_defaults()
return {
"status": "reset",
"settings_db_removed": bool(settings_removed),
@@ -355,7 +355,7 @@ class SettingsStore:
)
def list_machines(self) -> list[dict[str, Any]]:
self.ensure_defaults()
self.init_schema()
with self.connect() as conn:
rows = conn.execute(
"SELECT * FROM monitoring_machines ORDER BY CASE WHEN id = ? THEN 0 ELSE 1 END, name COLLATE NOCASE",
@@ -366,7 +366,7 @@ class SettingsStore:
def get_machine(self, machine_id: str | None) -> dict[str, Any] | None:
if not machine_id:
return None
self.ensure_defaults()
self.init_schema()
with self.connect() as conn:
row = conn.execute("SELECT * FROM monitoring_machines WHERE id = ?", (machine_id,)).fetchone()
return self._row_to_machine(row) if row else None
@@ -375,7 +375,7 @@ class SettingsStore:
"""Return the full machine config including secrets."""
if not machine_id:
return None
self.ensure_defaults()
self.init_schema()
with self.connect() as conn:
row = conn.execute("SELECT * FROM monitoring_machines WHERE id = ?", (machine_id,)).fetchone()
if not row: