-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
310 lines (286 loc) · 14.7 KB
/
Copy pathadmin.html
File metadata and controls
310 lines (286 loc) · 14.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
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Admin — Days Since Ohio Crash</title>
<meta name="robots" content="noindex, nofollow" />
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: { extend: { fontFamily: { sans: ['-apple-system','BlinkMacSystemFont','Segoe UI','sans-serif'], mono: ['JetBrains Mono','Fira Code','monospace'] } } }
}
</script>
</head>
<body class="bg-slate-950 text-slate-100 min-h-screen font-sans">
<!-- Header -->
<header class="border-b border-slate-800 bg-slate-900/80 backdrop-blur sticky top-0 z-50">
<div class="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between">
<div class="flex items-center gap-3">
<a href="/" class="text-slate-500 hover:text-white transition-colors text-sm">← Site</a>
<span class="text-slate-700">/</span>
<span class="text-white font-semibold text-sm">Admin Dashboard</span>
</div>
<span class="bg-red-500/20 text-red-400 text-xs px-2 py-0.5 rounded-full font-medium">NOT PUBLIC</span>
</div>
</header>
<main class="max-w-3xl mx-auto px-4 py-8 space-y-8">
<!-- Last run banner -->
<div id="last-run-banner" class="bg-slate-900 border border-slate-800 rounded-2xl p-5">
<div class="flex items-center justify-between flex-wrap gap-4">
<div>
<div class="text-slate-400 text-xs uppercase tracking-widest mb-1">Last Scraper Run</div>
<div id="last-run-time" class="text-white font-semibold text-lg">Loading...</div>
<div id="last-run-found" class="text-slate-500 text-sm mt-0.5"></div>
</div>
<div class="flex gap-3 flex-wrap">
<!-- Triggers the GitHub Actions workflow_dispatch -->
<a id="gh-actions-link"
href="https://github.com/tonefox/days_since_ohio/actions/workflows/daily-scrape.yml"
target="_blank" rel="noopener"
class="inline-flex items-center gap-2 bg-blue-600 hover:bg-blue-500 text-white px-4 py-2 rounded-full text-sm font-medium transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Run Scraper Now
</a>
<button onclick="refreshStatus()"
class="inline-flex items-center gap-2 bg-slate-800 hover:bg-slate-700 border border-slate-700 text-slate-300 hover:text-white px-4 py-2 rounded-full text-sm font-medium transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
<span id="refresh-label">Refresh Status</span>
</button>
</div>
</div>
</div>
<!-- Source status cards -->
<section>
<h2 class="text-slate-400 text-xs uppercase tracking-widest font-medium mb-4">Data Sources</h2>
<div id="source-cards" class="space-y-3">
<div class="text-slate-600 text-sm py-8 text-center">Loading source status...</div>
</div>
</section>
<!-- Incident summary -->
<section>
<h2 class="text-slate-400 text-xs uppercase tracking-widest font-medium mb-4">Incident Database</h2>
<div id="incident-summary" class="bg-slate-900 border border-slate-800 rounded-2xl p-5 space-y-4">
<div class="text-slate-600 text-sm">Loading...</div>
</div>
</section>
<!-- Setup checklist -->
<section>
<h2 class="text-slate-400 text-xs uppercase tracking-widest font-medium mb-4">Setup Checklist</h2>
<div id="setup-checklist" class="bg-slate-900 border border-slate-800 rounded-2xl divide-y divide-slate-800">
<div class="text-slate-600 text-sm p-5">Loading...</div>
</div>
</section>
<!-- Quick links -->
<section>
<h2 class="text-slate-400 text-xs uppercase tracking-widest font-medium mb-4">Quick Links</h2>
<div class="grid grid-cols-2 sm:grid-cols-3 gap-3 text-sm">
<a href="https://github.com/tonefox/days_since_ohio/actions" target="_blank" rel="noopener"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">⚙️</div>
<div class="text-white font-medium">GitHub Actions</div>
<div class="text-slate-500 text-xs">View workflow runs</div>
</a>
<a href="https://github.com/tonefox/days_since_ohio/pulls" target="_blank" rel="noopener"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">📋</div>
<div class="text-white font-medium">Open PRs</div>
<div class="text-slate-500 text-xs">Review scraper candidates</div>
</a>
<a href="https://app.netlify.com" target="_blank" rel="noopener"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">🚀</div>
<div class="text-white font-medium">Netlify</div>
<div class="text-slate-500 text-xs">Deploy status</div>
</a>
<a href="/incidents.json" target="_blank"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">📁</div>
<div class="text-white font-medium">incidents.json</div>
<div class="text-slate-500 text-xs">Raw approved data</div>
</a>
<a href="/api-status.json" target="_blank"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">📡</div>
<div class="text-white font-medium">api-status.json</div>
<div class="text-slate-500 text-xs">Raw source status</div>
</a>
<a href="/feed.xml" target="_blank"
class="bg-slate-900 border border-slate-800 hover:border-slate-600 rounded-xl p-4 transition-colors">
<div class="text-lg mb-1">📰</div>
<div class="text-white font-medium">feed.xml</div>
<div class="text-slate-500 text-xs">RSS feed</div>
</a>
</div>
</section>
</main>
<script>
const STATUS_DISPLAY = {
ok: { label: 'Live', cls: 'bg-green-500/20 text-green-400', dot: 'bg-green-400' },
not_configured: { label: 'Needs Setup', cls: 'bg-amber-500/20 text-amber-400', dot: 'bg-amber-400' },
never_run: { label: 'Never Run', cls: 'bg-slate-700 text-slate-400', dot: 'bg-slate-500' },
error: { label: 'Error', cls: 'bg-red-500/20 text-red-400', dot: 'bg-red-400' },
partial: { label: 'Partial', cls: 'bg-yellow-500/20 text-yellow-400',dot: 'bg-yellow-400' },
};
function badge(status) {
const d = STATUS_DISPLAY[status] || STATUS_DISPLAY.never_run;
return `<span class="inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full font-medium ${d.cls}">
<span class="w-1.5 h-1.5 rounded-full ${d.dot} inline-block"></span>${d.label}
</span>`;
}
function timeAgo(isoStr) {
if (!isoStr) return 'Never';
const diff = Date.now() - new Date(isoStr).getTime();
const mins = Math.floor(diff / 60000);
const hours = Math.floor(diff / 3600000);
const days = Math.floor(diff / 86400000);
if (mins < 2) return 'Just now';
if (mins < 60) return `${mins}m ago`;
if (hours < 24) return `${hours}h ago`;
return `${days}d ago`;
}
function renderSourceCard(s) {
const setupRow = s.requires_setup && s.status !== 'ok' && s.setup_url ? `
<a href="${s.setup_url}" target="_blank" rel="noopener"
class="inline-flex items-center gap-1 text-blue-400 hover:text-blue-300 text-xs mt-2 transition-colors">
Setup instructions →
</a>` : '';
const subSources = s.sources ? s.sources.map(sub => `
<div class="flex items-center justify-between text-xs text-slate-500 mt-1">
<span>${sub.name}</span>
${badge(sub.status)}
</div>`).join('') : '';
return `
<div class="bg-slate-900 border border-slate-800 rounded-xl p-5">
<div class="flex items-start justify-between gap-3 flex-wrap">
<div class="flex-1">
<div class="flex items-center gap-2 mb-1 flex-wrap">
<span class="text-white font-medium text-sm">${s.label}</span>
${s.requires_setup ? '<span class="text-slate-600 text-xs">(requires credentials)</span>' : '<span class="text-slate-600 text-xs">(no auth needed)</span>'}
</div>
<p class="text-slate-400 text-xs leading-relaxed">${s.note || ''}</p>
${subSources}
${setupRow}
</div>
<div class="text-right shrink-0">
${badge(s.status)}
<div class="text-slate-600 text-xs mt-1">${s.last_checked ? timeAgo(s.last_checked) : 'Never checked'}</div>
${s.new_candidates ? `<div class="text-blue-400 text-xs mt-0.5">+${s.new_candidates} candidates</div>` : ''}
</div>
</div>
</div>`;
}
function renderChecklist(sources) {
const items = [
{
label: 'Google News RSS',
done: sources.find(s => s.label.includes('Google'))?.status === 'ok',
note: 'Free, no setup — goes live on first scraper run',
action: null,
},
{
label: 'Reddit API credentials',
done: sources.find(s => s.label.includes('Reddit'))?.status === 'ok',
note: 'Add REDDIT_CLIENT_ID + REDDIT_CLIENT_SECRET to GitHub Secrets',
action: { label: 'reddit.com/prefs/apps', url: 'https://www.reddit.com/prefs/apps' },
},
{
label: 'Columbus PD / Fire scraper',
done: ['ok','partial'].includes(sources.find(s => s.label.includes('Columbus'))?.status),
note: 'Free, no setup — goes live on first scraper run',
action: null,
},
{
label: 'Domain connected (dayssinceohiocrash.com)',
done: window.location.hostname === 'dayssinceohiocrash.com',
note: 'Point nameservers to Netlify from name.com',
action: { label: 'Netlify DNS', url: 'https://app.netlify.com' },
},
{
label: 'Netlify deploy live',
done: window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1',
note: 'Connect repo at app.netlify.com',
action: { label: 'Netlify dashboard', url: 'https://app.netlify.com' },
},
];
return items.map(item => `
<div class="flex items-start gap-3 p-4">
<div class="mt-0.5 shrink-0">
${item.done
? '<div class="w-5 h-5 rounded-full bg-green-500/20 text-green-400 flex items-center justify-center text-xs">✓</div>'
: '<div class="w-5 h-5 rounded-full border-2 border-slate-700"></div>'}
</div>
<div class="flex-1">
<div class="text-sm font-medium ${item.done ? 'text-slate-400 line-through' : 'text-white'}">${item.label}</div>
<div class="text-slate-500 text-xs mt-0.5">${item.note}</div>
${item.action && !item.done ? `<a href="${item.action.url}" target="_blank" rel="noopener" class="text-blue-400 hover:text-blue-300 text-xs mt-1 inline-block transition-colors">${item.action.label} →</a>` : ''}
</div>
</div>`).join('');
}
async function loadStatus() {
try {
const [statusRes, incidentsRes] = await Promise.all([
fetch('/api-status.json'),
fetch('/incidents.json'),
]);
const status = await statusRes.json();
const incidents = await incidentsRes.json();
// Last run
document.getElementById('last-run-time').textContent =
status.last_run ? new Date(status.last_run).toLocaleString() : 'Never — trigger the scraper to begin';
document.getElementById('last-run-found').textContent =
status.last_run ? `${status.new_total} new candidate(s) found that run` : '';
// Source cards
document.getElementById('source-cards').innerHTML =
status.sources.map(renderSourceCard).join('');
// Incident summary
const sorted = incidents.sort((a, b) => new Date(b.date) - new Date(a.date));
const types = {};
incidents.forEach(i => { types[i.building_type] = (types[i.building_type] || 0) + 1; });
const topTypes = Object.entries(types).sort((a,b)=>b[1]-a[1]).slice(0,5);
document.getElementById('incident-summary').innerHTML = `
<div class="grid grid-cols-3 gap-4 text-center mb-4">
<div>
<div class="text-2xl font-bold text-white">${incidents.length}</div>
<div class="text-slate-500 text-xs">Total incidents</div>
</div>
<div>
<div class="text-2xl font-bold text-white">${sorted[0]?.date || '–'}</div>
<div class="text-slate-500 text-xs">Most recent</div>
</div>
<div>
<div class="text-2xl font-bold text-white">${sorted[sorted.length-1]?.date || '–'}</div>
<div class="text-slate-500 text-xs">Oldest</div>
</div>
</div>
<div class="border-t border-slate-800 pt-4">
<div class="text-slate-400 text-xs uppercase tracking-wide mb-2">By building type</div>
${topTypes.map(([type, count]) => `
<div class="flex items-center justify-between text-sm py-1">
<span class="text-slate-300">${type}</span>
<span class="text-white font-medium">${count}</span>
</div>`).join('')}
</div>`;
// Checklist
document.getElementById('setup-checklist').innerHTML = renderChecklist(status.sources);
} catch (err) {
console.error(err);
document.getElementById('source-cards').innerHTML =
`<div class="text-red-400 text-sm p-4">Failed to load status: ${err.message}</div>`;
}
}
async function refreshStatus() {
const btn = document.getElementById('refresh-label');
btn.textContent = 'Refreshing...';
await loadStatus();
btn.textContent = 'Refresh Status';
}
loadStatus();
</script>
</body>
</html>