-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
440 lines (428 loc) · 20.7 KB
/
index.html
File metadata and controls
440 lines (428 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Semfora Graph Explorer</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/src/styles.css">
</head>
<body>
<div id="app">
<!-- Header -->
<header class="header">
<div class="header-brand">
<svg class="logo" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<path d="M12 2v4M12 18v4M2 12h4M18 12h4"/>
<path d="M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/>
</svg>
<span class="logo-text">Semfora Graph</span>
</div>
<div class="header-stats" id="db-stats">
<span class="stat-label">No database loaded</span>
</div>
<div class="header-actions">
<button class="btn btn-primary" id="btn-load-db">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
Load Database
</button>
<input type="file" id="file-input" accept=".sqlite,.db,.sqlite3" style="display: none;">
</div>
</header>
<!-- Main Layout -->
<main class="main-layout">
<!-- Left Sidebar - Query Panel -->
<aside class="sidebar sidebar-left">
<div class="panel">
<h3 class="panel-title">Presets</h3>
<div class="preset-grid" id="preset-buttons">
<button class="preset-btn" data-preset="entry-points" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M15 3h6v6M14 10l6.1-6.1M9 21H3v-6M10 14l-6.1 6.1"/>
</svg>
Entry Points
</button>
<button class="preset-btn" data-preset="hot-functions" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83"/>
<circle cx="12" cy="12" r="5"/>
</svg>
Hot Functions
</button>
<button class="preset-btn" data-preset="dead-code" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/>
</svg>
Dead Code
</button>
<button class="preset-btn" data-preset="high-risk" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
<line x1="12" y1="9" x2="12" y2="13"/>
<line x1="12" y1="17" x2="12.01" y2="17"/>
</svg>
High Risk
</button>
<button class="preset-btn" data-preset="module-view" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"/>
<rect x="14" y="3" width="7" height="7"/>
<rect x="14" y="14" width="7" height="7"/>
<rect x="3" y="14" width="7" height="7"/>
</svg>
Module View
</button>
<button class="preset-btn" data-preset="external-calls" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
<polyline points="15 3 21 3 21 9"/>
<line x1="10" y1="14" x2="21" y2="3"/>
</svg>
External Calls
</button>
</div>
</div>
<div class="panel">
<h3 class="panel-title">Search</h3>
<div class="search-box">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
</svg>
<input type="text" id="search-input" placeholder="Search symbols..." disabled>
</div>
<div class="search-results" id="search-results"></div>
</div>
<div class="panel panel-grow">
<h3 class="panel-title">Custom Query</h3>
<textarea id="sql-input" class="sql-editor" placeholder="SELECT * FROM nodes WHERE ..." disabled></textarea>
<button class="btn btn-accent btn-full" id="btn-execute" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polygon points="5 3 19 12 5 21 5 3"/>
</svg>
Execute Query
</button>
</div>
</aside>
<!-- Center - Graph Canvas -->
<section class="graph-container">
<div class="graph-toolbar">
<div class="toolbar-group">
<span class="toolbar-label">Layout:</span>
<button class="toolbar-btn active" data-layout="dagre" title="Hierarchical">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="9" y="2" width="6" height="4"/>
<rect x="3" y="10" width="6" height="4"/>
<rect x="15" y="10" width="6" height="4"/>
<line x1="12" y1="6" x2="12" y2="10"/>
<line x1="6" y1="10" x2="12" y2="6"/>
<line x1="18" y1="10" x2="12" y2="6"/>
</svg>
</button>
<button class="toolbar-btn" data-layout="breadthfirst" title="Breadth-first (Directed Tree)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="6" cy="6" r="2"/>
<circle cx="18" cy="6" r="2"/>
<circle cx="6" cy="18" r="2"/>
<circle cx="18" cy="18" r="2"/>
<line x1="8" y1="6" x2="16" y2="6"/>
<line x1="6" y1="8" x2="6" y2="16"/>
<line x1="18" y1="8" x2="18" y2="16"/>
<line x1="8" y1="18" x2="16" y2="18"/>
</svg>
</button>
<button class="toolbar-btn" data-layout="circle" title="Circular">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<circle cx="12" cy="6" r="2"/>
<circle cx="6" cy="15" r="2"/>
<circle cx="18" cy="15" r="2"/>
</svg>
</button>
<button class="toolbar-btn" data-layout="grid" title="Grid">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"/>
<rect x="14" y="3" width="7" height="7"/>
<rect x="14" y="14" width="7" height="7"/>
<rect x="3" y="14" width="7" height="7"/>
</svg>
</button>
<button class="toolbar-btn" data-layout="cose" title="Force-directed (COSE)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="2"/>
<circle cx="4.5" cy="8" r="1.75"/>
<circle cx="19.5" cy="8" r="1.75"/>
<circle cx="6" cy="19" r="1.75"/>
<circle cx="18" cy="19" r="1.75"/>
<line x1="10.5" y1="11.2" x2="6.2" y2="8.8"/>
<line x1="13.5" y1="11.2" x2="17.8" y2="8.8"/>
<line x1="11.2" y1="13.5" x2="7.2" y2="17.6"/>
<line x1="12.8" y1="13.5" x2="16.8" y2="17.6"/>
</svg>
</button>
<button class="toolbar-btn" data-layout="fcose" title="Fast Force-directed (fCOSE)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="7" cy="7" r="2"/>
<circle cx="17" cy="7" r="2"/>
<circle cx="7" cy="17" r="2"/>
<circle cx="17" cy="17" r="2"/>
<line x1="9" y1="7" x2="15" y2="7"/>
<line x1="9" y1="17" x2="15" y2="17"/>
<line x1="7" y1="9" x2="7" y2="15"/>
<line x1="17" y1="9" x2="17" y2="15"/>
<path d="M12 4v4M12 16v4" />
</svg>
</button>
<button class="toolbar-btn" data-layout="cose-bilkent" title="Spring Layout (CoSE-Bilkent)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M7 4c0 2 4 2 4 4s-4 2-4 4 4 2 4 4-4 2-4 4" />
<path d="M13 4c0 2 4 2 4 4s-4 2-4 4 4 2 4 4-4 2-4 4" />
</svg>
</button>
<button class="toolbar-btn" data-layout="clustered" title="Clustered Circles">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="7" cy="7" r="5"/>
<circle cx="7" cy="7" r="1.5"/>
<circle cx="17" cy="17" r="5"/>
<circle cx="17" cy="17" r="1.5"/>
<circle cx="4" cy="4" r="1"/>
<circle cx="10" cy="4" r="1"/>
<circle cx="4" cy="10" r="1"/>
<circle cx="14" cy="14" r="1"/>
<circle cx="20" cy="14" r="1"/>
<circle cx="20" cy="20" r="1"/>
</svg>
</button>
</div>
<div class="toolbar-group">
<button class="toolbar-btn" id="btn-zoom-in" title="Zoom In">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
<line x1="11" y1="8" x2="11" y2="14"/>
<line x1="8" y1="11" x2="14" y2="11"/>
</svg>
</button>
<button class="toolbar-btn" id="btn-zoom-out" title="Zoom Out">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
<line x1="8" y1="11" x2="14" y2="11"/>
</svg>
</button>
<button class="toolbar-btn" id="btn-fit" title="Fit to View">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M8 3H5a2 2 0 0 0-2 2v3"/>
<path d="M21 8V5a2 2 0 0 0-2-2h-3"/>
<path d="M3 16v3a2 2 0 0 0 2 2h3"/>
<path d="M16 21h3a2 2 0 0 0 2-2v-3"/>
</svg>
</button>
<button class="toolbar-btn" id="btn-clear" title="Clear Graph">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="3 6 5 6 21 6"/>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
</svg>
</button>
</div>
</div>
<div id="cy" class="graph-canvas"></div>
<div class="graph-footer">
<span id="graph-info">Load a database to begin</span>
</div>
<!-- Empty State -->
<div class="empty-state" id="empty-state">
<div class="empty-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="3"/>
<path d="M12 2v4M12 18v4M2 12h4M18 12h4"/>
<path d="M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/>
</svg>
</div>
<h2>Semfora Graph Explorer</h2>
<p>Load a SQLite database exported from semfora-engine to visualize your call graph.</p>
<button class="btn btn-primary btn-lg" id="btn-load-empty">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
Load Database
</button>
</div>
</section>
<!-- Right Sidebar - Details Panel -->
<aside class="sidebar sidebar-right">
<div class="panel" id="details-panel">
<h3 class="panel-title">Details</h3>
<div class="details-empty" id="details-empty">
<p>Select a node to view details</p>
</div>
<div class="details-content" id="details-content" hidden>
<div class="detail-header">
<span class="detail-kind" id="detail-kind">fn</span>
<h4 class="detail-name" id="detail-name">functionName</h4>
</div>
<div class="detail-meta">
<div class="meta-item" id="module-row">
<span class="meta-label" id="detail-module-label">Module</span>
<span class="meta-value" id="detail-module">-</span>
</div>
<div class="meta-item">
<span class="meta-label">File</span>
<span class="meta-value meta-path" id="detail-file">-</span>
</div>
<div class="meta-item">
<span class="meta-label">Lines</span>
<span class="meta-value" id="detail-lines">-</span>
</div>
<div class="meta-item">
<span class="meta-label">Risk</span>
<span class="meta-value" id="detail-risk">-</span>
</div>
<div class="meta-item">
<span class="meta-label">Complexity</span>
<span class="meta-value" id="detail-complexity">-</span>
</div>
</div>
<div class="detail-stats">
<div class="stat-box">
<span class="stat-number" id="detail-callers">0</span>
<span class="stat-label">Callers</span>
</div>
<div class="stat-box">
<span class="stat-number" id="detail-callees">0</span>
<span class="stat-label">Callees</span>
</div>
</div>
<!-- Actions for regular nodes (functions, structs, etc.) -->
<div class="detail-actions" id="node-actions">
<button class="btn btn-primary btn-sm" id="btn-show-all" title="Show both callers and callees">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"/>
<polyline points="5 12 12 5 19 12"/>
<polyline points="5 12 12 19 19 12"/>
</svg>
Show All
</button>
<button class="btn btn-outline btn-sm" id="btn-show-callers">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="19" y1="12" x2="5" y2="12"/>
<polyline points="12 19 5 12 12 5"/>
</svg>
Callers
</button>
<button class="btn btn-outline btn-sm" id="btn-show-callees">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="5" y1="12" x2="19" y2="12"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
Callees
</button>
<button class="btn btn-outline btn-sm" id="btn-focus">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<path d="M12 2v4M12 18v4M2 12h4M18 12h4"/>
</svg>
Focus Here
</button>
<button class="btn btn-outline btn-sm" id="btn-copy-hash">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
Copy Hash
</button>
</div>
<!-- Actions for module nodes -->
<div class="detail-actions" id="module-actions" hidden>
<button class="btn btn-primary btn-sm" id="btn-expand-module" title="Show all symbols in this module with their connections">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7" rx="1"/>
<rect x="14" y="3" width="7" height="7" rx="1"/>
<rect x="3" y="14" width="7" height="7" rx="1"/>
<rect x="14" y="14" width="7" height="7" rx="1"/>
</svg>
Expand Module
</button>
<button class="btn btn-outline btn-sm" id="btn-module-contents" title="Show only symbols in this module">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
</svg>
Contents Only
</button>
<button class="btn btn-outline btn-sm" id="btn-module-connections" title="Show external callers and callees">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<line x1="12" y1="2" x2="12" y2="9"/>
<line x1="12" y1="15" x2="12" y2="22"/>
<line x1="2" y1="12" x2="9" y2="12"/>
<line x1="15" y1="12" x2="22" y2="12"/>
</svg>
Connections
</button>
</div>
</div>
</div>
<div class="panel">
<h3 class="panel-title">Export</h3>
<div class="export-buttons">
<button class="btn btn-secondary btn-sm" id="btn-export-dot" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
DOT
</button>
<button class="btn btn-secondary btn-sm" id="btn-export-mermaid" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
Mermaid
</button>
<button class="btn btn-secondary btn-sm" id="btn-export-json" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
JSON
</button>
<button class="btn btn-secondary btn-sm" id="btn-export-csv" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
CSV
</button>
<button class="btn btn-secondary btn-sm" id="btn-export-png" disabled>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
PNG
</button>
</div>
</div>
</aside>
</main>
<!-- Toast Notifications -->
<div class="toast-container" id="toast-container"></div>
<!-- Loading Overlay -->
<div class="loading-overlay" id="loading-overlay" hidden>
<div class="loading-spinner"></div>
<p class="loading-text" id="loading-text">Loading...</p>
</div>
</div>
<script type="module" src="/src/app.js"></script>
</body>
</html>