datamatters24 commited on
Commit
36d1c5d
·
verified ·
1 Parent(s): efda44d

Upload web/src/views/dashboard.php with huggingface_hub

Browse files
Files changed (1) hide show
  1. web/src/views/dashboard.php +223 -0
web/src/views/dashboard.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $title = 'Analytics Dashboard - Research Document Archive';
3
+ $content = '';
4
+ ob_start();
5
+
6
+ $sectionNames = [
7
+ 'cia_declassified' => 'CIA Declassified',
8
+ 'cia_mkultra' => 'CIA MKUltra',
9
+ 'cia_stargate' => 'CIA Stargate',
10
+ 'doj_disclosures' => 'DOJ Disclosures',
11
+ 'house_resolutions' => 'House Resolutions',
12
+ 'jfk_assassination' => 'JFK Assassination',
13
+ 'lincoln_archives' => 'Lincoln Archives',
14
+ ];
15
+
16
+ $sectionColors = [
17
+ 'cia_declassified' => 'bg-red-500',
18
+ 'cia_mkultra' => 'bg-purple-500',
19
+ 'cia_stargate' => 'bg-indigo-500',
20
+ 'doj_disclosures' => 'bg-amber-500',
21
+ 'house_resolutions' => 'bg-blue-500',
22
+ 'jfk_assassination' => 'bg-orange-500',
23
+ 'lincoln_archives' => 'bg-emerald-500',
24
+ ];
25
+ ?>
26
+
27
+ <div class="mb-6">
28
+ <h1 class="text-2xl font-bold text-gray-900">Analytics Dashboard</h1>
29
+ <p class="mt-1 text-sm text-gray-600">Cross-collection analysis, topic profiles, and key findings across <?= number_format(array_sum(array_column($collectionSummary, 'docs'))) ?> documents.</p>
30
+ </div>
31
+
32
+ <!-- Collection Overview Cards -->
33
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
34
+ <?php foreach ($collectionSummary as $section => $stats):
35
+ $color = $sectionColors[$section] ?? 'bg-gray-500';
36
+ ?>
37
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4">
38
+ <div class="flex items-center justify-between mb-2">
39
+ <h3 class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($sectionNames[$section] ?? $section) ?></h3>
40
+ <div class="w-3 h-3 rounded-full <?= $color ?>"></div>
41
+ </div>
42
+ <div class="grid grid-cols-2 gap-2 text-xs">
43
+ <div>
44
+ <span class="text-gray-500">Documents</span>
45
+ <p class="font-semibold text-gray-900"><?= number_format($stats['docs'] ?? 0) ?></p>
46
+ </div>
47
+ <div>
48
+ <span class="text-gray-500">Pages</span>
49
+ <p class="font-semibold text-gray-900"><?= number_format($stats['pages'] ?? 0) ?></p>
50
+ </div>
51
+ <?php if (($stats['top_secret'] ?? 0) > 0): ?>
52
+ <div>
53
+ <span class="text-gray-500">TOP SECRET</span>
54
+ <p class="font-semibold text-red-700"><?= number_format($stats['top_secret']) ?></p>
55
+ </div>
56
+ <?php endif; ?>
57
+ <?php if (($stats['secret'] ?? 0) > 0): ?>
58
+ <div>
59
+ <span class="text-gray-500">SECRET</span>
60
+ <p class="font-semibold text-orange-700"><?= number_format($stats['secret']) ?></p>
61
+ </div>
62
+ <?php endif; ?>
63
+ <?php if (($stats['redacted_docs'] ?? 0) > 0): ?>
64
+ <div>
65
+ <span class="text-gray-500">Redacted</span>
66
+ <p class="font-semibold text-gray-800"><?= number_format($stats['redacted_docs']) ?></p>
67
+ </div>
68
+ <?php endif; ?>
69
+ </div>
70
+ </div>
71
+ <?php endforeach; ?>
72
+ </div>
73
+
74
+ <!-- Classification Stamps -->
75
+ <?php if (!empty($stamps)): ?>
76
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4 mb-8">
77
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Classification Stamps Detected</h2>
78
+ <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-3">
79
+ <?php
80
+ $stampColors = [
81
+ 'TOP SECRET' => 'border-red-300 bg-red-50 text-red-800',
82
+ 'SECRET' => 'border-orange-300 bg-orange-50 text-orange-800',
83
+ 'CONFIDENTIAL' => 'border-yellow-300 bg-yellow-50 text-yellow-800',
84
+ 'CLASSIFIED' => 'border-amber-300 bg-amber-50 text-amber-800',
85
+ 'UNCLASSIFIED' => 'border-green-300 bg-green-50 text-green-800',
86
+ 'DECLASSIFIED' => 'border-emerald-300 bg-emerald-50 text-emerald-800',
87
+ 'EYES ONLY' => 'border-red-300 bg-red-50 text-red-800',
88
+ 'NOFORN' => 'border-rose-300 bg-rose-50 text-rose-800',
89
+ 'REDACTED' => 'border-gray-600 bg-gray-800 text-white',
90
+ ];
91
+ foreach ($stamps as $s):
92
+ $sColor = $stampColors[$s['classification']] ?? 'border-gray-300 bg-gray-50 text-gray-700';
93
+ ?>
94
+ <div class="border rounded-lg p-3 text-center <?= $sColor ?>">
95
+ <p class="text-[10px] font-bold uppercase"><?= htmlspecialchars($s['classification']) ?></p>
96
+ <p class="text-lg font-bold mt-1"><?= number_format((int)$s['doc_count']) ?></p>
97
+ <p class="text-[10px] opacity-70">documents</p>
98
+ </div>
99
+ <?php endforeach; ?>
100
+ </div>
101
+ </div>
102
+ <?php endif; ?>
103
+
104
+ <!-- Topic Profiles -->
105
+ <?php if (!empty($topicProfiles)): ?>
106
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4 mb-8">
107
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Topic Profiles by Collection</h2>
108
+ <div class="overflow-x-auto">
109
+ <table class="min-w-full text-xs">
110
+ <thead>
111
+ <tr class="border-b border-gray-200">
112
+ <th class="px-3 py-2 text-left font-semibold text-gray-500 uppercase">Collection</th>
113
+ <th class="px-3 py-2 text-left font-semibold text-gray-500 uppercase" colspan="3">Top Topics</th>
114
+ </tr>
115
+ </thead>
116
+ <tbody class="divide-y divide-gray-100">
117
+ <?php foreach ($topicProfiles as $section => $topics):
118
+ arsort($topics);
119
+ $top3 = array_slice($topics, 0, 3, true);
120
+ ?>
121
+ <tr>
122
+ <td class="px-3 py-2.5 font-medium text-gray-900">
123
+ <?= htmlspecialchars($sectionNames[$section] ?? $section) ?>
124
+ </td>
125
+ <?php foreach ($top3 as $topic => $pct): ?>
126
+ <td class="px-3 py-2.5">
127
+ <div class="flex items-center gap-2">
128
+ <div class="w-16 bg-gray-200 rounded-full h-1.5">
129
+ <div class="bg-blue-500 h-1.5 rounded-full" style="width: <?= min(100, $pct * 100) ?>%"></div>
130
+ </div>
131
+ <span class="text-gray-700"><?= htmlspecialchars($topic) ?></span>
132
+ <span class="text-gray-400"><?= number_format($pct * 100, 1) ?>%</span>
133
+ </div>
134
+ </td>
135
+ <?php endforeach; ?>
136
+ </tr>
137
+ <?php endforeach; ?>
138
+ </tbody>
139
+ </table>
140
+ </div>
141
+ </div>
142
+ <?php endif; ?>
143
+
144
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
145
+
146
+ <!-- Collection Similarity -->
147
+ <?php if (!empty($similarities)): ?>
148
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4">
149
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Collection Similarity (Jaccard Index)</h2>
150
+ <div class="space-y-2">
151
+ <?php foreach (array_slice($similarities, 0, 15) as $s):
152
+ $pct = $s['jaccard'] * 100;
153
+ $barWidth = min(100, $pct * 50); // scale up for visibility
154
+ ?>
155
+ <div>
156
+ <div class="flex justify-between items-center text-xs mb-0.5">
157
+ <span class="text-gray-700">
158
+ <?= htmlspecialchars($sectionNames[$s['section_a']] ?? $s['section_a']) ?>
159
+ &harr;
160
+ <?= htmlspecialchars($sectionNames[$s['section_b']] ?? $s['section_b']) ?>
161
+ </span>
162
+ <span class="text-gray-500 font-mono">
163
+ <?= number_format($s['shared_count']) ?> shared
164
+ </span>
165
+ </div>
166
+ <div class="w-full bg-gray-200 rounded-full h-1.5">
167
+ <div class="bg-indigo-500 h-1.5 rounded-full" style="width: <?= $barWidth ?>%"></div>
168
+ </div>
169
+ </div>
170
+ <?php endforeach; ?>
171
+ </div>
172
+ </div>
173
+ <?php endif; ?>
174
+
175
+ <!-- Bridge Entities -->
176
+ <?php if (!empty($bridgePersons)): ?>
177
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4">
178
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Bridge Entities (People Across Collections)</h2>
179
+ <div class="space-y-2 max-h-96 overflow-y-auto">
180
+ <?php foreach (array_slice($bridgePersons, 0, 25) as $bp): ?>
181
+ <div class="flex items-center justify-between py-1 border-b border-gray-100">
182
+ <div>
183
+ <span class="text-sm font-medium text-gray-900"><?= htmlspecialchars($bp['entity']) ?></span>
184
+ <span class="text-xs text-gray-500 ml-2"><?= $bp['doc_count'] ?> docs</span>
185
+ </div>
186
+ <div class="flex gap-1">
187
+ <?php foreach ($bp['sections'] ?? [] as $sec): ?>
188
+ <span class="inline-block w-2 h-2 rounded-full <?= $sectionColors[$sec] ?? 'bg-gray-400' ?>"
189
+ title="<?= htmlspecialchars($sectionNames[$sec] ?? $sec) ?>"></span>
190
+ <?php endforeach; ?>
191
+ </div>
192
+ </div>
193
+ <?php endforeach; ?>
194
+ </div>
195
+ </div>
196
+ <?php endif; ?>
197
+
198
+ </div>
199
+
200
+ <!-- Bridge Organizations -->
201
+ <?php if (!empty($bridgeOrgs)): ?>
202
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4 mb-8">
203
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Bridge Entities (Organizations Across Collections)</h2>
204
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2">
205
+ <?php foreach (array_slice($bridgeOrgs, 0, 30) as $bo): ?>
206
+ <div class="flex items-center justify-between py-1.5 px-2 rounded hover:bg-gray-50">
207
+ <span class="text-xs font-medium text-gray-800 truncate"><?= htmlspecialchars($bo['entity']) ?></span>
208
+ <div class="flex items-center gap-1.5 flex-shrink-0 ml-2">
209
+ <span class="text-[10px] text-gray-400"><?= $bo['collections'] ?> cols</span>
210
+ <?php foreach ($bo['sections'] ?? [] as $sec): ?>
211
+ <span class="inline-block w-1.5 h-1.5 rounded-full <?= $sectionColors[$sec] ?? 'bg-gray-400' ?>"></span>
212
+ <?php endforeach; ?>
213
+ </div>
214
+ </div>
215
+ <?php endforeach; ?>
216
+ </div>
217
+ </div>
218
+ <?php endif; ?>
219
+
220
+ <?php
221
+ $content = ob_get_clean();
222
+ include __DIR__ . '/layout.php';
223
+ ?>