Dedup page: shorten paths, fix column alignment, per-row delete
- Strip the common /data/music/Library/ prefix from displayed keep/delete paths (every track lives there, so it added width without adding information); full path is still available via a hover title. - Table now uses a colgroup with fixed column widths so headers stay aligned with their content regardless of how long a given path is, instead of drifting with the widest cell in the column. - Add a per-row Delete button (self-contained form per cell) alongside the existing checkbox + bulk "Delete selected" flow -- the checkboxes now target an external form via the HTML `form` attribute instead of wrapping the table in a form, since a form can't legally nest another form for the per-row buttons. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+22
-1
@@ -4,14 +4,35 @@ from fastapi.templating import Jinja2Templates
|
||||
|
||||
from app.security.deps import require_auth
|
||||
from app.services import dedup_review_service
|
||||
from app.settings import settings
|
||||
|
||||
router = APIRouter(prefix="/dedup", tags=["dedup"])
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
# Every library track lives under this prefix -- showing it on every row of
|
||||
# every candidate adds nothing but width, so strip it for display (the full
|
||||
# path is still available in the title attribute on hover).
|
||||
_LIBRARY_PREFIX = str(settings.music_data_dir / "Library") + "/"
|
||||
|
||||
|
||||
def _display_path(path: str) -> str:
|
||||
return path[len(_LIBRARY_PREFIX):] if path.startswith(_LIBRARY_PREFIX) else path
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def dedup_index(request: Request, user: dict = Depends(require_auth)):
|
||||
candidates = dedup_review_service.list_pending_candidates()
|
||||
candidates = [
|
||||
{
|
||||
"id": c.id,
|
||||
"pass_name": c.pass_name,
|
||||
"keep_path": c.keep_path,
|
||||
"delete_path": c.delete_path,
|
||||
"keep_display": _display_path(c.keep_path),
|
||||
"delete_display": _display_path(c.delete_path),
|
||||
"delete_size_bytes": c.delete_size_bytes,
|
||||
}
|
||||
for c in dedup_review_service.list_pending_candidates()
|
||||
]
|
||||
return templates.TemplateResponse(request, "dedup/index.html", {"candidates": candidates})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user