easy-devops 1.2.0 → 1.3.0

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 (132) hide show
  1. package/README.md +97 -6
  2. package/dist/ui/assets/index-B6zdwEnG.css +1 -0
  3. package/dist/ui/assets/index-Cy0oNmul.js +442 -0
  4. package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
  5. package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
  6. package/dist/ui/brand/apple-touch-icon.png +0 -0
  7. package/dist/ui/brand/favicon-16.png +0 -0
  8. package/dist/ui/brand/favicon-32.png +0 -0
  9. package/dist/ui/brand/favicon-light-16.png +0 -0
  10. package/dist/ui/brand/favicon-light-32.png +0 -0
  11. package/dist/ui/brand/favicon.ico +0 -0
  12. package/dist/ui/brand/icon-192.png +0 -0
  13. package/dist/ui/brand/icon-48.png +0 -0
  14. package/dist/ui/brand/icon-512.png +0 -0
  15. package/dist/ui/brand/icon-64-light.png +0 -0
  16. package/dist/ui/brand/icon-64.png +0 -0
  17. package/dist/ui/brand/logo-dark.png +0 -0
  18. package/dist/ui/brand/logo-light.png +0 -0
  19. package/dist/ui/brand/mark-dark.png +0 -0
  20. package/dist/ui/brand/mark-light.png +0 -0
  21. package/dist/ui/index.html +71 -0
  22. package/install.ps1 +188 -1
  23. package/install.sh +254 -29
  24. package/package.json +17 -5
  25. package/src/cli/dash.js +110 -0
  26. package/src/cli/index.js +237 -106
  27. package/src/cli/managers/domain-manager.js +60 -40
  28. package/src/cli/managers/ssl-manager.js +47 -330
  29. package/src/cli/menu.js +156 -0
  30. package/src/cli/menus/cleanup.js +205 -0
  31. package/src/cli/menus/dashboard.js +93 -2
  32. package/src/cli/menus/runtime.js +236 -0
  33. package/src/cli/menus/service.js +764 -0
  34. package/src/cli/menus/settings.js +176 -8
  35. package/src/cli/menus/uninstall.js +167 -0
  36. package/src/cli/menus/update.js +221 -65
  37. package/src/core/acme-challenge.js +273 -0
  38. package/src/core/cert-operations.js +189 -0
  39. package/src/{dashboard/lib → core}/cert-reader.js +2 -2
  40. package/src/core/cert-renewal.js +494 -0
  41. package/src/core/channels/discord.js +77 -0
  42. package/src/core/channels/telegram.js +120 -0
  43. package/src/core/cleanup.js +600 -0
  44. package/src/core/config.js +169 -2
  45. package/src/core/daemon/ipc.js +292 -0
  46. package/src/core/daemon/lock.js +294 -0
  47. package/src/core/daemon/run.js +241 -0
  48. package/src/core/daemon/stopRequest.js +162 -0
  49. package/src/core/db.js +44 -8
  50. package/src/core/deploy/apps.js +491 -0
  51. package/src/core/deploy/domainLink.js +200 -0
  52. package/src/core/deploy/engine.js +973 -0
  53. package/src/core/deploy/ezfile.js +361 -0
  54. package/src/core/deploy/github.js +239 -0
  55. package/src/core/deploy/githubApi.js +261 -0
  56. package/src/core/deploy/hookServer.js +325 -0
  57. package/src/core/deploy/hubCommands.js +267 -0
  58. package/src/core/deploy/launcher.js +57 -0
  59. package/src/core/deploy/status.js +91 -0
  60. package/src/core/deploy/store.js +398 -0
  61. package/src/core/domainNotifier.js +364 -0
  62. package/src/core/domains-db.js +234 -0
  63. package/src/core/events.js +222 -0
  64. package/src/core/hub/agent.js +842 -0
  65. package/src/core/hubLink.js +306 -0
  66. package/src/core/hubPermissions.js +430 -0
  67. package/src/core/installSource.js +162 -0
  68. package/src/core/jobs/bus.js +120 -0
  69. package/src/core/jobs/index.js +371 -0
  70. package/src/core/jobs/monitors.js +368 -0
  71. package/src/core/jobs/owner.js +217 -0
  72. package/src/core/jobs/revisionWatcher.js +106 -0
  73. package/src/core/nginx-apply.js +213 -0
  74. package/src/core/nginx-conf-generator.js +253 -17
  75. package/src/{dashboard/lib → core}/nginx-service.js +18 -9
  76. package/src/core/notifications/claim.js +214 -0
  77. package/src/core/notifications/dispatch.js +154 -0
  78. package/src/core/notifier.js +103 -0
  79. package/src/core/passwords.js +172 -0
  80. package/src/core/permissions.js +8 -4
  81. package/src/core/platform.js +709 -2
  82. package/src/core/probeCache.js +258 -0
  83. package/src/core/purge.js +372 -0
  84. package/src/core/runner.js +488 -0
  85. package/src/core/service/acl.js +226 -0
  86. package/src/core/service/dataDir.js +345 -0
  87. package/src/core/service/index.js +1128 -0
  88. package/src/core/service/legacy.js +218 -0
  89. package/src/core/service/runtime.js +446 -0
  90. package/src/core/service/runtimeUpdate.js +800 -0
  91. package/src/core/service/systemd.js +458 -0
  92. package/src/core/service/windowsPersonal.js +530 -0
  93. package/src/core/service/windowsService.js +576 -0
  94. package/src/core/service/winsw.js +260 -0
  95. package/src/core/setupCode.js +331 -0
  96. package/src/core/shell.js +128 -13
  97. package/src/core/ssl-issuer.js +627 -0
  98. package/src/core/updater.js +295 -0
  99. package/src/core/validators.js +99 -0
  100. package/src/dashboard/controllers/authController.js +316 -0
  101. package/src/dashboard/controllers/deploymentsController.js +479 -0
  102. package/src/dashboard/controllers/domainsController.js +403 -0
  103. package/src/dashboard/controllers/hubController.js +135 -0
  104. package/src/dashboard/controllers/nginxController.js +146 -0
  105. package/src/dashboard/controllers/processesController.js +368 -0
  106. package/src/dashboard/controllers/settingsController.js +503 -0
  107. package/src/dashboard/controllers/sslController.js +452 -0
  108. package/src/dashboard/lib/daemonBridge.js +163 -0
  109. package/src/dashboard/lib/localRequest.js +235 -0
  110. package/src/dashboard/lib/loginRateLimit.js +119 -0
  111. package/src/dashboard/lib/requireAuth.js +80 -0
  112. package/src/dashboard/public/img/icon.png +0 -0
  113. package/src/dashboard/public/img/icon_b.png +0 -0
  114. package/src/dashboard/public/js/app.js +595 -19
  115. package/src/dashboard/routes/auth.js +14 -33
  116. package/src/dashboard/routes/deployments.js +46 -0
  117. package/src/dashboard/routes/domains.js +20 -363
  118. package/src/dashboard/routes/hub.js +22 -0
  119. package/src/dashboard/routes/nginx.js +22 -146
  120. package/src/dashboard/routes/processes.js +29 -0
  121. package/src/dashboard/routes/settings.js +25 -232
  122. package/src/dashboard/routes/ssl.js +18 -276
  123. package/src/dashboard/server.js +279 -165
  124. package/src/dashboard/socketManager.js +246 -0
  125. package/src/dashboard/views/index.ejs +1 -0
  126. package/src/dashboard/views/partials/domain-form.ejs +64 -1
  127. package/src/dashboard/views/partials/login.ejs +69 -8
  128. package/src/dashboard/views/partials/processes-panel.ejs +261 -0
  129. package/src/dashboard/views/partials/settings-panel.ejs +549 -118
  130. package/src/dashboard/views/partials/sidebar.ejs +3 -1
  131. package/src/dashboard/lib/domains-db.js +0 -51
  132. /package/src/{dashboard/routes → core/channels}/.gitkeep +0 -0
