@datalabz_/dashboard-kit 6.0.10 → 6.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/v4.js +1 -1
- package/v5.js +1 -1
- package/v6.js +54 -14
package/package.json
CHANGED
package/v4.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = '679acd7'; // replaced at deploy: sed -i "s/679acd7/$(git rev-parse --short HEAD)/g" v4.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
package/v5.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = '679acd7'; // replaced at deploy: sed -i "s/679acd7/$(git rev-parse --short HEAD)/g" v4.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
package/v6.js
CHANGED
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = '679acd7'; // replaced at deploy: sed -i "s/679acd7/$(git rev-parse --short HEAD)/g" v6.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
|
+
let _pageErrors = []; // System Info: errors no load() caught (a handler's, a timer's, the page script's)
|
|
25
26
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
27
|
let _generation = 0;
|
|
27
28
|
let _abort = new AbortController(); // this generation's requests; _invalidateAll aborts them
|
|
@@ -1603,6 +1604,18 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1603
1604
|
// its own, so without this reset a section that fails once, then succeeds
|
|
1604
1605
|
// on retry, would keep showing its old error badge forever.
|
|
1605
1606
|
_sectionErrors[sec.id] = 0;
|
|
1607
|
+
// Chart.js keeps every chart in its registry, data and all, until destroy(). The spinner below
|
|
1608
|
+
// replaces the panel's canvases, so their charts go first: a dashboard that forgot its own
|
|
1609
|
+
// Chart.getChart(id)?.destroy() would keep one dead chart per reload. One that did not forget
|
|
1610
|
+
// then finds none, as on a first load.
|
|
1611
|
+
const Chart = global.Chart;
|
|
1612
|
+
if (Chart && Chart.instances) {
|
|
1613
|
+
Object.keys(Chart.instances).forEach(function (k) {
|
|
1614
|
+
const chart = Chart.instances[k];
|
|
1615
|
+
if (!chart || !chart.canvas || !panel.contains(chart.canvas)) return;
|
|
1616
|
+
try { chart.destroy(); } catch (err) { console.error('[DashboardKit] could not destroy a chart:', err); }
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1606
1619
|
setSectionState(panel, 'loading');
|
|
1607
1620
|
_setPill('loading', 'loading…');
|
|
1608
1621
|
// What a click point drawn by this load reports: this section, and the header filters and the
|
|
@@ -1611,8 +1624,8 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1611
1624
|
// Kept on the section for a render call that arrives without it (_ctxOf).
|
|
1612
1625
|
sec.ctx = ctx;
|
|
1613
1626
|
// A replaced load must not draw (see _superseded). It stops at its next query; these stop one that
|
|
1614
|
-
//
|
|
1615
|
-
//
|
|
1627
|
+
// was awaiting something else when it was replaced and draws on its return. Only while the load
|
|
1628
|
+
// runs: a handler it leaves behind calls and draws as it always has.
|
|
1616
1629
|
let running = true;
|
|
1617
1630
|
const replaced = function () { return running && gen !== _generation; };
|
|
1618
1631
|
try {
|
|
@@ -1638,8 +1651,6 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1638
1651
|
sec.errors = _sectionErrors[sec.id] || 0;
|
|
1639
1652
|
} catch (e) {
|
|
1640
1653
|
running = false;
|
|
1641
|
-
// Not a failure: a newer load replaced this one, and it reports its own.
|
|
1642
|
-
if (e && e.dkSuperseded && gen !== _generation) return;
|
|
1643
1654
|
// The real exception, stack and dkCall included — the panel and the report only get a phrase.
|
|
1644
1655
|
console.error('[DashboardKit] section "' + sec.id + '" failed:', e);
|
|
1645
1656
|
console.log('[DashboardKit] section "' + sec.id + '" failed:', e);
|
|
@@ -1712,13 +1723,14 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1712
1723
|
// ── runQuery ──────────────────────────────────────────────────────────────────
|
|
1713
1724
|
// A load that Refresh or new host params replaced must not draw: its rows are for the old period or
|
|
1714
1725
|
// filters, and would land over the newer load's, with drillthrough points reporting either load's
|
|
1715
|
-
// filters. So a query a replaced load made
|
|
1716
|
-
//
|
|
1717
|
-
// its
|
|
1726
|
+
// filters. So a query a replaced load made is aborted and never settles: the load stays on its
|
|
1727
|
+
// await and runs nothing after it. Not a throw: a dashboard that wraps its queries in try/catch
|
|
1728
|
+
// would draw its own "No data" or error text over the newer load's. A fresh promise each time:
|
|
1729
|
+
// one shared never-settling promise would hold every load ever left on it. A query no running
|
|
1730
|
+
// load made — a handler's — is left as it always was: replacing its section's load never touched
|
|
1731
|
+
// it, so it must not start failing now (README → Rules).
|
|
1718
1732
|
function _superseded() {
|
|
1719
|
-
|
|
1720
|
-
err.dkSuperseded = true;
|
|
1721
|
-
return err;
|
|
1733
|
+
return new Promise(function () {});
|
|
1722
1734
|
}
|
|
1723
1735
|
|
|
1724
1736
|
// One retry, only where _isRetryable says the same request may succeed.
|
|
@@ -1731,7 +1743,7 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1731
1743
|
gen = sec && sec.pending && sec.runGen === _generation ? _generation : null;
|
|
1732
1744
|
}
|
|
1733
1745
|
const replaced = function () { return gen !== null && gen !== _generation; };
|
|
1734
|
-
if (replaced())
|
|
1746
|
+
if (replaced()) return _superseded();
|
|
1735
1747
|
const signal = gen === null ? undefined : _abort.signal;
|
|
1736
1748
|
const t0 = performance.now();
|
|
1737
1749
|
const entry = {
|
|
@@ -1767,7 +1779,7 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1767
1779
|
});
|
|
1768
1780
|
entry.status = res.status;
|
|
1769
1781
|
const text = await res.text();
|
|
1770
|
-
if (replaced())
|
|
1782
|
+
if (replaced()) return _superseded();
|
|
1771
1783
|
entry.bytes = text.length;
|
|
1772
1784
|
let data;
|
|
1773
1785
|
try { data = JSON.parse(text); } catch { data = { _raw: text }; }
|
|
@@ -1802,7 +1814,7 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1802
1814
|
return data.rows;
|
|
1803
1815
|
} catch (err) {
|
|
1804
1816
|
// Before anything is counted: an aborted fetch is no network error, and a replaced load no failure.
|
|
1805
|
-
if (replaced())
|
|
1817
|
+
if (replaced()) return _superseded();
|
|
1806
1818
|
// The failed-response throw lands here too — already built.
|
|
1807
1819
|
if (err && err.dkCall) throw err;
|
|
1808
1820
|
entry.clientMs = Math.round(performance.now() - t0);
|
|
@@ -3066,6 +3078,15 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
3066
3078
|
'<tr><td>Client duration</td><td>' + totMs + ' ms</td></tr>' +
|
|
3067
3079
|
'<tr><td>Bytes received</td><td>' + fmtInt(totB) + '</td></tr>' +
|
|
3068
3080
|
'</table></div>' +
|
|
3081
|
+
(_pageErrors.length
|
|
3082
|
+
? '<div><h3>Page errors</h3>' + _pageErrors.map(function (p) {
|
|
3083
|
+
return '<details class="dk-call"><summary>' +
|
|
3084
|
+
'<span class="dk-s-err">' + (p.kind === 'rejection' ? 'REJECTED' : 'ERROR') + '</span>' +
|
|
3085
|
+
'<span style="flex:1">' + esc(p.message) + '</span>' +
|
|
3086
|
+
'<span style="color:var(--muted);font-size:10px">' + p.ts.slice(11, 19) + '</span>' +
|
|
3087
|
+
'</summary><div class="dk-call-body"><pre>' + esc(p.stack || p.message) + '</pre></div></details>';
|
|
3088
|
+
}).join('') + '</div>'
|
|
3089
|
+
: '') +
|
|
3069
3090
|
'<div><h3>Calls <button id="dk-sysinfo-export" style="margin-left:8px;background:transparent;color:var(--brand);border:1px solid var(--brand);border-radius:3px;padding:0 8px;height:22px;font-size:11px;cursor:pointer">Export JSON ↓</button></h3>' +
|
|
3070
3091
|
callsHtml + '</div>' +
|
|
3071
3092
|
'</div>';
|
|
@@ -3089,6 +3110,7 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
3089
3110
|
return Object.assign({}, c, { requestHeaders: { 'Content-Type': 'application/json', Authorization: 'Bearer ***' } });
|
|
3090
3111
|
}),
|
|
3091
3112
|
};
|
|
3113
|
+
if (_pageErrors.length) payload.pageErrors = _pageErrors;
|
|
3092
3114
|
const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application/json' });
|
|
3093
3115
|
const a = document.createElement('a');
|
|
3094
3116
|
a.href = URL.createObjectURL(blob);
|
|
@@ -3226,6 +3248,24 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
3226
3248
|
return div;
|
|
3227
3249
|
}
|
|
3228
3250
|
|
|
3251
|
+
// ── Errors no load() caught ── a section's load() failing shows in its panel; a click or change
|
|
3252
|
+
// handler, a timer or the page's own script failing showed nowhere but the browser console, so a
|
|
3253
|
+
// dead control looked like a working one in System Info. Recorded only: the page and the browser's
|
|
3254
|
+
// own reporting are left as they are. Capped, so a handler failing on every mousemove stays cheap.
|
|
3255
|
+
const PAGE_ERRORS_MAX = 50;
|
|
3256
|
+
function _pageError(kind, err, fallback) {
|
|
3257
|
+
if (_pageErrors.length >= PAGE_ERRORS_MAX) return;
|
|
3258
|
+
_pageErrors.push({
|
|
3259
|
+
ts: new Date().toISOString(),
|
|
3260
|
+
kind: kind,
|
|
3261
|
+
message: String((err && err.message) || fallback || err),
|
|
3262
|
+
stack: err && err.stack ? String(err.stack).slice(0, 2000) : null,
|
|
3263
|
+
});
|
|
3264
|
+
_renderSystemInfo();
|
|
3265
|
+
}
|
|
3266
|
+
global.addEventListener('error', function (e) { _pageError('error', e.error, e.message); });
|
|
3267
|
+
global.addEventListener('unhandledrejection', function (e) { _pageError('rejection', e.reason); });
|
|
3268
|
+
|
|
3229
3269
|
// ── Number-input guard ── a focused type=number takes the wheel. { passive: false }
|
|
3230
3270
|
// is required for preventDefault; v4.css hides the spinners.
|
|
3231
3271
|
document.addEventListener(
|