Dashboard sortable table column headers - #353
Open
MillanWangGadget wants to merge 1 commit into
Open
Conversation
MillanWangGadget
force-pushed
the
mill/sortableTableHeaders
branch
from
June 5, 2026 13:08
b3dd0ad to
4ad386f
Compare
kirinrastogi
reviewed
Jun 8, 2026
|
|
||
| /// Sort tenant rows in place by the given (already-normalized) column and | ||
| /// direction, with a stable tiebreaker on the tenant name. | ||
| fn sort_tenant_rows(rows: &mut [TenantSummaryRow], sort_key: &str, ascending: bool) { |
Contributor
There was a problem hiding this comment.
I think this causes all queries in the tenant view to time out in our staging env.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dashboard Sortable Table Column Headers
Summary
Adds sortable column headers to the web UI dashboard tables. Two distinct
mechanisms are introduced, one for each kind of table:
the rows in-browser with no server round trip.
reloads the page with
sort/dirquery parameters so the sort appliesacross all pages, not just the visible one.
Client-side sorting (non-paginated tables)
A self-contained script in
templates/base.htmlupgrades any<table data-sortable>into a sortable table:<th>) becomes clickable and gets a sort indicator (↕idle,▲/▼when active). Adddata-no-sortto a<th>to exclude it.(matching the server-side tenants convention); clicking the active column
toggles direction.
number — mixing numeric and string comparison in one sort would be
non-transitive, so one comparison type is chosen per column. Empty cells in a
numeric column sort as the smallest value.
data-sort-value="..."to override its sort key when thedisplayed text isn't directly comparable (e.g.
P5,1.50 MiB).htmx:afterSwap), so the SQL resultstable stays sortable after a query.
Tables marked
data-sortablein this commit:cluster.htmljob.htmlqueue.htmlqueues.htmlshard.htmlsql_result.htmltenant.htmldata-sort-valueoverrides added:queue.html— priority cell (data-sort-value="{{ req.priority }}"soP5sorts by
5).shard.html— size cell (data-sort-value="{{ sr.estimated_size_bytes }}"so
1.50 MiBsorts by raw byte count).Server-side sorting (paginated tenants table)
The tenants table is paginated, so sorting must happen on the server to order
rows across the whole dataset rather than just the current page. Changes in
src/webui.rs:TenantsParamsgainssortanddirquery params, defaulting toscheduled/desc(the prior hard-coded order).TENANT_SORT_COLUMNSdefines the five sortable columns(
name,jobs,scheduled,running,terminal) with display labels.normalize_tenant_sortvalidates the requested column, falling back toscheduledfor anything unrecognized (guards against query-string injection).tenant_column_is_numeric— onlynameis textual; this drives defaultclick direction (numeric → desc, text → asc).
sort_tenant_rowssorts in place by the chosen column/direction with a stableascending tiebreaker on tenant name (tiebreaker stays ascending regardless of
primary direction).
build_tenant_sort_headersproducesSortHeaderstructs (label, href,is_active, indicator) consumed by the template. The active column's link
toggles its direction; inactive columns open in their default direction.
tenants_handlerreplaces the old hard-codedsort_bywith this configurablepath and passes
sort,dir, andsort_headersinto the template.SortedRunViewgainsestimated_size_bytes(rawu64) so the shard templatecan expose it as a numeric sort key.
The
tenants.htmltemplate renders the headers in a loop, each as a link withan active arrow (
▲/▼) or idle↕. Pagination Previous/Next links now carrysortanddirso the sort persists when changing pages.Tests
A
#[cfg(test)]module insrc/webui.rscovers the server-side logic:normalize_tenant_sortaccepts known columns and falls back toscheduled(including aDROP TABLEinjection-style input).tenant_column_is_numericclassification.per_pageis preserved in the href.