Restructure Settings nav, modernize import page, dedup/genres UX polish

Settings is now one top-nav entry with Credentials and Jobs as sidebar
sub-pages (jobs moved from /jobs to /settings/jobs). Manual import page
replaces the bare file input and free-text filename field with a drag-drop
dropzone and a proper file-picker table. Genres page drops the "force"
checkbox for two explicit buttons (Preview / Fix genres now). Dedup's
"Scan now" runs both the file-naming and acoustic passes together, and the
table labels which pass caught each candidate instead of showing the raw
pass name. .btn-ghost gets a visible border so it reads as a real button
next to Delete/Danger actions instead of looking unaligned. Job names
throughout the UI are now human-readable instead of raw job_key strings.

Also includes the fpcalc exit-code fix from earlier (fingerprint index
was discarding valid fingerprints on files with a benign decode warning).
This commit is contained in:
andrew
2026-07-09 10:26:40 -06:00
parent 1f733d6e91
commit b4dd2286a9
18 changed files with 315 additions and 108 deletions
+2 -1
View File
@@ -7,7 +7,7 @@ from sqlalchemy import select
from app.db import get_db
from app.models import JobRun
from app.security.deps import require_auth
from app.services import beets_service, credential_service, playlist_service
from app.services import beets_service, credential_service, playlist_service, scheduler_service
router = APIRouter(tags=["dashboard"])
templates = Jinja2Templates(directory="app/templates")
@@ -44,5 +44,6 @@ async def dashboard(request: Request, user: dict = Depends(require_auth), db=Dep
"recent_runs": recent_runs,
"recent_tracks": recent_tracks,
"auth_states": credential_service.auth_states(db),
"humanize_job_key": scheduler_service.humanize_job_key,
},
)
+16 -7
View File
@@ -14,6 +14,17 @@ templates = Jinja2Templates(directory="app/templates")
# path is still available in the title attribute on hover).
_LIBRARY_PREFIX = str(settings.music_data_dir / "Library") + "/"
# dedup-library.sh's four tag-based passes (numbered_sibling, case_insensitive,
# normalized, cross_album_fuzzy) all match on filenames/tags; find-fuzzy-dupes.py's
# one pass (fuzzy_audio) matches on acoustic fingerprint. The specific pass
# name is an implementation detail -- the table just needs to say which of
# the two matching methods caught it.
_ACOUSTIC_PASS = "fuzzy_audio"
def _pass_label(pass_name: str) -> str:
return "Acoustically Similar" if pass_name == _ACOUSTIC_PASS else "File Naming"
def _display_path(path: str) -> str:
return path[len(_LIBRARY_PREFIX):] if path.startswith(_LIBRARY_PREFIX) else path
@@ -23,6 +34,7 @@ def _to_row(c) -> dict:
return {
"id": c.id,
"pass_name": c.pass_name,
"pass_label": _pass_label(c.pass_name),
"keep_path": c.keep_path,
"delete_path": c.delete_path,
"keep_display": _display_path(c.keep_path),
@@ -42,13 +54,10 @@ async def dedup_index(request: Request, user: dict = Depends(require_auth)):
@router.post("/scan")
async def scan(user: dict = Depends(require_auth)):
await dedup_review_service.scan(triggered_by="manual")
return RedirectResponse(url="/dedup", status_code=303)
@router.post("/scan-fuzzy")
async def scan_fuzzy(user: dict = Depends(require_auth)):
await dedup_review_service.scan_fuzzy(triggered_by="manual")
# Runs both the file-naming and acoustic passes -- see
# dedup_review_service.scan_all(). The candidates table shows which
# pass caught each one instead of needing two separate buttons.
await dedup_review_service.scan_all(triggered_by="manual")
return RedirectResponse(url="/dedup", status_code=303)
+11 -2
View File
@@ -28,8 +28,17 @@ async def genres_index(request: Request, user: dict = Depends(require_auth), db=
@router.post("/scan")
async def scan(force: bool = Form(False), user: dict = Depends(require_auth)):
await genre_review_service.run(apply=False, force=force, triggered_by="manual")
async def scan(user: dict = Depends(require_auth)):
# Always force=True: matches the weekly scheduled run's own behavior
# (see genre_review_service.run's docstring), so a preview accurately
# shows what "Fix genres now" would actually do.
await genre_review_service.run(apply=False, force=True, triggered_by="manual")
return RedirectResponse(url="/genres", status_code=303)
@router.post("/apply")
async def apply(user: dict = Depends(require_auth)):
await genre_review_service.run(apply=True, force=True, triggered_by="manual")
return RedirectResponse(url="/genres", status_code=303)
+9 -4
View File
@@ -8,7 +8,7 @@ from app.models import JobRun, ScheduledJob
from app.security.deps import require_auth
from app.services import scheduler_service
router = APIRouter(prefix="/jobs", tags=["jobs"])
router = APIRouter(prefix="/settings/jobs", tags=["jobs"])
templates = Jinja2Templates(directory="app/templates")
@@ -38,6 +38,7 @@ def _job_list_context(db):
maintenance_jobs.append(
{
"job_key": job_key,
"label": scheduler_service.humanize_job_key(job_key),
"description": scheduler_service.MAINTENANCE_JOB_DESCRIPTIONS.get(job_key, ""),
"next_run": _format_next_run(next_run),
"enabled": enabled_by_key.get(job_key, True),
@@ -46,7 +47,11 @@ def _job_list_context(db):
recent_runs = list(
db.execute(select(JobRun).order_by(JobRun.started_at.desc()).limit(50)).scalars()
)
return {"maintenance_jobs": maintenance_jobs, "recent_runs": recent_runs}
return {
"maintenance_jobs": maintenance_jobs,
"recent_runs": recent_runs,
"humanize_job_key": scheduler_service.humanize_job_key,
}
@router.get("")
@@ -70,7 +75,7 @@ async def run_now(job_key: str, user: dict = Depends(require_auth)):
await scheduler_service.trigger_now(scheduler, job_key)
except ValueError as exc:
raise HTTPException(404, str(exc))
return RedirectResponse(url="/jobs", status_code=303)
return RedirectResponse(url="/settings/jobs", status_code=303)
@router.post("/{job_key:path}/toggle")
@@ -81,7 +86,7 @@ async def toggle_enabled(job_key: str, user: dict = Depends(require_auth), db=De
row = db.execute(select(ScheduledJob).where(ScheduledJob.job_key == job_key)).scalar_one_or_none()
currently_enabled = row.enabled if row else True
scheduler_service.set_maintenance_enabled(scheduler, job_key, not currently_enabled)
return RedirectResponse(url="/jobs", status_code=303)
return RedirectResponse(url="/settings/jobs", status_code=303)
@router.get("/runs/{run_id}/log", response_class=PlainTextResponse)