@atolis-hq/corum 0.1.35 → 0.1.36

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.
@@ -181,9 +181,18 @@ export function computeClusterOverlay(multi, viewingRef, overlayRefs, clusterRoo
181
181
  }
182
182
  export function getGraphSummary(graph) {
183
183
  const components = new Set();
184
+ const nodesByComponent = {};
185
+ const nodesByTemplate = {};
186
+ const nodesByState = {};
187
+ const nodesByStability = {};
184
188
  for (const node of graph.nodesById.values()) {
185
- if (node.component)
189
+ if (node.component) {
186
190
  components.add(node.component);
191
+ nodesByComponent[node.component] = (nodesByComponent[node.component] ?? 0) + 1;
192
+ }
193
+ nodesByTemplate[node.template] = (nodesByTemplate[node.template] ?? 0) + 1;
194
+ nodesByState[node.state] = (nodesByState[node.state] ?? 0) + 1;
195
+ nodesByStability[node.stability] = (nodesByStability[node.stability] ?? 0) + 1;
187
196
  }
188
197
  const nodesWithEdges = new Set();
189
198
  const edgesByType = {};
@@ -207,6 +216,10 @@ export function getGraphSummary(graph) {
207
216
  return {
208
217
  nodeCount: graph.nodesById.size,
209
218
  componentCount: components.size,
219
+ nodesByComponent,
220
+ nodesByTemplate,
221
+ nodesByState,
222
+ nodesByStability,
210
223
  orphanNodeCount: Object.values(orphansByTemplate).reduce((sum, count) => sum + count, 0),
211
224
  orphansByTemplate,
212
225
  edgesByType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
package/web/app.jsx CHANGED
@@ -530,26 +530,25 @@ function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branch
530
530
  .catch(() => setBranchDiff(null));
531
531
  }, [isOnNonDefaultBranch, viewingRef, defaultBranchRef]);
532
532
 
533
- const componentCount = new Set(nodes.map(n => n.component).filter(Boolean)).size;
534
- const nodeCount = nodes.length;
535
533
  const totalEdges = stats ? Object.values(stats.edgesByType).reduce((a, b) => a + b, 0) : '…';
536
534
 
537
535
  const templateMap = new Map(templates.map(t => [t.name, t]));
538
536
 
539
- const nodesByTemplate = [...nodes.reduce((acc, node) => {
540
- acc.set(node.template, (acc.get(node.template) ?? 0) + 1);
541
- return acc;
542
- }, new Map()).entries()].sort((a, b) => b[1] - a[1]);
537
+ const nodesByTemplate = stats
538
+ ? Object.entries(stats.nodesByTemplate).sort((a, b) => b[1] - a[1])
539
+ : [];
540
+
541
+ const nodesByComponent = stats
542
+ ? Object.entries(stats.nodesByComponent).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
543
+ : [];
543
544
 
544
- const nodesByState = [...nodes.reduce((acc, node) => {
545
- acc.set(node.state, (acc.get(node.state) ?? 0) + 1);
546
- return acc;
547
- }, new Map()).entries()].sort((a, b) => b[1] - a[1]);
545
+ const nodesByState = stats
546
+ ? Object.entries(stats.nodesByState).sort((a, b) => b[1] - a[1])
547
+ : [];
548
548
 
549
- const nodesByStability = [...nodes.reduce((acc, node) => {
550
- acc.set(node.stability, (acc.get(node.stability) ?? 0) + 1);
551
- return acc;
552
- }, new Map()).entries()].sort((a, b) => b[1] - a[1]);
549
+ const nodesByStability = stats
550
+ ? Object.entries(stats.nodesByStability).sort((a, b) => b[1] - a[1])
551
+ : [];
553
552
 
554
553
  const edgeRows = stats
555
554
  ? Object.entries(stats.edgesByType).filter(([, count]) => count > 0).sort((a, b) => b[1] - a[1])
@@ -562,8 +561,8 @@ function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branch
562
561
  return (
563
562
  <div className="content">
564
563
  <div className="dashboard-hero">
565
- <HeroCard value={componentCount} label="Components" />
566
- <HeroCard value={nodeCount} label="Nodes" />
564
+ <HeroCard value={stats ? stats.componentCount : '…'} label="Components" />
565
+ <HeroCard value={stats ? stats.nodeCount : '…'} label="Nodes" />
567
566
  <HeroCard value={totalEdges} label="Edges" />
568
567
  <HeroCard value={stats ? stats.orphanNodeCount : '…'} label="Orphan Nodes" />
569
568
  </div>
@@ -584,6 +583,7 @@ function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branch
584
583
  <div className="dashboard-panel">
585
584
  <div className="card-head">Nodes by Type</div>
586
585
  <div className="card-body" style={{ padding: '12px 16px' }}>
586
+ {stats === null && <div className="label-sm">Loading…</div>}
587
587
  {nodesByTemplate.map(([name, count]) => {
588
588
  const tmpl = templateMap.get(name);
589
589
  const colour = tmpl?.ui?.colour ?? 'var(--ink-4)';
@@ -600,6 +600,19 @@ function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branch
600
600
  </div>
601
601
  </div>
602
602
 
603
+ <div className="dashboard-panel">
604
+ <div className="card-head">Nodes by Component</div>
605
+ <div className="card-body" style={{ padding: '12px 16px' }}>
606
+ {stats === null && <div className="label-sm">Loading…</div>}
607
+ {nodesByComponent.map(([name, count]) => (
608
+ <div key={name} className="stat-row">
609
+ <span className="stat-row-label">{name}</span>
610
+ <span className="stat-row-value">{count}</span>
611
+ </div>
612
+ ))}
613
+ </div>
614
+ </div>
615
+
603
616
  <div className="dashboard-panel">
604
617
  <div className="card-head">Orphan Nodes by Type</div>
605
618
  <div className="card-body" style={{ padding: '12px 16px' }}>
@@ -640,6 +653,7 @@ function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branch
640
653
  <div className="dashboard-panel">
641
654
  <div className="card-head">State & Stability</div>
642
655
  <div className="card-body" style={{ padding: '12px 16px' }}>
656
+ {stats === null && <div className="label-sm">Loading…</div>}
643
657
  {nodesByState.map(([state, count]) => (
644
658
  <div key={state} className="stat-row">
645
659
  <span className="stat-row-label"><StateTag state={state} /></span>
package/web/style.css CHANGED
@@ -1526,10 +1526,22 @@ button {
1526
1526
 
1527
1527
  .dashboard-grid {
1528
1528
  display: grid;
1529
- grid-template-columns: 1fr 1fr;
1529
+ grid-template-columns: repeat(3, minmax(260px, 1fr));
1530
1530
  gap: 16px;
1531
1531
  }
1532
1532
 
1533
+ @media (max-width: 960px) {
1534
+ .dashboard-grid {
1535
+ grid-template-columns: repeat(2, minmax(260px, 1fr));
1536
+ }
1537
+ }
1538
+
1539
+ @media (max-width: 640px) {
1540
+ .dashboard-grid {
1541
+ grid-template-columns: 1fr;
1542
+ }
1543
+ }
1544
+
1533
1545
  .dashboard-panel {
1534
1546
  overflow: hidden;
1535
1547
  border: 1px solid var(--rule-2);