@@ -0,0 +1,246 @@
1
+ /**
2
+ * dashboard/socketManager.js
3
+ *
4
+ * The browser-facing Socket.io layer. It no longer DOES any monitoring.
5
+ *
6
+ * It used to: nginx polling, domain health probes, certificate checks and the
7
+ * notification decisions all lived here, driven by intervals that only ran
8
+ * while a browser was connected. That is why none of it worked without an open
9
+ * dashboard, and why it could not move into a service.
10
+ *
11
+ * All of it now lives in core/jobs/, runs in whichever process owns the jobs,
12
+ * and arrives here as events on core/jobs/bus.js — published either by the
13
+ * monitors in this process, or by the daemon over IPC and republished onto the
14
+ * bus by dashboard/lib/daemonBridge.js. This module's whole job is to forward
15
+ * them to connected browsers unchanged, which is why the bus uses the names
16
+ * and payloads from docs/api-contract.md.
17
+ *
18
+ * What is still genuinely socket work and stays here: the session and
19
+ * local-request guards on the handshake, and the live log tails — a tail exists
20
+ * only for a client that is watching it, and dies with that client.
21
+ */
22
+
23
+ import { spawn } from 'child_process';
24
+ import { Server as SocketIO } from 'socket.io';
25
+
26
+ import { socketRequireAuth } from './lib/requireAuth.js';
27
+ import { socketRequireLocalRequest } from './lib/localRequest.js';
28
+ import { loadConfig } from '../core/config.js';
29
+ import { nginxLogPath } from '../core/platform.js';
30
+ import { publish, subscribeAll } from '../core/jobs/bus.js';
31
+
32
+ let connectedClients = 0;
33
+ const activeTails = new Map();
34
+
35
+ let ioServer = null;
36
+ let unsubscribeBus = null;
37
+
38
+ /**
39
+ * The most recent payload for each replayable event.
40
+ *
41
+ * A newly opened tab has to show something immediately. The monitors publish
42
+ * on their own schedule — domain health every 60 seconds — so without this a
43
+ * tab opened just after a poll would sit empty until the next one. Previously
44
+ * the fix was to run a fresh poll per connection; that does not work when the
45
+ * polling happens in another process, and it meant every opened tab triggered
46
+ * real work.
47
+ *
48
+ * `service:changed` is cached for the same reason, and matters more: a tab
49
+ * that opens while the daemon is already running must render the banner right
50
+ * away rather than waiting for the next hand-over to tell it anything.
51
+ *
52
+ * Only the state-like events are cached. `notification:new` is not: it is a
53
+ * discrete thing that happened, and replaying old notifications into each new
54
+ * tab would announce outages that are long over.
55
+ */
56
+ const REPLAYABLE = ['nginx:status', 'domain:health', 'service:changed'];
57
+ const lastKnown = new Map();
58
+
59
+ /**
60
+ * Initialize the Socket.IO server.
61
+ *
62
+ * @param {import('http').Server} httpServer
63
+ * @param {Function} sessionMiddleware Shared with Express so sockets see the same session
64
+ * @param {Function} getBinding Returns the current { port, bindAddress }
65
+ * @returns {import('socket.io').Server}
66
+ */
67
+ function initSocket(httpServer, sessionMiddleware, getBinding) {
68
+ const io = new SocketIO(httpServer);
69
+ ioServer = io;
70
+
71
+ // The socket stream is not a lesser surface than the REST API: it carries
72
+ // nginx status, domain health and live log tails. It gets the same session
73
+ // check.
74
+ //
75
+ // `io.engine.use` runs the express-session middleware on the handshake
76
+ // request, which is what puts `socket.request.session` in place for
77
+ // socketRequireAuth to read. Without the middleware there is no session
78
+ // object at all, and the guard then refuses every connection — which is the
79
+ // correct direction to fail, but would break the dashboard, so it is worth
80
+ // noticing rather than shipping.
81
+ if (typeof sessionMiddleware === 'function') {
82
+ io.engine.use(sessionMiddleware);
83
+ } else {
84
+ console.error('[socketManager] no session middleware supplied — refusing all socket connections');
85
+ }
86
+
87
+ // Host / Origin / X-EZ-Request, before the session check — the handshake is
88
+ // as reachable from a hostile page as any POST is, and a socket has no
89
+ // "safe method", so the custom header is required unconditionally.
90
+ //
91
+ // This is why the browser client must NOT force transports: ['websocket']:
92
+ // browsers cannot set headers on a WebSocket upgrade. socket.io's default
93
+ // starts with HTTP polling, where extraHeaders does apply, and the
94
+ // handshake is authenticated there before any upgrade happens.
95
+ if (typeof getBinding === 'function') {
96
+ io.use(socketRequireLocalRequest(getBinding));
97
+ } else {
98
+ console.error('[socketManager] no binding supplied — refusing all socket connections');
99
+ io.use((socket, next) => next(new Error('FORBIDDEN')));
100
+ }
101
+
102
+ io.use(socketRequireAuth);
103
+
104
+ // One subscription for the whole server, not one per client: these events are
105
+ // broadcasts, and subscribing per socket would deliver each one as many times
106
+ // as there are tabs open.
107
+ unsubscribeBus = subscribeAll((event, payload) => {
108
+ if (REPLAYABLE.includes(event)) lastKnown.set(event, payload);
109
+ if (connectedClients > 0) io.emit(event, payload);
110
+ });
111
+
112
+ io.on('connection', (socket) => {
113
+ connectedClients++;
114
+
115
+ // Whatever we last heard, so the UI renders immediately instead of waiting
116
+ // for the next poll in whichever process owns the jobs.
117
+ for (const event of REPLAYABLE) {
118
+ if (lastKnown.has(event)) socket.emit(event, lastKnown.get(event));
119
+ }
120
+
121
+ socket.on('logs:subscribe', ({ logFile } = {}) => startTail(socket, logFile || 'error'));
122
+ socket.on('logs:unsubscribe', () => stopTail(socket.id));
123
+
124
+ socket.on('disconnect', () => {
125
+ connectedClients--;
126
+ stopTail(socket.id);
127
+ });
128
+ });
129
+
130
+ return io;
131
+ }
132
+
133
+ // ─── Live log tails ───────────────────────────────────────────────────────────
134
+
135
+ /**
136
+ * Starts tailing a log file for one socket.
137
+ *
138
+ * `-n 50` / `-Tail 50` is what satisfies the contract's promise that a
139
+ * subscribe replays the last 50 lines before streaming: the tail command does
140
+ * both in one call, so there is no window between the replay and the live
141
+ * stream in which a line could be missed.
142
+ */
143
+ function startTail(socket, logFile) {
144
+ stopTail(socket.id);
145
+
146
+ const { nginxDir } = loadConfig();
147
+ const logPath = nginxLogPath(nginxDir, logFile === 'access' ? 'access' : 'error');
148
+
149
+ const args = process.platform === 'win32'
150
+ ? ['Get-Content', '-Path', logPath, '-Wait', '-Tail', '50']
151
+ : ['-n', '50', '-f', logPath];
152
+ const cmd = process.platform === 'win32' ? 'powershell' : 'tail';
153
+
154
+ const child = spawn(cmd, args, {
155
+ stdio: ['ignore', 'pipe', 'ignore'],
156
+ windowsHide: true,
157
+ });
158
+
159
+ let buf = '';
160
+ child.stdout.on('data', (chunk) => {
161
+ buf += chunk.toString();
162
+ const lines = buf.split('\n');
163
+ buf = lines.pop(); // keep the incomplete line in the buffer
164
+ for (const line of lines) {
165
+ if (line.trim()) socket.emit('logs:line', { line: line.trim(), logFile });
166
+ }
167
+ });
168
+
169
+ child.on('error', () => {});
170
+ child.on('close', () => {
171
+ activeTails.delete(socket.id);
172
+ });
173
+
174
+ activeTails.set(socket.id, { process: child, logFile });
175
+ }
176
+
177
+ /** Stops the tail belonging to one socket. */
178
+ function stopTail(socketId) {
179
+ const entry = activeTails.get(socketId);
180
+ if (entry) {
181
+ try {
182
+ entry.process.kill();
183
+ } catch {}
184
+ activeTails.delete(socketId);
185
+ }
186
+ }
187
+
188
+ // ─── Outbound helper ──────────────────────────────────────────────────────────
189
+
190
+ /**
191
+ * Tells every open dashboard tab that a section changed, so the UI can refresh
192
+ * just that part instead of reloading the page.
193
+ *
194
+ * Used when a change did NOT originate in this browser — most importantly when
195
+ * the Hub applies a command through core/hub/agent.js, or when another process
196
+ * moves the revision counter.
197
+ *
198
+ * It publishes to the job bus rather than emitting at the socket server
199
+ * directly, so the same call works in the daemon, which has no socket server,
200
+ * and still reaches browsers through IPC. Safe to call before initSocket().
201
+ *
202
+ * @param {'domains'|'ssl'|'nginx'|'settings'} section
203
+ * @param {Object} [detail] Optional extra context for the client
204
+ */
205
+ function emitLocalChange(section, detail = {}) {
206
+ publish('local:changed', { section, source: 'hub', at: Date.now(), ...detail });
207
+ }
208
+
209
+ /**
210
+ * Stops everything initSocket() started: the bus subscription, every active
211
+ * log tail (each is a spawned child process), and the Socket.io server itself.
212
+ * Safe to call more than once.
213
+ *
214
+ * It does NOT stop the background jobs — server.js owns those, because their
215
+ * lifetime is the process's, not the socket server's.
216
+ *
217
+ * @returns {Promise<void>} Resolves once the Socket.io server has closed
218
+ */
219
+ async function stopSocket() {
220
+ if (unsubscribeBus) {
221
+ unsubscribeBus();
222
+ unsubscribeBus = null;
223
+ }
224
+
225
+ // Kill the tail/Get-Content children; stopTail() removes each map entry.
226
+ for (const socketId of [...activeTails.keys()]) stopTail(socketId);
227
+
228
+ connectedClients = 0;
229
+ lastKnown.clear();
230
+
231
+ const io = ioServer;
232
+ ioServer = null;
233
+ if (!io) return;
234
+
235
+ await new Promise((resolve) => {
236
+ // close() disconnects clients and stops accepting new ones. It is given a
237
+ // short grace period so a wedged client cannot block shutdown.
238
+ const done = setTimeout(resolve, 2000);
239
+ io.close(() => {
240
+ clearTimeout(done);
241
+ resolve();
242
+ });
243
+ });
244
+ }
245
+
246
+ export { initSocket, stopSocket, emitLocalChange };
@@ -689,6 +689,7 @@ class="theme-accent-circle"
689
689
  <%- include('partials/ssl-panel.ejs') %>
