@datalabz_/dashboard-kit 6.0.4 → 6.0.6

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/wrapper.css CHANGED
@@ -259,6 +259,53 @@ iframe#iframe {
259
259
  color: var(--err);
260
260
  }
261
261
 
262
+ .drill-panel {
263
+ position: fixed;
264
+ top: 52px;
265
+ right: 12px;
266
+ width: 380px;
267
+ max-height: calc(100% - 64px);
268
+ overflow: auto;
269
+ display: flex;
270
+ flex-direction: column;
271
+ gap: 8px;
272
+ padding: 10px;
273
+ background: var(--surface);
274
+ border: 1px solid var(--border);
275
+ border-radius: 6px;
276
+ font-size: 12px;
277
+ z-index: 150;
278
+ }
279
+ .drill-panel textarea {
280
+ width: 100%;
281
+ background: var(--bg);
282
+ color: var(--text);
283
+ border: 1px solid var(--border);
284
+ border-radius: 4px;
285
+ font: 11px/1.4 ui-monospace, monospace;
286
+ }
287
+ .drill-panel .btn {
288
+ align-self: flex-start;
289
+ }
290
+ .drill-err {
291
+ color: var(--err);
292
+ }
293
+ .drill-log-title {
294
+ color: var(--muted);
295
+ }
296
+ .drill-log {
297
+ margin: 0;
298
+ padding: 6px;
299
+ max-height: 260px;
300
+ overflow: auto;
301
+ background: var(--bg);
302
+ border: 1px solid var(--border);
303
+ border-radius: 4px;
304
+ font: 11px/1.4 ui-monospace, monospace;
305
+ white-space: pre-wrap;
306
+ word-break: break-all;
307
+ }
308
+
262
309
  .modal-backdrop {
263
310
  position: fixed;
264
311
  inset: 0;
package/wrapper.js CHANGED
@@ -5,6 +5,9 @@
5
5
  // No data-platform means igaming, as before. An unknown name is an error, never a guess.
6
6
  // apiBase — sign-in (the BackOffice's own API)
7
7
  // gatewayEndpoint — the SQL gateway a dashboard's queries go to, sent as `endpoint`
8
+ // dashboardsApi — where the BackOffice's dashboards live, sent so a drillthrough can open another one;
9
+ // absent = none is sent and drillthroughs stay plain text on that platform
10
+ // dashboardsPermissionKey — sent with it, as the BackOffice sends it
8
11
  // storagePrefix — localStorage key prefix, so the two keep their own sign-in on one origin
9
12
  // label — the name in the top bar, before the word "Platform", that says which BackOffice this page talks to
10
13
  const PLATFORMS = {
@@ -12,6 +15,8 @@
12
15
  label: "iGaming",
13
16
  apiBase: "https://bcproxy.draftplaza.com",
14
17
  gatewayEndpoint: "https://aidqgateway.draftplaza.com/aidq",
18
+ dashboardsApi: "https://bcproxy.draftplaza.com/dashboards",
19
+ dashboardsPermissionKey: "CUSTOM_DASHBOARDS",
15
20
  storagePrefix: "iqg.harness.",
16
21
  },
17
22
  poker: {
@@ -29,6 +34,7 @@
29
34
  const LS_TOKEN = CFG.storagePrefix + "token";
30
35
  const LS_USER = CFG.storagePrefix + "user";
31
36
  const LS_THEME = CFG.storagePrefix + "theme";
37
+ const LS_DRILL = CFG.storagePrefix + "drillPoints";
32
38
 
33
39
  // Capture srcdoc from the inline iframe before DOM rebuild.
34
40
  const _srcdoc = document.getElementById("iframe")?.getAttribute("srcdoc") || "";
@@ -77,6 +83,7 @@
77
83
  </div>
78
84
  </label>
79
85
  <button class="btn btn-sm" id="snapshotBtn">Export snapshot</button>
86
+ <button class="btn btn-sm btn-ghost" id="drillBtn">Drillthrough</button>
80
87
  </div>
81
88
  <div class="user-badge">
82
89
  <span class="name" id="userName">Not signed in</span>
@@ -115,6 +122,14 @@
115
122
  </div>
116
123
  </div>
117
124
  </div>
125
+ <aside class="drill-panel" id="drillPanel" hidden>
126
+ <label><input type="checkbox" id="drillSetup"> Setup mode</label>
127
+ <label>drillPoints (JSON) <textarea id="drillJson" rows="6" spellcheck="false" placeholder='[{"point":"t1|username","dashboardId":7,"pass":{"player_id":{"from":"row","name":"player_id"}}}]'></textarea></label>
128
+ <div class="drill-err" id="drillErr" hidden></div>
129
+ <button class="btn btn-sm" id="drillApply">Apply</button>
130
+ <div class="drill-log-title">Reported by the kit</div>
131
+ <pre class="drill-log" id="drillLog"></pre>
132
+ </aside>
118
133
  <div class="toast" id="toast"></div>`;
119
134
 
120
135
  document.getElementById("iframe").setAttribute("srcdoc", _srcdoc);
@@ -136,6 +151,8 @@
136
151
  },
137
152
  user: lsGet(LS_USER, null), token: lsGet(LS_TOKEN, ""),
138
153
  theme: lsGet(LS_THEME, "dark"), pendingUsername: null,
154
+ // Drillthrough, for trying the kit without a BackOffice: the setups typed in, and what the kit reported.
155
+ setupMode: false, drillPoints: lsGet(LS_DRILL, []), points: null, lastSetup: null,
139
156
  };
140
157
 
141
158
  function todayYmd() {
@@ -205,7 +222,7 @@
205
222
  ? { dateFromIso: dayStart(State.filters.manualFrom, tz), dateToIso: dayEnd(State.filters.manualTo, tz) }
206
223
  : (presetDates(State.filters.datePreset, tz) || { dateFromIso: dayStart(todayYmd(), tz), dateToIso: dayEnd(todayYmd(), tz) });
207
224
  const hid = State.filters.hierarchyId;
208
- return {
225
+ const msg = {
209
226
  type: "CUSTOM_DASHBOARDS_PARAMS", token: State.token, theme: State.theme,
210
227
  // The SQL gateway of this BackOffice; the kit would otherwise use its own default.
211
228
  endpoint: CFG.gatewayEndpoint,
@@ -214,12 +231,21 @@
214
231
  hierarchyId: hid == null || Number.isNaN(hid) ? null : Number(hid)
215
232
  }
216
233
  };
234
+ if (CFG.dashboardsApi) {
235
+ msg.dashboardsApi = CFG.dashboardsApi;
236
+ if (CFG.dashboardsPermissionKey) msg.dashboardsPermissionKey = CFG.dashboardsPermissionKey;
237
+ msg.drillPoints = State.drillPoints;
238
+ }
239
+ return msg;
217
240
  }
218
241
  function maybeSend() {
219
242
  if (!State.token || tokenStatus(State.token).state === "err") return;
220
243
  const f = document.getElementById("iframe");
221
244
  if (!f || f.hidden || !f.contentWindow) return;
222
- try { f.contentWindow.postMessage(buildMsg(), "*"); } catch (e) { toast(`postMessage failed: ${e?.message || e}`, true); }
245
+ try {
246
+ f.contentWindow.postMessage(buildMsg(), "*");
247
+ if (State.setupMode) f.contentWindow.postMessage({ type: "DK_SETUP_MODE", on: true }, "*");
248
+ } catch (e) { toast(`postMessage failed: ${e?.message || e}`, true); }
223
249
  }
224
250
 
225
251
  // ── Render ───────────────────────────────────────────────────────────────────
@@ -326,6 +352,36 @@
326
352
  });
327
353
  $("themeToggle").addEventListener("click", e => { const b = e.target.closest("button[data-theme]"); if (b) setTheme(b.dataset.theme); });
328
354
  $("iframe").addEventListener("load", () => maybeSend());
355
+ wireDrill();
356
+ }
357
+
358
+ // The kit reports its points (DK_POINTS) and a click on a set-up button (DK_POINT_SETUP); a real BackOffice
359
+ // would open a dialog on the latter. Here both are shown as they came, and the setups are typed in.
360
+ function renderDrillLog() {
361
+ $("drillLog").textContent = JSON.stringify({ points: State.points, lastSetup: State.lastSetup }, null, 2);
362
+ }
363
+ function wireDrill() {
364
+ const frame = () => $("iframe").contentWindow;
365
+ $("drillJson").value = JSON.stringify(State.drillPoints, null, 2);
366
+ $("drillBtn").addEventListener("click", () => { $("drillPanel").hidden = !$("drillPanel").hidden; renderDrillLog(); });
367
+ $("drillSetup").addEventListener("change", e => {
368
+ State.setupMode = e.target.checked;
369
+ frame()?.postMessage({ type: "DK_SETUP_MODE", on: State.setupMode }, "*");
370
+ });
371
+ $("drillApply").addEventListener("click", () => {
372
+ let list;
373
+ try { list = JSON.parse($("drillJson").value || "[]"); } catch (e) { $("drillErr").textContent = "Not JSON: " + e.message; $("drillErr").hidden = false; return; }
374
+ if (!Array.isArray(list)) { $("drillErr").textContent = "drillPoints must be an array"; $("drillErr").hidden = false; return; }
375
+ $("drillErr").hidden = true;
376
+ State.drillPoints = list;
377
+ lsSet(LS_DRILL, list);
378
+ frame()?.postMessage({ type: "DK_DRILL_POINTS", drillPoints: list }, "*");
379
+ });
380
+ window.addEventListener("message", e => {
381
+ if (e.source !== frame() || !e.data) return;
382
+ if (e.data.type === "DK_POINTS") { State.points = e.data.points; renderDrillLog(); }
383
+ if (e.data.type === "DK_POINT_SETUP") { State.lastSetup = e.data; renderDrillLog(); $("drillPanel").hidden = false; toast("Set up: " + e.data.point); }
384
+ });
329
385
  }
330
386
 
331
387
  function boot() {