@enigmax/dashboard 0.1.9 → 0.1.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.
Files changed (2) hide show
  1. package/assets/index.html +43 -15
  2. package/package.json +1 -1
package/assets/index.html CHANGED
@@ -306,6 +306,9 @@
306
306
  <div>Projected <b id="uBlockProj">-</b></div>
307
307
  </div>
308
308
  </div>
309
+ <div id="uProviders" class="sub" style="margin:4px 0 0"></div>
310
+ <h2 style="margin:18px 0 10px">By Account <small>per Claude login</small></h2>
311
+ <div id="uByAccount"></div>
309
312
  <h2 style="margin:18px 0 10px">By Model</h2>
310
313
  <div id="uByModel"></div>
311
314
  <h2 style="margin:18px 0 10px">By Project</h2>
@@ -542,21 +545,36 @@
542
545
  const reset = w.kind === "session"
543
546
  ? (w.resetsAt ? "Resets " + fmtResetIn(w.resetsAt) : "No active session")
544
547
  : (w.resetsAt ? fmtResetAt(w.resetsAt) : "");
545
- let body;
546
- if (sub === "weeklySonnet" && (w.used || 0) === 0) {
547
- body = '<div class="wval muted">You haven\'t used Sonnet yet</div>';
548
- } else if (w.pct != null) {
549
- const p = Math.round(w.pct);
550
- const col = w.pct >= 90 ? "var(--accent2)" : "var(--accent)";
551
- body = '<div class="wval">' + p + '% used</div>'
552
- + '<div class="bar-track" style="margin-top:8px"><div class="bar-fill" style="width:' + Math.min(100, w.pct) + '%;background:' + col + '"></div></div>';
548
+ const live = w.live ? ' <span class="tag meas">live</span>' : "";
549
+ const span = w.kind === "session" ? 5 * 3600000 : 7 * 86400000;
550
+ const head = '<div class="wcard"><div class="wtitle">' + esc(w.label) + live + '</div><div class="wreset">' + esc(reset) + '</div>';
551
+ if (sub === "weeklySonnet" && (w.used || 0) === 0 && w.pct == null) {
552
+ return head + '<div class="wval muted">You haven\'t used Sonnet yet</div></div>';
553
+ }
554
+ // Every card shows a bar: the real usage % when known (live or vs a set limit),
555
+ // otherwise how much of the window has elapsed in time - so the weekly card has a
556
+ // bar even before the proxy has captured live limits.
557
+ let barPct, barCol, barNote, valLine;
558
+ if (w.pct != null) {
559
+ barPct = Math.min(100, w.pct);
560
+ barCol = w.pct >= 90 ? "var(--accent2)" : "var(--accent)";
561
+ barNote = (w.live ? "live · " : "") + fmt(w.used || 0) + " tok";
562
+ valLine = Math.round(w.pct) + "% used";
563
+ } else if (w.resetsAt) {
564
+ const start = w.resetsAt - span;
565
+ barPct = Math.max(0, Math.min(100, (Date.now() - start) / span * 100));
566
+ barCol = "var(--muted)";
567
+ barNote = "window " + Math.round(barPct) + "% elapsed";
568
+ valLine = fmt(w.used || 0) + " tok";
553
569
  } else {
554
- body = '<div class="wval">' + fmt(w.used || 0) + ' tok</div>'
555
- + '<div class="wset"><input type="number" min="0" class="wlimit" data-plan="' + sub + '" placeholder="set limit (tokens)">'
556
- + '<button type="button" class="laddb" data-plan="' + sub + '">Set</button></div>';
570
+ barPct = 0; barCol = "var(--muted)"; barNote = ""; valLine = fmt(w.used || 0) + " tok";
557
571
  }
558
- const live = w.live ? ' <span class="tag meas">live</span>' : "";
559
- return '<div class="wcard"><div class="wtitle">' + esc(w.label) + live + '</div><div class="wreset">' + esc(reset) + '</div>' + body + '</div>';
572
+ const bar = '<div class="bar-track" style="margin-top:8px"><div class="bar-fill" style="width:' + barPct + '%;background:' + barCol + '"></div></div>'
573
+ + (barNote ? '<div class="wreset" style="margin-top:4px">' + esc(barNote) + "</div>" : "");
574
+ const setter = w.pct == null
575
+ ? '<div class="wset"><input type="number" min="0" class="wlimit" data-plan="' + sub + '" placeholder="set limit for %"><button type="button" class="laddb" data-plan="' + sub + '">Set</button></div>'
576
+ : "";
577
+ return head + '<div class="wval">' + valLine + "</div>" + bar + setter + "</div>";
560
578
  }