690
690
  <%- include('partials/domains-panel.ejs') %>
691
691
  <%- include('partials/settings-panel.ejs') %>
692
+ <%- include('partials/processes-panel.ejs') %>
692
693
  <%- include('partials/logs-panel.ejs') %>
693
694
  </div>
694
695
  </transition>
@@ -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>
@@ -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;
@@ -95,7 +95,34 @@
95
95
 
96
96
  <!-- Login Card -->
97
97
  <div class="login-card w-full text-left" style="animation: card-enter 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;">
98
- <div class="mb-6">
98
+ <!--
99
+ First run: no password exists yet, so the only thing on offer is
100
+ setting one. There is deliberately no way to skip this — an empty
101
+ password used to be a valid login.
102
+ -->
103
+ <template v-if="login.needsSetup">
104
+ <p style="
105
+ font-size: 13px; color: var(--color-muted);
106
+ margin-top: 0; margin-bottom: 20px; font-weight: 500; line-height: 1.6;
107
+ ">
108
+ No dashboard password is set yet. Choose one to protect this dashboard —
109
+ at least {{ login.minLength }} characters.
110
+ </p>
111
+
112
+ <div class="mb-4">
113
+ <label class="login-label">New password</label>
114
+ <input v-model="login.password" type="password" class="login-input"
115
+ :placeholder="'At least ' + login.minLength + ' characters'" @keyup.enter="doSetup" />
116
+ </div>
117
+
118
+ <div class="mb-6">
119
+ <label class="login-label">Confirm password</label>
120
+ <input v-model="login.confirm" type="password" class="login-input"
121
+ placeholder="Repeat the password" @keyup.enter="doSetup" />
122
+ </div>
123
+ </template>
124
+
125
+ <div v-else class="mb-6">
99
126
  <label class="login-label">Password</label>
