From b8655ea052b0d7e49341501e41f837bd618df08c Mon Sep 17 00:00:00 2001 From: David Galloway Date: Mon, 20 Jul 2026 11:48:41 -0400 Subject: [PATCH] main.js: Fix sorting of timestamp columns paddles serializes timestamps as "YYYY-MM-DD HH:MM:SS[.ffffff]". tablesorter's auto-detected shortDate parser mangles the fractional seconds (its format() replaces the "." with "/"), so new Date() fails and every cell in e.g. the nodes page's Locked Since column gets an empty sort key, making the sort a no-op. Register a custom parser that converts these timestamps to epoch milliseconds via Date.UTC(), handling both the usual microsecond suffix and its absence when microseconds are zero. Fixes: https://tracker.ceph.com/issues/59629 Signed-off-by: David Galloway --- public/js/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/public/js/main.js b/public/js/main.js index 7770eb9..38a7105 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -114,6 +114,23 @@ function populate_suite_menus(suite_names) { } $( document ).ready(function() { + // paddles serializes timestamps as "YYYY-MM-DD HH:MM:SS[.ffffff]". + // The built-in shortDate parser mangles the fractional seconds + // (its format() turns the "." into "/"), making e.g. the nodes + // page's Locked Since column unsortable, so parse them ourselves. + $.tablesorter.addParser({ + id: "paddlesDate", + is: function(s) { + return /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}/.test(s); + }, + format: function(s) { + var m = s ? s.match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?/) : null; + if (!m) { return s; } + return Date.UTC(m[1], m[2] - 1, m[3], m[4], m[5], m[6], + m[7] ? Math.round(parseFloat("0." + m[7]) * 1000) : 0); + }, + type: "numeric" + }); $("table") .tablesorter({ selectorHeaders: "> thead th"