easy-devops 1.1.0 → 1.2.1

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.
Files changed (34) hide show
  1. package/README.md +2 -2
  2. package/package.json +6 -3
  3. package/src/cli/index.js +13 -1
  4. package/src/cli/menus/dashboard.js +1 -1
  5. package/src/core/channels/discord.js +77 -0
  6. package/src/core/channels/telegram.js +120 -0
  7. package/src/core/db.js +8 -1
  8. package/src/core/domainNotifier.js +298 -0
  9. package/src/core/events.js +130 -0
  10. package/src/core/notifier.js +73 -0
  11. package/src/core/shell.js +59 -7
  12. package/src/dashboard/controllers/authController.js +29 -0
  13. package/src/dashboard/controllers/domainsController.js +416 -0
  14. package/src/dashboard/controllers/nginxController.js +128 -0
  15. package/src/dashboard/controllers/settingsController.js +335 -0
  16. package/src/dashboard/controllers/sslController.js +291 -0
  17. package/src/dashboard/public/img/icon.png +0 -0
  18. package/src/dashboard/public/img/icon_b.png +0 -0
  19. package/src/dashboard/public/js/app.js +234 -2
  20. package/src/dashboard/routes/auth.js +12 -22
  21. package/src/dashboard/routes/domains.js +11 -363
  22. package/src/dashboard/routes/nginx.js +13 -146
  23. package/src/dashboard/routes/settings.js +16 -189
  24. package/src/dashboard/routes/ssl.js +9 -276
  25. package/src/dashboard/server.js +24 -27
  26. package/src/dashboard/socketManager.js +282 -0
  27. package/src/dashboard/views/index.ejs +52 -0
  28. package/src/dashboard/views/partials/domain-form.ejs +64 -1
  29. package/src/dashboard/views/partials/domains-panel.ejs +4 -0
  30. package/src/dashboard/views/partials/login.ejs +1 -1
  31. package/src/dashboard/views/partials/logs-panel.ejs +67 -0
  32. package/src/dashboard/views/partials/settings-panel.ejs +263 -87
  33. package/src/dashboard/views/partials/sidebar.ejs +3 -1
  34. /package/src/{dashboard/routes → core/channels}/.gitkeep +0 -0
