Skip to content

webadmin: sortable log columns, with a type column - #59

Draft
tridge wants to merge 2 commits into
ArduPilot:mainfrom
tridge:pr-log-sort
Draft

tridge wants to merge 2 commits into
ArduPilot:mainfrom
tridge:pr-log-sort

Conversation

@tridge

@tridge tridge commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

The session list on the log pages (owner, admin, and shared read-only access) can now be sorted by clicking a column header, and gains a type column showing the file extension (tlog, bin, ts, mkv).

Sorting

  • Click a header to sort ascending, and again for descending. The sorted column shows an arrow and carries aria-sort.
  • Each column uses its own comparison:
    • session: the server's own natural-order rank, so the browser never disagrees with the server about session10 vs session9, or a same-second -2 recording vs its original.
    • type: case-insensitive text.
    • size and last modified: numeric, from the raw bytes and epoch seconds rather than the formatted text. A value that is not a number goes last in either direction.
  • The sort is stable. Rows that compare equal keep the server's order in both directions, so sorting by type leaves each type's files in name order.
  • The page auto-refreshes every 5 s by replacing <main>. The chosen sort is kept in sessionStorage, with an in-memory fallback, and re-applied after each refresh. It also carries over between dates.
  • Keyboard focus on a header survives the refresh, without scrolling the page. auto-refresh.js now fires a pagebeforeupdate event just before the swap so focus can be captured.

Fix

  • The per-file delete's onsubmit put a tojson string inside a double-quoted attribute. Its quotes ended the attribute early, so the handler was invalid and a click deleted the file without asking. It is now escaped, on both templates.

Testing

  • A Node test (tests/js/table_sort_test.cjs) runs the script against a fake table. It covers:
    • each comparator, and stability in both directions;
    • non-numeric values;
    • re-applying the sort and focus on pageupdate;
    • not refocusing a header the user left;
    • storage that is broken or read-only.
  • Webadmin tests check the type column, each cell's raw sort values and the escaped confirm handler on both pages.
  • Checked in headless Chrome: header clicks and keyboard sorting, the sort and focus surviving the auto-refresh, and the delete confirmation appearing.

Click a column header to sort the session list; again to reverse. Type
compares as text; size and modified time compare numerically from the
raw values, and the name by the server's own natural-order rank, so the
two never disagree. Unparseable values go last either way. The sort is
stable, so equal rows keep the server's order, and the choice and the
header's keyboard focus survive the 5 s auto-refresh.

Also escape the file name in the per-file delete's confirm handler: its
JSON quotes ended the attribute early, so the delete went through with
no confirmation.
@tridge tridge added the AIReview Request an automated AI review; picked up by the reviewprs sweep label Dec 2, 2026
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 6f054454e7.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/supportproxy/59/1.html#prSupportProxy-59

This adds sortable session/type/size/modified columns to the log lists and fixes the per-file delete confirmation, which on the base templates never compiled and so deleted without asking. The JS and new template tests pass, and only one cosmetic nit remains.

Minor (1)
  • webadmin/static/table-sort.js:20: the header comment's last sentence runs to 99 columns, leaving "dates." alone on line 21; rewrap it to match the rest of the block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIReview Request an automated AI review; picked up by the reviewprs sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants