From 172706ee5133b5cb555eff8df6619af92a1e5a5a Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 29 Sep 2026 01:59:42 -0500 Subject: [PATCH] feat(dashboard): bug report, play key and system log pages update without reloading reloadInPlace() and goTo(url) (common.js) show the page again or open another one through nav.js, or reload/load normally without it. Resolving a bug report updates the page in place; deleting a bug report or play key goes back to its list without leaving the deleted page in the history. The System Log's server and file pickers and its Refresh button swap the page in (Refresh keeps the scroll position). The AI helper's "open the account" goes through nav.js too. Check: resolve a bug report: the Resolved badge and text appear with no reload. Delete a play key: back on Play Keys, and Back doesn't return to the deleted key. System Log: picking a server or file and Refresh change the log without a white flash. Co-Authored-By: Claude Opus 5.5 --- dDashboardServer/static/js/ai-suggest.js | 2 +- dDashboardServer/static/js/common.js | 15 +++++++++++++++ dDashboardServer/templates/bug_report-view.jinja2 | 4 ++-- dDashboardServer/templates/play_key-view.jinja2 | 2 +- dDashboardServer/templates/system_log.jinja2 | 9 ++++++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/dDashboardServer/static/js/ai-suggest.js b/dDashboardServer/static/js/ai-suggest.js index 6c71310fd..554b4ba17 100644 --- a/dDashboardServer/static/js/ai-suggest.js +++ b/dDashboardServer/static/js/ai-suggest.js @@ -206,7 +206,7 @@ var prefill = { account: String(data.account_id), action: s.action, days: s.days, strike: s.strike, reason: s.action === 'note' ? clip(s.staff_explanation, 300) : s.player_reason, at: Date.now() }; try { sessionStorage.setItem(PREFILL_KEY, JSON.stringify(prefill)); } catch (e) { return toast('Could not pass the suggestion on (browser storage is off)', 'warning'); } - window.location.href = '/accounts/' + encodeURIComponent(data.account_id); + goTo('/accounts/' + encodeURIComponent(data.account_id)); } // On an account page: fill in the form a suggestion was passed to. Nothing is submitted. diff --git a/dDashboardServer/static/js/common.js b/dDashboardServer/static/js/common.js index 6efe1c9a9..48738ac9a 100644 --- a/dDashboardServer/static/js/common.js +++ b/dDashboardServer/static/js/common.js @@ -92,6 +92,21 @@ }); }; + /** + * Show this page again with what the server has now, after a change made from it: in place when nav.js is there + * (Nav.refresh), otherwise a reload. goTo(url) opens another page the same way (Nav.go, or a normal load). + */ + window.reloadInPlace = function () { + if (window.Nav && Nav.refresh) return Nav.refresh({ force: true }); + window.location.reload(); + return Promise.resolve(); + }; + window.goTo = function (url, options) { + if (window.Nav && Nav.go) return Nav.go(url, options); + if (options && options.replace) window.location.replace(url); else window.location.href = url; + return Promise.resolve(); + }; + window.toast = function (message, type) { var container = document.getElementById('toast-container'); if (!container) { diff --git a/dDashboardServer/templates/bug_report-view.jinja2 b/dDashboardServer/templates/bug_report-view.jinja2 index 656d1697d..52f9e1aee 100644 --- a/dDashboardServer/templates/bug_report-view.jinja2 +++ b/dDashboardServer/templates/bug_report-view.jinja2 @@ -61,12 +61,12 @@ if (window.Live) Live.refreshPage('bug_reports', document.getElementById('report function resolveReport() { api.action(reportUrl + '/resolve', { resolution: document.getElementById('resolution').value.trim() }) - .then(function () { location.reload(); }).catch(function () {}); + .then(function () { reloadInPlace(); }).catch(function () {}); } function deleteReport() { if (!confirm('Delete this bug report?')) return; - api.action(reportUrl + '/delete').then(function () { window.location.href = '/bug_reports'; }).catch(function () {}); + api.action(reportUrl + '/delete').then(function () { goTo('/bug_reports', { replace: true }); }).catch(function () {}); } {% endblock %} diff --git a/dDashboardServer/templates/play_key-view.jinja2 b/dDashboardServer/templates/play_key-view.jinja2 index c3c866677..298fa0c5d 100644 --- a/dDashboardServer/templates/play_key-view.jinja2 +++ b/dDashboardServer/templates/play_key-view.jinja2 @@ -75,7 +75,7 @@ function saveKey() { function deleteKey() { if (!confirm('Delete this play key? Accounts that used it keep working but lose the link to it.')) return; - api.action(keyUrl + '/delete').then(function () { window.location.href = '/play_keys'; }).catch(function () {}); + api.action(keyUrl + '/delete').then(function () { goTo('/play_keys', { replace: true }); }).catch(function () {}); } {% endblock %} diff --git a/dDashboardServer/templates/system_log.jinja2 b/dDashboardServer/templates/system_log.jinja2 index 0042a4b2b..f350cdda5 100644 --- a/dDashboardServer/templates/system_log.jinja2 +++ b/dDashboardServer/templates/system_log.jinja2 @@ -28,7 +28,7 @@
- + {% if exists("log_file") %}Download{% endif %}
@@ -128,8 +128,11 @@ document.querySelectorAll('#logFilePick option').forEach(function (o) { var started = Number((o.value.match(/_(\d{9,})\.log$/) || [])[1]); o.textContent = (started ? 'Started ' + fmt.unix(started) + ', ' : '') + 'last written ' + fmt.unix(Number(o.dataset.time)) + ' (' + fileSize(o.dataset.size) + ')'; }); -document.getElementById('logServerPick').addEventListener('change', function () { location.href = '/system_log?server=' + encodeURIComponent(this.value); }); -document.getElementById('logFilePick').addEventListener('change', function () { this.form.submit(); }); +document.getElementById('logServerPick').addEventListener('change', function () { goTo('/system_log?server=' + encodeURIComponent(this.value)); }); +// requestSubmit, so the change goes through nav.js like a click on a link +document.getElementById('logFilePick').addEventListener('change', function () { if (this.form.requestSubmit) this.form.requestSubmit(); else this.form.submit(); }); +// The same file again with its newest lines, where the page was scrolled to +function showLogAgain() { goTo(location.href, { replace: true, scroll: window.scrollY }); } // Download logs function bundleLocal(date) { var d = new Date(date.getTime() - date.getTimezoneOffset() * 60000); return d.toISOString().slice(0, 16); }