100
127
  <input v-model="login.password" type="password" class="login-input" placeholder="Enter dashboard password" @keyup.enter="doLogin" />
101
128
  </div>
@@ -113,18 +140,52 @@
113
140
  {{ login.error }}
114
141
  </div>
115
142
 
116
- <button @click="doLogin" :disabled="login.loading" class="login-btn gap-2">
143
+ <button v-if="login.needsSetup" @click="doSetup" :disabled="login.loading" class="login-btn gap-2">
117
144
  <svg v-if="login.loading" class="w-4 h-4 animate-spin inline-block -ml-1" fill="none" viewBox="0 0 24 24">
118
145
  <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
119
146
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
120
147
  </svg>
121
- {{ login.loading ? 'Signing in...' : 'Sign In' }}
148
+ {{ login.loading ? 'Saving...' : 'Set a password' }}
122
149
  </button>
123
150
 
124
- <p style="
125
- text-align: center; font-size: 12px; color: var(--color-muted);
126
- margin-top: 24px; margin-bottom: 0; font-weight: 500;
127
- ">No password set? Leave blank and press Sign In.</p>
151
+ <!--
152
+ Shown only when the server says so: the dashboard must listen on this
153
+ machine only AND this page must have been opened from this machine.
154
+ Anywhere else the option does not appear at all.
155
+ -->
156
+ <template v-if="login.needsSetup && login.canUseNoPassword">
157
+ <div style="
158
+ display: flex; align-items: center; gap: 12px;
159
+ margin: 20px 0 16px; color: var(--color-muted);
160
+ font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
161
+ ">
162
+ <span style="flex: 1; height: 1px; background: var(--color-border);"></span>
163
+ or
164
+ <span style="flex: 1; height: 1px; background: var(--color-border);"></span>
165
+ </div>
166
+
167
+ <button @click="doSetupNoPassword" :disabled="login.loading"
168
+ class="login-btn gap-2"
169
+ style="background: transparent; border: 1px solid var(--color-border); color: var(--color-foreground);">
170
+ No password (this machine only)
171
+ </button>
172
+
173
+ <p style="
174
+ text-align: center; font-size: 11px; color: var(--color-muted);
175
+ margin-top: 12px; margin-bottom: 0; font-weight: 500; line-height: 1.6;
176
+ ">
177
+ The dashboard stays reachable from this computer only. You can set a
178
+ password later in Settings.
179
+ </p>
180
+ </template>
181
+
182
+ <button v-else @click="doLogin" :disabled="login.loading" class="login-btn gap-2">
183
+ <svg v-if="login.loading" class="w-4 h-4 animate-spin inline-block -ml-1" fill="none" viewBox="0 0 24 24">
184
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
185
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
186
+ </svg>
187
+ {{ login.loading ? 'Signing in...' : 'Sign In' }}
188
+ </button>
128
189
  </div>
129
190
 
130
191
  <!-- Bottom Theme Controls (Pill) -->