@@ -0,0 +1,282 @@
1
+ import http from 'http';
2
+ import { spawn } from 'child_process';
3
+ import path from 'path';
4
+ import { Server as SocketIO } from 'socket.io';
5
+
6
+ import { getStatus } from './lib/nginx-service.js';
7
+ import { listAllCerts } from './lib/cert-reader.js';
8
+ import { loadConfig } from '../core/config.js';
9
+ import { dbGet } from '../core/db.js';
10
+ import {
11
+ createNginxDownEvent,
12
+ createNginxRecoveredEvent,
13
+ createDomainDownEvent,
14
+ createDomainRecoveredEvent,
15
+ } from '../core/events.js';
16
+ import { sendNotification } from '../core/notifier.js';
17
+ import {
18
+ getEffectiveChannelIds,
19
+ getAllDomainChannelIds,
20
+ shouldSendNotification,
21
+ } from '../core/domainNotifier.js';
22
+
23
+ let connectedClients = 0;
24
+ const activeTails = new Map();
25
+
26
+ /**
27
+ * Emit nginx status and handle notification state transitions.
28
+ * Uses state tracking to prevent spam and support recovery notifications.
29
+ */
30
+ async function emitNginxStatus(target) {
31
+ try {
32
+ const status = await getStatus();
33
+ target.emit('nginx:status', status);
34
+
35
+ const currentStatus = status.running ? 'up' : 'down';
36
+ const decision = shouldSendNotification(null, 'nginx_down', currentStatus);
37
+
38
+ if (decision.shouldNotify) {
39
+ let event;
40
+ if (decision.reason === 'recovery') {
41
+ event = createNginxRecoveredEvent();
42
+ } else {
43
+ event = createNginxDownEvent();
44
+ }
45
+
46
+ console.log(`[socketManager] Sending nginx notification: ${decision.reason}`);
47
+ target.emit('notification:new', event);
48
+
49
+ // External channel routing (fire-and-forget, isolated)
50
+ try {
51
+ const channels = getAllDomainChannelIds('nginx_down');
52
+ await sendNotification(event, channels);
53
+ } catch (err) {
54
+ console.error('[socketManager] sendNotification failed:', err.message);
55
+ }
56
+ }
57
+ } catch (err) {
58
+ target.emit('nginx:status', { running: false, version: null, pid: null, error: err.message });
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Emit cert expiry notifications.
64
+ * Note: Cert expiry doesn't use state tracking because it's a time-based event,
65
+ * not a state transition. We notify whenever a cert is expiring, regardless of
66
+ * whether we notified before.
67
+ */
68
+ async function emitCertNotifications(target) {
69
+ try {
70
+ const certs = await listAllCerts();
71
+ for (const cert of certs) {
72
+ if (cert.daysLeft !== null && cert.daysLeft < 30) {
73
+ const event = {
74
+ id: `cert-expiry-${cert.domain}-${Date.now()}`,
75
+ type: 'cert_expiry',
76
+ severity: cert.daysLeft < 10 ? 'danger' : 'warning',
77
+ message: `🔒 SSL cert for ${cert.domain} expires in ${cert.daysLeft} day${cert.daysLeft === 1 ? '' : 's'}`,
78
+ domain: cert.domain,
79
+ timestamp: Date.now(),
80
+ };
81
+ target.emit('notification:new', event);
82
+
83
+ // External channel routing (fire-and-forget, isolated)
84
+ try {
85
+ const channels = getEffectiveChannelIds(cert.domain, 'cert_expiry');
86
+ await sendNotification(event, channels);
87
+ } catch (err) {
88
+ console.error('[socketManager] sendNotification failed:', err.message);
89
+ }
90
+ }
91
+ }
92
+ } catch {
93
+ /* non-fatal */
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Check if a domain backend is responding.
99
+ */
100
+ function checkDomainHealth(host, port) {
101
+ return new Promise((resolve) => {
102
+ const req = http.request(
103
+ {
104
+ host,
105
+ port: Number(port),
106
+ path: '/',
107
+ method: 'HEAD',
108
+ timeout: 5000,
109
+ },
110
+ (res) => {
111
+ resolve({ up: true, status: res.statusCode });
112
+ res.resume();
113
+ }
114
+ );
115
+ req.on('timeout', () => {
116
+ req.destroy();
117
+ resolve({ up: false });
118
+ });
119
+ req.on('error', () => resolve({ up: false }));
120
+ req.end();
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Emit domain health status and handle notification state transitions.
126
+ * Uses state tracking to:
127
+ * 1. Prevent spam (don't re-notify if already down)
128
+ * 2. Send recovery notifications when domain comes back up
129
+ */
130
+ async function emitDomainHealth(target) {
131
+ try {
132
+ const domains = dbGet('domains') || [];
133
+ const results = await Promise.all(
134
+ domains.map(async (d) => {
135
+ const host = d.backendHost || '127.0.0.1';
136
+ const port = d.port || 80;
137
+
138
+ // Skip external URL backends
139
+ if (typeof host === 'string' && host.startsWith('http')) return { name: d.name, up: null };
140
+
141
+ const { up } = await checkDomainHealth(host, port);
142
+ return { name: d.name, up, port, host };
143
+ })
144
+ );
145
+
146
+ target.emit('domain:health', results);
147
+
148
+ // Process state transitions for each domain
149
+ for (const result of results) {
150
+ if (result.up === null) continue; // Skip external URL backends
151
+
152
+ const currentStatus = result.up ? 'up' : 'down';
153
+ const decision = shouldSendNotification(result.name, 'domain_health', currentStatus);
154
+
155
+ if (decision.shouldNotify) {
156
+ let event;
157
+ if (decision.reason === 'recovery') {
158
+ event = createDomainRecoveredEvent(result.name, result.port);
159
+ } else {
160
+ event = createDomainDownEvent(result.name, result.port);
161
+ }
162
+
163
+ console.log(`[socketManager] Sending domain health notification for ${result.name}: ${decision.reason}`);
164
+ target.emit('notification:new', event);
165
+
166
+ try {
167
+ const channelIds = getEffectiveChannelIds(result.name, 'domain_health');
168
+ await sendNotification(event, channelIds);
169
+ } catch (err) {
170
+ console.error('[socketManager] domain health sendNotification failed:', err.message);
171
+ }
172
+ }
173
+ }
174
+ } catch (err) {
175
+ console.error('[socketManager] emitDomainHealth error:', err.message);
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Get the path to a log file.
181
+ */
182
+ function getLogPath(logFile) {
183
+ const { nginxDir } = loadConfig();
184
+ const file = logFile === 'access' ? 'access.log' : 'error.log';
185
+
186
+ // Linux standard path first, fall back to nginxDir/logs/
187
+ if (process.platform !== 'win32') {
188
+ return `/var/log/nginx/${file}`;
189
+ }
190
+ return path.join(nginxDir, 'logs', file);
191
+ }
192
+
193
+ /**
194
+ * Start tailing a log file for a socket.
195
+ */
196
+ function startTail(socket, logFile) {
197
+ // Kill any existing tail for this socket
198
+ stopTail(socket.id);
199
+
200
+ const logPath = getLogPath(logFile);
201
+ const args = process.platform === 'win32'
202
+ ? ['Get-Content', '-Path', logPath, '-Wait', '-Tail', '50']
203
+ : ['-n', '50', '-f', logPath];
204
+ const cmd = process.platform === 'win32' ? 'powershell' : 'tail';
205
+
206
+ const child = spawn(cmd, args, {
207
+ stdio: ['ignore', 'pipe', 'ignore'],
208
+ windowsHide: true,
209
+ });
210
+
211
+ let buf = '';
212
+ child.stdout.on('data', (chunk) => {
213
+ buf += chunk.toString();
214
+ const lines = buf.split('\n');
215
+ buf = lines.pop(); // keep incomplete line in buffer
216
+ for (const line of lines) {
217
+ if (line.trim()) socket.emit('logs:line', { line: line.trim(), logFile });
218
+ }
219
+ });
220
+
221
+ child.on('error', () => {});
222
+ child.on('close', () => {
223
+ activeTails.delete(socket.id);
224
+ });
225
+
226
+ activeTails.set(socket.id, { process: child, logFile });
227
+ }
228
+
229
+ /**
230
+ * Stop tailing a log file for a socket.
231
+ */
232
+ function stopTail(socketId) {
233
+ const entry = activeTails.get(socketId);
234
+ if (entry) {
235
+ try {
236
+ entry.process.kill();
237
+ } catch {}
238
+ activeTails.delete(socketId);
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Initialize the Socket.IO server.
244
+ */
245
+ function initSocket(httpServer) {
246
+ const io = new SocketIO(httpServer);
247
+
248
+ io.on('connection', (socket) => {
249
+ connectedClients++;
250
+
251
+ emitNginxStatus(socket);
252
+ emitCertNotifications(socket);
253
+
254
+ socket.on('logs:subscribe', ({ logFile }) => startTail(socket, logFile || 'error'));
255
+ socket.on('logs:unsubscribe', () => stopTail(socket.id));
256
+
257
+ // Send initial domain health on connect
258
+ emitDomainHealth(socket);
259
+
260
+ socket.on('disconnect', () => {
261
+ connectedClients--;
262
+ stopTail(socket.id);
263
+ });
264
+ });
265
+
266
+ // Poll domain health every 60 seconds
267
+ setInterval(() => {
268
+ if (connectedClients > 0) emitDomainHealth(io);
269
+ }, 60_000);
270
+
271
+ // Broadcast nginx status to all clients every 5 seconds
272
+ setInterval(() => {
273
+ if (connectedClients > 0) emitNginxStatus(io);
274
+ }, 5000);
275
+
276
+ // Check cert expiry every 12 hours
277
+ setInterval(() => {
278
+ if (connectedClients > 0) emitCertNotifications(io);
279
+ }, 12 * 60 * 60 * 1000);
280
+ }
281
+
282
+ export { initSocket };
@@ -473,6 +473,11 @@ animation: shimmer 1.5s ease infinite;
473
473
  .fade-enter-active, .fade-leave-active { transition: opacity 150ms ease; }
474
474
  .fade-enter-from, .fade-leave-to { opacity: 0; }
475
475
 
476
+ .notif-panel-enter-active { transition: opacity 150ms ease, transform 150ms ease; }
477
+ .notif-panel-leave-active { transition: opacity 100ms ease, transform 100ms ease; }
478
+ .notif-panel-enter-from { opacity: 0; transform: translateY(-8px) scale(0.97); }
479
+ .notif-panel-leave-to { opacity: 0; transform: translateY(-4px) scale(0.98); }
480
+
476
481
  /* Login Page Styles */
477
482
  .login-card {
478
483
  background: var(--color-surface);
@@ -618,6 +623,52 @@ class="theme-accent-circle"
618
623
  </button>
619
624
  </div>
620
625
 
626
+ <!-- Bell / Notifications -->
627
+ <div class="relative">
628
+ <button @click="toggleNotificationsPanel"
629
+ class="relative p-1.5 text-muted hover:text-foreground transition-colors rounded-lg"
630
+ :class="notifications.panelOpen ? 'text-foreground' : ''">
631
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
632
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"></path>
633
+ </svg>
634
+ <span v-if="notifications.unread > 0"
635
+ class="absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full text-[10px] font-bold flex items-center justify-center text-white"
636
+ style="background: var(--color-primary)">
637
+ {{ notifications.unread > 9 ? '9+' : notifications.unread }}
638
+ </span>
639
+ </button>
640
+
641
+ <!-- Sliding panel -->
642
+ <transition name="notif-panel">
643
+ <div v-if="notifications.panelOpen"
644
+ v-click-outside="() => { notifications.panelOpen = false; }"
645
+ class="absolute right-0 top-10 w-80 rounded-2xl border border-border shadow-2xl z-50 overflow-hidden"
646
+ style="background: var(--color-surface)">
647
+ <div class="flex items-center justify-between px-4 py-3 border-b border-border">
648
+ <span class="text-sm font-bold">Notifications</span>
649
+ <button v-if="notifications.items.length" @click="clearNotifications"
650
+ class="text-xs text-muted hover:text-foreground transition-colors">Clear all</button>
651
+ </div>
652
+ <div class="max-h-72 overflow-y-auto">
653
+ <div v-if="!notifications.items.length" class="px-4 py-6 text-center text-sm text-muted">
654
+ All clear — no notifications
655
+ </div>
656
+ <div v-for="n in notifications.items" :key="n.id"
657
+ class="flex items-start gap-3 px-4 py-3 border-b border-border last:border-0 hover:bg-primary/[0.03] transition-colors">
658
+ <span class="text-base leading-none mt-0.5">{{ notifIcon(n.type) }}</span>
659
+ <div class="flex-1 min-w-0">
660
+ <p class="text-xs font-medium leading-snug"
661
+ :class="n.severity === 'danger' ? 'text-red-400' : 'text-yellow-400'">
662
+ {{ n.message }}
663
+ </p>
664
+ <p class="text-[10px] text-muted mt-0.5">{{ new Date(n.timestamp).toLocaleTimeString() }}</p>
665
+ </div>
666
+ </div>
667
+ </div>
668
+ </div>
669
+ </transition>
670
+ </div>
671
+
621
672
  <div class="w-px h-6 border-l border-border mx-1"></div>
622
673
 
623
674
  <!-- Theme Toggle -->
@@ -638,6 +689,7 @@ class="theme-accent-circle"
638
689
  <%- include('partials/ssl-panel.ejs') %>
639
690
  <%- include('partials/domains-panel.ejs') %>
640
691
  <%- include('partials/settings-panel.ejs') %>
692
+ <%- include('partials/logs-panel.ejs') %>
641
693
  </div>
642
694
  </transition>
643
695
  </div>
@@ -324,7 +324,7 @@ Wildcard SSL requires DNS-01 validation.
324
324
  </div>
325
325
 
326
326
  <!-- Accordion Section: Advanced -->
327
- <div>
327
+ <div class="border-b border-border">
328
328
  <div @click="toggleSection('advanced')" class="flex items-center justify-between p-5 cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 transition-colors group">
329
329
  <span class="form-label !mb-0 group-hover:text-foreground transition-colors">Advanced</span>
330
330
  <svg class="w-4 h-4 text-muted transition-transform duration-200" :class="{ 'rotate-180': sections.advanced }" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /></svg>
@@ -350,6 +350,69 @@ placeholder="location /api/v2 {&#10; proxy_pass http://localhost:8080;&#10;}"></
350
350
  </div>
351
351
  </div>
352
352
 
353
+ <!-- Accordion Section: Notifications (edit mode only) -->
354
+ <div v-if="domains.editingName">
355
+ <div @click="toggleSection('notifications')" class="flex items-center justify-between p-5 cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 transition-colors group">
356
+ <span class="form-label !mb-0 group-hover:text-foreground transition-colors">Notifications</span>
357
+ <svg class="w-4 h-4 text-muted transition-transform duration-200" :class="{ 'rotate-180': sections.notifications }" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /></svg>
358
+ </div>
359
+ <div v-show="sections.notifications" class="p-6 pt-4 space-y-5 border-t border-border/50" style="background: rgba(0,0,0,0.1)">
360
+
361
+ <!-- No channels configured -->
362
+ <div v-if="channels.list.length === 0" class="p-4 border border-border/50 rounded-[12px] text-center">
363
+ <p class="text-muted text-[13px]">No channels configured —
364
+ <button type="button" @click="navigateTo('settings')" class="text-primary underline">go to Settings</button>
365
+ to add one first.</p>
366
+ </div>
367
+
368
+ <template v-else>
369
+
370
+ <!-- Port / Health -->
371
+ <div class="space-y-3">
372
+ <div class="flex items-center gap-4">
373
+ <label class="relative inline-flex items-center cursor-pointer flex-shrink-0">
374
+ <input type="checkbox" v-model="domains.form.notifications.domain_health.enabled" class="sr-only peer" />
375
+ <div class="w-8 h-4 bg-black/20 dark:bg-white/10 border border-border peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-primary"></div>
376
+ </label>
377
+ <span class="text-[13px] font-bold text-foreground">Port / Health check</span>
378
+ </div>
379
+ <div v-if="domains.form.notifications.domain_health.enabled" class="pl-10 flex flex-wrap gap-2">
380
+ <label v-for="ch in channels.list" :key="ch.id"
381
+ class="flex items-center gap-2 cursor-pointer px-3 py-1.5 rounded-[8px] border border-border/50 hover:border-primary/50 transition-colors text-[12px]">
382
+ <input type="checkbox" :value="ch.id" v-model="domains.form.notifications.domain_health.channelIds" class="w-3.5 h-3.5 text-primary" />
383
+ <span class="font-medium">{{ ch.name }}</span>
384
+ <span class="text-muted text-[10px] opacity-70">({{ ch.type }})</span>
385
+ </label>
386
+ </div>
387
+ </div>
388
+
389
+ <div class="border-t border-border/50"></div>
390
+
391
+ <!-- SSL / Certificate expiry -->
392
+ <div class="space-y-3">
393
+ <div class="flex items-center gap-4">
394
+ <label class="relative inline-flex items-center cursor-pointer flex-shrink-0">
395
+ <input type="checkbox" v-model="domains.form.notifications.cert_expiry.enabled" class="sr-only peer" />
396
+ <div class="w-8 h-4 bg-black/20 dark:bg-white/10 border border-border peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-primary"></div>
397
+ </label>
398
+ <span class="text-[13px] font-bold text-foreground">SSL / Certificate expiry</span>
399
+ </div>
400
+ <div v-if="domains.form.notifications.cert_expiry.enabled" class="pl-10 flex flex-wrap gap-2">
401
+ <label v-for="ch in channels.list" :key="ch.id"
402
+ class="flex items-center gap-2 cursor-pointer px-3 py-1.5 rounded-[8px] border border-border/50 hover:border-primary/50 transition-colors text-[12px]">
403
+ <input type="checkbox" :value="ch.id" v-model="domains.form.notifications.cert_expiry.channelIds" class="w-3.5 h-3.5 text-primary" />
404
+ <span class="font-medium">{{ ch.name }}</span>
405
+ <span class="text-muted text-[10px] opacity-70">({{ ch.type }})</span>
406
+ </label>
407
+ </div>
408
+ </div>
409
+
410
+
411
+ </template>
412
+
413
+ </div>
414
+ </div>
415
+
353
416
  </div>
354
417
  </div>
355
418
  </div>
@@ -73,6 +73,10 @@
73
73
  SSL: {{ d.daysLeft != null ? d.daysLeft + 'd' : 'Wait' }}
74
74
  </span>
75
75
  <span v-else class="badge badge-neutral">HTTP Only</span>
76
+
77
+ <!-- Backend Health Badge -->
78
+ <span v-if="domainHealth[d.name] === true" class="badge badge-success" title="Backend reachable">● Up</span>
79
+ <span v-else-if="domainHealth[d.name] === false" class="badge badge-danger" title="Backend unreachable">● Down</span>
76
80
  </div>
77
81
 
78
82
  <!-- Actions (appear on hover via .domain-actions in CSS) -->
@@ -74,7 +74,7 @@
74
74
  "
75
75
  onmouseover="this.style.transform='scale(1.05)'"
76
76
  onmouseout="this.style.transform='scale(1)'">
77
- <img src="/img/icon.png" alt="Easy DevOps" style="width: 72px; height: 72px; object-fit: contain;" />
77
+ <img src="/img/icon_b.png" alt="Easy DevOps" style="width: 72px; height: 72px; object-fit: contain;" />
78
78
  </div>
79
79
  <h1 style="
80
80
  font-size: 26px;
@@ -0,0 +1,67 @@
1
+ <!-- Logs Panel -->
2
+ <div v-if="page === 'logs'">
3
+ <div class="flex items-center justify-between mb-6">
4
+ <div>
5
+ <h2 class="text-xl font-bold text-foreground">Nginx Logs</h2>
6
+ <p class="text-sm text-muted mt-1">Live streaming — last 500 lines</p>
7
+ </div>
8
+ <div class="flex items-center gap-2">
9
+ <!-- Log file toggle -->
10
+ <div class="flex items-center gap-1 p-1 rounded-lg border border-border" style="background: var(--color-surface)">
11
+ <button @click="switchLog('error')"
12
+ class="px-3 py-1.5 text-xs font-semibold rounded-md transition-all"
13
+ :class="logs.activeLog === 'error' ? 'bg-primary text-white' : 'text-muted hover:text-foreground'">
14
+ Error
15
+ </button>
16
+ <button @click="switchLog('access')"
17
+ class="px-3 py-1.5 text-xs font-semibold rounded-md transition-all"
18
+ :class="logs.activeLog === 'access' ? 'bg-primary text-white' : 'text-muted hover:text-foreground'">
19
+ Access
20
+ </button>
21
+ </div>
22
+
23
+ <!-- Pause / Resume -->
24
+ <button @click="logs.paused = !logs.paused"
25
+ class="btn btn-secondary btn-sm flex items-center gap-1.5">
26
+ <svg v-if="!logs.paused" class="w-3.5 h-3.5" fill="currentColor" viewBox="0 0 24 24">
27
+ <path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>
28
+ </svg>
29
+ <svg v-else class="w-3.5 h-3.5" fill="currentColor" viewBox="0 0 24 24">
30
+ <path d="M8 5v14l11-7z"/>
31
+ </svg>
32
+ {{ logs.paused ? 'Resume' : 'Pause' }}
33
+ </button>
34
+
35
+ <!-- Clear -->
36
+ <button @click="logs.lines = []" class="btn btn-secondary btn-sm">Clear</button>
37
+ </div>
38
+ </div>
39
+
40
+ <!-- Live indicator -->
41
+ <div class="flex items-center gap-2 mb-3">
42
+ <div class="w-2 h-2 rounded-full" :class="logs.paused ? 'bg-yellow-500' : 'bg-green-500 animate-pulse'"></div>
43
+ <span class="text-xs text-muted font-mono">
44
+ {{ logs.paused ? 'Paused' : 'Live' }} · {{ logs.activeLog }}.log · {{ logs.lines.length }} lines
45
+ </span>
46
+ </div>
47
+
48
+ <!-- Log output -->
49
+ <div class="rounded-xl border border-border overflow-hidden" style="background: #0d0d0d">
50
+ <div
51
+ id="log-output"
52
+ class="h-[calc(100vh-280px)] overflow-y-auto p-4 font-mono text-xs leading-relaxed"
53
+ style="color: #c8d3f5"
54
+ ref="logOutput">
55
+ <div v-if="!logs.lines.length" class="text-muted italic">
56
+ Waiting for log output…
57
+ </div>
58
+ <div v-for="(line, i) in logs.lines" :key="i"
59
+ class="whitespace-pre-wrap break-all py-0.5"
60
+ :class="{
61
+ 'text-red-400': line.includes('[error]') || line.includes('[crit]') || line.includes('[emerg]'),
62
+ 'text-yellow-400': line.includes('[warn]'),
63
+ 'text-green-400': line.includes('200') || line.includes('304'),
64
+ }">{{ line }}</div>
65
+ </div>
66
+ </div>
67
+ </div>