@yaks/visualize 0.0.0-stage → 0.2.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.
- package/ActivityView.tsx +370 -0
- package/AnatomyList.tsx +183 -0
- package/Atlas.tsx +490 -0
- package/Detail.tsx +464 -0
- package/LICENSE +202 -0
- package/README.md +180 -2
- package/SectionHead.tsx +18 -0
- package/Topology.tsx +596 -0
- package/_dist/activity.d.ts +15 -0
- package/_dist/activity.d.ts.map +1 -0
- package/_dist/capture.d.ts +19 -0
- package/_dist/capture.d.ts.map +1 -0
- package/_dist/cli.d.ts +6 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/front.d.ts +6 -0
- package/_dist/front.d.ts.map +1 -0
- package/_dist/http.d.ts +21 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/main.d.ts +2 -0
- package/_dist/main.d.ts.map +1 -0
- package/_dist/mod.d.ts +6 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/model.d.ts +55 -0
- package/_dist/model.d.ts.map +1 -0
- package/_dist/parts.d.ts +19 -0
- package/_dist/parts.d.ts.map +1 -0
- package/_dist/routes.d.ts +7 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/snapshot.d.ts +38 -0
- package/_dist/snapshot.d.ts.map +1 -0
- package/_dist/stream.d.ts +3 -0
- package/_dist/stream.d.ts.map +1 -0
- package/_dist/tools.d.ts +10 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/vocab.d.ts +5 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/activity.js +73 -0
- package/activity.js.map +1 -0
- package/activity.ts +104 -0
- package/capture.js +46 -0
- package/capture.js.map +1 -0
- package/capture.ts +68 -0
- package/cli.js +173 -0
- package/cli.js.map +1 -0
- package/cli.ts +200 -0
- package/deno.json +1 -0
- package/front.js +21 -0
- package/front.js.map +1 -0
- package/front.json +210 -0
- package/front.ts +22 -0
- package/http.js +290 -0
- package/http.js.map +1 -0
- package/http.ts +338 -0
- package/main.js +51 -0
- package/main.js.map +1 -0
- package/main.ts +50 -0
- package/mod.js +6 -0
- package/mod.js.map +1 -0
- package/mod.ts +15 -0
- package/model.js +551 -0
- package/model.js.map +1 -0
- package/model.ts +543 -0
- package/package.json +76 -4
- package/parts.js +70 -0
- package/parts.js.map +1 -0
- package/parts.ts +113 -0
- package/routes.js +53 -0
- package/routes.js.map +1 -0
- package/routes.ts +76 -0
- package/snapshot.js +117 -0
- package/snapshot.js.map +1 -0
- package/snapshot.ts +157 -0
- package/stream.js +73 -0
- package/stream.js.map +1 -0
- package/stream.ts +95 -0
- package/tools.js +64 -0
- package/tools.js.map +1 -0
- package/tools.ts +79 -0
- package/visualize.css +1787 -0
- package/vocab.js +13 -0
- package/vocab.js.map +1 -0
- package/vocab.json +97 -0
- package/vocab.ts +14 -0
package/ActivityView.tsx
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
/** One bounded trace stream, presented as spans. Begin/end records share an
|
|
3
|
+
* identity; a selected cause is that span identity, never a graph row id.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { SectionHead } from './SectionHead.tsx'
|
|
7
|
+
import { Button, Chip, Timeline } from 'jsr:@yaks/ui@0.2.36'
|
|
8
|
+
import type { Activity, AtlasModel } from './model.ts'
|
|
9
|
+
import { elapsed } from './Topology.tsx'
|
|
10
|
+
|
|
11
|
+
// The model clears history and cause on epoch change, so these span IDs
|
|
12
|
+
// are compared only within one retained recording. Offsets never use a clock.
|
|
13
|
+
export let spanEvents = (events: readonly Activity[]) => {
|
|
14
|
+
let spans = new Map<string, { event: Activity; at: number }>()
|
|
15
|
+
events.forEach((event, at) => spans.set(event.id, { event, at }))
|
|
16
|
+
return [...spans.values()].sort((a, b) => b.at - a.at)
|
|
17
|
+
.map(({ event }) => event)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let tones: Record<string, string> = {
|
|
21
|
+
apply: 'accent',
|
|
22
|
+
phase: 'active',
|
|
23
|
+
rule: 'active',
|
|
24
|
+
effect: 'special',
|
|
25
|
+
query: 'info',
|
|
26
|
+
get: 'info',
|
|
27
|
+
request: 'link',
|
|
28
|
+
fanout: 'positive',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let offset = (event: Activity, latest: number) => {
|
|
32
|
+
let difference = Math.max(0, latest - event.time)
|
|
33
|
+
if (!difference) return 'latest'
|
|
34
|
+
return difference < 1000
|
|
35
|
+
? `−${difference.toFixed(0)} ms`
|
|
36
|
+
: `−${(difference / 1000).toFixed(1)} s`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let outcome = (event: Activity) =>
|
|
40
|
+
event.outcome ??
|
|
41
|
+
(event.stage == 'start' ? 'in flight' : 'observed')
|
|
42
|
+
|
|
43
|
+
let Counts = ({ event }: { event: Activity }) => {
|
|
44
|
+
let values = Object.entries(event.counts ?? {}).filter(([, count]) =>
|
|
45
|
+
typeof count == 'number' && Number.isFinite(count)
|
|
46
|
+
)
|
|
47
|
+
return values.length
|
|
48
|
+
? (
|
|
49
|
+
<dl className='Activity_Counts Atlas_Reset'>
|
|
50
|
+
{values.slice(0, 12).map(([name, count]) => (
|
|
51
|
+
<div className='Activity_Counts_Row' key={name}>
|
|
52
|
+
<dt className='Activity_Counts_Term'>{name}</dt>
|
|
53
|
+
<dd className='Activity_Counts_Value'>{count}</dd>
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
{values.length > 12 && (
|
|
57
|
+
<div className='Activity_Counts_Row'>
|
|
58
|
+
<dt className='Activity_Counts_Term'>additional counters</dt>
|
|
59
|
+
<dd className='Activity_Counts_Value'>{values.length - 12}</dd>
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
</dl>
|
|
63
|
+
)
|
|
64
|
+
: null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let depthOf = (event: Activity, events: Activity[]) => {
|
|
68
|
+
let byId = new Map(events.map((event) => [event.id, event]))
|
|
69
|
+
let seen = new Set([event.id])
|
|
70
|
+
let depth = 0, parent = event.parent
|
|
71
|
+
while (parent && byId.has(parent) && !seen.has(parent) && depth < 12) {
|
|
72
|
+
seen.add(parent)
|
|
73
|
+
depth++
|
|
74
|
+
parent = byId.get(parent)?.parent
|
|
75
|
+
}
|
|
76
|
+
return depth
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A missing parent is outside the retained window, not evidence of no cause. */
|
|
80
|
+
let Cause = ({ model }: { model: AtlasModel }) => {
|
|
81
|
+
let related = spanEvents(model.cause).reverse()
|
|
82
|
+
let events = spanEvents(model.events)
|
|
83
|
+
let selected = events.find((event) => event.id == model.state.cause) ??
|
|
84
|
+
related.find((event) => event.id == model.state.cause)
|
|
85
|
+
let parent = selected?.parent
|
|
86
|
+
? events.find((event) => event.id == selected.parent)
|
|
87
|
+
: undefined
|
|
88
|
+
let known = new Set(related.map((event) => event.id))
|
|
89
|
+
let clipped = related.some((event) =>
|
|
90
|
+
event.parent && !known.has(event.parent)
|
|
91
|
+
)
|
|
92
|
+
return (
|
|
93
|
+
<section
|
|
94
|
+
className='Cause Atlas_Focusable'
|
|
95
|
+
id='atlas-cause'
|
|
96
|
+
tabIndex={-1}
|
|
97
|
+
aria-label='Selected causal path'
|
|
98
|
+
>
|
|
99
|
+
<SectionHead
|
|
100
|
+
eyebrow='Causality'
|
|
101
|
+
title='Follow the work'
|
|
102
|
+
actions={model.state.cause && (
|
|
103
|
+
<Button
|
|
104
|
+
className='Atlas_Button'
|
|
105
|
+
type='button'
|
|
106
|
+
mod='quiet'
|
|
107
|
+
aria-label='Clear selected cause'
|
|
108
|
+
onClick={() => model.choose('')}
|
|
109
|
+
>
|
|
110
|
+
×
|
|
111
|
+
</Button>
|
|
112
|
+
)}
|
|
113
|
+
/>
|
|
114
|
+
{!selected
|
|
115
|
+
? (
|
|
116
|
+
<div className='Cause_Empty'>
|
|
117
|
+
<span className='Cause_EmptyMark' aria-hidden='true'>↳</span>
|
|
118
|
+
<h3 className='Atlas_Reset Cause_Empty_Title'>
|
|
119
|
+
{model.state.cause
|
|
120
|
+
? 'Outside the retained window'
|
|
121
|
+
: 'What caused this?'}
|
|
122
|
+
</h3>
|
|
123
|
+
<p className='Atlas_Reset Cause_Empty_Description'>
|
|
124
|
+
{model.state.cause
|
|
125
|
+
? 'The selected span is no longer retained. Choose another observation.'
|
|
126
|
+
: 'Choose an observation to reveal its ancestors and descendants. No activity is invented when the process is quiet.'}
|
|
127
|
+
</p>
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
130
|
+
: (
|
|
131
|
+
<div className='Cause_Body'>
|
|
132
|
+
<div className='Cause_Identity' data-outcome={selected.outcome}>
|
|
133
|
+
<div className='Cause_Tokens'>
|
|
134
|
+
<Chip className='Cause_Tokens_Text'>{selected.kind}</Chip>
|
|
135
|
+
<span className='Cause_Tokens_Text'>{outcome(selected)}</span>
|
|
136
|
+
</div>
|
|
137
|
+
<h3 className='Atlas_Reset Cause_Identity_Title'>
|
|
138
|
+
{selected.name}
|
|
139
|
+
</h3>
|
|
140
|
+
<div className='Cause_Measure'>
|
|
141
|
+
<strong className='Cause_Measure_Strong'>
|
|
142
|
+
{elapsed(selected)}
|
|
143
|
+
</strong>
|
|
144
|
+
<span className='Cause_Measure_Text'>
|
|
145
|
+
{selected.stage == 'start'
|
|
146
|
+
? 'unfinished span'
|
|
147
|
+
: selected.duration == undefined
|
|
148
|
+
? 'instant observation'
|
|
149
|
+
: 'observed duration'}
|
|
150
|
+
</span>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
{(selected.package || selected.plugin) && (
|
|
154
|
+
<dl className='Cause_Provenance Atlas_Reset'>
|
|
155
|
+
{selected.package && (
|
|
156
|
+
<div className='Cause_Provenance_Row'>
|
|
157
|
+
<dt className='Cause_Provenance_Term'>Package</dt>
|
|
158
|
+
<dd className='Cause_Provenance_Value'>
|
|
159
|
+
{selected.package}
|
|
160
|
+
</dd>
|
|
161
|
+
</div>
|
|
162
|
+
)}
|
|
163
|
+
{selected.plugin && (
|
|
164
|
+
<div className='Cause_Provenance_Row'>
|
|
165
|
+
<dt className='Cause_Provenance_Term'>Plugin</dt>
|
|
166
|
+
<dd className='Cause_Provenance_Value'>
|
|
167
|
+
{selected.plugin}
|
|
168
|
+
</dd>
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
</dl>
|
|
172
|
+
)}
|
|
173
|
+
<Counts event={selected} />
|
|
174
|
+
<p className='Cause_ClockNote Atlas_Reset'>
|
|
175
|
+
A recorded 0 ms is valid. Some runtime clocks advance only with
|
|
176
|
+
I/O; counts carry information too.
|
|
177
|
+
</p>
|
|
178
|
+
<div className='Cause_Actions'>
|
|
179
|
+
{selected.node && (
|
|
180
|
+
<Button
|
|
181
|
+
className='Atlas_Button'
|
|
182
|
+
type='button'
|
|
183
|
+
onClick={() => model.select(selected.node!)}
|
|
184
|
+
>
|
|
185
|
+
Locate part ↗
|
|
186
|
+
</Button>
|
|
187
|
+
)}
|
|
188
|
+
{parent && (
|
|
189
|
+
<Button
|
|
190
|
+
className='Atlas_Button'
|
|
191
|
+
type='button'
|
|
192
|
+
mod='quiet'
|
|
193
|
+
onClick={() => model.choose(parent.id)}
|
|
194
|
+
>
|
|
195
|
+
Parent span ↑
|
|
196
|
+
</Button>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
<div className='Cause_PathHead'>
|
|
200
|
+
<h3 className='Atlas_Reset Cause_PathHead_Title'>Causal path</h3>
|
|
201
|
+
<span className='Cause_PathHead_Text'>
|
|
202
|
+
{related.length} retained spans
|
|
203
|
+
</span>
|
|
204
|
+
</div>
|
|
205
|
+
<ol className='Cause_Path Atlas_Reset'>
|
|
206
|
+
{related.map((event) => (
|
|
207
|
+
<li
|
|
208
|
+
className='Cause_Path_Item'
|
|
209
|
+
key={`${event.epoch}:${event.id}`}
|
|
210
|
+
style={{ '--depth': Math.min(5, depthOf(event, related)) }}
|
|
211
|
+
>
|
|
212
|
+
<Button
|
|
213
|
+
type='button'
|
|
214
|
+
className='Cause_Span'
|
|
215
|
+
mod='quiet'
|
|
216
|
+
data-selected={event.id == selected.id}
|
|
217
|
+
data-outcome={event.outcome}
|
|
218
|
+
onClick={() => model.choose(event.id)}
|
|
219
|
+
>
|
|
220
|
+
<span className='Cause_Branch' aria-hidden='true'>↳</span>
|
|
221
|
+
<span className='Cause_SpanName'>
|
|
222
|
+
<small className='Cause_SpanName_Note'>
|
|
223
|
+
{event.kind}
|
|
224
|
+
</small>
|
|
225
|
+
{event.name}
|
|
226
|
+
</span>
|
|
227
|
+
<span className='Cause_SpanTime'>{elapsed(event)}</span>
|
|
228
|
+
</Button>
|
|
229
|
+
</li>
|
|
230
|
+
))}
|
|
231
|
+
</ol>
|
|
232
|
+
{(clipped || selected.parent && !parent) && (
|
|
233
|
+
<p className='Cause_Notice Atlas_Reset'>
|
|
234
|
+
An ancestor is outside this process's retained window. This is
|
|
235
|
+
not a complete distributed trace.
|
|
236
|
+
</p>
|
|
237
|
+
)}
|
|
238
|
+
<details className='Cause_Identifiers'>
|
|
239
|
+
<summary className='Atlas_Summary Cause_Identifiers_Summary'>
|
|
240
|
+
Span identifier
|
|
241
|
+
</summary>
|
|
242
|
+
<code className='Cause_Identifiers_Code'>{selected.id}</code>
|
|
243
|
+
</details>
|
|
244
|
+
</div>
|
|
245
|
+
)}
|
|
246
|
+
</section>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Newest first, without a ticking clock or auto-scroll that steals focus. */
|
|
251
|
+
export let ActivityView = ({ model }: { model: AtlasModel }) => {
|
|
252
|
+
let events = spanEvents(model.events)
|
|
253
|
+
let latest = model.events.at(-1)?.time ?? 0
|
|
254
|
+
let failed =
|
|
255
|
+
events.filter((event) =>
|
|
256
|
+
['error', 'refused', 'interrupted'].includes(event.outcome ?? '')
|
|
257
|
+
).length
|
|
258
|
+
return (
|
|
259
|
+
<section className='Activity' aria-label='Process activity and causality'>
|
|
260
|
+
<div className='Activity_Stream'>
|
|
261
|
+
<SectionHead
|
|
262
|
+
eyebrow='Live flow'
|
|
263
|
+
title='Process activity'
|
|
264
|
+
actions={
|
|
265
|
+
<div className='Activity_Summary'>
|
|
266
|
+
<span>
|
|
267
|
+
{events.length} spans · {model.events.length}/256 records
|
|
268
|
+
</span>
|
|
269
|
+
{failed > 0 && (
|
|
270
|
+
<span className='Activity_Failed'>{failed} non-ok</span>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
}
|
|
274
|
+
/>
|
|
275
|
+
<div className='Activity_Guide'>
|
|
276
|
+
<span>Newest first · offsets from latest record</span>
|
|
277
|
+
<span>
|
|
278
|
+
{model.state.paused ? 'Recording paused' : 'Subscriber-only'}
|
|
279
|
+
</span>
|
|
280
|
+
</div>
|
|
281
|
+
{!events.length
|
|
282
|
+
? (
|
|
283
|
+
<div className='Activity_Empty'>
|
|
284
|
+
<svg
|
|
285
|
+
className='Activity_Empty_Icon'
|
|
286
|
+
viewBox='0 0 220 58'
|
|
287
|
+
aria-hidden='true'
|
|
288
|
+
>
|
|
289
|
+
<path d='M0 29h60l12-8 14 16 14-32 14 48 14-24h92' />
|
|
290
|
+
</svg>
|
|
291
|
+
<h3 className='Atlas_Reset Activity_Empty_Title'>
|
|
292
|
+
{model.state.connected == 'live'
|
|
293
|
+
? 'Quiet is a real signal.'
|
|
294
|
+
: 'Waiting for the process.'}
|
|
295
|
+
</h3>
|
|
296
|
+
<p className='Atlas_Reset Activity_Empty_Description'>
|
|
297
|
+
{model.state.connected == 'live'
|
|
298
|
+
? 'No activity observed in this subscriber window. Anatomy is still available; execute real work to see a causal path.'
|
|
299
|
+
: 'Anatomy and activity come from the connected host. No sample traffic, timings or synthetic pulses are shown.'}
|
|
300
|
+
</p>
|
|
301
|
+
</div>
|
|
302
|
+
)
|
|
303
|
+
: (
|
|
304
|
+
<div
|
|
305
|
+
className='Activity_Window Atlas_Focusable'
|
|
306
|
+
tabIndex={0}
|
|
307
|
+
aria-label='Retained activity, scroll for older spans'
|
|
308
|
+
>
|
|
309
|
+
<Timeline className='Activity_Timeline Atlas_Reset'>
|
|
310
|
+
{events.map((event) => (
|
|
311
|
+
<Timeline.Item
|
|
312
|
+
key={`${event.epoch}:${event.id}`}
|
|
313
|
+
className='Activity_Item'
|
|
314
|
+
data-selected={model.state.cause == event.id}
|
|
315
|
+
data-outcome={event.outcome}
|
|
316
|
+
style={{
|
|
317
|
+
'--event': `var(--${tones[event.kind] ?? 'muted'})`,
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
320
|
+
<Button
|
|
321
|
+
type='button'
|
|
322
|
+
className='Activity_Row'
|
|
323
|
+
mod='quiet'
|
|
324
|
+
aria-pressed={model.state.cause == event.id}
|
|
325
|
+
aria-label={`${event.kind}: ${event.name}, ${
|
|
326
|
+
outcome(event)
|
|
327
|
+
}, ${elapsed(event)}`}
|
|
328
|
+
onClick={() => {
|
|
329
|
+
model.choose(event.id)
|
|
330
|
+
if (event.node) model.select(event.node)
|
|
331
|
+
}}
|
|
332
|
+
>
|
|
333
|
+
<span className='Activity_Dot' aria-hidden='true' />
|
|
334
|
+
<div className='Activity_RowText'>
|
|
335
|
+
<div className='Activity_RowMeta'>
|
|
336
|
+
<Timeline.When className='Activity_When'>
|
|
337
|
+
{offset(event, latest)}
|
|
338
|
+
</Timeline.When>
|
|
339
|
+
<Timeline.Who className='Activity_Kind'>
|
|
340
|
+
{event.kind}
|
|
341
|
+
</Timeline.Who>
|
|
342
|
+
<span className='Activity_Outcome'>
|
|
343
|
+
{outcome(event)}
|
|
344
|
+
</span>
|
|
345
|
+
</div>
|
|
346
|
+
<Timeline.What className='Activity_Name'>
|
|
347
|
+
{event.name}
|
|
348
|
+
</Timeline.What>
|
|
349
|
+
</div>
|
|
350
|
+
<span className='Activity_Duration'>
|
|
351
|
+
{elapsed(event)}
|
|
352
|
+
</span>
|
|
353
|
+
<span className='Activity_Arrow' aria-hidden='true'>
|
|
354
|
+
↗
|
|
355
|
+
</span>
|
|
356
|
+
</Button>
|
|
357
|
+
</Timeline.Item>
|
|
358
|
+
))}
|
|
359
|
+
</Timeline>
|
|
360
|
+
</div>
|
|
361
|
+
)}
|
|
362
|
+
<footer className='Activity_Footer'>
|
|
363
|
+
Bounded to 256 records in this page. Start/end records share one span.
|
|
364
|
+
Gaps and omitted history are not reconstructed.
|
|
365
|
+
</footer>
|
|
366
|
+
</div>
|
|
367
|
+
<Cause model={model} />
|
|
368
|
+
</section>
|
|
369
|
+
)
|
|
370
|
+
}
|
package/AnatomyList.tsx
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
/** The complete anatomy remains reachable without an unbounded DOM. Paging,
|
|
3
|
+
* filters and selection are graph-owned; the map's caps never cap the list.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { SectionHead } from './SectionHead.tsx'
|
|
7
|
+
import { Button, Chip, Tile } from 'jsr:@yaks/ui@0.2.36'
|
|
8
|
+
import type { AtlasModel } from './model.ts'
|
|
9
|
+
import { colorOf, filtered, groupName, statusOf } from './Topology.tsx'
|
|
10
|
+
|
|
11
|
+
export let PAGE_SIZE = 64
|
|
12
|
+
|
|
13
|
+
export let matchingEdges = (model: AtlasModel) => {
|
|
14
|
+
let text = model.state.filter.trim().toLocaleLowerCase()
|
|
15
|
+
let names = new Map(model.nodes.map((node) => [node.id, node.name]))
|
|
16
|
+
return model.edges.filter((edge) =>
|
|
17
|
+
!text ||
|
|
18
|
+
[edge.kind, names.get(edge.from), names.get(edge.to)].join(' ')
|
|
19
|
+
.toLocaleLowerCase().includes(text)
|
|
20
|
+
)
|
|
21
|
+
.sort((a, b) => a.kind.localeCompare(b.kind) || a.id.localeCompare(b.id))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export let AnatomyList = ({ model }: { model: AtlasModel }) => {
|
|
25
|
+
let relations = model.state.group == 'relations'
|
|
26
|
+
let unobserved = model.coverage[model.state.group] === false
|
|
27
|
+
let nodes = relations ? [] : filtered(model)
|
|
28
|
+
let edges = relations ? matchingEdges(model) : []
|
|
29
|
+
let total = relations ? edges.length : nodes.length
|
|
30
|
+
let lastPage = Math.max(0, Math.ceil(total / PAGE_SIZE) - 1)
|
|
31
|
+
let page = Math.min(lastPage, Math.max(0, model.state.listPage))
|
|
32
|
+
let start = page * PAGE_SIZE
|
|
33
|
+
let names = new Map(model.nodes.map((node) => [node.id, node.name]))
|
|
34
|
+
return (
|
|
35
|
+
<section className='AnatomyList' aria-label='Complete anatomy list'>
|
|
36
|
+
<SectionHead
|
|
37
|
+
eyebrow='Complete anatomy'
|
|
38
|
+
title={relations ? 'Every declared connection' : 'Every reported part'}
|
|
39
|
+
actions={
|
|
40
|
+
<span className='Map_Count'>
|
|
41
|
+
{total ? start + 1 : 0}–{Math.min(total, start + PAGE_SIZE)}
|
|
42
|
+
<span className='Map_Count_Text'>of {total}</span>
|
|
43
|
+
</span>
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
46
|
+
<div className='AnatomyList_Head' aria-hidden='true'>
|
|
47
|
+
<span>{relations ? 'From → to' : 'Name / provenance'}</span>
|
|
48
|
+
<span>{relations ? 'Relationship' : 'Group / state'}</span>
|
|
49
|
+
</div>
|
|
50
|
+
{!total
|
|
51
|
+
? (
|
|
52
|
+
<div className='AnatomyList_Empty' role='status'>
|
|
53
|
+
<h3 className='Atlas_Reset AnatomyList_Empty_Title'>
|
|
54
|
+
{unobserved
|
|
55
|
+
? 'Category unobserved here.'
|
|
56
|
+
: `No matching ${relations ? 'relationships' : 'parts'}.`}
|
|
57
|
+
</h3>
|
|
58
|
+
<p className='Atlas_Reset AnatomyList_Empty_Description'>
|
|
59
|
+
{unobserved
|
|
60
|
+
? 'This host does not report coverage for this category. No matches cannot establish absence.'
|
|
61
|
+
: 'Try a shorter filter or choose a different anatomy group.'}
|
|
62
|
+
</p>
|
|
63
|
+
{model.state.filter && (
|
|
64
|
+
<Button
|
|
65
|
+
className='Atlas_Button'
|
|
66
|
+
type='button'
|
|
67
|
+
onClick={() => {
|
|
68
|
+
model.search('')
|
|
69
|
+
model.set({ listPage: 0 })
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
Clear search
|
|
73
|
+
</Button>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
: (
|
|
78
|
+
<ul className='AnatomyList_Rows Atlas_Reset'>
|
|
79
|
+
{relations
|
|
80
|
+
? edges.slice(start, start + PAGE_SIZE).map((edge) => (
|
|
81
|
+
<li key={edge.id}>
|
|
82
|
+
<button
|
|
83
|
+
type='button'
|
|
84
|
+
className='AnatomyList_Row Atlas_Button'
|
|
85
|
+
aria-pressed={model.state.selected == edge.id}
|
|
86
|
+
onClick={() =>
|
|
87
|
+
model.select(edge.id)}
|
|
88
|
+
>
|
|
89
|
+
<Tile className='AnatomyList_Tile'>
|
|
90
|
+
<div className='AnatomyList_Name'>
|
|
91
|
+
<Tile.Title className='AnatomyList_Title'>
|
|
92
|
+
{names.get(edge.from) ?? edge.from}
|
|
93
|
+
</Tile.Title>
|
|
94
|
+
<Tile.Note className='AnatomyList_Note'>
|
|
95
|
+
→ {names.get(edge.to) ?? edge.to}
|
|
96
|
+
</Tile.Note>
|
|
97
|
+
</div>
|
|
98
|
+
<Tile.Count className='AnatomyList_Kind'>
|
|
99
|
+
<Chip>{edge.kind}</Chip>
|
|
100
|
+
</Tile.Count>
|
|
101
|
+
</Tile>
|
|
102
|
+
</button>
|
|
103
|
+
</li>
|
|
104
|
+
))
|
|
105
|
+
: nodes.slice(start, start + PAGE_SIZE).map((node) => (
|
|
106
|
+
<li key={node.id}>
|
|
107
|
+
<button
|
|
108
|
+
type='button'
|
|
109
|
+
className='AnatomyList_Row Atlas_Button'
|
|
110
|
+
aria-pressed={model.state.selected == node.id}
|
|
111
|
+
style={{ '--part': `var(--${colorOf(node)})` }}
|
|
112
|
+
onClick={() =>
|
|
113
|
+
model.select(node.id)}
|
|
114
|
+
>
|
|
115
|
+
<Tile className='AnatomyList_Tile'>
|
|
116
|
+
<i
|
|
117
|
+
className='AnatomyList_Mark'
|
|
118
|
+
aria-hidden='true'
|
|
119
|
+
data-bound={node.bound}
|
|
120
|
+
/>
|
|
121
|
+
<div className='AnatomyList_Name'>
|
|
122
|
+
<Tile.Title className='AnatomyList_Title'>
|
|
123
|
+
{node.name}
|
|
124
|
+
</Tile.Title>
|
|
125
|
+
<Tile.Note className='AnatomyList_Note'>
|
|
126
|
+
{node.package ?? node.facet ?? 'Composition metadata'}
|
|
127
|
+
</Tile.Note>
|
|
128
|
+
</div>
|
|
129
|
+
<div className='AnatomyList_State'>
|
|
130
|
+
<Tile.Kind className='AnatomyList_Kind'>
|
|
131
|
+
{groupName(node.group)}
|
|
132
|
+
</Tile.Kind>
|
|
133
|
+
<Chip
|
|
134
|
+
mod={statusOf(node) == 'unattempted'
|
|
135
|
+
? 'ghost'
|
|
136
|
+
: undefined}
|
|
137
|
+
>
|
|
138
|
+
{statusOf(node)}
|
|
139
|
+
</Chip>
|
|
140
|
+
</div>
|
|
141
|
+
</Tile>
|
|
142
|
+
</button>
|
|
143
|
+
</li>
|
|
144
|
+
))}
|
|
145
|
+
</ul>
|
|
146
|
+
)}
|
|
147
|
+
<footer className='AnatomyList_Pager'>
|
|
148
|
+
<span className='AnatomyList_Pager_Text'>
|
|
149
|
+
All {total} matches are accessible · {PAGE_SIZE} rows per page
|
|
150
|
+
</span>
|
|
151
|
+
<nav
|
|
152
|
+
className='AnatomyList_Pager_Nav'
|
|
153
|
+
aria-label='Anatomy list pagination'
|
|
154
|
+
>
|
|
155
|
+
<Button
|
|
156
|
+
className='Atlas_Button'
|
|
157
|
+
type='button'
|
|
158
|
+
disabled={!page}
|
|
159
|
+
aria-label='Previous anatomy page'
|
|
160
|
+
onClick={() => model.set({ listPage: page - 1 })}
|
|
161
|
+
>
|
|
162
|
+
← Previous
|
|
163
|
+
</Button>
|
|
164
|
+
<output
|
|
165
|
+
className='AnatomyList_Pager_Output'
|
|
166
|
+
aria-label='Anatomy list page'
|
|
167
|
+
>
|
|
168
|
+
{page + 1} / {lastPage + 1}
|
|
169
|
+
</output>
|
|
170
|
+
<Button
|
|
171
|
+
className='Atlas_Button'
|
|
172
|
+
type='button'
|
|
173
|
+
disabled={page >= lastPage}
|
|
174
|
+
aria-label='Next anatomy page'
|
|
175
|
+
onClick={() => model.set({ listPage: page + 1 })}
|
|
176
|
+
>
|
|
177
|
+
Next →
|
|
178
|
+
</Button>
|
|
179
|
+
</nav>
|
|
180
|
+
</footer>
|
|
181
|
+
</section>
|
|
182
|
+
)
|
|
183
|
+
}
|