561
579
  function renderWindows(u) {
562
580
  const w = u && u.windows;
@@ -599,12 +617,20 @@
599
617
  function renderRecentSessions(el, rows, pending) {
600
618
  rows = rows || [];
601
619
  if (!rows.length) { el.innerHTML = '<div class="empty" style="padding:16px 0">' + (pending ? "Scanning..." : "No sessions yet.") + "</div>"; return; }
602
- el.innerHTML = '<table class="tbl"><thead><tr><th>Last active</th><th>Project</th><th>Model</th><th class="r">Input</th><th class="r">Output</th><th class="r">Cost</th></tr></thead><tbody>'
603
- + rows.map((s) => '<tr><td>' + (s.lastActive ? new Date(s.lastActive).toLocaleString() : "-") + '</td><td>' + esc(shortProject(s.project)) + '</td><td>' + esc(s.model || "-")
620
+ el.innerHTML = '<table class="tbl"><thead><tr><th>Last active</th><th>Account</th><th>Project</th><th>Model</th><th class="r">Input</th><th class="r">Output</th><th class="r">Cost</th></tr></thead><tbody>'
621
+ + rows.map((s) => '<tr><td>' + (s.lastActive ? new Date(s.lastActive).toLocaleString() : "-") + '</td><td>' + esc(s.account || "default") + '</td><td>' + esc(shortProject(s.project)) + '</td><td>' + esc(s.model || "-")
604
622
  + '</td><td class="r">' + fmt(s.input) + '</td><td class="r">' + fmt(s.output) + '</td><td class="r">' + fmtUsd(s.cost || 0) + "</td></tr>").join("")
605
623
  + "</tbody></table>";
606
624
  }
607
625
 
626
+ function renderProviders(list) {
627
+ list = list || [];
628
+ const el = $("uProviders");
629
+ if (!list.length) { el.innerHTML = ""; return; }
630
+ el.innerHTML = "Providers: " + list.map((p) =>
631
+ '<span class="tag ' + (p.available ? "meas" : "") + '">' + esc(p.label) + (p.available ? "" : " - " + esc(p.note)) + "</span>").join("");
632
+ }
633
+
608
634
  function renderUsage(u) {
609
635
  const panel = $("usagePanel"), hint = $("usageHint");
610
636
  if (!u) { panel.style.display = "none"; hint.style.display = "block"; return; }
@@ -633,6 +659,8 @@
633
659
  $("uBlockBurn").textContent = fmt(Math.round(b.burnRatePerMin || 0)) + " tok/min";
634
660
  $("uBlockProj").textContent = fmt(b.projectedTokens || 0) + " · " + fmtUsd(b.projectedCost || 0);
635
661
  } else { bw.style.display = "none"; }
662
+ renderProviders(u.providers);
663
+ renderUsageTable($("uByAccount"), u.byAccount, u.pending, "Account");
636
664
  renderUsageTable($("uByModel"), u.byModel, u.pending, "Model");
637
665
  renderUsageTable($("uByProject"), u.byProject, u.pending, "Project");
638
666
  renderRecentSessions($("uRecent"), u.recentSessions, u.pending);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enigmax/dashboard",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Local browser dashboard UI for enigma: the static page and chart assets enigma serves on its loopback dashboard (savings, real tool usage, in-browser settings). Installed on demand by enigma-cli; not a runtime dependency.",
5
5
  "type": "module",
6
6
  "files": [