@datalabz_/dashboard-kit 6.0.9 → 6.0.10
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 +45 -8
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 = '320ab06'; // replaced at deploy: sed -i "s/320ab06/$(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 = '320ab06'; // replaced at deploy: sed -i "s/320ab06/$(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,10 +20,11 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = '320ab06'; // replaced at deploy: sed -i "s/320ab06/$(git rev-parse --short HEAD)/g" v6.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
|
27
|
+
let _abort = new AbortController(); // this generation's requests; _invalidateAll aborts them
|
|
27
28
|
let _ttEl = null;
|
|
28
29
|
let _pendingFilters = {}; // header filters a parent sent before boot, applied at boot
|
|
29
30
|
let _filtersRefused = false;
|
|
@@ -1583,6 +1584,8 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1583
1584
|
|
|
1584
1585
|
function _invalidateAll() {
|
|
1585
1586
|
_generation++;
|
|
1587
|
+
_abort.abort();
|
|
1588
|
+
_abort = new AbortController();
|
|
1586
1589
|
_sections.forEach(function (s) { s.loaded = false; s.errors = 0; });
|
|
1587
1590
|
_sectionErrors = {};
|
|
1588
1591
|
_calls = [];
|
|
@@ -1607,27 +1610,36 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1607
1610
|
const ctx = { id: sec.id, localFilters: _headerSnapshot(), context: _contextSnapshot() };
|
|
1608
1611
|
// Kept on the section for a render call that arrives without it (_ctxOf).
|
|
1609
1612
|
sec.ctx = ctx;
|
|
1613
|
+
// A replaced load must not draw (see _superseded). It stops at its next query; these stop one that
|
|
1614
|
+
// catches that itself and draws anyway, a dashboard wrapping its queries in try/catch. Only while
|
|
1615
|
+
// the load runs: a handler it leaves behind calls and draws as it always has.
|
|
1616
|
+
let running = true;
|
|
1617
|
+
const replaced = function () { return running && gen !== _generation; };
|
|
1610
1618
|
try {
|
|
1611
1619
|
await sec.load({
|
|
1612
|
-
runQuery,
|
|
1620
|
+
runQuery: function (s, l, q, a, p) { return runQuery(s, l, q, a, p, running ? gen : null); },
|
|
1613
1621
|
formatCurrency,
|
|
1614
1622
|
formatPercent,
|
|
1615
1623
|
formatInteger: fmtInt,
|
|
1616
1624
|
formatDate: fmtDate,
|
|
1617
1625
|
formatDatetime: fmtDatetime,
|
|
1618
|
-
renderTable: function (c, r, o) { return renderTable(c, r, o, ctx); },
|
|
1619
|
-
renderKpiCard: function (c, i) { return renderKpiCard(c, i, ctx); },
|
|
1620
|
-
renderKpiStrip: function (c, i, o) { return renderKpiStrip(c, i, o, ctx); },
|
|
1621
|
-
renderInfoGrid: function (c, i, o) { return renderInfoGrid(c, i, o, ctx); },
|
|
1622
|
-
renderTotalsStrip: function (c, i, o) { return renderTotalsStrip(c, i, o, ctx); },
|
|
1626
|
+
renderTable: function (c, r, o) { if (!replaced()) return renderTable(c, r, o, ctx); },
|
|
1627
|
+
renderKpiCard: function (c, i) { if (!replaced()) return renderKpiCard(c, i, ctx); },
|
|
1628
|
+
renderKpiStrip: function (c, i, o) { if (!replaced()) return renderKpiStrip(c, i, o, ctx); },
|
|
1629
|
+
renderInfoGrid: function (c, i, o) { if (!replaced()) return renderInfoGrid(c, i, o, ctx); },
|
|
1630
|
+
renderTotalsStrip: function (c, i, o) { if (!replaced()) return renderTotalsStrip(c, i, o, ctx); },
|
|
1623
1631
|
escHtml: esc,
|
|
1624
1632
|
colorClass,
|
|
1625
1633
|
filters: DashboardKit.filters,
|
|
1626
1634
|
});
|
|
1635
|
+
running = false;
|
|
1627
1636
|
if (gen !== _generation) return;
|
|
1628
1637
|
sec.loaded = true;
|
|
1629
1638
|
sec.errors = _sectionErrors[sec.id] || 0;
|
|
1630
1639
|
} catch (e) {
|
|
1640
|
+
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;
|
|
1631
1643
|
// The real exception, stack and dkCall included — the panel and the report only get a phrase.
|
|
1632
1644
|
console.error('[DashboardKit] section "' + sec.id + '" failed:', e);
|
|
1633
1645
|
console.log('[DashboardKit] section "' + sec.id + '" failed:', e);
|
|
@@ -1698,8 +1710,29 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1698
1710
|
}
|
|
1699
1711
|
|
|
1700
1712
|
// ── runQuery ──────────────────────────────────────────────────────────────────
|
|
1713
|
+
// A load that Refresh or new host params replaced must not draw: its rows are for the old period or
|
|
1714
|
+
// 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 never returns: it is aborted and throws this, which the
|
|
1716
|
+
// kit drops. A query no running load made — a handler's — is left as it always was: replacing
|
|
1717
|
+
// its section's load never touched it, so it must not start failing now (README → Rules).
|
|
1718
|
+
function _superseded() {
|
|
1719
|
+
const err = new Error('superseded by a newer load');
|
|
1720
|
+
err.dkSuperseded = true;
|
|
1721
|
+
return err;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1701
1724
|
// One retry, only where _isRetryable says the same request may succeed.
|
|
1702
|
-
|
|
1725
|
+
// _gen: the generation of the running load() that handed this runQuery over, or null when that
|
|
1726
|
+
// load had finished. A call by the global name belongs to its section's load if that is running.
|
|
1727
|
+
async function runQuery(sectionId, callLabel, sql, args, params, _gen) {
|
|
1728
|
+
let gen = _gen;
|
|
1729
|
+
if (gen === undefined) {
|
|
1730
|
+
const sec = _sections.find(function (s) { return s.id === sectionId; });
|
|
1731
|
+
gen = sec && sec.pending && sec.runGen === _generation ? _generation : null;
|
|
1732
|
+
}
|
|
1733
|
+
const replaced = function () { return gen !== null && gen !== _generation; };
|
|
1734
|
+
if (replaced()) throw _superseded();
|
|
1735
|
+
const signal = gen === null ? undefined : _abort.signal;
|
|
1703
1736
|
const t0 = performance.now();
|
|
1704
1737
|
const entry = {
|
|
1705
1738
|
index: _calls.length + 1,
|
|
@@ -1730,9 +1763,11 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1730
1763
|
method: 'POST',
|
|
1731
1764
|
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + _authToken },
|
|
1732
1765
|
body: JSON.stringify(body),
|
|
1766
|
+
signal: signal,
|
|
1733
1767
|
});
|
|
1734
1768
|
entry.status = res.status;
|
|
1735
1769
|
const text = await res.text();
|
|
1770
|
+
if (replaced()) throw _superseded();
|
|
1736
1771
|
entry.bytes = text.length;
|
|
1737
1772
|
let data;
|
|
1738
1773
|
try { data = JSON.parse(text); } catch { data = { _raw: text }; }
|
|
@@ -1766,6 +1801,8 @@ html[data-dk-setup="true"] .dk-resp-toggle {
|
|
|
1766
1801
|
entry.state = 'ok';
|
|
1767
1802
|
return data.rows;
|
|
1768
1803
|
} catch (err) {
|
|
1804
|
+
// Before anything is counted: an aborted fetch is no network error, and a replaced load no failure.
|
|
1805
|
+
if (replaced()) throw _superseded();
|
|
1769
1806
|
// The failed-response throw lands here too — already built.
|
|
1770
1807
|
if (err && err.dkCall) throw err;
|
|
1771
1808
|
entry.clientMs = Math.round(performance.now() - t0);
|