dsh-server-ops-agent 0.0.0-stage → 0.4.0-beta.5
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.
- package/DSH-Linux-/351/246/226/346/254/241/350/277/236/346/216/245.md +96 -0
- package/LICENSE +21 -0
- package/README.md +91 -2
- package/cordis.patch.yml +12 -0
- package/dist/client.js +4102 -0
- package/dist/plugin.d.ts +436 -0
- package/dist/plugin.js +18377 -0
- package/dist/server.js +5094 -0
- package/dist/workspace-tool.d.ts +362 -0
- package/dist/workspace-tool.js +1047 -0
- package/docs/distribution.md +75 -0
- package/docs/v0.4-migration-audit.md +53 -0
- package/generated/linux-release.json +28 -0
- package/generated/linux-release.sha256 +1 -0
- package/generated/linux-release.tgz +0 -0
- package/generated/ssh-licenses.txt +158 -0
- package/package.json +126 -4
package/dist/client.js
ADDED
|
@@ -0,0 +1,4102 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: 'dsh-server-ops-agent', factory(require) { const module = { exports: {} }; const exports = module.exports;
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
let react = require("react");
|
|
24
|
+
react = __toESM(react);
|
|
25
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
27
|
+
|
|
28
|
+
function getClientHeader() {
|
|
29
|
+
if (typeof window !== "undefined" && window.location?.protocol === "dsh-app:" && window.location?.hostname === "app") return "desktop";
|
|
30
|
+
return "1";
|
|
31
|
+
}
|
|
32
|
+
function unwrapPayload(raw) {
|
|
33
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
34
|
+
const rec = raw;
|
|
35
|
+
if (rec.ok === false && typeof rec.error === "string") throw new Error(rec.error);
|
|
36
|
+
if (rec.ok === true && "data" in rec && rec.data !== void 0 && "protocolVersion" in rec) return rec.data;
|
|
37
|
+
}
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
function normalizeConnectionStatus(raw) {
|
|
41
|
+
if (!raw || typeof raw !== "object") return {
|
|
42
|
+
active: null,
|
|
43
|
+
servers: []
|
|
44
|
+
};
|
|
45
|
+
const rec = raw;
|
|
46
|
+
const active = typeof rec.active === "string" ? rec.active : null;
|
|
47
|
+
const rawServers = rec.servers;
|
|
48
|
+
const servers = [];
|
|
49
|
+
if (Array.isArray(rawServers)) {
|
|
50
|
+
for (const item of rawServers) if (item && typeof item === "object") {
|
|
51
|
+
const s = item;
|
|
52
|
+
const cfg = s.config && typeof s.config === "object" ? s.config : s;
|
|
53
|
+
const serverId = String(s.serverId ?? s.id ?? "");
|
|
54
|
+
if (!serverId) continue;
|
|
55
|
+
servers.push({
|
|
56
|
+
serverId,
|
|
57
|
+
host: String(s.host ?? cfg.host ?? serverId),
|
|
58
|
+
port: Number(cfg.port ?? 22),
|
|
59
|
+
username: String(cfg.username ?? cfg.user ?? "root"),
|
|
60
|
+
fingerprint: typeof cfg.fingerprint === "string" ? cfg.fingerprint : void 0,
|
|
61
|
+
keyPath: typeof cfg.keyPath === "string" ? cfg.keyPath : void 0,
|
|
62
|
+
lastConnectedAt: typeof s.lastConnectedAt === "number" ? s.lastConnectedAt : null,
|
|
63
|
+
lastSyncedAt: typeof s.lastSyncedAt === "number" ? s.lastSyncedAt : null
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} else if (rawServers && typeof rawServers === "object") for (const [key, val] of Object.entries(rawServers)) {
|
|
67
|
+
if (!val || typeof val !== "object") continue;
|
|
68
|
+
const s = val;
|
|
69
|
+
const cfg = s.config && typeof s.config === "object" ? s.config : s;
|
|
70
|
+
servers.push({
|
|
71
|
+
serverId: String(s.serverId ?? key),
|
|
72
|
+
host: String(s.host ?? cfg.host ?? key),
|
|
73
|
+
port: Number(cfg.port ?? 22),
|
|
74
|
+
username: String(cfg.username ?? cfg.user ?? "root"),
|
|
75
|
+
fingerprint: typeof cfg.fingerprint === "string" ? cfg.fingerprint : void 0,
|
|
76
|
+
keyPath: typeof cfg.keyPath === "string" ? cfg.keyPath : void 0,
|
|
77
|
+
lastConnectedAt: typeof s.lastConnectedAt === "number" ? s.lastConnectedAt : null,
|
|
78
|
+
lastSyncedAt: typeof s.lastSyncedAt === "number" ? s.lastSyncedAt : null
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
active: active ?? servers[0]?.serverId ?? null,
|
|
83
|
+
servers
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function createHttpOpsApi(endpoint = "/server-operations/api") {
|
|
87
|
+
async function request(action, data = {}, serverId) {
|
|
88
|
+
const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
89
|
+
const timeoutMs = action === "overview" ? 32e3 : action === "overview-cached" ? 5e3 : 25e3;
|
|
90
|
+
const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
91
|
+
try {
|
|
92
|
+
const res = await fetch(endpoint, {
|
|
93
|
+
method: "POST",
|
|
94
|
+
cache: "no-store",
|
|
95
|
+
signal: controller?.signal,
|
|
96
|
+
headers: {
|
|
97
|
+
"content-type": "application/json",
|
|
98
|
+
"x-server-ops": getClientHeader()
|
|
99
|
+
},
|
|
100
|
+
body: JSON.stringify({
|
|
101
|
+
action,
|
|
102
|
+
data,
|
|
103
|
+
serverId
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
const parsed = await res.json().catch(() => ({}));
|
|
107
|
+
if (!res.ok) {
|
|
108
|
+
const errMsg = parsed && typeof parsed === "object" && typeof parsed.error === "string" ? String(parsed.error) : `请求 ${action} 失败(HTTP ${res.status})`;
|
|
109
|
+
throw new Error(errMsg);
|
|
110
|
+
}
|
|
111
|
+
return unwrapPayload(parsed);
|
|
112
|
+
} finally {
|
|
113
|
+
if (timer) clearTimeout(timer);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
request,
|
|
118
|
+
async getConnectionStatus() {
|
|
119
|
+
return normalizeConnectionStatus(await request("connection-status"));
|
|
120
|
+
},
|
|
121
|
+
probeFingerprint(host, port) {
|
|
122
|
+
return request("connection-fingerprint", {
|
|
123
|
+
host,
|
|
124
|
+
port
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
async addConnection(input) {
|
|
128
|
+
const raw = await request("connection-add", {
|
|
129
|
+
host: input.host,
|
|
130
|
+
port: input.port ?? 22,
|
|
131
|
+
user: input.username,
|
|
132
|
+
username: input.username,
|
|
133
|
+
fingerprint: input.fingerprint,
|
|
134
|
+
...input.keyPath ? { keyPath: input.keyPath } : {}
|
|
135
|
+
});
|
|
136
|
+
const status = normalizeConnectionStatus(raw.status ?? raw);
|
|
137
|
+
const installCmd = typeof raw.installCommand === "string" ? raw.installCommand : typeof raw.instructions === "string" ? raw.instructions : typeof raw.command === "string" ? raw.command : typeof raw.manualCommand === "string" ? raw.manualCommand : void 0;
|
|
138
|
+
return {
|
|
139
|
+
status,
|
|
140
|
+
serverId: typeof raw.added === "string" ? raw.added : typeof raw.serverId === "string" ? raw.serverId : status.active ?? void 0,
|
|
141
|
+
needsInstall: Boolean(raw.needsDeploy ?? raw.needsInstall),
|
|
142
|
+
installCommand: installCmd,
|
|
143
|
+
probe: raw.probe
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
async selectConnection(serverId) {
|
|
147
|
+
return normalizeConnectionStatus(await request("connection-select", { serverId }));
|
|
148
|
+
},
|
|
149
|
+
async removeConnection(serverId) {
|
|
150
|
+
return normalizeConnectionStatus(await request("connection-remove", { serverId }));
|
|
151
|
+
},
|
|
152
|
+
reconnect(serverId) {
|
|
153
|
+
return request("connection-reconnect", { serverId }, serverId);
|
|
154
|
+
},
|
|
155
|
+
async getOverviewCached(serverId) {
|
|
156
|
+
try {
|
|
157
|
+
const res = await request("overview-cached", {}, serverId);
|
|
158
|
+
if (!res) return null;
|
|
159
|
+
if (typeof res === "object" && "overview" in res) return res.overview ?? null;
|
|
160
|
+
return res;
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
getOverview(serverId) {
|
|
166
|
+
return request("overview", {}, serverId);
|
|
167
|
+
},
|
|
168
|
+
getServiceInfo(serverId) {
|
|
169
|
+
return request("service-info", {}, serverId);
|
|
170
|
+
},
|
|
171
|
+
getResourceHistory(req, serverId) {
|
|
172
|
+
return request("resource-history", req, serverId);
|
|
173
|
+
},
|
|
174
|
+
getActivityList(req = {}, serverId) {
|
|
175
|
+
return request("activity-list", req, serverId);
|
|
176
|
+
},
|
|
177
|
+
getIncidentDetail(id, serverId) {
|
|
178
|
+
return request("incident-detail", { id }, serverId);
|
|
179
|
+
},
|
|
180
|
+
getReportDetail(req, serverId) {
|
|
181
|
+
return request("report-detail", req, serverId);
|
|
182
|
+
},
|
|
183
|
+
getVaultStatus(serverId) {
|
|
184
|
+
return request("vault.status", {}, serverId);
|
|
185
|
+
},
|
|
186
|
+
getSnapshotList(req = {}, serverId) {
|
|
187
|
+
return request("snapshot.list", req, serverId);
|
|
188
|
+
},
|
|
189
|
+
browseSnapshots(req, serverId) {
|
|
190
|
+
return request("browse", req, serverId);
|
|
191
|
+
},
|
|
192
|
+
diffSnapshots(req, serverId) {
|
|
193
|
+
return request("diff", req, serverId);
|
|
194
|
+
},
|
|
195
|
+
previewRestore(req, serverId) {
|
|
196
|
+
return request("restore.preview", req, serverId);
|
|
197
|
+
},
|
|
198
|
+
executeRestore(req, serverId) {
|
|
199
|
+
return request("restore", req, serverId);
|
|
200
|
+
},
|
|
201
|
+
triggerSnapshotNow(req = {}, serverId) {
|
|
202
|
+
return request("snapshot.now", req, serverId);
|
|
203
|
+
},
|
|
204
|
+
retryVault(req, serverId) {
|
|
205
|
+
return request("vault.retry", req, serverId);
|
|
206
|
+
},
|
|
207
|
+
getJobStatus(jobId, serverId) {
|
|
208
|
+
return request("job.status", { jobId }, serverId);
|
|
209
|
+
},
|
|
210
|
+
getJobList(req = {}, serverId) {
|
|
211
|
+
return request("job.list", req, serverId);
|
|
212
|
+
},
|
|
213
|
+
getAgentModels() {
|
|
214
|
+
return request("agent-models");
|
|
215
|
+
},
|
|
216
|
+
setAgentModel(selection) {
|
|
217
|
+
return request("agent-model", { selection });
|
|
218
|
+
},
|
|
219
|
+
prepareAgentWorkspace(serverId, host) {
|
|
220
|
+
return request("agent-workspace", {
|
|
221
|
+
serverId,
|
|
222
|
+
host
|
|
223
|
+
}, serverId);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
async function openNativeOpsAgent(dshClient, api, serverId, host) {
|
|
228
|
+
const ws = await api.prepareAgentWorkspace(serverId, host);
|
|
229
|
+
if (dshClient?.sessions?.refresh) await dshClient.sessions.refresh().catch(() => {});
|
|
230
|
+
if (dshClient?.sessions?.create && dshClient?.uiWorkspace?.openSession) {
|
|
231
|
+
const sessionId = await dshClient.sessions.create({
|
|
232
|
+
workspaceId: ws.workspaceId,
|
|
233
|
+
agentPreset: "server-ops-chat"
|
|
234
|
+
});
|
|
235
|
+
await api.request("agent-workspace-model", {
|
|
236
|
+
host: ws.host,
|
|
237
|
+
session: sessionId
|
|
238
|
+
}, serverId).catch(() => {});
|
|
239
|
+
await dshClient.uiWorkspace.openSession(sessionId);
|
|
240
|
+
return {
|
|
241
|
+
workspaceId: ws.workspaceId,
|
|
242
|
+
sessionId
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (dshClient?.uiWorkspace?.openWorkspace) await dshClient.uiWorkspace.openWorkspace(ws.workspaceId);
|
|
246
|
+
return { workspaceId: ws.workspaceId };
|
|
247
|
+
}
|
|
248
|
+
function createFixtureOpsApi(fixture) {
|
|
249
|
+
const serverRecord = {
|
|
250
|
+
serverId: fixture.overview.serverId,
|
|
251
|
+
host: fixture.overview.hostname,
|
|
252
|
+
port: 22,
|
|
253
|
+
username: "ops",
|
|
254
|
+
fingerprint: "SHA256:exampleFixtureFingerprint0123456789abc",
|
|
255
|
+
lastConnectedAt: fixture.overview.collectedAt,
|
|
256
|
+
lastSyncedAt: fixture.overview.collectedAt
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
async request() {
|
|
260
|
+
return {};
|
|
261
|
+
},
|
|
262
|
+
async getConnectionStatus() {
|
|
263
|
+
return {
|
|
264
|
+
active: serverRecord.serverId,
|
|
265
|
+
servers: [serverRecord]
|
|
266
|
+
};
|
|
267
|
+
},
|
|
268
|
+
async probeFingerprint(host, port) {
|
|
269
|
+
return {
|
|
270
|
+
host,
|
|
271
|
+
port,
|
|
272
|
+
fingerprint: "SHA256:probedExampleFingerprint0123456789"
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
async addConnection() {
|
|
276
|
+
return {
|
|
277
|
+
status: {
|
|
278
|
+
active: serverRecord.serverId,
|
|
279
|
+
servers: [serverRecord]
|
|
280
|
+
},
|
|
281
|
+
serverId: serverRecord.serverId
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
async selectConnection() {
|
|
285
|
+
return {
|
|
286
|
+
active: serverRecord.serverId,
|
|
287
|
+
servers: [serverRecord]
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
async removeConnection() {
|
|
291
|
+
return {
|
|
292
|
+
active: null,
|
|
293
|
+
servers: []
|
|
294
|
+
};
|
|
295
|
+
},
|
|
296
|
+
async reconnect() {
|
|
297
|
+
return { ok: true };
|
|
298
|
+
},
|
|
299
|
+
async getOverviewCached() {
|
|
300
|
+
return fixture.overview;
|
|
301
|
+
},
|
|
302
|
+
async getOverview() {
|
|
303
|
+
return fixture.overview;
|
|
304
|
+
},
|
|
305
|
+
async getServiceInfo() {
|
|
306
|
+
return fixture.serviceInfo;
|
|
307
|
+
},
|
|
308
|
+
async getResourceHistory() {
|
|
309
|
+
return fixture.resourceHistory;
|
|
310
|
+
},
|
|
311
|
+
async getActivityList() {
|
|
312
|
+
return fixture.activityList;
|
|
313
|
+
},
|
|
314
|
+
async getIncidentDetail() {
|
|
315
|
+
if (!fixture.incidentDetail) throw new Error("未找到事件详情");
|
|
316
|
+
return fixture.incidentDetail;
|
|
317
|
+
},
|
|
318
|
+
async getReportDetail() {
|
|
319
|
+
if (!fixture.reportDetail) throw new Error("未找到日报详情");
|
|
320
|
+
return fixture.reportDetail;
|
|
321
|
+
},
|
|
322
|
+
async getVaultStatus() {
|
|
323
|
+
return fixture.vaultStatus;
|
|
324
|
+
},
|
|
325
|
+
async getSnapshotList() {
|
|
326
|
+
return fixture.snapshotList;
|
|
327
|
+
},
|
|
328
|
+
async browseSnapshots() {
|
|
329
|
+
return fixture.browse;
|
|
330
|
+
},
|
|
331
|
+
async diffSnapshots() {
|
|
332
|
+
return fixture.diff;
|
|
333
|
+
},
|
|
334
|
+
async previewRestore() {
|
|
335
|
+
if (!fixture.restorePreview) throw new Error("当前场景无恢复预览");
|
|
336
|
+
return fixture.restorePreview;
|
|
337
|
+
},
|
|
338
|
+
async executeRestore() {
|
|
339
|
+
return fixture.jobs[0] ?? {
|
|
340
|
+
jobId: "job-restore-fixture",
|
|
341
|
+
kind: "restore",
|
|
342
|
+
state: "queued",
|
|
343
|
+
createdAt: Math.floor(Date.now() / 1e3)
|
|
344
|
+
};
|
|
345
|
+
},
|
|
346
|
+
async triggerSnapshotNow() {
|
|
347
|
+
return {
|
|
348
|
+
jobId: "job-snapshot-fixture",
|
|
349
|
+
kind: "snapshot",
|
|
350
|
+
state: "queued",
|
|
351
|
+
createdAt: Math.floor(Date.now() / 1e3)
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
async retryVault() {
|
|
355
|
+
return {
|
|
356
|
+
jobId: "job-retry-fixture",
|
|
357
|
+
kind: "vault-retry",
|
|
358
|
+
state: "queued",
|
|
359
|
+
createdAt: Math.floor(Date.now() / 1e3)
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
async getJobStatus(jobId) {
|
|
363
|
+
return fixture.jobs.find((j) => j.jobId === jobId) ?? {
|
|
364
|
+
jobId,
|
|
365
|
+
kind: "restore",
|
|
366
|
+
state: "done",
|
|
367
|
+
createdAt: Math.floor(Date.now() / 1e3)
|
|
368
|
+
};
|
|
369
|
+
},
|
|
370
|
+
async getJobList() {
|
|
371
|
+
return { jobs: fixture.jobs };
|
|
372
|
+
},
|
|
373
|
+
async getAgentModels() {
|
|
374
|
+
return {
|
|
375
|
+
providers: [{
|
|
376
|
+
id: "deepseek",
|
|
377
|
+
name: "DeepSeek",
|
|
378
|
+
models: [{
|
|
379
|
+
id: "deepseek-reasoner",
|
|
380
|
+
name: "DeepSeek Reasoner"
|
|
381
|
+
}]
|
|
382
|
+
}],
|
|
383
|
+
default: {
|
|
384
|
+
provider: "deepseek",
|
|
385
|
+
model: "deepseek-reasoner"
|
|
386
|
+
},
|
|
387
|
+
selection: null
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
async setAgentModel(selection) {
|
|
391
|
+
return { selection };
|
|
392
|
+
},
|
|
393
|
+
async prepareAgentWorkspace(serverId, host) {
|
|
394
|
+
return {
|
|
395
|
+
workspaceId: `ws-${serverId}`,
|
|
396
|
+
cwd: `/tmp/server-ops/${serverId}`,
|
|
397
|
+
host: host ?? serverRecord.host,
|
|
398
|
+
serverId
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const defaultApi = createHttpOpsApi();
|
|
405
|
+
const OpsRuntimeContext = (0, react.createContext)({ api: defaultApi });
|
|
406
|
+
function useApi() {
|
|
407
|
+
return (0, react.useContext)(OpsRuntimeContext).api;
|
|
408
|
+
}
|
|
409
|
+
const queryCache = /* @__PURE__ */ new Map();
|
|
410
|
+
function invalidateBridgeQuery(prefix) {
|
|
411
|
+
for (const key of queryCache.keys()) if (key === prefix || key.startsWith(`${prefix}:`)) queryCache.delete(key);
|
|
412
|
+
}
|
|
413
|
+
function useBridgeQuery(key, fetcher, options = {}) {
|
|
414
|
+
const { enabled = true, initialData, staleTimeMs = 1e4, retryCount = 0 } = options;
|
|
415
|
+
const activeKey = enabled ? key : null;
|
|
416
|
+
const cached = activeKey ? queryCache.get(activeKey) : void 0;
|
|
417
|
+
const [state, setState] = (0, react.useState)(() => ({
|
|
418
|
+
key: activeKey,
|
|
419
|
+
data: initialData ?? cached?.data
|
|
420
|
+
}));
|
|
421
|
+
const [error, setError] = (0, react.useState)({
|
|
422
|
+
key: activeKey,
|
|
423
|
+
message: null
|
|
424
|
+
});
|
|
425
|
+
const [loading, setLoading] = (0, react.useState)(() => Boolean(activeKey && !initialData && !cached));
|
|
426
|
+
const [refreshing, setRefreshing] = (0, react.useState)(false);
|
|
427
|
+
const reqCounter = (0, react.useRef)(0);
|
|
428
|
+
const mounted = (0, react.useRef)(true);
|
|
429
|
+
const fetcherRef = (0, react.useRef)(fetcher);
|
|
430
|
+
fetcherRef.current = fetcher;
|
|
431
|
+
(0, react.useEffect)(() => {
|
|
432
|
+
mounted.current = true;
|
|
433
|
+
return () => {
|
|
434
|
+
mounted.current = false;
|
|
435
|
+
};
|
|
436
|
+
}, []);
|
|
437
|
+
const run = (0, react.useCallback)(async (force = false) => {
|
|
438
|
+
if (!activeKey) return;
|
|
439
|
+
const existing = queryCache.get(activeKey);
|
|
440
|
+
if (!force && existing && Date.now() - existing.updatedAt < staleTimeMs) {
|
|
441
|
+
if (mounted.current) {
|
|
442
|
+
setState({
|
|
443
|
+
key: activeKey,
|
|
444
|
+
data: existing.data
|
|
445
|
+
});
|
|
446
|
+
setLoading(false);
|
|
447
|
+
setRefreshing(false);
|
|
448
|
+
setError({
|
|
449
|
+
key: activeKey,
|
|
450
|
+
message: null
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const seq = ++reqCounter.current;
|
|
456
|
+
if (mounted.current) {
|
|
457
|
+
if (existing) setRefreshing(true);
|
|
458
|
+
else setLoading(true);
|
|
459
|
+
setError({
|
|
460
|
+
key: activeKey,
|
|
461
|
+
message: null
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
let lastErr = null;
|
|
465
|
+
for (let attempt = 0; attempt <= retryCount; attempt++) try {
|
|
466
|
+
const result = await fetcherRef.current();
|
|
467
|
+
if (!mounted.current || seq !== reqCounter.current) return;
|
|
468
|
+
queryCache.set(activeKey, {
|
|
469
|
+
data: result,
|
|
470
|
+
updatedAt: Date.now()
|
|
471
|
+
});
|
|
472
|
+
setState({
|
|
473
|
+
key: activeKey,
|
|
474
|
+
data: result
|
|
475
|
+
});
|
|
476
|
+
setError({
|
|
477
|
+
key: activeKey,
|
|
478
|
+
message: null
|
|
479
|
+
});
|
|
480
|
+
setLoading(false);
|
|
481
|
+
setRefreshing(false);
|
|
482
|
+
return;
|
|
483
|
+
} catch (err) {
|
|
484
|
+
lastErr = err;
|
|
485
|
+
if (attempt < retryCount) await new Promise((r) => setTimeout(r, 400 * (attempt + 1)));
|
|
486
|
+
}
|
|
487
|
+
if (!mounted.current || seq !== reqCounter.current) return;
|
|
488
|
+
setError({
|
|
489
|
+
key: activeKey,
|
|
490
|
+
message: lastErr instanceof Error ? lastErr.message : String(lastErr)
|
|
491
|
+
});
|
|
492
|
+
setLoading(false);
|
|
493
|
+
setRefreshing(false);
|
|
494
|
+
}, [
|
|
495
|
+
activeKey,
|
|
496
|
+
staleTimeMs,
|
|
497
|
+
retryCount
|
|
498
|
+
]);
|
|
499
|
+
(0, react.useEffect)(() => {
|
|
500
|
+
reqCounter.current++;
|
|
501
|
+
if (!activeKey) {
|
|
502
|
+
setState({
|
|
503
|
+
key: null,
|
|
504
|
+
data: void 0
|
|
505
|
+
});
|
|
506
|
+
setError({
|
|
507
|
+
key: null,
|
|
508
|
+
message: null
|
|
509
|
+
});
|
|
510
|
+
setLoading(false);
|
|
511
|
+
setRefreshing(false);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const existing = queryCache.get(activeKey);
|
|
515
|
+
if (existing) {
|
|
516
|
+
setState({
|
|
517
|
+
key: activeKey,
|
|
518
|
+
data: existing.data
|
|
519
|
+
});
|
|
520
|
+
setError({
|
|
521
|
+
key: activeKey,
|
|
522
|
+
message: null
|
|
523
|
+
});
|
|
524
|
+
setLoading(false);
|
|
525
|
+
} else if (initialData !== void 0) {
|
|
526
|
+
setState({
|
|
527
|
+
key: activeKey,
|
|
528
|
+
data: initialData
|
|
529
|
+
});
|
|
530
|
+
setError({
|
|
531
|
+
key: activeKey,
|
|
532
|
+
message: null
|
|
533
|
+
});
|
|
534
|
+
setLoading(false);
|
|
535
|
+
return;
|
|
536
|
+
} else {
|
|
537
|
+
setState({
|
|
538
|
+
key: activeKey,
|
|
539
|
+
data: void 0
|
|
540
|
+
});
|
|
541
|
+
setError({
|
|
542
|
+
key: activeKey,
|
|
543
|
+
message: null
|
|
544
|
+
});
|
|
545
|
+
setLoading(true);
|
|
546
|
+
setRefreshing(false);
|
|
547
|
+
}
|
|
548
|
+
run(false);
|
|
549
|
+
}, [activeKey]);
|
|
550
|
+
const refetch = (0, react.useCallback)(async () => {
|
|
551
|
+
await run(true);
|
|
552
|
+
}, [run]);
|
|
553
|
+
const effectiveData = !activeKey ? void 0 : state.key === activeKey ? state.data : cached?.data ?? initialData;
|
|
554
|
+
return {
|
|
555
|
+
data: effectiveData,
|
|
556
|
+
error: !activeKey ? null : error.key === activeKey ? error.message : null,
|
|
557
|
+
loading: !activeKey ? false : state.key === activeKey ? loading : effectiveData === void 0,
|
|
558
|
+
refreshing: state.key === activeKey ? refreshing : false,
|
|
559
|
+
refetch
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function useDebouncedValue(value, delayMs = 300) {
|
|
563
|
+
const [debounced, setDebounced] = (0, react.useState)(value);
|
|
564
|
+
(0, react.useEffect)(() => {
|
|
565
|
+
const timer = setTimeout(() => setDebounced(value), delayMs);
|
|
566
|
+
return () => clearTimeout(timer);
|
|
567
|
+
}, [value, delayMs]);
|
|
568
|
+
return debounced;
|
|
569
|
+
}
|
|
570
|
+
let sidebarSnapshot = {
|
|
571
|
+
status: "unknown",
|
|
572
|
+
unreadAlerts: 0
|
|
573
|
+
};
|
|
574
|
+
const sidebarListeners = /* @__PURE__ */ new Set();
|
|
575
|
+
function publishSidebarBadge(next) {
|
|
576
|
+
if (sidebarSnapshot.status === next.status && sidebarSnapshot.unreadAlerts === next.unreadAlerts) return;
|
|
577
|
+
sidebarSnapshot = next;
|
|
578
|
+
for (const listener of sidebarListeners) listener();
|
|
579
|
+
}
|
|
580
|
+
function useSidebarBadge() {
|
|
581
|
+
const [snap, setSnap] = (0, react.useState)(sidebarSnapshot);
|
|
582
|
+
(0, react.useEffect)(() => {
|
|
583
|
+
const onChange = () => setSnap(sidebarSnapshot);
|
|
584
|
+
sidebarListeners.add(onChange);
|
|
585
|
+
onChange();
|
|
586
|
+
return () => {
|
|
587
|
+
sidebarListeners.delete(onChange);
|
|
588
|
+
};
|
|
589
|
+
}, []);
|
|
590
|
+
return snap;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
const SHANGHAI_TZ = "Asia/Shanghai";
|
|
594
|
+
function formatShortServerId(serverId, maxLen = 12) {
|
|
595
|
+
if (!serverId) return "";
|
|
596
|
+
return serverId.length > maxLen ? `${serverId.slice(0, maxLen)}…` : serverId;
|
|
597
|
+
}
|
|
598
|
+
function relativeParentPath(entryPath, currentPath) {
|
|
599
|
+
if (!entryPath) return null;
|
|
600
|
+
const prefix = currentPath ? `${currentPath}/` : "";
|
|
601
|
+
const rel = prefix && entryPath.startsWith(prefix) ? entryPath.slice(prefix.length) : entryPath;
|
|
602
|
+
const lastSlash = rel.lastIndexOf("/");
|
|
603
|
+
return lastSlash > 0 ? rel.slice(0, lastSlash) : null;
|
|
604
|
+
}
|
|
605
|
+
function formatBytes(bytes, digits = 1) {
|
|
606
|
+
if (bytes === null || bytes === void 0 || !Number.isFinite(bytes)) return "—";
|
|
607
|
+
const abs = Math.abs(bytes);
|
|
608
|
+
const sign = bytes < 0 ? "-" : "";
|
|
609
|
+
if (abs < 1024) return `${sign}${Math.round(abs)} B`;
|
|
610
|
+
const units = [
|
|
611
|
+
"KiB",
|
|
612
|
+
"MiB",
|
|
613
|
+
"GiB",
|
|
614
|
+
"TiB"
|
|
615
|
+
];
|
|
616
|
+
let value = abs / 1024;
|
|
617
|
+
let idx = 0;
|
|
618
|
+
while (value >= 1024 && idx < units.length - 1) {
|
|
619
|
+
value /= 1024;
|
|
620
|
+
idx++;
|
|
621
|
+
}
|
|
622
|
+
return `${sign}${value.toFixed(value >= 100 ? 0 : digits)} ${units[idx]}`;
|
|
623
|
+
}
|
|
624
|
+
function formatDelta24h(deltaBytes) {
|
|
625
|
+
if (deltaBytes === null || deltaBytes === void 0 || !Number.isFinite(deltaBytes)) return {
|
|
626
|
+
label: "采样不足",
|
|
627
|
+
tone: "unknown"
|
|
628
|
+
};
|
|
629
|
+
const mb = deltaBytes / (1024 * 1024);
|
|
630
|
+
if (Math.abs(mb) < 50) return {
|
|
631
|
+
label: "平稳",
|
|
632
|
+
tone: "flat"
|
|
633
|
+
};
|
|
634
|
+
if (deltaBytes > 0) return {
|
|
635
|
+
label: `+${formatBytes(deltaBytes)} ↑`,
|
|
636
|
+
tone: "up"
|
|
637
|
+
};
|
|
638
|
+
return {
|
|
639
|
+
label: `${formatBytes(deltaBytes)} ↓`,
|
|
640
|
+
tone: "down"
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function formatPercent(value, digits = 1) {
|
|
644
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return "—";
|
|
645
|
+
return `${value.toFixed(digits)}%`;
|
|
646
|
+
}
|
|
647
|
+
function formatDaysLeft(days) {
|
|
648
|
+
if (days === null || days === void 0 || !Number.isFinite(days)) return "暂无增长预估";
|
|
649
|
+
if (days < 1) return "预计不足 1 天写满";
|
|
650
|
+
if (days > 365) return "预计 >365 天";
|
|
651
|
+
return `预计 ${days < 10 ? days.toFixed(1) : Math.round(days)} 天`;
|
|
652
|
+
}
|
|
653
|
+
function formatUptime(sec) {
|
|
654
|
+
if (!sec || !Number.isFinite(sec) || sec <= 0) return "—";
|
|
655
|
+
const days = Math.floor(sec / 86400);
|
|
656
|
+
const hours = Math.floor(sec % 86400 / 3600);
|
|
657
|
+
const mins = Math.floor(sec % 3600 / 60);
|
|
658
|
+
if (days > 0) return `${days} 天 ${hours} 小时`;
|
|
659
|
+
if (hours > 0) return `${hours} 小时 ${mins} 分钟`;
|
|
660
|
+
return `${Math.max(1, mins)} 分钟`;
|
|
661
|
+
}
|
|
662
|
+
function formatRelativeTime(tsSec, nowSec = Math.floor(Date.now() / 1e3)) {
|
|
663
|
+
if (!tsSec || !Number.isFinite(tsSec)) return "未知";
|
|
664
|
+
const diff = nowSec - tsSec;
|
|
665
|
+
if (diff < 0) return "刚刚";
|
|
666
|
+
if (diff < 60) return `${Math.max(1, Math.round(diff))} 秒前`;
|
|
667
|
+
if (diff < 3600) return `${Math.floor(diff / 60)} 分钟前`;
|
|
668
|
+
if (diff < 86400) return `${Math.floor(diff / 3600)} 小时前`;
|
|
669
|
+
return `${Math.floor(diff / 86400)} 天前`;
|
|
670
|
+
}
|
|
671
|
+
function shanghaiParts(tsSec) {
|
|
672
|
+
const formatter = new Intl.DateTimeFormat("zh-CN", {
|
|
673
|
+
timeZone: SHANGHAI_TZ,
|
|
674
|
+
year: "numeric",
|
|
675
|
+
month: "2-digit",
|
|
676
|
+
day: "2-digit",
|
|
677
|
+
hour: "2-digit",
|
|
678
|
+
minute: "2-digit",
|
|
679
|
+
second: "2-digit",
|
|
680
|
+
hour12: false
|
|
681
|
+
});
|
|
682
|
+
const out = {};
|
|
683
|
+
for (const part of formatter.formatToParts(/* @__PURE__ */ new Date(tsSec * 1e3))) out[part.type] = part.value;
|
|
684
|
+
return out;
|
|
685
|
+
}
|
|
686
|
+
function formatBeijingDate(tsSec) {
|
|
687
|
+
const p = shanghaiParts(tsSec);
|
|
688
|
+
return `${p.year}-${p.month}-${p.day}`;
|
|
689
|
+
}
|
|
690
|
+
function formatBeijingTime(tsSec) {
|
|
691
|
+
const p = shanghaiParts(tsSec);
|
|
692
|
+
return `${p.hour}:${p.minute}`;
|
|
693
|
+
}
|
|
694
|
+
function formatBeijingDateTime(tsSec) {
|
|
695
|
+
if (!tsSec || !Number.isFinite(tsSec)) return "—";
|
|
696
|
+
const p = shanghaiParts(tsSec);
|
|
697
|
+
return `${p.month}-${p.day} ${p.hour}:${p.minute}`;
|
|
698
|
+
}
|
|
699
|
+
function formatBeijingFull(tsSec) {
|
|
700
|
+
if (!tsSec || !Number.isFinite(tsSec)) return "—";
|
|
701
|
+
const p = shanghaiParts(tsSec);
|
|
702
|
+
return `${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}`;
|
|
703
|
+
}
|
|
704
|
+
function healthLabel(state) {
|
|
705
|
+
switch (state) {
|
|
706
|
+
case "ok": return "正常";
|
|
707
|
+
case "warn": return "需关注";
|
|
708
|
+
case "bad": return "异常";
|
|
709
|
+
default: return "未知";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Splits a time series into contiguous segments so missing-data gaps are never
|
|
714
|
+
* bridged with misleading straight lines.
|
|
715
|
+
*/
|
|
716
|
+
function splitSeriesByGaps(points, accessor, gaps, maxStepSec) {
|
|
717
|
+
const valid = [];
|
|
718
|
+
for (const p of points) {
|
|
719
|
+
const value = accessor(p);
|
|
720
|
+
if (value !== void 0 && Number.isFinite(value)) valid.push({
|
|
721
|
+
ts: p.ts,
|
|
722
|
+
value
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
valid.sort((a, b) => a.ts - b.ts);
|
|
726
|
+
if (valid.length === 0) return [];
|
|
727
|
+
const segments = [];
|
|
728
|
+
let current = [valid[0]];
|
|
729
|
+
for (let i = 1; i < valid.length; i++) {
|
|
730
|
+
const prev = valid[i - 1];
|
|
731
|
+
const next = valid[i];
|
|
732
|
+
const crossesGap = gaps.some(([gStart, gEnd]) => gEnd > prev.ts && gStart < next.ts);
|
|
733
|
+
const exceedsStep = maxStepSec > 0 && next.ts - prev.ts > maxStepSec * 2.5;
|
|
734
|
+
if (crossesGap || exceedsStep) {
|
|
735
|
+
segments.push({ points: current });
|
|
736
|
+
current = [next];
|
|
737
|
+
} else current.push(next);
|
|
738
|
+
}
|
|
739
|
+
if (current.length > 0) segments.push({ points: current });
|
|
740
|
+
return segments;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const DEFAULT_INSTALL_CMD = "curl -fsSL https://github.com/yanaoyong/dsh-server-ops-agent/releases/latest/download/install-linux.sh | sudo bash";
|
|
744
|
+
function OnboardingView({ onConnected, onOpenDeployAgent }) {
|
|
745
|
+
const api = useApi();
|
|
746
|
+
const [host, setHost] = (0, react.useState)("");
|
|
747
|
+
const [port, setPort] = (0, react.useState)("22");
|
|
748
|
+
const [username, setUsername] = (0, react.useState)("root");
|
|
749
|
+
const [fingerprint, setFingerprint] = (0, react.useState)("");
|
|
750
|
+
const [keyPath, setKeyPath] = (0, react.useState)("");
|
|
751
|
+
const [probing, setProbing] = (0, react.useState)(false);
|
|
752
|
+
const [submitting, setSubmitting] = (0, react.useState)(false);
|
|
753
|
+
const [error, setError] = (0, react.useState)(null);
|
|
754
|
+
const [installPrompt, setInstallPrompt] = (0, react.useState)(null);
|
|
755
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
756
|
+
async function handleProbeFingerprint() {
|
|
757
|
+
const trimmedHost = host.trim();
|
|
758
|
+
if (!trimmedHost) {
|
|
759
|
+
setError("请先填写主机地址(IP 或域名),再探测 SSH 指纹。");
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const parsedPort = Number(port) || 22;
|
|
763
|
+
setProbing(true);
|
|
764
|
+
setError(null);
|
|
765
|
+
try {
|
|
766
|
+
setFingerprint((await api.probeFingerprint(trimmedHost, parsedPort)).fingerprint);
|
|
767
|
+
} catch (err) {
|
|
768
|
+
setError(err instanceof Error ? err.message : "探测 SSH 指纹失败,请核对网络或端口。");
|
|
769
|
+
} finally {
|
|
770
|
+
setProbing(false);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
async function handleSubmit(e) {
|
|
774
|
+
e.preventDefault();
|
|
775
|
+
const trimmedHost = host.trim();
|
|
776
|
+
const trimmedUser = username.trim();
|
|
777
|
+
const trimmedFp = fingerprint.trim();
|
|
778
|
+
if (!trimmedHost || !trimmedUser || !trimmedFp) {
|
|
779
|
+
setError("请完整填写主机地址、SSH 用户名与已核对的 SHA-256 指纹。");
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
setSubmitting(true);
|
|
783
|
+
setError(null);
|
|
784
|
+
try {
|
|
785
|
+
const res = await api.addConnection({
|
|
786
|
+
host: trimmedHost,
|
|
787
|
+
port: Number(port) || 22,
|
|
788
|
+
username: trimmedUser,
|
|
789
|
+
fingerprint: trimmedFp,
|
|
790
|
+
keyPath: keyPath.trim() || void 0
|
|
791
|
+
});
|
|
792
|
+
if (res.needsInstall) setInstallPrompt({
|
|
793
|
+
host: trimmedHost,
|
|
794
|
+
serverId: res.serverId,
|
|
795
|
+
command: res.installCommand || DEFAULT_INSTALL_CMD
|
|
796
|
+
});
|
|
797
|
+
else onConnected(res);
|
|
798
|
+
} catch (err) {
|
|
799
|
+
setError(err instanceof Error ? err.message : "连接服务器失败,请检查 SSH 认证与网络状态。");
|
|
800
|
+
} finally {
|
|
801
|
+
setSubmitting(false);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
async function handleCopyInstall() {
|
|
805
|
+
if (!installPrompt) return;
|
|
806
|
+
try {
|
|
807
|
+
await navigator.clipboard.writeText(installPrompt.command);
|
|
808
|
+
setCopied(true);
|
|
809
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
810
|
+
} catch {
|
|
811
|
+
setError("未能写入剪贴板,请手动复制上方命令。");
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
815
|
+
className: "ops-onboarding-wrap",
|
|
816
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
817
|
+
className: "ops-onboarding-card",
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
820
|
+
className: "ops-onboarding-header",
|
|
821
|
+
children: [
|
|
822
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
823
|
+
className: "ops-onboarding-badge",
|
|
824
|
+
children: "零公网端口 · SSH 原生通道"
|
|
825
|
+
}),
|
|
826
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: "连接你的第一台 Linux 服务器" }),
|
|
827
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "所有监控采集与备份索引均在服务器本机只读运行,通过固定 SHA-256 指纹的 SSH 连接安全同步至工作台。" })
|
|
828
|
+
]
|
|
829
|
+
}),
|
|
830
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
831
|
+
className: "ops-inline-alert is-bad",
|
|
832
|
+
role: "alert",
|
|
833
|
+
children: error
|
|
834
|
+
}),
|
|
835
|
+
installPrompt ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
836
|
+
className: "ops-install-guide",
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
839
|
+
className: "ops-install-title",
|
|
840
|
+
children: "SSH 已验证,目标主机尚未安装服务端组件"
|
|
841
|
+
}),
|
|
842
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
843
|
+
className: "ops-muted",
|
|
844
|
+
children: "请选择以下任一方式完成部署(支持自动校验安装 Node 22 LTS,且服务端以低权限只读用户运行):"
|
|
845
|
+
}),
|
|
846
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
847
|
+
className: "ops-code-block",
|
|
848
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: installPrompt.command })
|
|
849
|
+
}),
|
|
850
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
851
|
+
className: "ops-install-actions",
|
|
852
|
+
children: [
|
|
853
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
854
|
+
type: "button",
|
|
855
|
+
className: "ops-btn ops-btn-secondary",
|
|
856
|
+
onClick: handleCopyInstall,
|
|
857
|
+
children: copied ? "已复制安装命令" : "复制安装命令"
|
|
858
|
+
}),
|
|
859
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
860
|
+
type: "button",
|
|
861
|
+
className: "ops-btn ops-btn-info",
|
|
862
|
+
onClick: () => onOpenDeployAgent({
|
|
863
|
+
host: installPrompt.host,
|
|
864
|
+
serverId: installPrompt.serverId
|
|
865
|
+
}),
|
|
866
|
+
children: "由运维 Agent 引导部署"
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
869
|
+
type: "button",
|
|
870
|
+
className: "ops-btn ops-btn-ghost",
|
|
871
|
+
onClick: () => setInstallPrompt(null),
|
|
872
|
+
children: "返回修改连接"
|
|
873
|
+
})
|
|
874
|
+
]
|
|
875
|
+
})
|
|
876
|
+
]
|
|
877
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
878
|
+
className: "ops-form",
|
|
879
|
+
onSubmit: handleSubmit,
|
|
880
|
+
children: [
|
|
881
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
882
|
+
className: "ops-form-row ops-form-row-host",
|
|
883
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
884
|
+
className: "ops-field",
|
|
885
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "主机地址" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
886
|
+
type: "text",
|
|
887
|
+
value: host,
|
|
888
|
+
onChange: (e) => setHost(e.target.value),
|
|
889
|
+
placeholder: "例如 198.51.100.10 或 srv.example.com",
|
|
890
|
+
autoComplete: "off",
|
|
891
|
+
required: true
|
|
892
|
+
})]
|
|
893
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
894
|
+
className: "ops-field",
|
|
895
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "端口" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
896
|
+
type: "number",
|
|
897
|
+
min: 1,
|
|
898
|
+
max: 65535,
|
|
899
|
+
value: port,
|
|
900
|
+
onChange: (e) => setPort(e.target.value)
|
|
901
|
+
})]
|
|
902
|
+
})]
|
|
903
|
+
}),
|
|
904
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
905
|
+
className: "ops-form-row ops-form-row-two",
|
|
906
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
907
|
+
className: "ops-field",
|
|
908
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "SSH 用户名" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
909
|
+
type: "text",
|
|
910
|
+
value: username,
|
|
911
|
+
onChange: (e) => setUsername(e.target.value),
|
|
912
|
+
placeholder: "root 或 ops",
|
|
913
|
+
autoComplete: "off",
|
|
914
|
+
required: true
|
|
915
|
+
})]
|
|
916
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
917
|
+
className: "ops-field",
|
|
918
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "私钥路径(可选,默认使用 SSH Agent)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
919
|
+
type: "text",
|
|
920
|
+
value: keyPath,
|
|
921
|
+
onChange: (e) => setKeyPath(e.target.value),
|
|
922
|
+
placeholder: "~/.ssh/id_ed25519",
|
|
923
|
+
autoComplete: "off"
|
|
924
|
+
})]
|
|
925
|
+
})]
|
|
926
|
+
}),
|
|
927
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
928
|
+
className: "ops-field",
|
|
929
|
+
children: [
|
|
930
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "主机 SSH SHA-256 指纹" }),
|
|
931
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
932
|
+
className: "ops-input-action",
|
|
933
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
934
|
+
type: "text",
|
|
935
|
+
value: fingerprint,
|
|
936
|
+
onChange: (e) => setFingerprint(e.target.value),
|
|
937
|
+
placeholder: "SHA256:...",
|
|
938
|
+
autoComplete: "off",
|
|
939
|
+
required: true
|
|
940
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
941
|
+
type: "button",
|
|
942
|
+
className: "ops-btn ops-btn-secondary",
|
|
943
|
+
disabled: probing,
|
|
944
|
+
onClick: handleProbeFingerprint,
|
|
945
|
+
children: probing ? "探测中…" : "一键探测指纹"
|
|
946
|
+
})]
|
|
947
|
+
}),
|
|
948
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
|
|
949
|
+
className: "ops-field-hint",
|
|
950
|
+
children: "探测后请与你的云服务商控制台或本机核对一致,以防中间人劫持。"
|
|
951
|
+
})
|
|
952
|
+
]
|
|
953
|
+
}),
|
|
954
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
955
|
+
className: "ops-form-footer",
|
|
956
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
957
|
+
type: "submit",
|
|
958
|
+
className: "ops-btn ops-btn-primary",
|
|
959
|
+
disabled: submitting,
|
|
960
|
+
children: submitting ? "正在验证并连接…" : "验证指纹并连接服务器"
|
|
961
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
962
|
+
type: "button",
|
|
963
|
+
className: "ops-btn ops-btn-ghost",
|
|
964
|
+
onClick: () => onOpenDeployAgent(host.trim() ? { host: host.trim() } : void 0),
|
|
965
|
+
children: "由运维 Agent 引导部署"
|
|
966
|
+
})]
|
|
967
|
+
})
|
|
968
|
+
]
|
|
969
|
+
})
|
|
970
|
+
]
|
|
971
|
+
})
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function SettingsDrawer({ open, onClose, servers, activeServerId, activeSyncedAt, onConnectionChange, onReconnect }) {
|
|
976
|
+
const api = useApi();
|
|
977
|
+
const [host, setHost] = (0, react.useState)("");
|
|
978
|
+
const [port, setPort] = (0, react.useState)("22");
|
|
979
|
+
const [username, setUsername] = (0, react.useState)("root");
|
|
980
|
+
const [fingerprint, setFingerprint] = (0, react.useState)("");
|
|
981
|
+
const [keyPath, setKeyPath] = (0, react.useState)("");
|
|
982
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
983
|
+
const [probing, setProbing] = (0, react.useState)(false);
|
|
984
|
+
const [feedback, setFeedback] = (0, react.useState)(null);
|
|
985
|
+
const [models, setModels] = (0, react.useState)(null);
|
|
986
|
+
const [modelDraft, setModelDraft] = (0, react.useState)({
|
|
987
|
+
provider: "",
|
|
988
|
+
model: ""
|
|
989
|
+
});
|
|
990
|
+
const [modelSaving, setModelSaving] = (0, react.useState)(false);
|
|
991
|
+
(0, react.useEffect)(() => {
|
|
992
|
+
if (!open) return;
|
|
993
|
+
let active = true;
|
|
994
|
+
api.getAgentModels().then((res) => {
|
|
995
|
+
if (!active) return;
|
|
996
|
+
setModels(res);
|
|
997
|
+
setModelDraft(res.selection ?? {
|
|
998
|
+
provider: "",
|
|
999
|
+
model: ""
|
|
1000
|
+
});
|
|
1001
|
+
}).catch(() => {});
|
|
1002
|
+
return () => {
|
|
1003
|
+
active = false;
|
|
1004
|
+
};
|
|
1005
|
+
}, [open, api]);
|
|
1006
|
+
if (!open) return null;
|
|
1007
|
+
async function handleProbe() {
|
|
1008
|
+
if (!host.trim()) {
|
|
1009
|
+
setFeedback({
|
|
1010
|
+
tone: "bad",
|
|
1011
|
+
text: "请先输入主机地址。"
|
|
1012
|
+
});
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
setProbing(true);
|
|
1016
|
+
setFeedback(null);
|
|
1017
|
+
try {
|
|
1018
|
+
setFingerprint((await api.probeFingerprint(host.trim(), Number(port) || 22)).fingerprint);
|
|
1019
|
+
setFeedback({
|
|
1020
|
+
tone: "ok",
|
|
1021
|
+
text: "已获取主机指纹,请核对无误后添加。"
|
|
1022
|
+
});
|
|
1023
|
+
} catch (err) {
|
|
1024
|
+
setFeedback({
|
|
1025
|
+
tone: "bad",
|
|
1026
|
+
text: err instanceof Error ? err.message : "探测指纹失败"
|
|
1027
|
+
});
|
|
1028
|
+
} finally {
|
|
1029
|
+
setProbing(false);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
async function handleAddServer(e) {
|
|
1033
|
+
e.preventDefault();
|
|
1034
|
+
if (!host.trim() || !username.trim() || !fingerprint.trim()) {
|
|
1035
|
+
setFeedback({
|
|
1036
|
+
tone: "bad",
|
|
1037
|
+
text: "请填写主机地址、用户名和已核对的 SSH 指纹。"
|
|
1038
|
+
});
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
setBusy(true);
|
|
1042
|
+
setFeedback(null);
|
|
1043
|
+
try {
|
|
1044
|
+
const res = await api.addConnection({
|
|
1045
|
+
host: host.trim(),
|
|
1046
|
+
port: Number(port) || 22,
|
|
1047
|
+
username: username.trim(),
|
|
1048
|
+
fingerprint: fingerprint.trim(),
|
|
1049
|
+
keyPath: keyPath.trim() || void 0
|
|
1050
|
+
});
|
|
1051
|
+
if (res.needsInstall) {
|
|
1052
|
+
setFeedback({
|
|
1053
|
+
tone: "bad",
|
|
1054
|
+
text: res.installCommand ? `目标主机尚未安装服务端组件,请先在目标主机执行安装或由运维 Agent 引导部署:${res.installCommand.split("\n")[0]}` : "目标主机尚未安装服务端组件,请先部署 Linux 运维服务后再连接。"
|
|
1055
|
+
});
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
onConnectionChange(res.status);
|
|
1059
|
+
setHost("");
|
|
1060
|
+
setFingerprint("");
|
|
1061
|
+
setKeyPath("");
|
|
1062
|
+
setFeedback({
|
|
1063
|
+
tone: "ok",
|
|
1064
|
+
text: "服务器已登记并切换为当前主机。"
|
|
1065
|
+
});
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
setFeedback({
|
|
1068
|
+
tone: "bad",
|
|
1069
|
+
text: err instanceof Error ? err.message : "添加服务器失败"
|
|
1070
|
+
});
|
|
1071
|
+
} finally {
|
|
1072
|
+
setBusy(false);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
async function handleSelect(serverId) {
|
|
1076
|
+
setBusy(true);
|
|
1077
|
+
setFeedback(null);
|
|
1078
|
+
try {
|
|
1079
|
+
onConnectionChange(await api.selectConnection(serverId));
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
setFeedback({
|
|
1082
|
+
tone: "bad",
|
|
1083
|
+
text: err instanceof Error ? err.message : "切换服务器失败"
|
|
1084
|
+
});
|
|
1085
|
+
} finally {
|
|
1086
|
+
setBusy(false);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
async function handleRemove(serverId) {
|
|
1090
|
+
setBusy(true);
|
|
1091
|
+
setFeedback(null);
|
|
1092
|
+
try {
|
|
1093
|
+
onConnectionChange(await api.removeConnection(serverId));
|
|
1094
|
+
setFeedback({
|
|
1095
|
+
tone: "ok",
|
|
1096
|
+
text: `已移除服务器 ${formatShortServerId(serverId)}`
|
|
1097
|
+
});
|
|
1098
|
+
} catch (err) {
|
|
1099
|
+
setFeedback({
|
|
1100
|
+
tone: "bad",
|
|
1101
|
+
text: err instanceof Error ? err.message : "移除服务器失败"
|
|
1102
|
+
});
|
|
1103
|
+
} finally {
|
|
1104
|
+
setBusy(false);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
async function handleSaveModel() {
|
|
1108
|
+
setModelSaving(true);
|
|
1109
|
+
setFeedback(null);
|
|
1110
|
+
try {
|
|
1111
|
+
const selection = modelDraft.provider && modelDraft.model ? modelDraft : null;
|
|
1112
|
+
const res = await api.setAgentModel(selection);
|
|
1113
|
+
setModels((prev) => prev ? {
|
|
1114
|
+
...prev,
|
|
1115
|
+
selection: res.selection
|
|
1116
|
+
} : prev);
|
|
1117
|
+
setFeedback({
|
|
1118
|
+
tone: "ok",
|
|
1119
|
+
text: selection ? "运维 Agent 专用模型已保存。" : "已恢复跟随 DSH 默认模型。"
|
|
1120
|
+
});
|
|
1121
|
+
} catch (err) {
|
|
1122
|
+
setFeedback({
|
|
1123
|
+
tone: "bad",
|
|
1124
|
+
text: err instanceof Error ? err.message : "保存模型配置失败"
|
|
1125
|
+
});
|
|
1126
|
+
} finally {
|
|
1127
|
+
setModelSaving(false);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
const selectedProvider = models?.providers.find((p) => p.id === modelDraft.provider);
|
|
1131
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1132
|
+
className: "ops-drawer-backdrop",
|
|
1133
|
+
role: "presentation",
|
|
1134
|
+
onClick: onClose,
|
|
1135
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("aside", {
|
|
1136
|
+
className: "ops-drawer",
|
|
1137
|
+
role: "dialog",
|
|
1138
|
+
"aria-modal": "true",
|
|
1139
|
+
"aria-label": "服务器与模型设置",
|
|
1140
|
+
onClick: (e) => e.stopPropagation(),
|
|
1141
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1142
|
+
className: "ops-drawer-head",
|
|
1143
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "连接与设置" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1144
|
+
type: "button",
|
|
1145
|
+
className: "ops-icon-btn",
|
|
1146
|
+
"aria-label": "关闭设置",
|
|
1147
|
+
onClick: onClose,
|
|
1148
|
+
children: "✕"
|
|
1149
|
+
})]
|
|
1150
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1151
|
+
className: "ops-drawer-body",
|
|
1152
|
+
children: [
|
|
1153
|
+
feedback && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1154
|
+
className: `ops-inline-alert ${feedback.tone === "ok" ? "is-ok" : "is-bad"}`,
|
|
1155
|
+
role: "status",
|
|
1156
|
+
children: feedback.text
|
|
1157
|
+
}),
|
|
1158
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1159
|
+
className: "ops-drawer-section",
|
|
1160
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", { children: [
|
|
1161
|
+
"已登记服务器 (",
|
|
1162
|
+
servers.length,
|
|
1163
|
+
")"
|
|
1164
|
+
] }), servers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1165
|
+
className: "ops-muted",
|
|
1166
|
+
children: "尚未添加任何服务器。"
|
|
1167
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1168
|
+
className: "ops-server-list",
|
|
1169
|
+
children: servers.map((srv) => {
|
|
1170
|
+
const isCurrent = srv.serverId === activeServerId;
|
|
1171
|
+
const syncedAt = isCurrent && activeSyncedAt != null ? activeSyncedAt : srv.lastSyncedAt;
|
|
1172
|
+
const shortId = formatShortServerId(srv.serverId);
|
|
1173
|
+
const endpointFull = `${srv.username}@${srv.host}:${srv.port} · ID ${srv.serverId}`;
|
|
1174
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1175
|
+
className: `ops-server-item ${isCurrent ? "is-active" : ""}`,
|
|
1176
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1177
|
+
className: "ops-server-meta",
|
|
1178
|
+
children: [
|
|
1179
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1180
|
+
className: "ops-server-name",
|
|
1181
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
1182
|
+
className: "ops-truncate",
|
|
1183
|
+
title: srv.host,
|
|
1184
|
+
children: srv.host
|
|
1185
|
+
}), isCurrent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1186
|
+
className: "ops-pill is-info",
|
|
1187
|
+
children: "当前"
|
|
1188
|
+
})]
|
|
1189
|
+
}),
|
|
1190
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1191
|
+
className: "ops-muted ops-mono ops-truncate ops-server-endpoint",
|
|
1192
|
+
title: endpointFull,
|
|
1193
|
+
children: [
|
|
1194
|
+
srv.username,
|
|
1195
|
+
"@",
|
|
1196
|
+
srv.host,
|
|
1197
|
+
":",
|
|
1198
|
+
srv.port,
|
|
1199
|
+
" · ID ",
|
|
1200
|
+
shortId
|
|
1201
|
+
]
|
|
1202
|
+
}),
|
|
1203
|
+
syncedAt && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1204
|
+
className: "ops-caption",
|
|
1205
|
+
children: ["最近同步:", formatRelativeTime(syncedAt)]
|
|
1206
|
+
})
|
|
1207
|
+
]
|
|
1208
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1209
|
+
className: "ops-server-actions",
|
|
1210
|
+
children: [
|
|
1211
|
+
!isCurrent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1212
|
+
type: "button",
|
|
1213
|
+
className: "ops-btn ops-btn-secondary ops-btn-xs",
|
|
1214
|
+
disabled: busy,
|
|
1215
|
+
onClick: () => handleSelect(srv.serverId),
|
|
1216
|
+
children: "切换"
|
|
1217
|
+
}),
|
|
1218
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1219
|
+
type: "button",
|
|
1220
|
+
className: "ops-btn ops-btn-ghost ops-btn-xs",
|
|
1221
|
+
disabled: busy,
|
|
1222
|
+
onClick: () => void onReconnect(srv.serverId),
|
|
1223
|
+
children: "重连"
|
|
1224
|
+
}),
|
|
1225
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1226
|
+
type: "button",
|
|
1227
|
+
className: "ops-btn ops-btn-danger-ghost ops-btn-xs",
|
|
1228
|
+
disabled: busy,
|
|
1229
|
+
onClick: () => handleRemove(srv.serverId),
|
|
1230
|
+
children: "移除"
|
|
1231
|
+
})
|
|
1232
|
+
]
|
|
1233
|
+
})]
|
|
1234
|
+
}, srv.serverId);
|
|
1235
|
+
})
|
|
1236
|
+
})]
|
|
1237
|
+
}),
|
|
1238
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1239
|
+
className: "ops-drawer-section",
|
|
1240
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "新增服务器" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
1241
|
+
className: "ops-form ops-form-compact",
|
|
1242
|
+
onSubmit: handleAddServer,
|
|
1243
|
+
children: [
|
|
1244
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1245
|
+
className: "ops-form-row ops-form-row-host",
|
|
1246
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1247
|
+
className: "ops-field",
|
|
1248
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "主机地址" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1249
|
+
type: "text",
|
|
1250
|
+
value: host,
|
|
1251
|
+
onChange: (e) => setHost(e.target.value),
|
|
1252
|
+
placeholder: "IP 或域名",
|
|
1253
|
+
required: true
|
|
1254
|
+
})]
|
|
1255
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1256
|
+
className: "ops-field",
|
|
1257
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "端口" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1258
|
+
type: "number",
|
|
1259
|
+
min: 1,
|
|
1260
|
+
max: 65535,
|
|
1261
|
+
value: port,
|
|
1262
|
+
onChange: (e) => setPort(e.target.value)
|
|
1263
|
+
})]
|
|
1264
|
+
})]
|
|
1265
|
+
}),
|
|
1266
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1267
|
+
className: "ops-form-row ops-form-row-two",
|
|
1268
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1269
|
+
className: "ops-field",
|
|
1270
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "用户名" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1271
|
+
type: "text",
|
|
1272
|
+
value: username,
|
|
1273
|
+
onChange: (e) => setUsername(e.target.value),
|
|
1274
|
+
placeholder: "root",
|
|
1275
|
+
required: true
|
|
1276
|
+
})]
|
|
1277
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1278
|
+
className: "ops-field",
|
|
1279
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "私钥路径(可选)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1280
|
+
type: "text",
|
|
1281
|
+
value: keyPath,
|
|
1282
|
+
onChange: (e) => setKeyPath(e.target.value),
|
|
1283
|
+
placeholder: "~/.ssh/id_ed25519"
|
|
1284
|
+
})]
|
|
1285
|
+
})]
|
|
1286
|
+
}),
|
|
1287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1288
|
+
className: "ops-field",
|
|
1289
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "SSH 指纹(SHA-256)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1290
|
+
className: "ops-input-action",
|
|
1291
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1292
|
+
type: "text",
|
|
1293
|
+
value: fingerprint,
|
|
1294
|
+
onChange: (e) => setFingerprint(e.target.value),
|
|
1295
|
+
placeholder: "SHA256:...",
|
|
1296
|
+
required: true
|
|
1297
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1298
|
+
type: "button",
|
|
1299
|
+
className: "ops-btn ops-btn-secondary ops-btn-xs",
|
|
1300
|
+
disabled: probing,
|
|
1301
|
+
onClick: handleProbe,
|
|
1302
|
+
children: probing ? "探测中" : "探测指纹"
|
|
1303
|
+
})]
|
|
1304
|
+
})]
|
|
1305
|
+
}),
|
|
1306
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1307
|
+
type: "submit",
|
|
1308
|
+
className: "ops-btn ops-btn-primary",
|
|
1309
|
+
disabled: busy,
|
|
1310
|
+
children: busy ? "验证中…" : "核对并添加服务器"
|
|
1311
|
+
})
|
|
1312
|
+
]
|
|
1313
|
+
})]
|
|
1314
|
+
}),
|
|
1315
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1316
|
+
className: "ops-drawer-section",
|
|
1317
|
+
children: [
|
|
1318
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "运维 Agent 模型" }),
|
|
1319
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1320
|
+
className: "ops-muted",
|
|
1321
|
+
children: "用于侧栏原生运维会话;留空则自动跟随 DSH 桌面端默认模型。"
|
|
1322
|
+
}),
|
|
1323
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1324
|
+
className: "ops-form ops-form-compact",
|
|
1325
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1326
|
+
className: "ops-form-row ops-form-row-two",
|
|
1327
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1328
|
+
className: "ops-field",
|
|
1329
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "模型提供方" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1330
|
+
value: modelDraft.provider,
|
|
1331
|
+
onChange: (e) => {
|
|
1332
|
+
const nextProvider = e.target.value;
|
|
1333
|
+
const found = models?.providers.find((p) => p.id === nextProvider);
|
|
1334
|
+
setModelDraft({
|
|
1335
|
+
provider: nextProvider,
|
|
1336
|
+
model: found?.models[0]?.id ?? ""
|
|
1337
|
+
});
|
|
1338
|
+
},
|
|
1339
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1340
|
+
value: "",
|
|
1341
|
+
children: "跟随 DSH 默认"
|
|
1342
|
+
}), models?.providers.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1343
|
+
value: p.id,
|
|
1344
|
+
children: p.name
|
|
1345
|
+
}, p.id))]
|
|
1346
|
+
})]
|
|
1347
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1348
|
+
className: "ops-field",
|
|
1349
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "模型" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1350
|
+
value: modelDraft.model,
|
|
1351
|
+
disabled: !modelDraft.provider,
|
|
1352
|
+
onChange: (e) => setModelDraft((prev) => ({
|
|
1353
|
+
...prev,
|
|
1354
|
+
model: e.target.value
|
|
1355
|
+
})),
|
|
1356
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1357
|
+
value: "",
|
|
1358
|
+
children: modelDraft.provider ? "选择模型" : "默认"
|
|
1359
|
+
}), selectedProvider?.models.map((m) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1360
|
+
value: m.id,
|
|
1361
|
+
children: m.name ?? m.id
|
|
1362
|
+
}, m.id))]
|
|
1363
|
+
})]
|
|
1364
|
+
})]
|
|
1365
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1366
|
+
type: "button",
|
|
1367
|
+
className: "ops-btn ops-btn-secondary",
|
|
1368
|
+
disabled: modelSaving,
|
|
1369
|
+
onClick: handleSaveModel,
|
|
1370
|
+
children: modelSaving ? "保存中…" : "保存模型偏好"
|
|
1371
|
+
})]
|
|
1372
|
+
})
|
|
1373
|
+
]
|
|
1374
|
+
})
|
|
1375
|
+
]
|
|
1376
|
+
})]
|
|
1377
|
+
})
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
const TONE_VAR = {
|
|
1382
|
+
business: "var(--dsw-alias-link, #4176e6)",
|
|
1383
|
+
success: "var(--dsw-alias-state-success-primary, #22c55e)",
|
|
1384
|
+
warn: "var(--dsw-alias-state-warn-primary, #f59e0b)",
|
|
1385
|
+
error: "var(--dsw-alias-state-error-primary, #ec1313)"
|
|
1386
|
+
};
|
|
1387
|
+
function TrendSvgChart({ points, gaps, fromTs, toTs, intervalSec, accessor, unit = "%", minY = 0, maxY, thresholdY, tone = "business", height = 128, ariaLabel }) {
|
|
1388
|
+
const uid = (0, react.useId)().replace(/:/g, "");
|
|
1389
|
+
const width = 420;
|
|
1390
|
+
const padL = 38;
|
|
1391
|
+
const padR = 10;
|
|
1392
|
+
const padT = 10;
|
|
1393
|
+
const padB = 22;
|
|
1394
|
+
const innerW = width - padL - padR;
|
|
1395
|
+
const innerH = height - padT - padB;
|
|
1396
|
+
const segments = splitSeriesByGaps(points, accessor, gaps, intervalSec);
|
|
1397
|
+
const allValues = segments.flatMap((s) => s.points.map((pt) => pt.value));
|
|
1398
|
+
const computedMax = maxY ?? Math.max(thresholdY ? thresholdY * 1.1 : 1, allValues.length > 0 ? Math.max(...allValues) * 1.15 : 100);
|
|
1399
|
+
const computedMin = Math.min(minY, allValues.length > 0 ? Math.min(...allValues) : minY);
|
|
1400
|
+
const spanY = Math.max(.01, computedMax - computedMin);
|
|
1401
|
+
const spanT = Math.max(1, toTs - fromTs);
|
|
1402
|
+
const xOf = (ts) => padL + (Math.max(fromTs, Math.min(toTs, ts)) - fromTs) / spanT * innerW;
|
|
1403
|
+
const yOf = (val) => padT + innerH - (Math.max(computedMin, Math.min(computedMax, val)) - computedMin) / spanY * innerH;
|
|
1404
|
+
const strokeColor = TONE_VAR[tone];
|
|
1405
|
+
const yMid = (computedMin + computedMax) / 2;
|
|
1406
|
+
const formatY = (v) => unit === "%" ? `${Math.round(v)}%` : v < 10 ? v.toFixed(1) : `${Math.round(v)}`;
|
|
1407
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1408
|
+
className: "ops-chart-wrap",
|
|
1409
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1410
|
+
className: "ops-svg-chart",
|
|
1411
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1412
|
+
role: "img",
|
|
1413
|
+
"aria-label": ariaLabel,
|
|
1414
|
+
preserveAspectRatio: "none",
|
|
1415
|
+
children: [
|
|
1416
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
1417
|
+
id: `area-${uid}`,
|
|
1418
|
+
x1: "0",
|
|
1419
|
+
y1: "0",
|
|
1420
|
+
x2: "0",
|
|
1421
|
+
y2: "1",
|
|
1422
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
1423
|
+
offset: "0%",
|
|
1424
|
+
stopColor: strokeColor,
|
|
1425
|
+
stopOpacity: "0.22"
|
|
1426
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
1427
|
+
offset: "100%",
|
|
1428
|
+
stopColor: strokeColor,
|
|
1429
|
+
stopOpacity: "0.01"
|
|
1430
|
+
})]
|
|
1431
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pattern", {
|
|
1432
|
+
id: `gap-hatch-${uid}`,
|
|
1433
|
+
width: "6",
|
|
1434
|
+
height: "6",
|
|
1435
|
+
patternUnits: "userSpaceOnUse",
|
|
1436
|
+
patternTransform: "rotate(45)",
|
|
1437
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
1438
|
+
x1: "0",
|
|
1439
|
+
y1: "0",
|
|
1440
|
+
x2: "0",
|
|
1441
|
+
y2: "6",
|
|
1442
|
+
stroke: "var(--dsw-alias-border-l3, rgba(128,128,128,0.28))",
|
|
1443
|
+
strokeWidth: "2"
|
|
1444
|
+
})
|
|
1445
|
+
})] }),
|
|
1446
|
+
[
|
|
1447
|
+
computedMin,
|
|
1448
|
+
yMid,
|
|
1449
|
+
computedMax
|
|
1450
|
+
].map((tick, idx) => {
|
|
1451
|
+
const y = yOf(tick);
|
|
1452
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
1453
|
+
x1: padL,
|
|
1454
|
+
y1: y,
|
|
1455
|
+
x2: width - padR,
|
|
1456
|
+
y2: y,
|
|
1457
|
+
stroke: "var(--dsw-alias-border-l1, rgba(0,0,0,0.06))",
|
|
1458
|
+
strokeWidth: "1"
|
|
1459
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
1460
|
+
x: padL - 6,
|
|
1461
|
+
y: y + 3.5,
|
|
1462
|
+
textAnchor: "end",
|
|
1463
|
+
className: "ops-chart-tick",
|
|
1464
|
+
children: formatY(tick)
|
|
1465
|
+
})] }, idx);
|
|
1466
|
+
}),
|
|
1467
|
+
gaps.map(([gStart, gEnd], idx) => {
|
|
1468
|
+
const x1 = xOf(gStart);
|
|
1469
|
+
const x2 = xOf(gEnd);
|
|
1470
|
+
const w = Math.max(4, x2 - x1);
|
|
1471
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", {
|
|
1472
|
+
className: "ops-chart-gap-band",
|
|
1473
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
1474
|
+
x: x1,
|
|
1475
|
+
y: padT,
|
|
1476
|
+
width: w,
|
|
1477
|
+
height: innerH,
|
|
1478
|
+
fill: `url(#gap-hatch-${uid})`,
|
|
1479
|
+
opacity: "0.7"
|
|
1480
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
1481
|
+
x: x1,
|
|
1482
|
+
y: padT,
|
|
1483
|
+
width: w,
|
|
1484
|
+
height: innerH,
|
|
1485
|
+
fill: "var(--dsw-alias-bg-module-platform, rgba(140,145,155,0.14))",
|
|
1486
|
+
opacity: "0.45",
|
|
1487
|
+
stroke: "var(--dsw-alias-border-l3, rgba(128,128,128,0.3))",
|
|
1488
|
+
strokeDasharray: "3 3",
|
|
1489
|
+
strokeWidth: "1"
|
|
1490
|
+
})]
|
|
1491
|
+
}, `gap-${idx}`);
|
|
1492
|
+
}),
|
|
1493
|
+
thresholdY !== void 0 && thresholdY >= computedMin && thresholdY <= computedMax && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
1494
|
+
x1: padL,
|
|
1495
|
+
y1: yOf(thresholdY),
|
|
1496
|
+
x2: width - padR,
|
|
1497
|
+
y2: yOf(thresholdY),
|
|
1498
|
+
stroke: "var(--dsw-alias-state-warn-primary, #f59e0b)",
|
|
1499
|
+
strokeWidth: "1.2",
|
|
1500
|
+
strokeDasharray: "4 3"
|
|
1501
|
+
}),
|
|
1502
|
+
segments.map((seg, idx) => {
|
|
1503
|
+
if (seg.points.length === 1) {
|
|
1504
|
+
const pt = seg.points[0];
|
|
1505
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1506
|
+
cx: xOf(pt.ts),
|
|
1507
|
+
cy: yOf(pt.value),
|
|
1508
|
+
r: "3",
|
|
1509
|
+
fill: strokeColor
|
|
1510
|
+
}, `pt-${idx}`);
|
|
1511
|
+
}
|
|
1512
|
+
const linePath = seg.points.map((pt, i) => `${i === 0 ? "M" : "L"} ${xOf(pt.ts).toFixed(1)} ${yOf(pt.value).toFixed(1)}`).join(" ");
|
|
1513
|
+
const first = seg.points[0];
|
|
1514
|
+
const last = seg.points[seg.points.length - 1];
|
|
1515
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1516
|
+
d: `${linePath} L ${xOf(last.ts).toFixed(1)} ${(padT + innerH).toFixed(1)} L ${xOf(first.ts).toFixed(1)} ${(padT + innerH).toFixed(1)} Z`,
|
|
1517
|
+
fill: `url(#area-${uid})`
|
|
1518
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1519
|
+
d: linePath,
|
|
1520
|
+
fill: "none",
|
|
1521
|
+
stroke: strokeColor,
|
|
1522
|
+
strokeWidth: "2",
|
|
1523
|
+
strokeLinecap: "round",
|
|
1524
|
+
strokeLinejoin: "round"
|
|
1525
|
+
})] }, `seg-${idx}`);
|
|
1526
|
+
}),
|
|
1527
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
1528
|
+
x: padL,
|
|
1529
|
+
y: height - 5,
|
|
1530
|
+
textAnchor: "start",
|
|
1531
|
+
className: "ops-chart-tick",
|
|
1532
|
+
children: formatBeijingTime(fromTs)
|
|
1533
|
+
}),
|
|
1534
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
1535
|
+
x: padL + innerW / 2,
|
|
1536
|
+
y: height - 5,
|
|
1537
|
+
textAnchor: "middle",
|
|
1538
|
+
className: "ops-chart-tick",
|
|
1539
|
+
children: formatBeijingTime(Math.round((fromTs + toTs) / 2))
|
|
1540
|
+
}),
|
|
1541
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
1542
|
+
x: width - padR,
|
|
1543
|
+
y: height - 5,
|
|
1544
|
+
textAnchor: "end",
|
|
1545
|
+
className: "ops-chart-tick",
|
|
1546
|
+
children: formatBeijingTime(toTs)
|
|
1547
|
+
})
|
|
1548
|
+
]
|
|
1549
|
+
}), gaps.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1550
|
+
className: "ops-chart-legend",
|
|
1551
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1552
|
+
className: "ops-gap-swatch",
|
|
1553
|
+
"aria-hidden": "true"
|
|
1554
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1555
|
+
"灰纹区间表示采样缺测(共 ",
|
|
1556
|
+
gaps.length,
|
|
1557
|
+
" 段),不以直线插值补全"
|
|
1558
|
+
] })]
|
|
1559
|
+
})]
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
function MiniSparkline({ values, tone = "business", ariaLabel }) {
|
|
1563
|
+
if (!values || values.length < 2) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1564
|
+
className: "ops-spark-empty",
|
|
1565
|
+
children: "采样积累中"
|
|
1566
|
+
});
|
|
1567
|
+
const w = 132;
|
|
1568
|
+
const h = 34;
|
|
1569
|
+
const pad = 3;
|
|
1570
|
+
const min = Math.min(...values);
|
|
1571
|
+
const max = Math.max(...values);
|
|
1572
|
+
const span = Math.max(.01, max - min);
|
|
1573
|
+
const color = TONE_VAR[tone];
|
|
1574
|
+
const pts = values.map((v, i) => {
|
|
1575
|
+
return {
|
|
1576
|
+
x: pad + i / (values.length - 1) * (w - pad * 2),
|
|
1577
|
+
y: pad + (h - pad * 2) - (v - min) / span * (h - pad * 2)
|
|
1578
|
+
};
|
|
1579
|
+
});
|
|
1580
|
+
const d = pts.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join(" ");
|
|
1581
|
+
const area = `${d} L ${pts[pts.length - 1].x.toFixed(1)} ${h - pad} L ${pts[0].x.toFixed(1)} ${h - pad} Z`;
|
|
1582
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1583
|
+
className: "ops-sparkline",
|
|
1584
|
+
viewBox: `0 0 ${w} ${h}`,
|
|
1585
|
+
role: "img",
|
|
1586
|
+
"aria-label": ariaLabel,
|
|
1587
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1588
|
+
d: area,
|
|
1589
|
+
fill: color,
|
|
1590
|
+
opacity: "0.12"
|
|
1591
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1592
|
+
d,
|
|
1593
|
+
fill: "none",
|
|
1594
|
+
stroke: color,
|
|
1595
|
+
strokeWidth: "1.8",
|
|
1596
|
+
strokeLinecap: "round",
|
|
1597
|
+
strokeLinejoin: "round"
|
|
1598
|
+
})]
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
function SshMiniBarChart({ hourly }) {
|
|
1602
|
+
const buckets = hourly.length > 0 ? hourly.slice(-24) : new Array(24).fill(0);
|
|
1603
|
+
const max = Math.max(1, ...buckets);
|
|
1604
|
+
const w = 240;
|
|
1605
|
+
const h = 42;
|
|
1606
|
+
const gap = 2;
|
|
1607
|
+
const barW = (w - gap * (buckets.length - 1)) / buckets.length;
|
|
1608
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1609
|
+
className: "ops-ssh-bars",
|
|
1610
|
+
viewBox: `0 0 ${w} ${h}`,
|
|
1611
|
+
role: "img",
|
|
1612
|
+
"aria-label": "近 24 小时异常 SSH 尝试分布",
|
|
1613
|
+
children: buckets.map((count, i) => {
|
|
1614
|
+
const barH = count > 0 ? Math.max(4, count / max * (h - 6)) : 2;
|
|
1615
|
+
const y = h - barH;
|
|
1616
|
+
const fill = count === 0 ? "var(--dsw-alias-border-l2, rgba(0,0,0,0.1))" : count >= 20 ? "var(--dsw-alias-state-error-primary, #ec1313)" : "var(--dsw-alias-state-warn-primary, #f59e0b)";
|
|
1617
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
1618
|
+
x: i * (barW + gap),
|
|
1619
|
+
y,
|
|
1620
|
+
width: Math.max(2, barW),
|
|
1621
|
+
height: barH,
|
|
1622
|
+
rx: "1.5",
|
|
1623
|
+
fill,
|
|
1624
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("title", { children: `第 ${i + 1} 小时:${count} 次` })
|
|
1625
|
+
}, i);
|
|
1626
|
+
})
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
function CapacityMeter({ usedPct, thresholdPct, status }) {
|
|
1630
|
+
const clamped = Math.max(0, Math.min(100, usedPct));
|
|
1631
|
+
const barClass = status === "bad" ? "ops-meter-fill is-bad" : status === "warn" ? "ops-meter-fill is-warn" : "ops-meter-fill is-ok";
|
|
1632
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1633
|
+
className: "ops-meter-track",
|
|
1634
|
+
role: "progressbar",
|
|
1635
|
+
"aria-valuenow": Math.round(clamped),
|
|
1636
|
+
"aria-valuemin": 0,
|
|
1637
|
+
"aria-valuemax": 100,
|
|
1638
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1639
|
+
className: barClass,
|
|
1640
|
+
style: { width: `${clamped}%` }
|
|
1641
|
+
}), thresholdPct !== void 0 && thresholdPct > 0 && thresholdPct < 100 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1642
|
+
className: "ops-meter-threshold",
|
|
1643
|
+
style: { left: `${thresholdPct}%` },
|
|
1644
|
+
title: `告警阈值 ${thresholdPct}%`
|
|
1645
|
+
})]
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
const RANGES = [
|
|
1650
|
+
{
|
|
1651
|
+
key: "6h",
|
|
1652
|
+
label: "6h"
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
key: "24h",
|
|
1656
|
+
label: "24h"
|
|
1657
|
+
},
|
|
1658
|
+
{
|
|
1659
|
+
key: "7d",
|
|
1660
|
+
label: "7d"
|
|
1661
|
+
}
|
|
1662
|
+
];
|
|
1663
|
+
function OverviewTab({ serverId, overview, syncing = false, offlineError, initialHistory, onReconnect, onGoActivity, onGoTimeMachine, onOpenAgent }) {
|
|
1664
|
+
const api = useApi();
|
|
1665
|
+
const [range, setRange] = (0, react.useState)("24h");
|
|
1666
|
+
const [reportExpanded, setReportExpanded] = (0, react.useState)(false);
|
|
1667
|
+
const [expandedMount, setExpandedMount] = (0, react.useState)(() => {
|
|
1668
|
+
if (initialHistory?.resource.startsWith("mount:")) return initialHistory.resource.slice(6);
|
|
1669
|
+
return overview.metrics.mounts.find((m) => m.status !== "ok")?.mount ?? null;
|
|
1670
|
+
});
|
|
1671
|
+
const systemHistory = useBridgeQuery(`history:${serverId}:system:${range}`, () => api.getResourceHistory({
|
|
1672
|
+
resource: "system",
|
|
1673
|
+
range
|
|
1674
|
+
}, serverId), {
|
|
1675
|
+
initialData: initialHistory,
|
|
1676
|
+
staleTimeMs: 3e4
|
|
1677
|
+
});
|
|
1678
|
+
const mountResource = expandedMount ? `mount:${expandedMount}` : null;
|
|
1679
|
+
const mountHistory = useBridgeQuery(mountResource ? `history:${serverId}:${mountResource}:${range}` : null, () => api.getResourceHistory({
|
|
1680
|
+
resource: mountResource,
|
|
1681
|
+
range,
|
|
1682
|
+
includeTopDirs: true
|
|
1683
|
+
}, serverId), {
|
|
1684
|
+
enabled: Boolean(mountResource),
|
|
1685
|
+
initialData: initialHistory && initialHistory.resource === mountResource ? initialHistory : void 0,
|
|
1686
|
+
staleTimeMs: 3e4
|
|
1687
|
+
});
|
|
1688
|
+
const { health, metrics, services, backupSummary, todayReport } = overview;
|
|
1689
|
+
const isOffline = Boolean(offlineError || overview.offlineCache || overview.stale);
|
|
1690
|
+
const hasActiveAlerts = health.status === "bad" || health.activeIncidents > 0;
|
|
1691
|
+
const hasServices = services.containers.length > 0 || services.httpProbes.length > 0 || services.supervisors.length > 0 || services.externalProbes.length > 0;
|
|
1692
|
+
const nearestCert = (0, react.useMemo)(() => {
|
|
1693
|
+
if (metrics.security.certs.length === 0) return null;
|
|
1694
|
+
return [...metrics.security.certs].sort((a, b) => a.daysLeft - b.daysLeft)[0];
|
|
1695
|
+
}, [metrics.security.certs]);
|
|
1696
|
+
const memSwapHot = (metrics.memory.swapUsedPct ?? 0) >= 60 || metrics.memory.status === "bad";
|
|
1697
|
+
const usedMemBytes = Math.max(0, metrics.memory.totalBytes - metrics.memory.availableBytes);
|
|
1698
|
+
const historyPts = systemHistory.data?.points ?? [];
|
|
1699
|
+
const historyGaps = systemHistory.data?.gaps ?? [];
|
|
1700
|
+
const historyFrom = systemHistory.data?.fromTs ?? overview.collectedAt - 86400;
|
|
1701
|
+
const historyTo = systemHistory.data?.toTs ?? overview.collectedAt;
|
|
1702
|
+
const historyStep = systemHistory.data?.intervalSec ?? 3600;
|
|
1703
|
+
function renderMountRow(mount) {
|
|
1704
|
+
const isExpanded = expandedMount === mount.mount;
|
|
1705
|
+
const delta = formatDelta24h(mount.delta24hBytes);
|
|
1706
|
+
const activeMountHist = isExpanded ? mountHistory.data : void 0;
|
|
1707
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1708
|
+
className: `ops-mount-block ${isExpanded ? "is-expanded" : ""}`,
|
|
1709
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1710
|
+
type: "button",
|
|
1711
|
+
className: "ops-mount-row",
|
|
1712
|
+
"aria-expanded": isExpanded,
|
|
1713
|
+
onClick: () => setExpandedMount(isExpanded ? null : mount.mount),
|
|
1714
|
+
children: [
|
|
1715
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1716
|
+
className: "ops-mount-top",
|
|
1717
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1718
|
+
className: "ops-mount-id",
|
|
1719
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1720
|
+
className: "ops-mono ops-mount-path",
|
|
1721
|
+
children: mount.mount
|
|
1722
|
+
}), mount.device && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1723
|
+
className: "ops-caption ops-mono",
|
|
1724
|
+
children: mount.device
|
|
1725
|
+
})]
|
|
1726
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1727
|
+
className: "ops-mount-stats",
|
|
1728
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1729
|
+
className: `ops-delta-badge is-${delta.tone}`,
|
|
1730
|
+
children: delta.label
|
|
1731
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
1732
|
+
className: `ops-tabular ${mount.status === "bad" ? "is-text-bad" : mount.status === "warn" ? "is-text-warn" : ""}`,
|
|
1733
|
+
children: formatPercent(mount.usedPct)
|
|
1734
|
+
})]
|
|
1735
|
+
})]
|
|
1736
|
+
}),
|
|
1737
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CapacityMeter, {
|
|
1738
|
+
usedPct: mount.usedPct,
|
|
1739
|
+
thresholdPct: mount.thresholdPct,
|
|
1740
|
+
status: mount.status
|
|
1741
|
+
}),
|
|
1742
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1743
|
+
className: "ops-mount-foot",
|
|
1744
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1745
|
+
className: "ops-caption ops-tabular",
|
|
1746
|
+
children: [
|
|
1747
|
+
"已用 ",
|
|
1748
|
+
formatBytes(mount.usedBytes),
|
|
1749
|
+
" / 共 ",
|
|
1750
|
+
formatBytes(mount.totalBytes),
|
|
1751
|
+
"(余 ",
|
|
1752
|
+
formatBytes(mount.availBytes),
|
|
1753
|
+
")"
|
|
1754
|
+
]
|
|
1755
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1756
|
+
className: "ops-caption",
|
|
1757
|
+
children: [
|
|
1758
|
+
formatDaysLeft(mount.estimatedDaysLeft),
|
|
1759
|
+
" · ",
|
|
1760
|
+
isExpanded ? "收起趋势 ▲" : "查看增长 ▾"
|
|
1761
|
+
]
|
|
1762
|
+
})]
|
|
1763
|
+
})
|
|
1764
|
+
]
|
|
1765
|
+
}), isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1766
|
+
className: "ops-mount-detail",
|
|
1767
|
+
children: activeMountHist ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendSvgChart, {
|
|
1768
|
+
points: activeMountHist.points,
|
|
1769
|
+
gaps: activeMountHist.gaps,
|
|
1770
|
+
fromTs: activeMountHist.fromTs,
|
|
1771
|
+
toTs: activeMountHist.toTs,
|
|
1772
|
+
intervalSec: activeMountHist.intervalSec,
|
|
1773
|
+
accessor: (p) => p.usedPct,
|
|
1774
|
+
unit: "%",
|
|
1775
|
+
minY: 0,
|
|
1776
|
+
maxY: 100,
|
|
1777
|
+
thresholdY: mount.thresholdPct,
|
|
1778
|
+
tone: mount.status === "bad" ? "error" : mount.status === "warn" ? "warn" : "business",
|
|
1779
|
+
height: 118,
|
|
1780
|
+
ariaLabel: `${mount.mount} 使用率历史趋势`
|
|
1781
|
+
}), activeMountHist.topDirs && activeMountHist.topDirs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1782
|
+
className: "ops-topdirs",
|
|
1783
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1784
|
+
className: "ops-topdirs-head",
|
|
1785
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "主要占用与增长目录" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1786
|
+
type: "button",
|
|
1787
|
+
className: "ops-link-btn",
|
|
1788
|
+
onClick: () => onOpenAgent(`analyze-disk:${mount.mount}`),
|
|
1789
|
+
children: "让 Agent 分析增长 →"
|
|
1790
|
+
})]
|
|
1791
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1792
|
+
className: "ops-topdirs-list",
|
|
1793
|
+
children: activeMountHist.topDirs.map((dir) => {
|
|
1794
|
+
const d = formatDelta24h(dir.delta24hBytes);
|
|
1795
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1796
|
+
className: "ops-topdir-row",
|
|
1797
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1798
|
+
className: "ops-mono ops-truncate",
|
|
1799
|
+
title: dir.path,
|
|
1800
|
+
children: dir.path
|
|
1801
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1802
|
+
className: "ops-topdir-right ops-tabular",
|
|
1803
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatBytes(dir.bytes) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1804
|
+
className: `ops-delta-badge is-${d.tone}`,
|
|
1805
|
+
children: d.label
|
|
1806
|
+
})]
|
|
1807
|
+
})]
|
|
1808
|
+
}, dir.path);
|
|
1809
|
+
})
|
|
1810
|
+
})]
|
|
1811
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1812
|
+
className: "ops-inline-loading",
|
|
1813
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1814
|
+
"正在加载 ",
|
|
1815
|
+
mount.mount,
|
|
1816
|
+
" 历史趋势与目录分布…"
|
|
1817
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1818
|
+
type: "button",
|
|
1819
|
+
className: "ops-link-btn",
|
|
1820
|
+
onClick: () => onOpenAgent(`analyze-disk:${mount.mount}`),
|
|
1821
|
+
children: "让 Agent 分析增长"
|
|
1822
|
+
})]
|
|
1823
|
+
})
|
|
1824
|
+
})]
|
|
1825
|
+
}, mount.mount);
|
|
1826
|
+
}
|
|
1827
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1828
|
+
className: "ops-tab-stack",
|
|
1829
|
+
children: [
|
|
1830
|
+
isOffline && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1831
|
+
className: "ops-banner is-offline",
|
|
1832
|
+
role: "status",
|
|
1833
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1834
|
+
className: "ops-banner-main",
|
|
1835
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "ops-dot is-idle" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: offlineError ? "与服务器暂未连通,当前显示上次缓存快照" : health.headline }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1836
|
+
className: "ops-caption",
|
|
1837
|
+
children: [
|
|
1838
|
+
"最后同步时间:",
|
|
1839
|
+
formatBeijingDateTime(overview.cachedAt ?? overview.collectedAt),
|
|
1840
|
+
syncing ? " · 正在同步最新数据…" : offlineError ? ` · ${offlineError}` : ""
|
|
1841
|
+
]
|
|
1842
|
+
})] })]
|
|
1843
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1844
|
+
type: "button",
|
|
1845
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm",
|
|
1846
|
+
onClick: onReconnect,
|
|
1847
|
+
children: "重新连接"
|
|
1848
|
+
})]
|
|
1849
|
+
}),
|
|
1850
|
+
hasActiveAlerts ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1851
|
+
className: "ops-banner is-alert",
|
|
1852
|
+
role: "alert",
|
|
1853
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1854
|
+
className: "ops-banner-main",
|
|
1855
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "ops-dot is-bad" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: health.headline }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1856
|
+
className: "ops-caption",
|
|
1857
|
+
children: [
|
|
1858
|
+
"活跃异常 ",
|
|
1859
|
+
health.activeIncidents,
|
|
1860
|
+
" 项 · 采集于 ",
|
|
1861
|
+
formatBeijingDateTime(overview.collectedAt)
|
|
1862
|
+
]
|
|
1863
|
+
})] })]
|
|
1864
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1865
|
+
className: "ops-banner-actions",
|
|
1866
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1867
|
+
type: "button",
|
|
1868
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm",
|
|
1869
|
+
onClick: onGoActivity,
|
|
1870
|
+
children: "查看详情"
|
|
1871
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1872
|
+
type: "button",
|
|
1873
|
+
className: "ops-btn ops-btn-info ops-btn-sm",
|
|
1874
|
+
onClick: () => onOpenAgent("investigate-alert"),
|
|
1875
|
+
children: "在 Agent 中排查"
|
|
1876
|
+
})]
|
|
1877
|
+
})]
|
|
1878
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1879
|
+
className: `ops-reassurance ${health.status === "warn" ? "is-warn" : "is-ok"}`,
|
|
1880
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1881
|
+
className: "ops-reassurance-top",
|
|
1882
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1883
|
+
className: "ops-banner-main",
|
|
1884
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${health.status === "warn" ? "warn" : "ok"}` }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: health.headline }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1885
|
+
className: "ops-caption ops-sep",
|
|
1886
|
+
children: [
|
|
1887
|
+
"采集于 ",
|
|
1888
|
+
formatBeijingDateTime(overview.collectedAt),
|
|
1889
|
+
syncing ? " · 正在同步最新数据…" : ""
|
|
1890
|
+
]
|
|
1891
|
+
})] })]
|
|
1892
|
+
}), todayReport && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1893
|
+
type: "button",
|
|
1894
|
+
className: "ops-btn ops-btn-ghost ops-btn-sm",
|
|
1895
|
+
"aria-expanded": reportExpanded,
|
|
1896
|
+
onClick: () => setReportExpanded((v) => !v),
|
|
1897
|
+
children: ["今日 07:00 日报 ", reportExpanded ? "▲" : "▾"]
|
|
1898
|
+
})]
|
|
1899
|
+
}), todayReport && reportExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1900
|
+
className: "ops-report-inline",
|
|
1901
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1902
|
+
className: "ops-report-inline-head",
|
|
1903
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1904
|
+
className: "ops-caption",
|
|
1905
|
+
children: [
|
|
1906
|
+
todayReport.date,
|
|
1907
|
+
" · 生成于 ",
|
|
1908
|
+
formatBeijingDateTime(todayReport.generatedAt)
|
|
1909
|
+
]
|
|
1910
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1911
|
+
type: "button",
|
|
1912
|
+
className: "ops-link-btn",
|
|
1913
|
+
onClick: onGoActivity,
|
|
1914
|
+
children: "查看完整日报 →"
|
|
1915
|
+
})]
|
|
1916
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1917
|
+
className: "ops-bullet-list",
|
|
1918
|
+
children: todayReport.summaryLines.slice(0, 3).map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: line }, i))
|
|
1919
|
+
})]
|
|
1920
|
+
})]
|
|
1921
|
+
}),
|
|
1922
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1923
|
+
className: "ops-section-header",
|
|
1924
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "核心资源与安全趋势" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1925
|
+
className: "ops-segmented",
|
|
1926
|
+
role: "group",
|
|
1927
|
+
"aria-label": "时间范围切换",
|
|
1928
|
+
children: RANGES.map((r) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1929
|
+
type: "button",
|
|
1930
|
+
className: `ops-seg-btn ${range === r.key ? "is-active" : ""}`,
|
|
1931
|
+
"aria-pressed": range === r.key,
|
|
1932
|
+
onClick: () => setRange(r.key),
|
|
1933
|
+
children: r.label
|
|
1934
|
+
}, r.key))
|
|
1935
|
+
})]
|
|
1936
|
+
}),
|
|
1937
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1938
|
+
className: "ops-grid-2x2",
|
|
1939
|
+
children: [
|
|
1940
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1941
|
+
className: "ops-card",
|
|
1942
|
+
children: [
|
|
1943
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1944
|
+
className: "ops-card-head",
|
|
1945
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1946
|
+
className: "ops-card-label",
|
|
1947
|
+
children: "CPU 与系统负载"
|
|
1948
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1949
|
+
className: "ops-card-kpi ops-tabular",
|
|
1950
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: metrics.cpu.loadPerCpu.toFixed(2) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1951
|
+
className: "ops-caption",
|
|
1952
|
+
children: [
|
|
1953
|
+
"/ 核(共 ",
|
|
1954
|
+
metrics.cpu.cores,
|
|
1955
|
+
" 核)"
|
|
1956
|
+
]
|
|
1957
|
+
})]
|
|
1958
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1959
|
+
className: `ops-pill is-${metrics.cpu.status}`,
|
|
1960
|
+
children: healthLabel(metrics.cpu.status)
|
|
1961
|
+
})]
|
|
1962
|
+
}),
|
|
1963
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1964
|
+
className: "ops-kv-strip ops-tabular",
|
|
1965
|
+
children: [
|
|
1966
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["1m ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: metrics.cpu.load1.toFixed(2) })] }),
|
|
1967
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["5m ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: metrics.cpu.load5.toFixed(2) })] }),
|
|
1968
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["15m ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: metrics.cpu.load15.toFixed(2) })] })
|
|
1969
|
+
]
|
|
1970
|
+
}),
|
|
1971
|
+
historyPts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendSvgChart, {
|
|
1972
|
+
points: historyPts,
|
|
1973
|
+
gaps: historyGaps,
|
|
1974
|
+
fromTs: historyFrom,
|
|
1975
|
+
toTs: historyTo,
|
|
1976
|
+
intervalSec: historyStep,
|
|
1977
|
+
accessor: (p) => p.loadPerCpu ?? p.load15,
|
|
1978
|
+
unit: "",
|
|
1979
|
+
minY: 0,
|
|
1980
|
+
tone: metrics.cpu.status === "bad" ? "error" : metrics.cpu.status === "warn" ? "warn" : "business",
|
|
1981
|
+
height: 112,
|
|
1982
|
+
ariaLabel: "CPU 负载历史趋势"
|
|
1983
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniSparkline, {
|
|
1984
|
+
values: metrics.cpu.sparkline,
|
|
1985
|
+
ariaLabel: "CPU 近期趋势"
|
|
1986
|
+
})
|
|
1987
|
+
]
|
|
1988
|
+
}),
|
|
1989
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1990
|
+
className: "ops-card",
|
|
1991
|
+
children: [
|
|
1992
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1993
|
+
className: "ops-card-head",
|
|
1994
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1995
|
+
className: "ops-card-label",
|
|
1996
|
+
children: "内存与 Swap"
|
|
1997
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1998
|
+
className: "ops-card-kpi ops-tabular",
|
|
1999
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatPercent(metrics.memory.usedPct) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2000
|
+
className: "ops-caption",
|
|
2001
|
+
children: [
|
|
2002
|
+
"可用 ",
|
|
2003
|
+
formatBytes(metrics.memory.availableBytes),
|
|
2004
|
+
" / ",
|
|
2005
|
+
formatBytes(metrics.memory.totalBytes)
|
|
2006
|
+
]
|
|
2007
|
+
})]
|
|
2008
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2009
|
+
className: `ops-pill is-${metrics.memory.status}`,
|
|
2010
|
+
children: healthLabel(metrics.memory.status)
|
|
2011
|
+
})]
|
|
2012
|
+
}),
|
|
2013
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2014
|
+
className: "ops-kv-strip ops-tabular",
|
|
2015
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["已用 ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatBytes(usedMemBytes) })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2016
|
+
className: memSwapHot ? "is-text-bad" : "",
|
|
2017
|
+
children: ["Swap ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: metrics.memory.swapUsedPct !== void 0 ? formatPercent(metrics.memory.swapUsedPct) : "0.0%" })]
|
|
2018
|
+
})]
|
|
2019
|
+
}),
|
|
2020
|
+
historyPts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendSvgChart, {
|
|
2021
|
+
points: historyPts,
|
|
2022
|
+
gaps: historyGaps,
|
|
2023
|
+
fromTs: historyFrom,
|
|
2024
|
+
toTs: historyTo,
|
|
2025
|
+
intervalSec: historyStep,
|
|
2026
|
+
accessor: (p) => p.memAvailPct !== void 0 ? Number((100 - p.memAvailPct).toFixed(1)) : void 0,
|
|
2027
|
+
unit: "%",
|
|
2028
|
+
minY: 0,
|
|
2029
|
+
maxY: 100,
|
|
2030
|
+
thresholdY: 85,
|
|
2031
|
+
tone: memSwapHot ? "error" : metrics.memory.status === "warn" ? "warn" : "success",
|
|
2032
|
+
height: 112,
|
|
2033
|
+
ariaLabel: "内存使用率历史趋势"
|
|
2034
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniSparkline, {
|
|
2035
|
+
values: metrics.memory.sparkline,
|
|
2036
|
+
tone: memSwapHot ? "error" : "success",
|
|
2037
|
+
ariaLabel: "内存近期趋势"
|
|
2038
|
+
})
|
|
2039
|
+
]
|
|
2040
|
+
}),
|
|
2041
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
2042
|
+
className: "ops-card",
|
|
2043
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
2044
|
+
className: "ops-card-head",
|
|
2045
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2046
|
+
className: "ops-card-label",
|
|
2047
|
+
children: "磁盘容量与 24h 增长"
|
|
2048
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2049
|
+
className: "ops-caption",
|
|
2050
|
+
children: "点击任一挂载点展开趋势与 Top 目录"
|
|
2051
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2052
|
+
className: "ops-caption ops-tabular",
|
|
2053
|
+
children: [metrics.mounts.length, " 个挂载点"]
|
|
2054
|
+
})]
|
|
2055
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2056
|
+
className: "ops-mount-list",
|
|
2057
|
+
children: metrics.mounts.map((m) => renderMountRow(m))
|
|
2058
|
+
})]
|
|
2059
|
+
}),
|
|
2060
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
2061
|
+
className: "ops-card",
|
|
2062
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
2063
|
+
className: "ops-card-head",
|
|
2064
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2065
|
+
className: "ops-card-label",
|
|
2066
|
+
children: "安全与网关"
|
|
2067
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2068
|
+
className: "ops-card-kpi ops-tabular",
|
|
2069
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: metrics.security.failedUnits.length }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2070
|
+
className: "ops-caption",
|
|
2071
|
+
children: "个失败 systemd 单元"
|
|
2072
|
+
})]
|
|
2073
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2074
|
+
className: `ops-pill is-${metrics.security.status}`,
|
|
2075
|
+
children: healthLabel(metrics.security.status)
|
|
2076
|
+
})]
|
|
2077
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2078
|
+
className: "ops-security-rows",
|
|
2079
|
+
children: [
|
|
2080
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2081
|
+
className: "ops-security-row",
|
|
2082
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2083
|
+
className: "ops-muted",
|
|
2084
|
+
children: "最近到期 TLS 证书"
|
|
2085
|
+
}), nearestCert ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2086
|
+
className: "ops-tabular",
|
|
2087
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2088
|
+
className: "ops-mono",
|
|
2089
|
+
children: nearestCert.host
|
|
2090
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2091
|
+
className: `ops-pill is-${nearestCert.status} ops-ml-xs`,
|
|
2092
|
+
children: [
|
|
2093
|
+
"剩 ",
|
|
2094
|
+
nearestCert.daysLeft,
|
|
2095
|
+
" 天"
|
|
2096
|
+
]
|
|
2097
|
+
})]
|
|
2098
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2099
|
+
className: "ops-caption",
|
|
2100
|
+
children: "未配置 TLS 监测"
|
|
2101
|
+
})]
|
|
2102
|
+
}),
|
|
2103
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2104
|
+
className: "ops-security-ssh",
|
|
2105
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2106
|
+
className: "ops-security-row",
|
|
2107
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2108
|
+
className: "ops-muted",
|
|
2109
|
+
children: "近 24h 异常 SSH 尝试"
|
|
2110
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2111
|
+
className: "ops-tabular",
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: metrics.security.sshFailures24h }),
|
|
2114
|
+
" 次",
|
|
2115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2116
|
+
className: "ops-caption",
|
|
2117
|
+
children: [
|
|
2118
|
+
"(近 5m ",
|
|
2119
|
+
metrics.security.sshFailures5m,
|
|
2120
|
+
" 次)"
|
|
2121
|
+
]
|
|
2122
|
+
})
|
|
2123
|
+
]
|
|
2124
|
+
})]
|
|
2125
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshMiniBarChart, { hourly: metrics.security.sshHourly24h })]
|
|
2126
|
+
}),
|
|
2127
|
+
metrics.security.failedUnits.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2128
|
+
className: "ops-failed-units",
|
|
2129
|
+
children: metrics.security.failedUnits.slice(0, 4).map((u) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2130
|
+
className: "ops-failed-unit-item",
|
|
2131
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2132
|
+
className: "ops-mono is-text-bad",
|
|
2133
|
+
children: u.unit
|
|
2134
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2135
|
+
className: "ops-caption",
|
|
2136
|
+
children: u.subState
|
|
2137
|
+
})]
|
|
2138
|
+
}, u.unit))
|
|
2139
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2140
|
+
className: "ops-caption",
|
|
2141
|
+
children: "systemd 全部活跃单元运行正常"
|
|
2142
|
+
})
|
|
2143
|
+
]
|
|
2144
|
+
})]
|
|
2145
|
+
})
|
|
2146
|
+
]
|
|
2147
|
+
}),
|
|
2148
|
+
hasServices && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2149
|
+
className: "ops-card",
|
|
2150
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
2151
|
+
className: "ops-card-head",
|
|
2152
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2153
|
+
className: "ops-card-label",
|
|
2154
|
+
children: "服务与业务健康矩阵"
|
|
2155
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2156
|
+
className: "ops-caption",
|
|
2157
|
+
children: "按主机配置动态发现的容器、探针与常驻进程"
|
|
2158
|
+
})] })
|
|
2159
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2160
|
+
className: "ops-service-grid",
|
|
2161
|
+
children: [
|
|
2162
|
+
services.containers.map((c) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2163
|
+
className: "ops-service-tile",
|
|
2164
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2165
|
+
className: "ops-service-top",
|
|
2166
|
+
children: [
|
|
2167
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${c.status}` }),
|
|
2168
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2169
|
+
className: "ops-truncate",
|
|
2170
|
+
children: c.label ?? c.name
|
|
2171
|
+
}),
|
|
2172
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2173
|
+
className: `ops-pill is-${c.status}`,
|
|
2174
|
+
children: c.health && c.health !== "none" ? c.health : c.state
|
|
2175
|
+
})
|
|
2176
|
+
]
|
|
2177
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2178
|
+
className: "ops-caption ops-mono ops-truncate",
|
|
2179
|
+
children: [c.name, c.uptimeSec ? ` · 运行 ${formatUptime(c.uptimeSec)}` : ""]
|
|
2180
|
+
})]
|
|
2181
|
+
}, `c-${c.name}`)),
|
|
2182
|
+
services.httpProbes.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2183
|
+
className: "ops-service-tile",
|
|
2184
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2185
|
+
className: "ops-service-top",
|
|
2186
|
+
children: [
|
|
2187
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${p.status}` }),
|
|
2188
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2189
|
+
className: "ops-truncate",
|
|
2190
|
+
children: p.label ?? p.id
|
|
2191
|
+
}),
|
|
2192
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2193
|
+
className: `ops-pill is-${p.status} ops-tabular`,
|
|
2194
|
+
children: [p.statusCode ?? "ERR", p.latencyMs !== null ? ` · ${p.latencyMs}ms` : ""]
|
|
2195
|
+
})
|
|
2196
|
+
]
|
|
2197
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2198
|
+
className: "ops-caption ops-mono ops-truncate",
|
|
2199
|
+
title: p.url,
|
|
2200
|
+
children: p.url
|
|
2201
|
+
})]
|
|
2202
|
+
}, `p-${p.id}`)),
|
|
2203
|
+
services.supervisors.map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2204
|
+
className: "ops-service-tile",
|
|
2205
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2206
|
+
className: "ops-service-top",
|
|
2207
|
+
children: [
|
|
2208
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${s.status}` }),
|
|
2209
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2210
|
+
className: "ops-truncate",
|
|
2211
|
+
children: s.label
|
|
2212
|
+
}),
|
|
2213
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2214
|
+
className: `ops-pill is-${s.status}`,
|
|
2215
|
+
children: [
|
|
2216
|
+
s.runningPrograms.length,
|
|
2217
|
+
" 运行 / ",
|
|
2218
|
+
s.stoppedPrograms.length,
|
|
2219
|
+
" 停止"
|
|
2220
|
+
]
|
|
2221
|
+
})
|
|
2222
|
+
]
|
|
2223
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2224
|
+
className: "ops-caption ops-truncate",
|
|
2225
|
+
children: s.detail ?? s.runningPrograms.join("、")
|
|
2226
|
+
})]
|
|
2227
|
+
}, `s-${s.id}`)),
|
|
2228
|
+
services.externalProbes.map((ep) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2229
|
+
className: "ops-service-tile",
|
|
2230
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2231
|
+
className: "ops-service-top",
|
|
2232
|
+
children: [
|
|
2233
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${ep.status}` }),
|
|
2234
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2235
|
+
className: "ops-truncate",
|
|
2236
|
+
children: ep.label
|
|
2237
|
+
}),
|
|
2238
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2239
|
+
className: `ops-pill is-${ep.status}`,
|
|
2240
|
+
children: ep.stale ? "已过期" : healthLabel(ep.status)
|
|
2241
|
+
})
|
|
2242
|
+
]
|
|
2243
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2244
|
+
className: "ops-caption ops-truncate",
|
|
2245
|
+
children: ep.summary ?? (ep.observedAt ? `更新于 ${formatRelativeTime(ep.observedAt)}` : "暂无观测")
|
|
2246
|
+
})]
|
|
2247
|
+
}, `e-${ep.id}`))
|
|
2248
|
+
]
|
|
2249
|
+
})]
|
|
2250
|
+
}),
|
|
2251
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2252
|
+
className: "ops-backup-strip",
|
|
2253
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2254
|
+
className: "ops-backup-strip-left",
|
|
2255
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${backupSummary.enabled ? backupSummary.status : "idle"}` }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2256
|
+
className: "ops-backup-strip-info",
|
|
2257
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2258
|
+
className: "ops-backup-strip-title",
|
|
2259
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "备份保护" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2260
|
+
className: "ops-caption",
|
|
2261
|
+
children: backupSummary.headline
|
|
2262
|
+
})]
|
|
2263
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2264
|
+
className: "ops-copy-pills",
|
|
2265
|
+
children: [backupSummary.copyStates.map((copy) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2266
|
+
className: `ops-copy-pill is-${copy.status}`,
|
|
2267
|
+
children: [
|
|
2268
|
+
"[",
|
|
2269
|
+
copy.code,
|
|
2270
|
+
"] ",
|
|
2271
|
+
copy.label
|
|
2272
|
+
]
|
|
2273
|
+
}, copy.vaultId)), backupSummary.lastSnapshotAt && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2274
|
+
className: "ops-caption",
|
|
2275
|
+
children: ["最新快照:", formatBeijingDateTime(backupSummary.lastSnapshotAt)]
|
|
2276
|
+
})]
|
|
2277
|
+
})]
|
|
2278
|
+
})]
|
|
2279
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2280
|
+
type: "button",
|
|
2281
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm",
|
|
2282
|
+
onClick: onGoTimeMachine,
|
|
2283
|
+
children: "进入时间机器 →"
|
|
2284
|
+
})]
|
|
2285
|
+
})
|
|
2286
|
+
]
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
const MAX_REQUEST_BYTES = 1024 * 1024;
|
|
2291
|
+
const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
2292
|
+
const SSH_IDLE_MS = 300 * 1e3;
|
|
2293
|
+
const DEFAULT_BROWSE_LIMIT = 200;
|
|
2294
|
+
const READ_VERBS = [
|
|
2295
|
+
"service-info",
|
|
2296
|
+
"overview",
|
|
2297
|
+
"resource-history",
|
|
2298
|
+
"activity-list",
|
|
2299
|
+
"incident-detail",
|
|
2300
|
+
"report-detail",
|
|
2301
|
+
"agent-observations",
|
|
2302
|
+
"agent-record",
|
|
2303
|
+
"vault.status",
|
|
2304
|
+
"snapshot.list",
|
|
2305
|
+
"browse",
|
|
2306
|
+
"diff",
|
|
2307
|
+
"job.status",
|
|
2308
|
+
"job.list"
|
|
2309
|
+
];
|
|
2310
|
+
const ADMIN_VERBS = [
|
|
2311
|
+
"restore.preview",
|
|
2312
|
+
"restore",
|
|
2313
|
+
"snapshot.now",
|
|
2314
|
+
"vault.retry"
|
|
2315
|
+
];
|
|
2316
|
+
const readVerbSet = new Set(READ_VERBS);
|
|
2317
|
+
const adminVerbSet = new Set(ADMIN_VERBS);
|
|
2318
|
+
|
|
2319
|
+
const PROVIDER_LABELS = {
|
|
2320
|
+
local: "本地",
|
|
2321
|
+
baidu: "百度网盘",
|
|
2322
|
+
"google-drive": "Google Drive",
|
|
2323
|
+
s3: "对象存储",
|
|
2324
|
+
rclone: "远端存储"
|
|
2325
|
+
};
|
|
2326
|
+
function groupSnapshotsByBeijingDate(snapshots) {
|
|
2327
|
+
const map = /* @__PURE__ */ new Map();
|
|
2328
|
+
for (const snap of snapshots) {
|
|
2329
|
+
const date = formatBeijingDate(snap.ts);
|
|
2330
|
+
const list = map.get(date);
|
|
2331
|
+
if (list) list.push(snap);
|
|
2332
|
+
else map.set(date, [snap]);
|
|
2333
|
+
}
|
|
2334
|
+
return [...map.entries()].map(([date, items]) => ({
|
|
2335
|
+
date,
|
|
2336
|
+
items
|
|
2337
|
+
}));
|
|
2338
|
+
}
|
|
2339
|
+
function changeLabel(change) {
|
|
2340
|
+
switch (change) {
|
|
2341
|
+
case "added": return "新增";
|
|
2342
|
+
case "modified": return "变更";
|
|
2343
|
+
case "deleted": return "已删除";
|
|
2344
|
+
default: return "";
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
function formatChangeSummaryReason(reason) {
|
|
2348
|
+
switch (reason) {
|
|
2349
|
+
case "unindexed": return "该快照尚未建立本地目录索引,暂无法计算变更数量";
|
|
2350
|
+
case "prev_unindexed": return "前一个相邻快照未建立索引,暂无法计算相对变更数量";
|
|
2351
|
+
case "oldest_snapshot": return "当前为最早快照,无更早基线可对比";
|
|
2352
|
+
case "metadata_incomplete": return "此仓库缺少文件大小与修改时间元数据,无法识别修改数量,仅统计新增和删除";
|
|
2353
|
+
default: return "变更数量暂未计算";
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
function formatUnindexedNotice(options) {
|
|
2357
|
+
const { isDiff, errorCode, reason } = options;
|
|
2358
|
+
if (isDiff || errorCode === "COMPARE_SNAPSHOT_UNINDEXED") return "当前快照或上一相邻快照尚未在本地建立目录索引,暂无法直接对比差异。";
|
|
2359
|
+
if (errorCode === "SNAPSHOT_UNINDEXED" || !reason || /not indexed on disk|materialize/i.test(reason)) return "该历史快照尚未在本地建立目录索引,暂无法直接浏览文件列表。请切换至已索引快照,或在服务器端按需建立该快照索引后再查看。";
|
|
2360
|
+
return reason;
|
|
2361
|
+
}
|
|
2362
|
+
function TimeMachineTab({ serverId, capabilities, initialData, initialQuery = "", initialOnlyChanged = false, onOpenAgent }) {
|
|
2363
|
+
const api = useApi();
|
|
2364
|
+
const hasBackupCap = capabilities.includes("backup");
|
|
2365
|
+
const [selectedVaultId, setSelectedVaultId] = (0, react.useState)("");
|
|
2366
|
+
const [onlyVerifiedOffsite, setOnlyVerifiedOffsite] = (0, react.useState)(false);
|
|
2367
|
+
const [selectedPoint, setSelectedPoint] = (0, react.useState)(() => initialData?.browse?.point ?? initialData?.snapshotList?.snapshots[0]?.point ?? "");
|
|
2368
|
+
const [currentPath, setCurrentPath] = (0, react.useState)(() => initialData?.browse?.path ?? "");
|
|
2369
|
+
const [searchText, setSearchText] = (0, react.useState)(initialQuery);
|
|
2370
|
+
const debouncedQuery = useDebouncedValue(searchText.trim(), 300);
|
|
2371
|
+
const [onlyChanged, setOnlyChanged] = (0, react.useState)(initialOnlyChanged);
|
|
2372
|
+
const [cursor, setCursor] = (0, react.useState)(void 0);
|
|
2373
|
+
const [selectedPaths, setSelectedPaths] = (0, react.useState)([]);
|
|
2374
|
+
const [restoreSourceVault, setRestoreSourceVault] = (0, react.useState)("");
|
|
2375
|
+
const [previewModal, setPreviewModal] = (0, react.useState)(null);
|
|
2376
|
+
const [emergencyOpen, setEmergencyOpen] = (0, react.useState)(false);
|
|
2377
|
+
const [activeJob, setActiveJob] = (0, react.useState)(() => initialData?.jobs?.find((j) => j.state === "running" || j.state === "queued") ?? null);
|
|
2378
|
+
const [actionBusy, setActionBusy] = (0, react.useState)(false);
|
|
2379
|
+
const [actionError, setActionError] = (0, react.useState)(null);
|
|
2380
|
+
const [copiedPath, setCopiedPath] = (0, react.useState)(false);
|
|
2381
|
+
const vaultQuery = useBridgeQuery(hasBackupCap ? `vault:${serverId}` : null, () => api.getVaultStatus(serverId), {
|
|
2382
|
+
enabled: hasBackupCap,
|
|
2383
|
+
initialData: initialData?.vaultStatus,
|
|
2384
|
+
staleTimeMs: 3e4
|
|
2385
|
+
});
|
|
2386
|
+
const snapQuery = useBridgeQuery(hasBackupCap ? `snapshots:${serverId}:${selectedVaultId || "all"}` : null, () => api.getSnapshotList({
|
|
2387
|
+
vaultId: selectedVaultId || void 0,
|
|
2388
|
+
limit: 60
|
|
2389
|
+
}, serverId), {
|
|
2390
|
+
enabled: hasBackupCap,
|
|
2391
|
+
initialData: initialData?.snapshotList,
|
|
2392
|
+
staleTimeMs: 3e4
|
|
2393
|
+
});
|
|
2394
|
+
const jobsQuery = useBridgeQuery(hasBackupCap ? `jobs:${serverId}` : null, () => api.getJobList({ limit: 20 }, serverId), {
|
|
2395
|
+
enabled: hasBackupCap,
|
|
2396
|
+
initialData: initialData?.jobs ? { jobs: initialData.jobs } : void 0,
|
|
2397
|
+
staleTimeMs: 1e4
|
|
2398
|
+
});
|
|
2399
|
+
const snapshots = snapQuery.data?.snapshots ?? [];
|
|
2400
|
+
const filteredSnapshots = (0, react.useMemo)(() => {
|
|
2401
|
+
if (!onlyVerifiedOffsite) return snapshots;
|
|
2402
|
+
return snapshots.filter((s) => s.copies.some((c) => c.provider !== "local" && c.state === "ok" && Boolean(c.verifiedAt)));
|
|
2403
|
+
}, [snapshots, onlyVerifiedOffsite]);
|
|
2404
|
+
const effectivePoint = selectedPoint && filteredSnapshots.some((s) => s.point === selectedPoint) ? selectedPoint : filteredSnapshots[0]?.point ?? "";
|
|
2405
|
+
const currentSnapIndex = filteredSnapshots.findIndex((s) => s.point === effectivePoint);
|
|
2406
|
+
const currentSnap = currentSnapIndex >= 0 ? filteredSnapshots[currentSnapIndex] : void 0;
|
|
2407
|
+
const previousSnap = currentSnapIndex >= 0 && currentSnapIndex + 1 < filteredSnapshots.length ? filteredSnapshots[currentSnapIndex + 1] : void 0;
|
|
2408
|
+
const previousPoint = previousSnap?.point;
|
|
2409
|
+
const isSnapUnindexed = (snap) => Boolean(snap && (snap.indexed === false || snap.state === "unindexed" || snap.state === "unavailable"));
|
|
2410
|
+
const isCurrentSnapUnindexed = isSnapUnindexed(currentSnap);
|
|
2411
|
+
const isPreviousSnapUnindexed = isSnapUnindexed(previousSnap);
|
|
2412
|
+
const canDiffPrevious = Boolean(previousPoint) && !isCurrentSnapUnindexed && !isPreviousSnapUnindexed;
|
|
2413
|
+
const browseKey = hasBackupCap && effectivePoint ? `browse:${serverId}:${effectivePoint}:${currentPath}:${debouncedQuery}:${onlyChanged ? "1" : "0"}:${cursor ?? ""}:${selectedVaultId}` : null;
|
|
2414
|
+
const browseQuery = useBridgeQuery(browseKey, () => api.browseSnapshots({
|
|
2415
|
+
point: effectivePoint,
|
|
2416
|
+
path: currentPath,
|
|
2417
|
+
query: debouncedQuery || void 0,
|
|
2418
|
+
onlyChanged,
|
|
2419
|
+
compareToPoint: onlyChanged ? previousPoint : void 0,
|
|
2420
|
+
cursor,
|
|
2421
|
+
limit: DEFAULT_BROWSE_LIMIT,
|
|
2422
|
+
vaultId: selectedVaultId || void 0
|
|
2423
|
+
}, serverId), {
|
|
2424
|
+
enabled: Boolean(browseKey),
|
|
2425
|
+
initialData: initialData?.browse && initialData.browse.point === effectivePoint && initialData.browse.path === currentPath && debouncedQuery === initialQuery.trim() && !onlyChanged && !cursor ? initialData.browse : void 0,
|
|
2426
|
+
staleTimeMs: 2e4
|
|
2427
|
+
});
|
|
2428
|
+
const diffQuery = useBridgeQuery(hasBackupCap && onlyChanged && canDiffPrevious && effectivePoint && previousPoint ? `diff:${serverId}:${previousPoint}:${effectivePoint}:${currentPath}:${debouncedQuery}` : null, () => api.diffSnapshots({
|
|
2429
|
+
fromPoint: previousPoint,
|
|
2430
|
+
toPoint: effectivePoint,
|
|
2431
|
+
pathPrefix: currentPath || void 0,
|
|
2432
|
+
query: debouncedQuery || void 0,
|
|
2433
|
+
limit: DEFAULT_BROWSE_LIMIT
|
|
2434
|
+
}, serverId), {
|
|
2435
|
+
enabled: Boolean(hasBackupCap && onlyChanged && canDiffPrevious && effectivePoint && previousPoint),
|
|
2436
|
+
initialData: initialData?.diff,
|
|
2437
|
+
staleTimeMs: 2e4
|
|
2438
|
+
});
|
|
2439
|
+
(0, react.useEffect)(() => {
|
|
2440
|
+
if (!activeJob || activeJob.state === "done" || activeJob.state === "failed") return;
|
|
2441
|
+
let live = true;
|
|
2442
|
+
const timer = setInterval(async () => {
|
|
2443
|
+
try {
|
|
2444
|
+
const next = await api.getJobStatus(activeJob.jobId, serverId);
|
|
2445
|
+
if (!live) return;
|
|
2446
|
+
setActiveJob(next);
|
|
2447
|
+
if (next.state === "done" || next.state === "failed") {
|
|
2448
|
+
invalidateBridgeQuery(`jobs:${serverId}`);
|
|
2449
|
+
invalidateBridgeQuery(`vault:${serverId}`);
|
|
2450
|
+
invalidateBridgeQuery(`snapshots:${serverId}`);
|
|
2451
|
+
jobsQuery.refetch();
|
|
2452
|
+
vaultQuery.refetch();
|
|
2453
|
+
snapQuery.refetch();
|
|
2454
|
+
}
|
|
2455
|
+
} catch {}
|
|
2456
|
+
}, 1800);
|
|
2457
|
+
return () => {
|
|
2458
|
+
live = false;
|
|
2459
|
+
clearInterval(timer);
|
|
2460
|
+
};
|
|
2461
|
+
}, [
|
|
2462
|
+
activeJob,
|
|
2463
|
+
api,
|
|
2464
|
+
serverId,
|
|
2465
|
+
jobsQuery,
|
|
2466
|
+
vaultQuery,
|
|
2467
|
+
snapQuery
|
|
2468
|
+
]);
|
|
2469
|
+
const allJobs = (0, react.useMemo)(() => {
|
|
2470
|
+
const list = [...jobsQuery.data?.jobs ?? []];
|
|
2471
|
+
if (activeJob && !list.some((j) => j.jobId === activeJob.jobId)) list.unshift(activeJob);
|
|
2472
|
+
return list;
|
|
2473
|
+
}, [jobsQuery.data?.jobs, activeJob]);
|
|
2474
|
+
const hasUrgentJobs = allJobs.some((j) => j.state === "running" || j.state === "queued" || j.state === "failed");
|
|
2475
|
+
const [jobsDrawerOpen, setJobsDrawerOpen] = (0, react.useState)(hasUrgentJobs);
|
|
2476
|
+
(0, react.useEffect)(() => {
|
|
2477
|
+
if (hasUrgentJobs) setJobsDrawerOpen(true);
|
|
2478
|
+
}, [hasUrgentJobs]);
|
|
2479
|
+
if (!hasBackupCap || vaultQuery.data && !vaultQuery.data.enabled) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2480
|
+
className: "ops-empty-card",
|
|
2481
|
+
children: [
|
|
2482
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2483
|
+
className: "ops-empty-icon",
|
|
2484
|
+
"aria-hidden": "true",
|
|
2485
|
+
children: "⏱"
|
|
2486
|
+
}),
|
|
2487
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "该主机尚未启用时间机器备份" }),
|
|
2488
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2489
|
+
className: "ops-muted",
|
|
2490
|
+
children: [
|
|
2491
|
+
"启用通用 ",
|
|
2492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
2493
|
+
className: "ops-mono",
|
|
2494
|
+
children: "restic"
|
|
2495
|
+
}),
|
|
2496
|
+
" 加密备份后,即可按时间点浏览目录历史、比对跨天文件变更,并一键安全恢复到隔离目录(绝不覆盖原工作区)。"
|
|
2497
|
+
]
|
|
2498
|
+
}),
|
|
2499
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2500
|
+
className: "ops-empty-actions",
|
|
2501
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2502
|
+
type: "button",
|
|
2503
|
+
className: "ops-btn ops-btn-info",
|
|
2504
|
+
onClick: () => onOpenAgent("setup-restic-backup"),
|
|
2505
|
+
children: "由运维 Agent 引导配置 restic 备份"
|
|
2506
|
+
})
|
|
2507
|
+
})
|
|
2508
|
+
]
|
|
2509
|
+
});
|
|
2510
|
+
const vaults = vaultQuery.data?.vaults ?? [];
|
|
2511
|
+
const emergency = vaultQuery.data?.emergencyRecovery;
|
|
2512
|
+
const groupedSnapshots = groupSnapshotsByBeijingDate(filteredSnapshots);
|
|
2513
|
+
const displayEntries = (0, react.useMemo)(() => {
|
|
2514
|
+
if (onlyChanged && diffQuery.data) return diffQuery.data.entries.map((d) => ({
|
|
2515
|
+
name: d.name,
|
|
2516
|
+
path: d.path,
|
|
2517
|
+
kind: d.kind,
|
|
2518
|
+
size: d.afterSize ?? d.beforeSize,
|
|
2519
|
+
mtime: d.afterMtime ?? d.beforeMtime,
|
|
2520
|
+
change: d.change
|
|
2521
|
+
}));
|
|
2522
|
+
return browseQuery.data?.entries ?? [];
|
|
2523
|
+
}, [
|
|
2524
|
+
onlyChanged,
|
|
2525
|
+
diffQuery.data,
|
|
2526
|
+
browseQuery.data?.entries
|
|
2527
|
+
]);
|
|
2528
|
+
const isBrowseUnindexed = isCurrentSnapUnindexed || browseQuery.data?.indexed === false || browseQuery.data?.state === "unindexed" || browseQuery.data?.state === "unavailable";
|
|
2529
|
+
const isDiffUnindexed = onlyChanged && (!canDiffPrevious || diffQuery.data?.indexed === false || diffQuery.data?.state === "unindexed" || diffQuery.data?.state === "unavailable");
|
|
2530
|
+
const unindexedReason = formatUnindexedNotice({
|
|
2531
|
+
isDiff: Boolean(isDiffUnindexed),
|
|
2532
|
+
errorCode: isDiffUnindexed ? diffQuery.data?.errorCode : browseQuery.data?.errorCode,
|
|
2533
|
+
reason: isDiffUnindexed ? diffQuery.data?.reason : browseQuery.data?.reason
|
|
2534
|
+
});
|
|
2535
|
+
const isDiffMetadataIncomplete = currentSnap?.metadataComplete === false || diffQuery.data?.metadataComplete === false || diffQuery.data?.summary.modified === null || diffQuery.data?.summary.reason === "metadata_incomplete";
|
|
2536
|
+
const metadataComplete = onlyChanged ? !isDiffMetadataIncomplete : currentSnap?.metadataComplete !== false && (browseQuery.data?.metadataComplete ?? true);
|
|
2537
|
+
const isApproximate = browseQuery.data?.approximate ?? false;
|
|
2538
|
+
const breadcrumbs = currentPath ? currentPath.split("/") : [];
|
|
2539
|
+
function togglePathSelection(path) {
|
|
2540
|
+
setSelectedPaths((prev) => prev.includes(path) ? prev.filter((p) => p !== path) : [...prev, path]);
|
|
2541
|
+
}
|
|
2542
|
+
async function handleSnapshotNow() {
|
|
2543
|
+
setActionBusy(true);
|
|
2544
|
+
setActionError(null);
|
|
2545
|
+
try {
|
|
2546
|
+
setActiveJob(await api.triggerSnapshotNow({ vaultId: selectedVaultId || vaults.find((v) => v.canCaptureNow)?.id }, serverId));
|
|
2547
|
+
setJobsDrawerOpen(true);
|
|
2548
|
+
} catch (err) {
|
|
2549
|
+
setActionError(err instanceof Error ? err.message : "触发即时快照失败");
|
|
2550
|
+
} finally {
|
|
2551
|
+
setActionBusy(false);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
async function handleRetryVault(vault) {
|
|
2555
|
+
setActionBusy(true);
|
|
2556
|
+
setActionError(null);
|
|
2557
|
+
try {
|
|
2558
|
+
setActiveJob(await api.retryVault({ vaultId: vault.id }, serverId));
|
|
2559
|
+
setJobsDrawerOpen(true);
|
|
2560
|
+
} catch (err) {
|
|
2561
|
+
setActionError(err instanceof Error ? err.message : `重试 ${vault.label} 失败`);
|
|
2562
|
+
} finally {
|
|
2563
|
+
setActionBusy(false);
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
async function handlePreviewRestore() {
|
|
2567
|
+
if (!effectivePoint || selectedPaths.length === 0) return;
|
|
2568
|
+
setActionBusy(true);
|
|
2569
|
+
setActionError(null);
|
|
2570
|
+
try {
|
|
2571
|
+
setPreviewModal(await api.previewRestore({
|
|
2572
|
+
point: effectivePoint,
|
|
2573
|
+
paths: selectedPaths,
|
|
2574
|
+
vaultId: restoreSourceVault || selectedVaultId || vaults[0]?.id
|
|
2575
|
+
}, serverId));
|
|
2576
|
+
} catch (err) {
|
|
2577
|
+
setActionError(err instanceof Error ? err.message : "生成恢复预览失败");
|
|
2578
|
+
} finally {
|
|
2579
|
+
setActionBusy(false);
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
async function handleConfirmRestore() {
|
|
2583
|
+
if (!previewModal) return;
|
|
2584
|
+
setActionBusy(true);
|
|
2585
|
+
setActionError(null);
|
|
2586
|
+
try {
|
|
2587
|
+
const job = await api.executeRestore({
|
|
2588
|
+
confirmToken: previewModal.confirmToken,
|
|
2589
|
+
point: previewModal.point,
|
|
2590
|
+
paths: previewModal.paths,
|
|
2591
|
+
vaultId: previewModal.vaultId
|
|
2592
|
+
}, serverId);
|
|
2593
|
+
setPreviewModal(null);
|
|
2594
|
+
setSelectedPaths([]);
|
|
2595
|
+
setActiveJob(job);
|
|
2596
|
+
setJobsDrawerOpen(true);
|
|
2597
|
+
} catch (err) {
|
|
2598
|
+
setActionError(err instanceof Error ? err.message : "提交恢复任务失败");
|
|
2599
|
+
} finally {
|
|
2600
|
+
setActionBusy(false);
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
async function copyRestoredDir(dir) {
|
|
2604
|
+
try {
|
|
2605
|
+
await navigator.clipboard.writeText(dir);
|
|
2606
|
+
setCopiedPath(true);
|
|
2607
|
+
setTimeout(() => setCopiedPath(false), 2e3);
|
|
2608
|
+
} catch {
|
|
2609
|
+
setActionError("复制失败,请手动选中路径复制。");
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
const restoredDirectory = activeJob?.state === "done" && typeof activeJob.result?.directory === "string" ? activeJob.result.directory : null;
|
|
2613
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2614
|
+
className: "ops-tab-stack",
|
|
2615
|
+
children: [
|
|
2616
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2617
|
+
className: "ops-card ops-vault-bar",
|
|
2618
|
+
children: [
|
|
2619
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2620
|
+
className: "ops-vault-bar-top",
|
|
2621
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2622
|
+
className: "ops-vault-pills",
|
|
2623
|
+
role: "group",
|
|
2624
|
+
"aria-label": "备份仓库状态",
|
|
2625
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2626
|
+
type: "button",
|
|
2627
|
+
className: `ops-vault-chip ${selectedVaultId === "" ? "is-selected" : ""}`,
|
|
2628
|
+
onClick: () => setSelectedVaultId(""),
|
|
2629
|
+
children: [
|
|
2630
|
+
"全部存储端 (",
|
|
2631
|
+
vaults.length,
|
|
2632
|
+
")"
|
|
2633
|
+
]
|
|
2634
|
+
}), vaults.map((v) => {
|
|
2635
|
+
const formattedRepoSize = typeof v.repoSizeBytes === "number" && Number.isFinite(v.repoSizeBytes) && v.repoSizeBytes >= 0 ? formatBytes(v.repoSizeBytes) : null;
|
|
2636
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2637
|
+
className: `ops-vault-chip is-${v.status} ${selectedVaultId === v.id ? "is-selected" : ""}`,
|
|
2638
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2639
|
+
type: "button",
|
|
2640
|
+
className: "ops-vault-chip-main",
|
|
2641
|
+
onClick: () => setSelectedVaultId(v.id === selectedVaultId ? "" : v.id),
|
|
2642
|
+
title: v.lastError ?? `${PROVIDER_LABELS[v.provider] ?? v.provider} · ${v.snapshotCount} 个快照${formattedRepoSize ? ` · 仓库大小 ${formattedRepoSize}` : ""}`,
|
|
2643
|
+
children: [
|
|
2644
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${v.status}` }),
|
|
2645
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [
|
|
2646
|
+
"[",
|
|
2647
|
+
v.code,
|
|
2648
|
+
"] ",
|
|
2649
|
+
v.label
|
|
2650
|
+
] }),
|
|
2651
|
+
formattedRepoSize && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2652
|
+
className: "ops-vault-size ops-tabular",
|
|
2653
|
+
title: `仓库大小 ${formattedRepoSize}`,
|
|
2654
|
+
children: formattedRepoSize
|
|
2655
|
+
}),
|
|
2656
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2657
|
+
className: "ops-caption",
|
|
2658
|
+
children: v.lastSuccessAt ? formatBeijingDateTime(v.lastSuccessAt) : healthLabel(v.status)
|
|
2659
|
+
})
|
|
2660
|
+
]
|
|
2661
|
+
}), v.canRetry && v.status !== "ok" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2662
|
+
type: "button",
|
|
2663
|
+
className: "ops-btn ops-btn-secondary ops-btn-xs",
|
|
2664
|
+
disabled: actionBusy,
|
|
2665
|
+
onClick: () => void handleRetryVault(v),
|
|
2666
|
+
children: "重试"
|
|
2667
|
+
})]
|
|
2668
|
+
}, v.id);
|
|
2669
|
+
})]
|
|
2670
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2671
|
+
className: "ops-vault-actions",
|
|
2672
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2673
|
+
type: "button",
|
|
2674
|
+
className: "ops-btn ops-btn-primary ops-btn-sm",
|
|
2675
|
+
disabled: actionBusy,
|
|
2676
|
+
onClick: () => void handleSnapshotNow(),
|
|
2677
|
+
children: "立即创建快照"
|
|
2678
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2679
|
+
type: "button",
|
|
2680
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm",
|
|
2681
|
+
onClick: () => setEmergencyOpen(true),
|
|
2682
|
+
children: "应急恢复指引"
|
|
2683
|
+
})]
|
|
2684
|
+
})]
|
|
2685
|
+
}),
|
|
2686
|
+
vaults.some((v) => v.lastError) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2687
|
+
className: "ops-vault-warnings",
|
|
2688
|
+
children: vaults.filter((v) => v.lastError).map((v) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2689
|
+
className: "ops-caption is-text-warn",
|
|
2690
|
+
children: [
|
|
2691
|
+
"[",
|
|
2692
|
+
v.code,
|
|
2693
|
+
"] ",
|
|
2694
|
+
v.label,
|
|
2695
|
+
":",
|
|
2696
|
+
v.lastError
|
|
2697
|
+
]
|
|
2698
|
+
}, v.id))
|
|
2699
|
+
}),
|
|
2700
|
+
activeJob && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2701
|
+
className: `ops-job-progress is-${activeJob.state}`,
|
|
2702
|
+
children: [
|
|
2703
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2704
|
+
className: "ops-job-progress-head",
|
|
2705
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [
|
|
2706
|
+
activeJob.kind === "restore" ? "恢复任务" : activeJob.kind === "snapshot" ? "即时快照" : "备份重试",
|
|
2707
|
+
" ",
|
|
2708
|
+
"· ",
|
|
2709
|
+
activeJob.state === "done" ? "已完成" : activeJob.state === "failed" ? "失败" : "执行中"
|
|
2710
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2711
|
+
className: "ops-caption ops-mono",
|
|
2712
|
+
children: activeJob.jobId
|
|
2713
|
+
})]
|
|
2714
|
+
}),
|
|
2715
|
+
activeJob.progress?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2716
|
+
className: "ops-caption",
|
|
2717
|
+
children: activeJob.progress.message
|
|
2718
|
+
}),
|
|
2719
|
+
activeJob.error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2720
|
+
className: "ops-caption is-text-bad",
|
|
2721
|
+
children: activeJob.error
|
|
2722
|
+
}),
|
|
2723
|
+
activeJob.progress?.percent !== void 0 && activeJob.state !== "done" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2724
|
+
className: "ops-meter-track",
|
|
2725
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2726
|
+
className: "ops-meter-fill is-ok",
|
|
2727
|
+
style: { width: `${Math.min(100, Math.max(0, activeJob.progress.percent))}%` }
|
|
2728
|
+
})
|
|
2729
|
+
}),
|
|
2730
|
+
restoredDirectory && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2731
|
+
className: "ops-restored-receipt",
|
|
2732
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2733
|
+
className: "ops-mono",
|
|
2734
|
+
children: restoredDirectory
|
|
2735
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2736
|
+
type: "button",
|
|
2737
|
+
className: "ops-btn ops-btn-secondary ops-btn-xs",
|
|
2738
|
+
onClick: () => void copyRestoredDir(restoredDirectory),
|
|
2739
|
+
children: copiedPath ? "已复制路径" : "复制路径"
|
|
2740
|
+
})]
|
|
2741
|
+
})
|
|
2742
|
+
]
|
|
2743
|
+
}),
|
|
2744
|
+
actionError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2745
|
+
className: "ops-inline-alert is-bad",
|
|
2746
|
+
role: "alert",
|
|
2747
|
+
children: actionError
|
|
2748
|
+
})
|
|
2749
|
+
]
|
|
2750
|
+
}),
|
|
2751
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2752
|
+
className: "ops-tm-grid",
|
|
2753
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("aside", {
|
|
2754
|
+
className: "ops-card ops-tm-timeline",
|
|
2755
|
+
"aria-label": "快照时间轴",
|
|
2756
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2757
|
+
className: "ops-tm-pane-head",
|
|
2758
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "快照时间轴" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2759
|
+
className: "ops-segmented",
|
|
2760
|
+
role: "group",
|
|
2761
|
+
"aria-label": "快照筛选",
|
|
2762
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2763
|
+
type: "button",
|
|
2764
|
+
className: `ops-seg-btn ${!onlyVerifiedOffsite ? "is-active" : ""}`,
|
|
2765
|
+
"aria-pressed": !onlyVerifiedOffsite,
|
|
2766
|
+
onClick: () => setOnlyVerifiedOffsite(false),
|
|
2767
|
+
children: "全部"
|
|
2768
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2769
|
+
type: "button",
|
|
2770
|
+
className: `ops-seg-btn ${onlyVerifiedOffsite ? "is-active" : ""}`,
|
|
2771
|
+
"aria-pressed": onlyVerifiedOffsite,
|
|
2772
|
+
onClick: () => setOnlyVerifiedOffsite(true),
|
|
2773
|
+
children: "仅异地已验真"
|
|
2774
|
+
})]
|
|
2775
|
+
})]
|
|
2776
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2777
|
+
className: "ops-timeline-scroll",
|
|
2778
|
+
children: groupedSnapshots.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2779
|
+
className: "ops-empty-inline",
|
|
2780
|
+
children: "当前筛选条件下暂无快照"
|
|
2781
|
+
}) : groupedSnapshots.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2782
|
+
className: "ops-timeline-group",
|
|
2783
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2784
|
+
className: "ops-timeline-date",
|
|
2785
|
+
children: [group.date, "(北京时间)"]
|
|
2786
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2787
|
+
className: "ops-timeline-items",
|
|
2788
|
+
children: group.items.map((snap) => {
|
|
2789
|
+
const active = snap.point === effectivePoint;
|
|
2790
|
+
const snapUnindexed = isSnapUnindexed(snap);
|
|
2791
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2792
|
+
type: "button",
|
|
2793
|
+
className: `ops-snap-item ${active ? "is-active" : ""} ${snapUnindexed ? "is-unindexed" : ""}`,
|
|
2794
|
+
onClick: () => {
|
|
2795
|
+
setSelectedPoint(snap.point);
|
|
2796
|
+
setCursor(void 0);
|
|
2797
|
+
setSelectedPaths([]);
|
|
2798
|
+
if (snapUnindexed) setOnlyChanged(false);
|
|
2799
|
+
},
|
|
2800
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2801
|
+
className: "ops-snap-top",
|
|
2802
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2803
|
+
className: "ops-tabular",
|
|
2804
|
+
children: formatBeijingTime(snap.ts)
|
|
2805
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2806
|
+
className: "ops-snap-copies",
|
|
2807
|
+
children: [snapUnindexed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2808
|
+
className: "ops-pill is-idle",
|
|
2809
|
+
title: "该快照尚未物化目录索引",
|
|
2810
|
+
children: "未索引"
|
|
2811
|
+
}), snap.copies.map((c) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2812
|
+
className: `ops-copy-badge is-${c.state}`,
|
|
2813
|
+
title: `${PROVIDER_LABELS[c.provider] ?? c.provider}:${c.state}`,
|
|
2814
|
+
children: c.code
|
|
2815
|
+
}, c.vaultId))]
|
|
2816
|
+
})]
|
|
2817
|
+
}), snap.changeSummary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2818
|
+
className: "ops-snap-changes ops-tabular",
|
|
2819
|
+
children: typeof snap.changeSummary.added === "number" && typeof snap.changeSummary.deleted === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2820
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2821
|
+
className: "is-chg-added",
|
|
2822
|
+
children: ["+", snap.changeSummary.added]
|
|
2823
|
+
}),
|
|
2824
|
+
typeof snap.changeSummary.modified === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2825
|
+
className: "is-chg-modified",
|
|
2826
|
+
children: ["~", snap.changeSummary.modified]
|
|
2827
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2828
|
+
className: "is-chg-modified",
|
|
2829
|
+
title: formatChangeSummaryReason(snap.changeSummary.reason ?? "metadata_incomplete"),
|
|
2830
|
+
children: "~—"
|
|
2831
|
+
}),
|
|
2832
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2833
|
+
className: "is-chg-deleted",
|
|
2834
|
+
children: ["-", snap.changeSummary.deleted]
|
|
2835
|
+
})
|
|
2836
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2837
|
+
className: "ops-caption",
|
|
2838
|
+
title: formatChangeSummaryReason(snap.changeSummary.reason),
|
|
2839
|
+
children: "— 未计算"
|
|
2840
|
+
})
|
|
2841
|
+
})]
|
|
2842
|
+
}, snap.point);
|
|
2843
|
+
})
|
|
2844
|
+
})]
|
|
2845
|
+
}, group.date))
|
|
2846
|
+
})]
|
|
2847
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2848
|
+
className: "ops-card ops-tm-browser",
|
|
2849
|
+
children: [
|
|
2850
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2851
|
+
className: "ops-tm-toolbar",
|
|
2852
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
2853
|
+
className: "ops-breadcrumbs",
|
|
2854
|
+
"aria-label": "当前目录路径",
|
|
2855
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2856
|
+
type: "button",
|
|
2857
|
+
className: `ops-crumb ${currentPath === "" ? "is-current" : ""}`,
|
|
2858
|
+
onClick: () => {
|
|
2859
|
+
setCurrentPath("");
|
|
2860
|
+
setCursor(void 0);
|
|
2861
|
+
},
|
|
2862
|
+
children: "根目录"
|
|
2863
|
+
}), breadcrumbs.map((seg, idx) => {
|
|
2864
|
+
const segPath = breadcrumbs.slice(0, idx + 1).join("/");
|
|
2865
|
+
const isLast = idx === breadcrumbs.length - 1;
|
|
2866
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2867
|
+
className: "ops-crumb-wrap",
|
|
2868
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2869
|
+
className: "ops-crumb-sep",
|
|
2870
|
+
children: "/"
|
|
2871
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2872
|
+
type: "button",
|
|
2873
|
+
className: `ops-crumb ${isLast ? "is-current" : ""}`,
|
|
2874
|
+
onClick: () => {
|
|
2875
|
+
setCurrentPath(segPath);
|
|
2876
|
+
setCursor(void 0);
|
|
2877
|
+
},
|
|
2878
|
+
children: seg
|
|
2879
|
+
})]
|
|
2880
|
+
}, segPath);
|
|
2881
|
+
})]
|
|
2882
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2883
|
+
className: "ops-tm-controls",
|
|
2884
|
+
children: [
|
|
2885
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2886
|
+
type: "search",
|
|
2887
|
+
className: "ops-search-input",
|
|
2888
|
+
value: searchText,
|
|
2889
|
+
onChange: (e) => {
|
|
2890
|
+
setSearchText(e.target.value);
|
|
2891
|
+
setCursor(void 0);
|
|
2892
|
+
},
|
|
2893
|
+
placeholder: "按文件名筛选(300ms 防抖)…",
|
|
2894
|
+
"aria-label": "按文件名筛选"
|
|
2895
|
+
}),
|
|
2896
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2897
|
+
className: "ops-toggle-label",
|
|
2898
|
+
title: canDiffPrevious ? void 0 : "当前或上一快照未物化目录索引,无法直接对比",
|
|
2899
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2900
|
+
type: "checkbox",
|
|
2901
|
+
checked: onlyChanged && canDiffPrevious,
|
|
2902
|
+
disabled: !canDiffPrevious,
|
|
2903
|
+
onChange: (e) => {
|
|
2904
|
+
setOnlyChanged(e.target.checked);
|
|
2905
|
+
setCursor(void 0);
|
|
2906
|
+
}
|
|
2907
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "仅看较上一快照变化" })]
|
|
2908
|
+
}),
|
|
2909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2910
|
+
type: "button",
|
|
2911
|
+
className: "ops-btn ops-btn-info ops-btn-sm",
|
|
2912
|
+
onClick: () => onOpenAgent(`find-deleted:${currentPath}`),
|
|
2913
|
+
children: "✨ 让 Agent 跨天找误删"
|
|
2914
|
+
})
|
|
2915
|
+
]
|
|
2916
|
+
})]
|
|
2917
|
+
}),
|
|
2918
|
+
(!metadataComplete || isApproximate) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2919
|
+
className: "ops-tm-meta-note",
|
|
2920
|
+
role: "status",
|
|
2921
|
+
children: onlyChanged && !metadataComplete ? "此仓库无法识别修改,只显示新增和删除" : !metadataComplete ? "部分历史快照索引未包含完整文件大小与修改时间,已以「—」优雅占位。" : "当前列表来自增量索引目录,大小与修改时间为近似值。"
|
|
2922
|
+
}),
|
|
2923
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2924
|
+
className: "ops-file-table",
|
|
2925
|
+
role: "table",
|
|
2926
|
+
"aria-label": "快照文件列表",
|
|
2927
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2928
|
+
className: "ops-file-row is-header",
|
|
2929
|
+
role: "row",
|
|
2930
|
+
children: [
|
|
2931
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2932
|
+
className: "ops-file-col-check",
|
|
2933
|
+
role: "columnheader",
|
|
2934
|
+
"aria-label": "选择"
|
|
2935
|
+
}),
|
|
2936
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2937
|
+
className: "ops-file-col-name",
|
|
2938
|
+
role: "columnheader",
|
|
2939
|
+
children: "名称"
|
|
2940
|
+
}),
|
|
2941
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2942
|
+
className: "ops-file-col-change",
|
|
2943
|
+
role: "columnheader",
|
|
2944
|
+
children: "变化"
|
|
2945
|
+
}),
|
|
2946
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2947
|
+
className: "ops-file-col-size",
|
|
2948
|
+
role: "columnheader",
|
|
2949
|
+
children: "大小"
|
|
2950
|
+
}),
|
|
2951
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2952
|
+
className: "ops-file-col-mtime",
|
|
2953
|
+
role: "columnheader",
|
|
2954
|
+
children: "修改时间"
|
|
2955
|
+
})
|
|
2956
|
+
]
|
|
2957
|
+
}), browseQuery.loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2958
|
+
className: "ops-empty-inline",
|
|
2959
|
+
children: "正在读取快照目录…"
|
|
2960
|
+
}) : isBrowseUnindexed || isDiffUnindexed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2961
|
+
className: "ops-empty-inline",
|
|
2962
|
+
role: "status",
|
|
2963
|
+
children: [
|
|
2964
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "未索引快照" }),
|
|
2965
|
+
":",
|
|
2966
|
+
unindexedReason
|
|
2967
|
+
]
|
|
2968
|
+
}) : displayEntries.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2969
|
+
className: "ops-empty-inline",
|
|
2970
|
+
children: onlyChanged ? !metadataComplete ? "较上一快照无新增或删除文件(此仓库无法识别修改)" : "较上一快照无新增、变更或删除文件" : "该目录下暂无匹配文件"
|
|
2971
|
+
}) : displayEntries.map((entry) => {
|
|
2972
|
+
const checked = selectedPaths.includes(entry.path);
|
|
2973
|
+
const isDeleted = entry.change === "deleted";
|
|
2974
|
+
const parentPath = Boolean(debouncedQuery || searchText.trim() || onlyChanged) ? relativeParentPath(entry.path, currentPath) : null;
|
|
2975
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2976
|
+
role: "row",
|
|
2977
|
+
className: `ops-file-row ${checked ? "is-checked" : ""} ${isDeleted ? "is-deleted" : ""}`,
|
|
2978
|
+
children: [
|
|
2979
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2980
|
+
className: "ops-file-col-check",
|
|
2981
|
+
role: "cell",
|
|
2982
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2983
|
+
type: "checkbox",
|
|
2984
|
+
checked,
|
|
2985
|
+
disabled: isDeleted && onlyChanged,
|
|
2986
|
+
"aria-label": `选择 ${entry.name}`,
|
|
2987
|
+
onChange: () => togglePathSelection(entry.path)
|
|
2988
|
+
})
|
|
2989
|
+
}),
|
|
2990
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2991
|
+
className: "ops-file-col-name",
|
|
2992
|
+
role: "cell",
|
|
2993
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2994
|
+
className: "ops-file-icon",
|
|
2995
|
+
"aria-hidden": "true",
|
|
2996
|
+
children: entry.kind === "dir" ? "📁" : entry.kind === "symlink" ? "🔗" : "📄"
|
|
2997
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2998
|
+
className: "ops-file-name-wrap",
|
|
2999
|
+
children: [entry.kind === "dir" && !isDeleted ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3000
|
+
type: "button",
|
|
3001
|
+
className: "ops-file-dir-btn ops-truncate",
|
|
3002
|
+
title: entry.path,
|
|
3003
|
+
onClick: () => {
|
|
3004
|
+
setCurrentPath(entry.path);
|
|
3005
|
+
setCursor(void 0);
|
|
3006
|
+
setSelectedPaths([]);
|
|
3007
|
+
},
|
|
3008
|
+
children: entry.name
|
|
3009
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3010
|
+
className: "ops-file-name-text ops-truncate",
|
|
3011
|
+
title: entry.path,
|
|
3012
|
+
children: entry.name
|
|
3013
|
+
}), parentPath && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3014
|
+
className: "ops-file-subpath ops-mono ops-truncate",
|
|
3015
|
+
title: entry.path,
|
|
3016
|
+
children: parentPath
|
|
3017
|
+
})]
|
|
3018
|
+
})]
|
|
3019
|
+
}),
|
|
3020
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3021
|
+
className: "ops-file-col-change",
|
|
3022
|
+
role: "cell",
|
|
3023
|
+
children: entry.change && entry.change !== "unchanged" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3024
|
+
className: `ops-change-pill is-${entry.change}`,
|
|
3025
|
+
children: changeLabel(entry.change)
|
|
3026
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3027
|
+
className: "ops-caption",
|
|
3028
|
+
children: "—"
|
|
3029
|
+
})
|
|
3030
|
+
}),
|
|
3031
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3032
|
+
className: "ops-file-col-size ops-tabular",
|
|
3033
|
+
role: "cell",
|
|
3034
|
+
title: metadataComplete ? void 0 : "索引元数据未完整",
|
|
3035
|
+
children: entry.kind === "dir" ? "—" : metadataComplete && entry.size !== void 0 ? formatBytes(entry.size) : "—"
|
|
3036
|
+
}),
|
|
3037
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3038
|
+
className: "ops-file-col-mtime ops-tabular",
|
|
3039
|
+
role: "cell",
|
|
3040
|
+
title: metadataComplete ? void 0 : "索引元数据未完整",
|
|
3041
|
+
children: metadataComplete && entry.mtime ? formatBeijingDateTime(entry.mtime) : "—"
|
|
3042
|
+
})
|
|
3043
|
+
]
|
|
3044
|
+
}, entry.path);
|
|
3045
|
+
})]
|
|
3046
|
+
}),
|
|
3047
|
+
browseQuery.data && (browseQuery.data.nextCursor || browseQuery.data.totalCount !== void 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3048
|
+
className: "ops-table-footer",
|
|
3049
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3050
|
+
className: "ops-caption ops-tabular",
|
|
3051
|
+
children: [
|
|
3052
|
+
"当前显示 ",
|
|
3053
|
+
displayEntries.length,
|
|
3054
|
+
" 项",
|
|
3055
|
+
browseQuery.data.totalCount !== void 0 ? ` / 共 ${browseQuery.data.totalCount} 项` : "",
|
|
3056
|
+
"(每页上限 ",
|
|
3057
|
+
DEFAULT_BROWSE_LIMIT,
|
|
3058
|
+
" 条)"
|
|
3059
|
+
]
|
|
3060
|
+
}), browseQuery.data.nextCursor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3061
|
+
type: "button",
|
|
3062
|
+
className: "ops-btn ops-btn-secondary ops-btn-xs",
|
|
3063
|
+
onClick: () => setCursor(browseQuery.data?.nextCursor ?? void 0),
|
|
3064
|
+
children: "加载下一页"
|
|
3065
|
+
})]
|
|
3066
|
+
}),
|
|
3067
|
+
selectedPaths.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3068
|
+
className: "ops-restore-bar",
|
|
3069
|
+
role: "region",
|
|
3070
|
+
"aria-label": "安全恢复操作条",
|
|
3071
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3072
|
+
className: "ops-restore-bar-left",
|
|
3073
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [
|
|
3074
|
+
"已勾选 ",
|
|
3075
|
+
selectedPaths.length,
|
|
3076
|
+
" 项"
|
|
3077
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
3078
|
+
"aria-label": "选择恢复来源",
|
|
3079
|
+
value: restoreSourceVault,
|
|
3080
|
+
onChange: (e) => setRestoreSourceVault(e.target.value),
|
|
3081
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3082
|
+
value: "",
|
|
3083
|
+
children: "自动优先(本地优先)"
|
|
3084
|
+
}), vaults.map((v) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
3085
|
+
value: v.id,
|
|
3086
|
+
children: [
|
|
3087
|
+
"[",
|
|
3088
|
+
v.code,
|
|
3089
|
+
"] ",
|
|
3090
|
+
v.label
|
|
3091
|
+
]
|
|
3092
|
+
}, v.id))]
|
|
3093
|
+
})]
|
|
3094
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3095
|
+
className: "ops-restore-bar-right",
|
|
3096
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3097
|
+
type: "button",
|
|
3098
|
+
className: "ops-btn ops-btn-ghost ops-btn-sm",
|
|
3099
|
+
onClick: () => setSelectedPaths([]),
|
|
3100
|
+
children: "取消选择"
|
|
3101
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3102
|
+
type: "button",
|
|
3103
|
+
className: "ops-btn ops-btn-primary ops-btn-sm",
|
|
3104
|
+
disabled: actionBusy || isBrowseUnindexed,
|
|
3105
|
+
onClick: () => void handlePreviewRestore(),
|
|
3106
|
+
children: "确认恢复到新目录"
|
|
3107
|
+
})]
|
|
3108
|
+
})]
|
|
3109
|
+
})
|
|
3110
|
+
]
|
|
3111
|
+
})]
|
|
3112
|
+
}),
|
|
3113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3114
|
+
className: "ops-card ops-jobs-drawer",
|
|
3115
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3116
|
+
type: "button",
|
|
3117
|
+
className: "ops-jobs-toggle",
|
|
3118
|
+
"aria-expanded": jobsDrawerOpen,
|
|
3119
|
+
onClick: () => setJobsDrawerOpen((v) => !v),
|
|
3120
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "恢复与备份任务记录" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3121
|
+
className: "ops-caption ops-sep",
|
|
3122
|
+
children: [
|
|
3123
|
+
"共 ",
|
|
3124
|
+
allJobs.length,
|
|
3125
|
+
" 条",
|
|
3126
|
+
hasUrgentJobs ? " · 有进行中或异常任务" : ""
|
|
3127
|
+
]
|
|
3128
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3129
|
+
className: "ops-caption",
|
|
3130
|
+
children: jobsDrawerOpen ? "收起 ▲" : "展开 ▾"
|
|
3131
|
+
})]
|
|
3132
|
+
}), jobsDrawerOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3133
|
+
className: "ops-jobs-list",
|
|
3134
|
+
children: allJobs.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3135
|
+
className: "ops-caption",
|
|
3136
|
+
children: "暂无近期备份或恢复任务记录。"
|
|
3137
|
+
}) : allJobs.map((job) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3138
|
+
className: "ops-job-row",
|
|
3139
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3140
|
+
className: "ops-job-row-main",
|
|
3141
|
+
children: [
|
|
3142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${job.state === "done" ? "ok" : job.state === "failed" ? "bad" : "warn"}` }),
|
|
3143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3144
|
+
className: "ops-mono",
|
|
3145
|
+
children: job.jobId
|
|
3146
|
+
}),
|
|
3147
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3148
|
+
className: "ops-pill is-idle",
|
|
3149
|
+
children: job.kind
|
|
3150
|
+
}),
|
|
3151
|
+
job.progress?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3152
|
+
className: "ops-caption",
|
|
3153
|
+
children: job.progress.message
|
|
3154
|
+
}),
|
|
3155
|
+
job.error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3156
|
+
className: "ops-caption is-text-bad",
|
|
3157
|
+
children: job.error
|
|
3158
|
+
})
|
|
3159
|
+
]
|
|
3160
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3161
|
+
className: "ops-job-row-right ops-tabular",
|
|
3162
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3163
|
+
className: "ops-caption",
|
|
3164
|
+
children: formatBeijingFull(job.createdAt)
|
|
3165
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3166
|
+
className: `ops-pill is-${job.state === "done" ? "ok" : job.state === "failed" ? "bad" : "warn"}`,
|
|
3167
|
+
children: job.state === "running" && job.progress?.percent !== void 0 ? `${job.progress.percent}%` : job.state
|
|
3168
|
+
})]
|
|
3169
|
+
})]
|
|
3170
|
+
}, job.jobId))
|
|
3171
|
+
})]
|
|
3172
|
+
}),
|
|
3173
|
+
previewModal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3174
|
+
className: "ops-modal-backdrop",
|
|
3175
|
+
role: "presentation",
|
|
3176
|
+
onClick: () => setPreviewModal(null),
|
|
3177
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3178
|
+
className: "ops-modal",
|
|
3179
|
+
role: "dialog",
|
|
3180
|
+
"aria-modal": "true",
|
|
3181
|
+
"aria-label": "确认安全恢复到隔离目录",
|
|
3182
|
+
onClick: (e) => e.stopPropagation(),
|
|
3183
|
+
children: [
|
|
3184
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3185
|
+
className: "ops-modal-head",
|
|
3186
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "确认恢复到全新隔离目录" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3187
|
+
type: "button",
|
|
3188
|
+
className: "ops-icon-btn",
|
|
3189
|
+
onClick: () => setPreviewModal(null),
|
|
3190
|
+
children: "✕"
|
|
3191
|
+
})]
|
|
3192
|
+
}),
|
|
3193
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3194
|
+
className: "ops-modal-body",
|
|
3195
|
+
children: [
|
|
3196
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3197
|
+
className: "ops-inline-alert is-ok",
|
|
3198
|
+
children: "安全承诺:仅恢复到全新隔离目录,绝不覆盖当前工作区中的任何原文件。"
|
|
3199
|
+
}),
|
|
3200
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", {
|
|
3201
|
+
className: "ops-preview-dl",
|
|
3202
|
+
children: [
|
|
3203
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: "恢复来源" }),
|
|
3204
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: previewModal.sourceLabel }),
|
|
3205
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: "隔离目标目录" }),
|
|
3206
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
|
3207
|
+
className: "ops-mono",
|
|
3208
|
+
children: previewModal.directory
|
|
3209
|
+
}),
|
|
3210
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: "空间预检" }),
|
|
3211
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dd", {
|
|
3212
|
+
className: "ops-tabular",
|
|
3213
|
+
children: [previewModal.spaceCheckPassed ? "通过" : "空间不足", previewModal.availableSpaceBytes !== null && `(剩余 ${formatBytes(previewModal.availableSpaceBytes)})`]
|
|
3214
|
+
})
|
|
3215
|
+
]
|
|
3216
|
+
}),
|
|
3217
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3218
|
+
className: "ops-preview-paths",
|
|
3219
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3220
|
+
className: "ops-caption",
|
|
3221
|
+
children: [
|
|
3222
|
+
"待恢复路径(共 ",
|
|
3223
|
+
previewModal.paths.length,
|
|
3224
|
+
" 项):"
|
|
3225
|
+
]
|
|
3226
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: previewModal.paths.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
3227
|
+
className: "ops-mono",
|
|
3228
|
+
children: p
|
|
3229
|
+
}, p)) })]
|
|
3230
|
+
}),
|
|
3231
|
+
previewModal.warnings.map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3232
|
+
className: "ops-caption is-text-warn",
|
|
3233
|
+
children: w
|
|
3234
|
+
}, i))
|
|
3235
|
+
]
|
|
3236
|
+
}),
|
|
3237
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3238
|
+
className: "ops-modal-foot",
|
|
3239
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3240
|
+
type: "button",
|
|
3241
|
+
className: "ops-btn ops-btn-ghost",
|
|
3242
|
+
onClick: () => setPreviewModal(null),
|
|
3243
|
+
children: "取消"
|
|
3244
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3245
|
+
type: "button",
|
|
3246
|
+
className: "ops-btn ops-btn-primary",
|
|
3247
|
+
disabled: actionBusy || !previewModal.spaceCheckPassed,
|
|
3248
|
+
onClick: () => void handleConfirmRestore(),
|
|
3249
|
+
children: actionBusy ? "提交恢复任务…" : "确认提交恢复"
|
|
3250
|
+
})]
|
|
3251
|
+
})
|
|
3252
|
+
]
|
|
3253
|
+
})
|
|
3254
|
+
}),
|
|
3255
|
+
emergencyOpen && emergency && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3256
|
+
className: "ops-drawer-backdrop",
|
|
3257
|
+
role: "presentation",
|
|
3258
|
+
onClick: () => setEmergencyOpen(false),
|
|
3259
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("aside", {
|
|
3260
|
+
className: "ops-drawer",
|
|
3261
|
+
role: "dialog",
|
|
3262
|
+
"aria-modal": "true",
|
|
3263
|
+
"aria-label": "脱机应急恢复指引",
|
|
3264
|
+
onClick: (e) => e.stopPropagation(),
|
|
3265
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3266
|
+
className: "ops-drawer-head",
|
|
3267
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "脱机应急恢复指引" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3268
|
+
type: "button",
|
|
3269
|
+
className: "ops-icon-btn",
|
|
3270
|
+
onClick: () => setEmergencyOpen(false),
|
|
3271
|
+
children: "✕"
|
|
3272
|
+
})]
|
|
3273
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3274
|
+
className: "ops-drawer-body",
|
|
3275
|
+
children: [
|
|
3276
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3277
|
+
className: "ops-inline-alert is-ok",
|
|
3278
|
+
children: "零密钥明文承诺:本指引仅展示仓库位置与脱机步骤,绝不包含或存储任何解密口令。"
|
|
3279
|
+
}),
|
|
3280
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3281
|
+
className: "ops-drawer-section",
|
|
3282
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "仓库位置核对清单" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3283
|
+
className: "ops-server-list",
|
|
3284
|
+
children: emergency.repoLocations.map((loc) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3285
|
+
className: "ops-server-item",
|
|
3286
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3287
|
+
className: "ops-server-meta",
|
|
3288
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: PROVIDER_LABELS[loc.provider] ?? loc.provider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3289
|
+
className: "ops-mono ops-caption",
|
|
3290
|
+
children: loc.locatorHint
|
|
3291
|
+
})]
|
|
3292
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3293
|
+
className: "ops-pill is-ok",
|
|
3294
|
+
children: loc.encrypted ? "已加密" : "未加密"
|
|
3295
|
+
})]
|
|
3296
|
+
}, loc.id))
|
|
3297
|
+
})]
|
|
3298
|
+
}),
|
|
3299
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3300
|
+
className: "ops-drawer-section",
|
|
3301
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "脱机恢复步骤" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
3302
|
+
className: "ops-pre-block",
|
|
3303
|
+
children: emergency.instructionsMarkdown
|
|
3304
|
+
})]
|
|
3305
|
+
}),
|
|
3306
|
+
emergency.notes.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3307
|
+
className: "ops-drawer-section",
|
|
3308
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "注意事项" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
3309
|
+
className: "ops-bullet-list",
|
|
3310
|
+
children: emergency.notes.map((n, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: n }, i))
|
|
3311
|
+
})]
|
|
3312
|
+
})
|
|
3313
|
+
]
|
|
3314
|
+
})]
|
|
3315
|
+
})
|
|
3316
|
+
})
|
|
3317
|
+
]
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
const FILTER_LABELS = {
|
|
3322
|
+
all: "全部",
|
|
3323
|
+
alert: "告警与故障",
|
|
3324
|
+
report: "每日早报"
|
|
3325
|
+
};
|
|
3326
|
+
const REPORT_DATE_RE = /\b(\d{4}-\d{2}-\d{2})\b/;
|
|
3327
|
+
function extractReportDateKey(item) {
|
|
3328
|
+
const fromId = item.id.match(REPORT_DATE_RE);
|
|
3329
|
+
if (fromId) return fromId[1];
|
|
3330
|
+
const fromTitle = item.title.match(REPORT_DATE_RE);
|
|
3331
|
+
return fromTitle ? fromTitle[1] : "";
|
|
3332
|
+
}
|
|
3333
|
+
function ActivityTab({ serverId, initialData, initialExpandedId, onOpenAgent }) {
|
|
3334
|
+
const api = useApi();
|
|
3335
|
+
const [filter, setFilter] = (0, react.useState)("all");
|
|
3336
|
+
const [keyword, setKeyword] = (0, react.useState)("");
|
|
3337
|
+
const [expandedId, setExpandedId] = (0, react.useState)(() => initialExpandedId !== void 0 ? initialExpandedId : initialData?.incidentDetail?.id ?? initialData?.reportDetail?.id ?? null);
|
|
3338
|
+
const [rawOpenIds, setRawOpenIds] = (0, react.useState)({});
|
|
3339
|
+
const listQuery = useBridgeQuery(`activity:${serverId}:${filter}`, () => api.getActivityList({
|
|
3340
|
+
kind: filter === "all" ? "all" : filter,
|
|
3341
|
+
limit: 50
|
|
3342
|
+
}, serverId), {
|
|
3343
|
+
initialData: filter === "all" ? initialData?.activityList : void 0,
|
|
3344
|
+
staleTimeMs: 15e3
|
|
3345
|
+
});
|
|
3346
|
+
const items = listQuery.data?.items ?? [];
|
|
3347
|
+
const filteredItems = (0, react.useMemo)(() => {
|
|
3348
|
+
const q = keyword.trim().toLowerCase();
|
|
3349
|
+
const matched = items.filter((item) => {
|
|
3350
|
+
if (filter !== "all" && item.kind !== filter) return false;
|
|
3351
|
+
if (!q) return true;
|
|
3352
|
+
return item.id.toLowerCase().includes(q) || item.title.toLowerCase().includes(q) || item.summary.toLowerCase().includes(q) || (item.signal?.toLowerCase().includes(q) ?? false);
|
|
3353
|
+
});
|
|
3354
|
+
if (filter === "report") return [...matched].sort((a, b) => extractReportDateKey(b).localeCompare(extractReportDateKey(a)) || b.ts - a.ts || b.id.localeCompare(a.id));
|
|
3355
|
+
return matched;
|
|
3356
|
+
}, [
|
|
3357
|
+
items,
|
|
3358
|
+
filter,
|
|
3359
|
+
keyword
|
|
3360
|
+
]);
|
|
3361
|
+
const expandedItem = filteredItems.find((i) => i.id === expandedId) ?? null;
|
|
3362
|
+
const incidentDetailQuery = useBridgeQuery(expandedItem && expandedItem.kind !== "report" ? `incident:${serverId}:${expandedItem.id}` : null, () => api.getIncidentDetail(expandedItem.id, serverId), {
|
|
3363
|
+
enabled: Boolean(expandedItem && expandedItem.kind !== "report"),
|
|
3364
|
+
initialData: initialData?.incidentDetail && initialData.incidentDetail.id === expandedItem?.id ? initialData.incidentDetail : void 0,
|
|
3365
|
+
staleTimeMs: 2e4
|
|
3366
|
+
});
|
|
3367
|
+
const reportDetailQuery = useBridgeQuery(expandedItem && expandedItem.kind === "report" ? `report:${serverId}:${expandedItem.id}` : null, () => api.getReportDetail({ id: expandedItem.id }, serverId), {
|
|
3368
|
+
enabled: Boolean(expandedItem && expandedItem.kind === "report"),
|
|
3369
|
+
initialData: initialData?.reportDetail && initialData.reportDetail.id === expandedItem?.id ? initialData.reportDetail : void 0,
|
|
3370
|
+
staleTimeMs: 6e4
|
|
3371
|
+
});
|
|
3372
|
+
function toggleExpand(item) {
|
|
3373
|
+
setExpandedId((prev) => prev === item.id ? null : item.id);
|
|
3374
|
+
}
|
|
3375
|
+
function renderReportExpanded(detail) {
|
|
3376
|
+
const badges = [...detail.highlights, ...detail.backupReceipt ? [{
|
|
3377
|
+
label: "备份回执",
|
|
3378
|
+
value: `${detail.backupReceipt.snapshotsInWindow} 次快照`,
|
|
3379
|
+
status: detail.backupReceipt.status
|
|
3380
|
+
}] : []].slice(0, 4);
|
|
3381
|
+
const totalGaps = detail.coverage.reduce((sum, c) => sum + c.gaps.length, 0);
|
|
3382
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3383
|
+
className: "ops-activity-expanded",
|
|
3384
|
+
children: [
|
|
3385
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3386
|
+
className: "ops-highlight-grid",
|
|
3387
|
+
children: badges.map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3388
|
+
className: "ops-highlight-chip",
|
|
3389
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3390
|
+
className: "ops-caption",
|
|
3391
|
+
children: b.label
|
|
3392
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
3393
|
+
className: `ops-tabular is-text-${b.status}`,
|
|
3394
|
+
children: b.value
|
|
3395
|
+
})]
|
|
3396
|
+
}, i))
|
|
3397
|
+
}),
|
|
3398
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
3399
|
+
className: "ops-bullet-list",
|
|
3400
|
+
children: detail.summaryLines.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: line }, i))
|
|
3401
|
+
}),
|
|
3402
|
+
detail.backupReceipt && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3403
|
+
className: "ops-caption",
|
|
3404
|
+
children: ["备份摘要:", detail.backupReceipt.detail]
|
|
3405
|
+
}),
|
|
3406
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3407
|
+
className: "ops-details-box",
|
|
3408
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
3409
|
+
"采样覆盖与缺测详情(",
|
|
3410
|
+
detail.coverage.length,
|
|
3411
|
+
" 项信号 · 缺测 ",
|
|
3412
|
+
totalGaps,
|
|
3413
|
+
" 段)"
|
|
3414
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3415
|
+
className: "ops-coverage-list",
|
|
3416
|
+
children: detail.coverage.map((c) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3417
|
+
className: "ops-coverage-row ops-tabular",
|
|
3418
|
+
children: [
|
|
3419
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3420
|
+
className: "ops-mono",
|
|
3421
|
+
children: c.signal
|
|
3422
|
+
}),
|
|
3423
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
3424
|
+
c.sampleCount,
|
|
3425
|
+
"/",
|
|
3426
|
+
c.expectedCount,
|
|
3427
|
+
" 次采样"
|
|
3428
|
+
] }),
|
|
3429
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3430
|
+
className: c.gaps.length > 0 ? "is-text-warn" : "ops-caption",
|
|
3431
|
+
children: c.gaps.length > 0 ? `缺测 ${c.gaps.length} 段` : "无缺测"
|
|
3432
|
+
})
|
|
3433
|
+
]
|
|
3434
|
+
}, c.signal))
|
|
3435
|
+
})]
|
|
3436
|
+
})
|
|
3437
|
+
]
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
function renderIncidentExpanded(detail) {
|
|
3441
|
+
const showRaw = Boolean(rawOpenIds[detail.id]);
|
|
3442
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3443
|
+
className: "ops-activity-expanded",
|
|
3444
|
+
children: [
|
|
3445
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3446
|
+
className: "ops-incident-summary",
|
|
3447
|
+
children: detail.summary
|
|
3448
|
+
}),
|
|
3449
|
+
detail.pendingChecks.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3450
|
+
className: "ops-pending-checks",
|
|
3451
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3452
|
+
className: "ops-caption",
|
|
3453
|
+
children: "建议核查要点:"
|
|
3454
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
3455
|
+
className: "ops-bullet-list",
|
|
3456
|
+
children: detail.pendingChecks.map((chk, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: chk }, idx))
|
|
3457
|
+
})]
|
|
3458
|
+
}),
|
|
3459
|
+
detail.logSummary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3460
|
+
className: "ops-log-summary",
|
|
3461
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3462
|
+
className: "ops-caption",
|
|
3463
|
+
children: [
|
|
3464
|
+
"日志聚合(",
|
|
3465
|
+
detail.logSummary.unit ?? "系统",
|
|
3466
|
+
",窗口 ",
|
|
3467
|
+
detail.logSummary.windowSec,
|
|
3468
|
+
"s,命中",
|
|
3469
|
+
" ",
|
|
3470
|
+
detail.logSummary.matchedCount,
|
|
3471
|
+
" 条)"
|
|
3472
|
+
]
|
|
3473
|
+
})
|
|
3474
|
+
}),
|
|
3475
|
+
detail.samples.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3476
|
+
className: "ops-raw-evidence",
|
|
3477
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3478
|
+
type: "button",
|
|
3479
|
+
className: "ops-link-btn",
|
|
3480
|
+
onClick: () => setRawOpenIds((prev) => ({
|
|
3481
|
+
...prev,
|
|
3482
|
+
[detail.id]: !showRaw
|
|
3483
|
+
})),
|
|
3484
|
+
children: showRaw ? "收起原始观测证据 ▲" : `展开原始观测证据(${detail.samples.length} 条采样) ▾`
|
|
3485
|
+
}), showRaw && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3486
|
+
className: "ops-evidence-list",
|
|
3487
|
+
children: detail.samples.map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3488
|
+
className: "ops-evidence-item",
|
|
3489
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3490
|
+
className: "ops-evidence-head",
|
|
3491
|
+
children: [
|
|
3492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3493
|
+
className: `ops-pill is-${s.state}`,
|
|
3494
|
+
children: healthLabel(s.state)
|
|
3495
|
+
}),
|
|
3496
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3497
|
+
className: "ops-mono",
|
|
3498
|
+
children: s.signal
|
|
3499
|
+
}),
|
|
3500
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3501
|
+
className: "ops-caption ops-tabular",
|
|
3502
|
+
children: formatBeijingFull(s.ts)
|
|
3503
|
+
})
|
|
3504
|
+
]
|
|
3505
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
3506
|
+
className: "ops-pre-inline",
|
|
3507
|
+
children: JSON.stringify(s.facts, null, 2)
|
|
3508
|
+
})]
|
|
3509
|
+
}, s.id))
|
|
3510
|
+
})]
|
|
3511
|
+
})
|
|
3512
|
+
]
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3516
|
+
className: "ops-tab-stack",
|
|
3517
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3518
|
+
className: "ops-activity-toolbar",
|
|
3519
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3520
|
+
className: "ops-segmented",
|
|
3521
|
+
role: "group",
|
|
3522
|
+
"aria-label": "动态类型筛选",
|
|
3523
|
+
children: Object.keys(FILTER_LABELS).map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3524
|
+
type: "button",
|
|
3525
|
+
className: `ops-seg-btn ${filter === key ? "is-active" : ""}`,
|
|
3526
|
+
"aria-pressed": filter === key,
|
|
3527
|
+
onClick: () => setFilter(key),
|
|
3528
|
+
children: FILTER_LABELS[key]
|
|
3529
|
+
}, key))
|
|
3530
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3531
|
+
type: "search",
|
|
3532
|
+
className: "ops-search-input",
|
|
3533
|
+
value: keyword,
|
|
3534
|
+
onChange: (e) => setKeyword(e.target.value),
|
|
3535
|
+
placeholder: "搜索编号、信号或关键词…",
|
|
3536
|
+
"aria-label": "搜索动态与日报"
|
|
3537
|
+
})]
|
|
3538
|
+
}), listQuery.loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3539
|
+
className: "ops-card ops-empty-inline",
|
|
3540
|
+
children: "正在加载动态与每日早报…"
|
|
3541
|
+
}) : filteredItems.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3542
|
+
className: "ops-empty-card",
|
|
3543
|
+
children: [
|
|
3544
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3545
|
+
className: "ops-empty-icon",
|
|
3546
|
+
"aria-hidden": "true",
|
|
3547
|
+
children: "📋"
|
|
3548
|
+
}),
|
|
3549
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "暂无匹配的告警或早报记录" }),
|
|
3550
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3551
|
+
className: "ops-muted",
|
|
3552
|
+
children: "服务运行平稳,每日 07:00 将自动由纯函数汇总过去 24 小时采样生成结构化早报。"
|
|
3553
|
+
})
|
|
3554
|
+
]
|
|
3555
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3556
|
+
className: "ops-activity-list",
|
|
3557
|
+
children: filteredItems.map((item) => {
|
|
3558
|
+
const isExpanded = expandedId === item.id;
|
|
3559
|
+
const isReport = item.kind === "report";
|
|
3560
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
3561
|
+
className: `ops-card ops-activity-card ${item.unread ? "is-unread" : ""}`,
|
|
3562
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3563
|
+
className: "ops-activity-head",
|
|
3564
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3565
|
+
type: "button",
|
|
3566
|
+
className: "ops-activity-trigger",
|
|
3567
|
+
"aria-expanded": isExpanded,
|
|
3568
|
+
onClick: () => toggleExpand(item),
|
|
3569
|
+
children: [
|
|
3570
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3571
|
+
className: "ops-activity-meta",
|
|
3572
|
+
children: [
|
|
3573
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3574
|
+
className: `ops-pill is-${item.status}`,
|
|
3575
|
+
children: isReport ? "07:00 日报" : healthLabel(item.status)
|
|
3576
|
+
}),
|
|
3577
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3578
|
+
className: "ops-caption ops-mono",
|
|
3579
|
+
children: item.id
|
|
3580
|
+
}),
|
|
3581
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3582
|
+
className: "ops-caption ops-tabular",
|
|
3583
|
+
children: formatBeijingDateTime(item.ts)
|
|
3584
|
+
}),
|
|
3585
|
+
item.unread && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3586
|
+
className: "ops-unread-dot",
|
|
3587
|
+
"aria-label": "未读"
|
|
3588
|
+
})
|
|
3589
|
+
]
|
|
3590
|
+
}),
|
|
3591
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
3592
|
+
className: "ops-activity-title",
|
|
3593
|
+
children: item.title
|
|
3594
|
+
}),
|
|
3595
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3596
|
+
className: "ops-muted",
|
|
3597
|
+
children: item.summary
|
|
3598
|
+
})
|
|
3599
|
+
]
|
|
3600
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3601
|
+
className: "ops-activity-actions",
|
|
3602
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3603
|
+
type: "button",
|
|
3604
|
+
className: "ops-btn ops-btn-ghost ops-btn-sm",
|
|
3605
|
+
onClick: () => toggleExpand(item),
|
|
3606
|
+
children: isExpanded ? "收起 ▲" : "详情 ▾"
|
|
3607
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3608
|
+
type: "button",
|
|
3609
|
+
className: "ops-btn ops-btn-info ops-btn-sm",
|
|
3610
|
+
onClick: () => onOpenAgent(`record:${item.id}`),
|
|
3611
|
+
children: "在 Agent 会话中深挖"
|
|
3612
|
+
})]
|
|
3613
|
+
})]
|
|
3614
|
+
}), isExpanded && (() => {
|
|
3615
|
+
const matchedReportDetail = isReport && reportDetailQuery.data?.id === item.id ? reportDetailQuery.data : null;
|
|
3616
|
+
const matchedIncidentDetail = !isReport && incidentDetailQuery.data?.id === item.id ? incidentDetailQuery.data : null;
|
|
3617
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: isReport ? matchedReportDetail ? renderReportExpanded(matchedReportDetail) : reportDetailQuery.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3618
|
+
className: "ops-inline-alert is-bad",
|
|
3619
|
+
role: "alert",
|
|
3620
|
+
children: ["加载日报失败:", reportDetailQuery.error]
|
|
3621
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3622
|
+
className: "ops-inline-loading",
|
|
3623
|
+
role: "status",
|
|
3624
|
+
children: "正在加载完整日报…"
|
|
3625
|
+
}) : matchedIncidentDetail ? renderIncidentExpanded(matchedIncidentDetail) : incidentDetailQuery.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3626
|
+
className: "ops-inline-alert is-bad",
|
|
3627
|
+
role: "alert",
|
|
3628
|
+
children: ["加载事件详情失败:", incidentDetailQuery.error]
|
|
3629
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3630
|
+
className: "ops-inline-loading",
|
|
3631
|
+
role: "status",
|
|
3632
|
+
children: "正在加载事件观测证据…"
|
|
3633
|
+
}) });
|
|
3634
|
+
})()]
|
|
3635
|
+
}, item.id);
|
|
3636
|
+
})
|
|
3637
|
+
})]
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
|
|
3641
|
+
var styles_css_default = ".dsh-ops-root {\n height: 100%;\n width: 100%;\n overflow: auto;\n container-type: inline-size;\n background: var(--dsw-alias-bg-base, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n font-family: var(--dsw-font-family, system-ui, -apple-system, BlinkMacSystemFont, \"PingFang SC\", sans-serif);\n font-size: 13px;\n line-height: 1.5;\n -webkit-font-smoothing: antialiased;\n}\n\n.dsh-ops-root *,\n.dsh-ops-root *::before,\n.dsh-ops-root *::after {\n box-sizing: border-box;\n}\n\n.dsh-ops-root .ops-shell {\n max-width: 1180px;\n margin: 0 auto;\n padding: 18px 24px 48px;\n}\n\n/* Typography utilities */\n.dsh-ops-root .ops-mono {\n font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, monospace);\n}\n\n.dsh-ops-root .ops-tabular {\n font-variant-numeric: tabular-nums;\n}\n\n.dsh-ops-root .ops-muted {\n color: var(--dsw-alias-label-secondary, #61666b);\n margin: 0;\n}\n\n.dsh-ops-root .ops-caption {\n font-size: 12px;\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.dsh-ops-root .ops-sep {\n margin-left: 8px;\n}\n\n.dsh-ops-root .ops-ml-xs {\n margin-left: 6px;\n}\n\n.dsh-ops-root .ops-mt-sm {\n margin-top: 10px;\n}\n\n.dsh-ops-root .is-text-ok {\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .is-text-warn {\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .is-text-bad {\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n/* Global Topbar */\n.dsh-ops-root .ops-topbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n padding-bottom: 14px;\n border-bottom: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n}\n\n.dsh-ops-root .ops-topbar-left,\n.dsh-ops-root .ops-topbar-right,\n.dsh-ops-root .ops-host-switcher {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-brand {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-size: 15px;\n font-weight: 600;\n letter-spacing: -0.01em;\n}\n\n.dsh-ops-root .ops-brand-mark {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border-radius: var(--dsw-radius-xs, 4px);\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n color: var(--dsw-alias-state-business-primary, #4176e6);\n font-size: 13px;\n}\n\n.dsh-ops-root .ops-host-select {\n height: 30px;\n padding: 0 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n font: inherit;\n font-weight: 500;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-conn-pill {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n border-radius: 999px;\n font-size: 12px;\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-conn-pill.is-online {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-label-primary, #0f1115);\n}\n\n/* Status Dots & Pills */\n.dsh-ops-root .ops-dot {\n display: inline-block;\n width: 8px;\n height: 8px;\n border-radius: 999px;\n flex-shrink: 0;\n background: var(--dsw-alias-state-idle-primary, #d4d4d4);\n}\n\n.dsh-ops-root .ops-dot.is-ok {\n background: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .ops-dot.is-warn {\n background: var(--dsw-alias-state-warn-primary, #f59e0b);\n}\n\n.dsh-ops-root .ops-dot.is-bad {\n background: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-pill {\n display: inline-flex;\n align-items: center;\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 500;\n line-height: 1.5;\n white-space: nowrap;\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-pill.is-ok {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .ops-pill.is-warn {\n background: var(--dsw-alias-state-warn-tertiary, #fef5e7);\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .ops-pill.is-bad {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.08));\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-pill.is-info {\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n/* Buttons */\n.dsh-ops-root .ops-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n height: 34px;\n padding: 0 14px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid transparent;\n font: inherit;\n font-weight: 500;\n cursor: pointer;\n white-space: nowrap;\n transition: background-color 120ms ease, border-color 120ms ease;\n}\n\n.dsh-ops-root .ops-btn:disabled {\n opacity: 0.52;\n cursor: not-allowed;\n}\n\n.dsh-ops-root .ops-btn-sm {\n height: 30px;\n padding: 0 11px;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-btn-xs {\n height: 24px;\n padding: 0 8px;\n font-size: 12px;\n border-radius: var(--dsw-radius-xs, 4px);\n}\n\n.dsh-ops-root .ops-btn-primary {\n background: var(--dsw-alias-button-primary-fill, #0f1115);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n}\n\n.dsh-ops-root .ops-btn-primary:hover:not(:disabled) {\n background: var(--dsw-alias-button-primary-hover, #43454a);\n}\n\n.dsh-ops-root .ops-btn-info {\n background: var(--dsw-alias-button-info-fill, #4176e6);\n color: var(--dsw-alias-label-on-color, #ffffff);\n}\n\n.dsh-ops-root .ops-btn-info:hover:not(:disabled) {\n filter: brightness(1.06);\n}\n\n.dsh-ops-root .ops-btn-secondary {\n background: var(--dsw-alias-card-fill, #fafafa);\n border-color: var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n color: var(--dsw-alias-label-primary, #0f1115);\n}\n\n.dsh-ops-root .ops-btn-secondary:hover:not(:disabled) {\n background: var(--dsw-alias-card-fill-hover, #f5f5f5);\n}\n\n.dsh-ops-root .ops-btn-ghost {\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-btn-ghost:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n color: var(--dsw-alias-label-primary, #0f1115);\n}\n\n.dsh-ops-root .ops-btn-danger-ghost {\n background: transparent;\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-btn-danger-ghost:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.06));\n}\n\n.dsh-ops-root .ops-link-btn {\n border: 0;\n padding: 0;\n background: transparent;\n color: var(--dsw-alias-link, #4176e6);\n font: inherit;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-link-btn:hover {\n text-decoration: underline;\n}\n\n.dsh-ops-root .ops-icon-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: 0;\n border-radius: var(--dsw-radius-xs, 4px);\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-icon-btn:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n}\n\n/* 3-Tab Navigation */\n.dsh-ops-root .ops-tabs {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-top: 14px;\n border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n padding-bottom: 8px;\n}\n\n.dsh-ops-root .ops-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 14px;\n border: 1px solid transparent;\n border-radius: var(--dsw-radius-sm, 8px);\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n font: inherit;\n font-weight: 500;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-tab:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n color: var(--dsw-alias-label-primary, #0f1115);\n}\n\n.dsh-ops-root .ops-tab.is-active {\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n color: var(--dsw-alias-state-business-primary, #4176e6);\n border-color: var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n}\n\n.dsh-ops-root .ops-tab-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 18px;\n height: 18px;\n padding: 0 5px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n background: var(--dsw-alias-state-error-primary, #ec1313);\n color: var(--dsw-alias-label-on-color, #ffffff);\n}\n\n.dsh-ops-root .ops-main {\n margin-top: 16px;\n}\n\n.dsh-ops-root .ops-tab-stack {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* Cards & Banners */\n.dsh-ops-root .ops-card {\n padding: 16px;\n border-radius: var(--dsw-radius-md, 12px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-card-fill, #fafafa);\n}\n\n.dsh-ops-root .ops-card-head {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 10px;\n margin-bottom: 10px;\n}\n\n.dsh-ops-root .ops-card-label {\n display: block;\n font-size: 12px;\n font-weight: 600;\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-card-kpi {\n display: flex;\n align-items: baseline;\n gap: 6px;\n margin-top: 2px;\n}\n\n.dsh-ops-root .ops-card-kpi strong {\n font-size: 22px;\n font-weight: 600;\n letter-spacing: -0.02em;\n}\n\n.dsh-ops-root .ops-kv-strip {\n display: flex;\n align-items: center;\n gap: 14px;\n flex-wrap: wrap;\n font-size: 12px;\n color: var(--dsw-alias-label-secondary, #61666b);\n margin-bottom: 8px;\n}\n\n.dsh-ops-root .ops-kv-strip b {\n color: var(--dsw-alias-label-primary, #0f1115);\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-banner,\n.dsh-ops-root .ops-reassurance {\n padding: 12px 16px;\n border-radius: var(--dsw-radius-md, 12px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n}\n\n.dsh-ops-root .ops-banner {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-banner.is-alert {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.06));\n border-color: var(--dsw-alias-state-error-secondary, #f25a5a);\n}\n\n.dsh-ops-root .ops-banner.is-offline {\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n}\n\n.dsh-ops-root .ops-reassurance.is-ok {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n border-color: var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n}\n\n.dsh-ops-root .ops-reassurance.is-warn {\n background: var(--dsw-alias-state-warn-tertiary, #fef5e7);\n}\n\n.dsh-ops-root .ops-reassurance-top {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-banner-main {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\n.dsh-ops-root .ops-banner-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-report-inline {\n margin-top: 10px;\n padding-top: 10px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n}\n\n.dsh-ops-root .ops-report-inline-head {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 6px;\n}\n\n.dsh-ops-root .ops-bullet-list {\n margin: 4px 0 0;\n padding-left: 18px;\n display: grid;\n gap: 4px;\n}\n\n/* Segmented controls */\n.dsh-ops-root .ops-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-section-header h2 {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-segmented {\n display: inline-flex;\n padding: 2px;\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n}\n\n.dsh-ops-root .ops-seg-btn {\n border: 0;\n padding: 4px 10px;\n border-radius: 6px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n font: inherit;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-seg-btn.is-active {\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n box-shadow: var(--dsw-shadow-lv1, 0 1px 2px rgba(0, 0, 0, 0.06));\n}\n\n/* 2x2 Metrics Grid */\n.dsh-ops-root .ops-grid-2x2 {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 14px;\n}\n\n/* Charts */\n.dsh-ops-root .ops-chart-wrap {\n margin-top: 6px;\n}\n\n.dsh-ops-root .ops-svg-chart {\n display: block;\n width: 100%;\n height: auto;\n}\n\n.dsh-ops-root .ops-chart-tick {\n font-size: 10px;\n fill: var(--dsw-alias-label-tertiary, #81858c);\n font-variant-numeric: tabular-nums;\n}\n\n.dsh-ops-root .ops-chart-legend {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-top: 4px;\n font-size: 11px;\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-gap-swatch {\n display: inline-block;\n width: 12px;\n height: 10px;\n border-radius: 2px;\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n border: 1px dashed var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.16));\n}\n\n.dsh-ops-root .ops-sparkline {\n display: block;\n width: 100%;\n max-width: 180px;\n height: 36px;\n}\n\n.dsh-ops-root .ops-spark-empty {\n font-size: 12px;\n color: var(--dsw-alias-label-caption, #adb2b8);\n}\n\n.dsh-ops-root .ops-ssh-bars {\n display: block;\n width: 100%;\n height: 44px;\n margin-top: 6px;\n}\n\n/* Disk Mounts */\n.dsh-ops-root .ops-mount-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-mount-block {\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-mount-block.is-expanded {\n border-color: var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12));\n}\n\n.dsh-ops-root .ops-mount-row {\n display: flex;\n flex-direction: column;\n gap: 6px;\n width: 100%;\n padding: 10px 12px;\n border: 0;\n background: transparent;\n color: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-mount-row:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.04));\n}\n\n.dsh-ops-root .ops-mount-top,\n.dsh-ops-root .ops-mount-foot {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-mount-id,\n.dsh-ops-root .ops-mount-stats {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-mount-path {\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-delta-badge {\n display: inline-flex;\n align-items: center;\n padding: 1px 6px;\n border-radius: var(--dsw-radius-xs, 4px);\n font-size: 11px;\n font-weight: 500;\n font-variant-numeric: tabular-nums;\n}\n\n.dsh-ops-root .ops-delta-badge.is-up {\n background: var(--dsw-alias-state-warn-tertiary, #fef5e7);\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .ops-delta-badge.is-down,\n.dsh-ops-root .ops-delta-badge.is-flat {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .ops-delta-badge.is-unknown {\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-meter-track {\n position: relative;\n height: 7px;\n width: 100%;\n border-radius: 999px;\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n overflow: visible;\n}\n\n.dsh-ops-root .ops-meter-fill {\n height: 100%;\n border-radius: 999px;\n background: var(--dsw-alias-link, #4176e6);\n}\n\n.dsh-ops-root .ops-meter-fill.is-warn {\n background: var(--dsw-alias-state-warn-primary, #f59e0b);\n}\n\n.dsh-ops-root .ops-meter-fill.is-bad {\n background: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-meter-threshold {\n position: absolute;\n top: -2px;\n bottom: -2px;\n width: 2px;\n background: var(--dsw-alias-label-secondary, #61666b);\n border-radius: 1px;\n}\n\n.dsh-ops-root .ops-mount-detail {\n padding: 10px 12px 12px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n}\n\n.dsh-ops-root .ops-topdirs {\n margin-top: 10px;\n}\n\n.dsh-ops-root .ops-topdirs-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n font-size: 12px;\n font-weight: 500;\n margin-bottom: 6px;\n}\n\n.dsh-ops-root .ops-topdirs-list {\n display: grid;\n gap: 5px;\n}\n\n.dsh-ops-root .ops-topdir-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-topdir-right {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n}\n\n/* Security Card */\n.dsh-ops-root .ops-security-rows {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.dsh-ops-root .ops-security-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex-wrap: wrap;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-failed-units {\n display: grid;\n gap: 5px;\n padding-top: 6px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n}\n\n.dsh-ops-root .ops-failed-unit-item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font-size: 12px;\n}\n\n/* Service Matrix */\n.dsh-ops-root .ops-service-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));\n gap: 10px;\n}\n\n.dsh-ops-root .ops-service-tile {\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.dsh-ops-root .ops-service-top {\n display: flex;\n align-items: center;\n gap: 7px;\n}\n\n.dsh-ops-root .ops-service-top strong {\n flex: 1;\n}\n\n/* Bottom Backup Strip */\n.dsh-ops-root .ops-backup-strip {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n padding: 12px 16px;\n border-radius: var(--dsw-radius-md, 12px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-card-fill, #fafafa);\n}\n\n.dsh-ops-root .ops-backup-strip-left {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-backup-strip-info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.dsh-ops-root .ops-backup-strip-title {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-copy-pills {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-copy-pill {\n display: inline-flex;\n align-items: center;\n padding: 1px 7px;\n border-radius: var(--dsw-radius-xs, 4px);\n font-size: 11px;\n font-weight: 500;\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n}\n\n.dsh-ops-root .ops-copy-pill.is-ok {\n border-color: var(--dsw-alias-state-success-secondary, #4ed17e);\n}\n\n.dsh-ops-root .ops-copy-pill.is-warn {\n border-color: var(--dsw-alias-state-warn-primary, #f59e0b);\n}\n\n.dsh-ops-root .ops-copy-pill.is-bad {\n border-color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n/* Time Machine Tab */\n.dsh-ops-root .ops-vault-bar {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-ops-root .ops-vault-bar-top {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-vault-pills,\n.dsh-ops-root .ops-vault-actions {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-vault-chip {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: inherit;\n font: inherit;\n font-size: 12px;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-vault-chip.is-selected {\n border-color: var(--dsw-alias-link, #4176e6);\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n}\n\n.dsh-ops-root .ops-vault-chip-main {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 0;\n padding: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-vault-size {\n padding: 1px 6px;\n border-radius: var(--dsw-radius-xs, 4px);\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-secondary, #61666b);\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n}\n\n.dsh-ops-root .ops-vault-warnings {\n display: grid;\n gap: 3px;\n}\n\n.dsh-ops-root .ops-job-progress {\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.dsh-ops-root .ops-job-progress-head,\n.dsh-ops-root .ops-restored-receipt {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-tm-grid {\n display: grid;\n grid-template-columns: 280px minmax(0, 1fr);\n gap: 14px;\n align-items: start;\n}\n\n.dsh-ops-root .ops-tm-timeline {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.dsh-ops-root .ops-tm-pane-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-tm-pane-head h3 {\n margin: 0;\n font-size: 13px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-timeline-scroll {\n display: flex;\n flex-direction: column;\n gap: 12px;\n max-height: 520px;\n overflow-y: auto;\n}\n\n.dsh-ops-root .ops-timeline-date {\n font-size: 11px;\n font-weight: 600;\n color: var(--dsw-alias-label-tertiary, #81858c);\n margin-bottom: 6px;\n}\n\n.dsh-ops-root .ops-timeline-items {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.dsh-ops-root .ops-snap-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n width: 100%;\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-snap-item:hover {\n background: var(--dsw-alias-card-fill-hover, #f5f5f5);\n}\n\n.dsh-ops-root .ops-snap-item.is-active {\n border-color: var(--dsw-alias-link, #4176e6);\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n}\n\n.dsh-ops-root .ops-snap-top {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 6px;\n}\n\n.dsh-ops-root .ops-snap-copies {\n display: inline-flex;\n gap: 4px;\n}\n\n.dsh-ops-root .ops-copy-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border-radius: var(--dsw-radius-xs, 4px);\n font-size: 10px;\n font-weight: 700;\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-copy-badge.is-ok {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .ops-copy-badge.is-pending {\n background: var(--dsw-alias-state-warn-tertiary, #fef5e7);\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .ops-copy-badge.is-failed {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.08));\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-snap-changes {\n display: flex;\n gap: 8px;\n font-size: 11px;\n}\n\n.dsh-ops-root .is-chg-added {\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .is-chg-modified {\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .is-chg-deleted {\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n/* Right Pane File Browser (Clean CSS Grid Table) */\n.dsh-ops-root .ops-tm-browser {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.dsh-ops-root .ops-tm-toolbar {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-breadcrumbs {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 4px;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-crumb-wrap {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n.dsh-ops-root .ops-crumb-sep {\n color: var(--dsw-alias-label-caption, #adb2b8);\n}\n\n.dsh-ops-root .ops-crumb {\n border: 0;\n padding: 2px 6px;\n border-radius: var(--dsw-radius-xs, 4px);\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n font: inherit;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-crumb:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n}\n\n.dsh-ops-root .ops-crumb.is-current {\n color: var(--dsw-alias-label-primary, #0f1115);\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-tm-controls {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-search-input {\n flex: 1;\n min-width: 180px;\n height: 30px;\n padding: 0 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n font: inherit;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-toggle-label {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n color: var(--dsw-alias-label-secondary, #61666b);\n cursor: pointer;\n white-space: nowrap;\n}\n\n.dsh-ops-root .ops-tm-meta-note {\n padding: 6px 10px;\n border-radius: var(--dsw-radius-xs, 4px);\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-secondary, #61666b);\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-file-table {\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-file-row {\n display: grid;\n grid-template-columns: 32px minmax(0, 1fr) 68px 84px 104px;\n align-items: center;\n gap: 8px;\n min-height: 36px;\n padding: 4px 10px;\n border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-file-row:last-child {\n border-bottom: 0;\n}\n\n.dsh-ops-root .ops-file-row.is-header {\n min-height: 32px;\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n color: var(--dsw-alias-label-tertiary, #81858c);\n font-weight: 600;\n font-size: 11px;\n}\n\n.dsh-ops-root .ops-file-row:not(.is-header):hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.04));\n}\n\n.dsh-ops-root .ops-file-row.is-checked {\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n}\n\n.dsh-ops-root .ops-file-row.is-deleted {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.05));\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-file-row.is-deleted .ops-file-name-text {\n text-decoration: line-through;\n}\n\n.dsh-ops-root .ops-file-col-check {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.dsh-ops-root .ops-file-col-name {\n display: flex;\n align-items: center;\n gap: 7px;\n min-width: 0;\n}\n\n.dsh-ops-root .ops-file-name-wrap {\n display: flex;\n flex-direction: column;\n min-width: 0;\n flex: 1;\n line-height: 1.35;\n}\n\n.dsh-ops-root .ops-file-subpath {\n font-size: 11px;\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-file-icon {\n flex-shrink: 0;\n font-size: 13px;\n line-height: 1;\n}\n\n.dsh-ops-root .ops-file-dir-btn {\n border: 0;\n padding: 0;\n background: transparent;\n color: var(--dsw-alias-link, #4176e6);\n font: inherit;\n font-weight: 500;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-file-dir-btn:hover {\n text-decoration: underline;\n}\n\n.dsh-ops-root .ops-file-col-size,\n.dsh-ops-root .ops-file-col-mtime {\n text-align: right;\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-change-pill {\n display: inline-flex;\n align-items: center;\n padding: 1px 6px;\n border-radius: var(--dsw-radius-xs, 4px);\n font-size: 11px;\n font-weight: 500;\n}\n\n.dsh-ops-root .ops-change-pill.is-added {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-state-success-primary, #22c55e);\n}\n\n.dsh-ops-root .ops-change-pill.is-modified {\n background: var(--dsw-alias-state-warn-tertiary, #fef5e7);\n color: var(--dsw-alias-state-warn-label, #dd8629);\n}\n\n.dsh-ops-root .ops-change-pill.is-deleted {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.09));\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-table-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n}\n\n/* Floating Safe Restore Action Bar */\n.dsh-ops-root .ops-restore-bar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n padding: 10px 14px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-link, #4176e6);\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n}\n\n.dsh-ops-root .ops-restore-bar-left,\n.dsh-ops-root .ops-restore-bar-right {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-restore-bar select {\n height: 28px;\n padding: 0 8px;\n border-radius: var(--dsw-radius-xs, 4px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n font: inherit;\n font-size: 12px;\n}\n\n/* Collapsible Job Drawer */\n.dsh-ops-root .ops-jobs-drawer {\n padding: 0;\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-jobs-toggle {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 12px 16px;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-jobs-list {\n padding: 0 16px 14px;\n display: grid;\n gap: 8px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n padding-top: 10px;\n}\n\n.dsh-ops-root .ops-job-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-job-row-main,\n.dsh-ops-root .ops-job-row-right {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n/* Activity Tab */\n.dsh-ops-root .ops-activity-toolbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-activity-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-ops-root .ops-activity-card.is-unread {\n border-left: 3px solid var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-activity-head {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dsh-ops-root .ops-activity-trigger {\n flex: 1;\n min-width: 240px;\n border: 0;\n padding: 0;\n background: transparent;\n color: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-ops-root .ops-activity-meta {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n margin-bottom: 4px;\n}\n\n.dsh-ops-root .ops-unread-dot {\n width: 7px;\n height: 7px;\n border-radius: 999px;\n background: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dsh-ops-root .ops-activity-title {\n margin: 0 0 3px;\n font-size: 14px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-activity-actions {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.dsh-ops-root .ops-activity-expanded {\n margin-top: 12px;\n padding-top: 12px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-ops-root .ops-highlight-grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 8px;\n}\n\n.dsh-ops-root .ops-highlight-chip {\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.dsh-ops-root .ops-details-box {\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05));\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-details-box summary {\n cursor: pointer;\n font-weight: 500;\n}\n\n.dsh-ops-root .ops-coverage-list {\n display: grid;\n gap: 5px;\n margin-top: 8px;\n}\n\n.dsh-ops-root .ops-coverage-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-incident-summary {\n margin: 0;\n}\n\n.dsh-ops-root .ops-evidence-list {\n display: grid;\n gap: 8px;\n margin-top: 8px;\n}\n\n.dsh-ops-root .ops-evidence-item {\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n}\n\n.dsh-ops-root .ops-evidence-head {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 6px;\n}\n\n.dsh-ops-root .ops-pre-inline,\n.dsh-ops-root .ops-pre-block {\n margin: 0;\n padding: 8px 10px;\n border-radius: var(--dsw-radius-xs, 4px);\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n font-family: var(--ds-font-family-code, ui-monospace, monospace);\n font-size: 11px;\n white-space: pre-wrap;\n word-break: break-word;\n}\n\n/* Onboarding & Empty Cards */\n.dsh-ops-root .ops-onboarding-wrap {\n display: flex;\n justify-content: center;\n padding: 28px 0;\n}\n\n.dsh-ops-root .ops-onboarding-card {\n width: 100%;\n max-width: 600px;\n padding: 24px;\n border-radius: var(--dsw-radius-lg, 16px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-card-fill, #fafafa);\n box-shadow: var(--dsw-shadow-lv1, 0 2px 8px rgba(0, 0, 0, 0.04));\n}\n\n.dsh-ops-root .ops-onboarding-badge {\n display: inline-flex;\n padding: 2px 9px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n.dsh-ops-root .ops-onboarding-header h1 {\n margin: 10px 0 6px;\n font-size: 20px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-onboarding-header p {\n margin: 0 0 18px;\n color: var(--dsw-alias-label-secondary, #61666b);\n}\n\n.dsh-ops-root .ops-empty-card {\n padding: 36px 24px;\n border-radius: var(--dsw-radius-md, 12px);\n border: 1px dashed var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.14));\n background: var(--dsw-alias-card-fill, #fafafa);\n text-align: center;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-empty-card h2 {\n margin: 0;\n font-size: 16px;\n}\n\n.dsh-ops-root .ops-empty-card p {\n max-width: 480px;\n}\n\n.dsh-ops-root .ops-empty-icon {\n font-size: 28px;\n}\n\n.dsh-ops-root .ops-empty-actions {\n margin-top: 8px;\n display: flex;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-empty-inline,\n.dsh-ops-root .ops-inline-loading {\n padding: 18px 12px;\n text-align: center;\n color: var(--dsw-alias-label-tertiary, #81858c);\n font-size: 12px;\n}\n\n/* Forms */\n.dsh-ops-root .ops-form {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n.dsh-ops-root .ops-form-compact {\n gap: 10px;\n}\n\n.dsh-ops-root .ops-form-row {\n display: grid;\n gap: 10px;\n}\n\n.dsh-ops-root .ops-form-row-host {\n grid-template-columns: minmax(0, 1fr) 96px;\n}\n\n.dsh-ops-root .ops-form-row-two {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n\n.dsh-ops-root .ops-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n font-size: 12px;\n font-weight: 500;\n}\n\n.dsh-ops-root .ops-field input,\n.dsh-ops-root .ops-field select {\n height: 34px;\n padding: 0 10px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n color: var(--dsw-alias-label-primary, #0f1115);\n font: inherit;\n}\n\n.dsh-ops-root .ops-input-action {\n display: flex;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-input-action input {\n flex: 1;\n min-width: 0;\n}\n\n.dsh-ops-root .ops-field-hint {\n font-weight: 400;\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-form-footer,\n.dsh-ops-root .ops-install-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n margin-top: 4px;\n}\n\n.dsh-ops-root .ops-code-block {\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-bg-module-platform, #f5f6f7);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n font-family: var(--ds-font-family-code, ui-monospace, monospace);\n font-size: 12px;\n overflow-x: auto;\n margin: 10px 0;\n}\n\n.dsh-ops-root .ops-install-title {\n font-weight: 600;\n margin-bottom: 4px;\n}\n\n/* Inline Alerts */\n.dsh-ops-root .ops-inline-alert {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 9px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-inline-alert.is-ok {\n background: var(--dsw-alias-state-success-tertiary, #e6faed);\n color: var(--dsw-alias-label-primary, #0f1115);\n}\n\n.dsh-ops-root .ops-inline-alert.is-bad {\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.08));\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n/* Drawers & Modals */\n.dsh-ops-root .ops-drawer-backdrop,\n.dsh-ops-root .ops-modal-backdrop {\n position: fixed;\n inset: 0;\n z-index: 60;\n background: rgba(15, 17, 21, 0.36);\n display: flex;\n}\n\n.dsh-ops-root .ops-drawer-backdrop {\n justify-content: flex-end;\n}\n\n.dsh-ops-root .ops-modal-backdrop {\n align-items: center;\n justify-content: center;\n padding: 16px;\n}\n\n.dsh-ops-root .ops-drawer {\n width: min(440px, 100%);\n height: 100%;\n background: var(--dsw-alias-bg-layer-1, #ffffff);\n border-left: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n box-shadow: var(--dsw-shadow-lv3, 0 12px 32px rgba(0, 0, 0, 0.18));\n display: flex;\n flex-direction: column;\n}\n\n.dsh-ops-root .ops-drawer-head,\n.dsh-ops-root .ops-modal-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 14px 18px;\n border-bottom: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n}\n\n.dsh-ops-root .ops-drawer-head h2,\n.dsh-ops-root .ops-modal-head h3 {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-drawer-body,\n.dsh-ops-root .ops-modal-body {\n flex: 1;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 16px 18px;\n display: flex;\n flex-direction: column;\n gap: 18px;\n}\n\n.dsh-ops-root .ops-drawer-section h3 {\n margin: 0 0 8px;\n font-size: 13px;\n font-weight: 600;\n}\n\n.dsh-ops-root .ops-server-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.dsh-ops-root .ops-server-item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n background: var(--dsw-alias-bg-layer-2, #ffffff);\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-server-item.is-active {\n border-color: var(--dsw-alias-link, #4176e6);\n}\n\n.dsh-ops-root .ops-server-meta {\n display: flex;\n flex-direction: column;\n gap: 2px;\n flex: 1;\n min-width: 0;\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-server-name {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n\n.dsh-ops-root .ops-server-endpoint {\n display: block;\n max-width: 100%;\n}\n\n.dsh-ops-root .ops-server-actions {\n display: flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n}\n\n.dsh-ops-root .ops-modal {\n width: min(520px, 100%);\n max-height: 85vh;\n border-radius: var(--dsw-radius-md, 12px);\n border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-layer-1, #ffffff);\n box-shadow: var(--dsw-shadow-lv3, 0 12px 32px rgba(0, 0, 0, 0.2));\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n.dsh-ops-root .ops-modal-foot {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding: 12px 18px;\n border-top: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n}\n\n.dsh-ops-root .ops-preview-dl {\n display: grid;\n grid-template-columns: 100px minmax(0, 1fr);\n gap: 6px 10px;\n margin: 0;\n font-size: 12px;\n}\n\n.dsh-ops-root .ops-preview-dl dt {\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dsh-ops-root .ops-preview-dl dd {\n margin: 0;\n word-break: break-all;\n}\n\n.dsh-ops-root .ops-preview-paths ul {\n margin: 6px 0 0;\n padding-left: 18px;\n max-height: 150px;\n overflow-y: auto;\n font-size: 12px;\n}\n\n/* Narrow / Responsive Support */\n@container (max-width: 820px) {\n .dsh-ops-root .ops-shell {\n padding: 14px 14px 36px;\n }\n\n .dsh-ops-root .ops-grid-2x2,\n .dsh-ops-root .ops-tm-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n\n@container (max-width: 560px) {\n .dsh-ops-root .ops-form-row-host,\n .dsh-ops-root .ops-form-row-two {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .dsh-ops-root .ops-file-row {\n grid-template-columns: 28px minmax(0, 1fr) 56px 72px;\n }\n\n .dsh-ops-root .ops-file-col-mtime {\n display: none;\n }\n}\n";
|
|
3642
|
+
|
|
3643
|
+
const TAB_ITEMS = [
|
|
3644
|
+
{
|
|
3645
|
+
key: "overview",
|
|
3646
|
+
label: "总览"
|
|
3647
|
+
},
|
|
3648
|
+
{
|
|
3649
|
+
key: "timemachine",
|
|
3650
|
+
label: "时间机器"
|
|
3651
|
+
},
|
|
3652
|
+
{
|
|
3653
|
+
key: "activity",
|
|
3654
|
+
label: "动态与日报"
|
|
3655
|
+
}
|
|
3656
|
+
];
|
|
3657
|
+
function OpsApp({ api: providedApi, dshClient, initialTab = "overview", initialFixture, initialServers }) {
|
|
3658
|
+
const api = (0, react.useMemo)(() => providedApi ?? (initialFixture ? createFixtureOpsApi(initialFixture) : createHttpOpsApi()), [providedApi, initialFixture]);
|
|
3659
|
+
const [tab, setTab] = (0, react.useState)(initialTab);
|
|
3660
|
+
const [settingsOpen, setSettingsOpen] = (0, react.useState)(false);
|
|
3661
|
+
const [agentNotice, setAgentNotice] = (0, react.useState)(null);
|
|
3662
|
+
const [servers, setServers] = (0, react.useState)(() => {
|
|
3663
|
+
if (initialServers) return initialServers;
|
|
3664
|
+
if (initialFixture) return [{
|
|
3665
|
+
serverId: initialFixture.overview.serverId,
|
|
3666
|
+
host: initialFixture.overview.hostname,
|
|
3667
|
+
port: 22,
|
|
3668
|
+
username: "ops",
|
|
3669
|
+
lastConnectedAt: initialFixture.overview.collectedAt,
|
|
3670
|
+
lastSyncedAt: initialFixture.overview.collectedAt
|
|
3671
|
+
}];
|
|
3672
|
+
return [];
|
|
3673
|
+
});
|
|
3674
|
+
const [activeServerId, setActiveServerId] = (0, react.useState)(() => {
|
|
3675
|
+
if (initialServers) return initialServers[0]?.serverId ?? null;
|
|
3676
|
+
return initialFixture?.overview.serverId ?? null;
|
|
3677
|
+
});
|
|
3678
|
+
const [bootLoading, setBootLoading] = (0, react.useState)(() => !initialFixture && !initialServers);
|
|
3679
|
+
const [overview, setOverview] = (0, react.useState)(() => initialFixture?.overview ?? null);
|
|
3680
|
+
const [syncing, setSyncing] = (0, react.useState)(false);
|
|
3681
|
+
const [offlineError, setOfflineError] = (0, react.useState)(null);
|
|
3682
|
+
const [connState, setConnState] = (0, react.useState)(() => {
|
|
3683
|
+
if (!initialFixture) return "syncing";
|
|
3684
|
+
if (initialFixture.overview.offlineCache || initialFixture.overview.stale) return "offline";
|
|
3685
|
+
return "online";
|
|
3686
|
+
});
|
|
3687
|
+
const loadSeq = (0, react.useRef)(0);
|
|
3688
|
+
const loadOverviewDualStage = (0, react.useCallback)(async (serverId, forceReconnect = false) => {
|
|
3689
|
+
const seq = ++loadSeq.current;
|
|
3690
|
+
setSyncing(true);
|
|
3691
|
+
setOfflineError(null);
|
|
3692
|
+
setConnState("syncing");
|
|
3693
|
+
if (forceReconnect) await api.reconnect(serverId).catch(() => {});
|
|
3694
|
+
const cachedPromise = api.getOverviewCached(serverId).then((cached) => {
|
|
3695
|
+
if (seq !== loadSeq.current || !cached) return;
|
|
3696
|
+
setOverview((prev) => prev ?? {
|
|
3697
|
+
...cached,
|
|
3698
|
+
offlineCache: true
|
|
3699
|
+
});
|
|
3700
|
+
}).catch(() => {});
|
|
3701
|
+
const livePromise = api.getOverview(serverId).then((fresh) => {
|
|
3702
|
+
if (seq !== loadSeq.current) return;
|
|
3703
|
+
setOverview(fresh);
|
|
3704
|
+
setOfflineError(null);
|
|
3705
|
+
setConnState(fresh.offlineCache || fresh.stale ? "offline" : "online");
|
|
3706
|
+
setSyncing(false);
|
|
3707
|
+
if (typeof fresh.collectedAt === "number" && Number.isFinite(fresh.collectedAt)) setServers((prev) => prev.map((s) => s.serverId === serverId ? {
|
|
3708
|
+
...s,
|
|
3709
|
+
lastSyncedAt: fresh.collectedAt
|
|
3710
|
+
} : s));
|
|
3711
|
+
publishSidebarBadge({
|
|
3712
|
+
status: fresh.health.status,
|
|
3713
|
+
unreadAlerts: fresh.health.unreadAlerts
|
|
3714
|
+
});
|
|
3715
|
+
}).catch((err) => {
|
|
3716
|
+
if (seq !== loadSeq.current) return;
|
|
3717
|
+
setOfflineError(err instanceof Error ? err.message : "SSH 连接暂不可达");
|
|
3718
|
+
setConnState("offline");
|
|
3719
|
+
setSyncing(false);
|
|
3720
|
+
});
|
|
3721
|
+
await Promise.allSettled([cachedPromise, livePromise]);
|
|
3722
|
+
}, [api]);
|
|
3723
|
+
(0, react.useEffect)(() => {
|
|
3724
|
+
if (initialFixture || initialServers) {
|
|
3725
|
+
if (initialFixture) publishSidebarBadge({
|
|
3726
|
+
status: initialFixture.overview.health.status,
|
|
3727
|
+
unreadAlerts: initialFixture.overview.health.unreadAlerts
|
|
3728
|
+
});
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3731
|
+
let alive = true;
|
|
3732
|
+
setBootLoading(true);
|
|
3733
|
+
api.getConnectionStatus().then((status) => {
|
|
3734
|
+
if (!alive) return;
|
|
3735
|
+
setServers(status.servers);
|
|
3736
|
+
setActiveServerId(status.active);
|
|
3737
|
+
setBootLoading(false);
|
|
3738
|
+
if (status.active) loadOverviewDualStage(status.active);
|
|
3739
|
+
}).catch((err) => {
|
|
3740
|
+
if (!alive) return;
|
|
3741
|
+
setBootLoading(false);
|
|
3742
|
+
setOfflineError(err instanceof Error ? err.message : "读取服务器列表失败");
|
|
3743
|
+
});
|
|
3744
|
+
return () => {
|
|
3745
|
+
alive = false;
|
|
3746
|
+
};
|
|
3747
|
+
}, [
|
|
3748
|
+
api,
|
|
3749
|
+
initialFixture,
|
|
3750
|
+
initialServers,
|
|
3751
|
+
loadOverviewDualStage
|
|
3752
|
+
]);
|
|
3753
|
+
const activeServer = (0, react.useMemo)(() => servers.find((s) => s.serverId === activeServerId) ?? servers[0] ?? null, [servers, activeServerId]);
|
|
3754
|
+
async function handleSelectServer(nextId) {
|
|
3755
|
+
if (!nextId || nextId === activeServerId) return;
|
|
3756
|
+
setActiveServerId(nextId);
|
|
3757
|
+
setOverview(null);
|
|
3758
|
+
try {
|
|
3759
|
+
const status = await api.selectConnection(nextId);
|
|
3760
|
+
setServers(status.servers);
|
|
3761
|
+
setActiveServerId(status.active ?? nextId);
|
|
3762
|
+
} catch {}
|
|
3763
|
+
loadOverviewDualStage(nextId);
|
|
3764
|
+
}
|
|
3765
|
+
function handleConnectionChange(status) {
|
|
3766
|
+
setServers(status.servers);
|
|
3767
|
+
setActiveServerId(status.active);
|
|
3768
|
+
if (status.active) {
|
|
3769
|
+
invalidateBridgeQuery("");
|
|
3770
|
+
loadOverviewDualStage(status.active);
|
|
3771
|
+
} else setOverview(null);
|
|
3772
|
+
}
|
|
3773
|
+
function handleConnectedFromOnboarding(res) {
|
|
3774
|
+
handleConnectionChange(res.status);
|
|
3775
|
+
}
|
|
3776
|
+
async function handleReconnect(targetServerId) {
|
|
3777
|
+
const id = targetServerId ?? activeServerId;
|
|
3778
|
+
if (!id) return;
|
|
3779
|
+
invalidateBridgeQuery(`history:${id}`);
|
|
3780
|
+
await loadOverviewDualStage(id, true);
|
|
3781
|
+
}
|
|
3782
|
+
async function handleOpenAgent(_topic) {
|
|
3783
|
+
const id = activeServerId ?? activeServer?.serverId;
|
|
3784
|
+
if (!id) {
|
|
3785
|
+
setAgentNotice("请先在左侧 DSH 原生会话区打开「运维 Agent」,或先连接一台服务器。");
|
|
3786
|
+
return;
|
|
3787
|
+
}
|
|
3788
|
+
setAgentNotice(null);
|
|
3789
|
+
try {
|
|
3790
|
+
await openNativeOpsAgent(dshClient, api, id, activeServer?.host);
|
|
3791
|
+
} catch (err) {
|
|
3792
|
+
setAgentNotice(err instanceof Error ? err.message : "拉起原生运维 Agent 会话失败");
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
const unreadAlerts = overview?.health.unreadAlerts ?? 0;
|
|
3796
|
+
const activeSyncedAt = overview && activeServer && overview.serverId === activeServer.serverId ? connState === "online" ? overview.collectedAt : overview.cachedAt ?? overview.collectedAt : null;
|
|
3797
|
+
const connLabel = connState === "online" ? `在线 · ${formatRelativeTime(overview?.collectedAt)}同步` : connState === "syncing" ? "同步中…" : `离线${overview?.cachedAt || overview?.collectedAt ? ` · ${formatRelativeTime(overview.cachedAt ?? overview.collectedAt)}` : ""}`;
|
|
3798
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpsRuntimeContext.Provider, {
|
|
3799
|
+
value: {
|
|
3800
|
+
api,
|
|
3801
|
+
dshClient
|
|
3802
|
+
},
|
|
3803
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3804
|
+
className: "dsh-ops-root",
|
|
3805
|
+
children: [
|
|
3806
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: styles_css_default }),
|
|
3807
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3808
|
+
className: "ops-shell",
|
|
3809
|
+
children: [
|
|
3810
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
3811
|
+
className: "ops-topbar",
|
|
3812
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3813
|
+
className: "ops-topbar-left",
|
|
3814
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3815
|
+
className: "ops-brand",
|
|
3816
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3817
|
+
className: "ops-brand-mark",
|
|
3818
|
+
"aria-hidden": "true",
|
|
3819
|
+
children: "▣"
|
|
3820
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "服务器运维" })]
|
|
3821
|
+
}), servers.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3822
|
+
className: "ops-host-switcher",
|
|
3823
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
3824
|
+
"aria-label": "切换主机",
|
|
3825
|
+
className: "ops-host-select",
|
|
3826
|
+
value: activeServer?.serverId ?? "",
|
|
3827
|
+
onChange: (e) => void handleSelectServer(e.target.value),
|
|
3828
|
+
children: servers.map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3829
|
+
value: s.serverId,
|
|
3830
|
+
children: s.host
|
|
3831
|
+
}, s.serverId))
|
|
3832
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3833
|
+
className: `ops-conn-pill is-${connState}`,
|
|
3834
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `ops-dot is-${connState === "online" ? "ok" : connState === "syncing" ? "warn" : "idle"}` }), connLabel]
|
|
3835
|
+
})]
|
|
3836
|
+
})]
|
|
3837
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3838
|
+
className: "ops-topbar-right",
|
|
3839
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3840
|
+
type: "button",
|
|
3841
|
+
className: "ops-btn ops-btn-info ops-btn-sm",
|
|
3842
|
+
onClick: () => void handleOpenAgent("general"),
|
|
3843
|
+
children: "✨ 问运维 Agent"
|
|
3844
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3845
|
+
type: "button",
|
|
3846
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm",
|
|
3847
|
+
"aria-label": "打开设置",
|
|
3848
|
+
onClick: () => setSettingsOpen(true),
|
|
3849
|
+
children: "⚙ 设置"
|
|
3850
|
+
})]
|
|
3851
|
+
})]
|
|
3852
|
+
}),
|
|
3853
|
+
agentNotice && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3854
|
+
className: "ops-inline-alert is-bad ops-mt-sm",
|
|
3855
|
+
role: "status",
|
|
3856
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: agentNotice }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3857
|
+
type: "button",
|
|
3858
|
+
className: "ops-icon-btn",
|
|
3859
|
+
onClick: () => setAgentNotice(null),
|
|
3860
|
+
children: "✕"
|
|
3861
|
+
})]
|
|
3862
|
+
}),
|
|
3863
|
+
bootLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3864
|
+
className: "ops-card ops-empty-inline",
|
|
3865
|
+
children: "正在初始化服务器运维工作台…"
|
|
3866
|
+
}) : servers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OnboardingView, {
|
|
3867
|
+
onConnected: handleConnectedFromOnboarding,
|
|
3868
|
+
onOpenDeployAgent: () => void handleOpenAgent("deploy-guide")
|
|
3869
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
3870
|
+
className: "ops-tabs",
|
|
3871
|
+
role: "tablist",
|
|
3872
|
+
"aria-label": "服务器运维视图",
|
|
3873
|
+
children: TAB_ITEMS.map((item) => {
|
|
3874
|
+
const selected = tab === item.key;
|
|
3875
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3876
|
+
type: "button",
|
|
3877
|
+
role: "tab",
|
|
3878
|
+
className: `ops-tab ${selected ? "is-active" : ""}`,
|
|
3879
|
+
"aria-selected": selected,
|
|
3880
|
+
onClick: () => setTab(item.key),
|
|
3881
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.label }), item.key === "activity" && unreadAlerts > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3882
|
+
className: "ops-tab-badge ops-tabular",
|
|
3883
|
+
children: unreadAlerts
|
|
3884
|
+
})]
|
|
3885
|
+
}, item.key);
|
|
3886
|
+
})
|
|
3887
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("main", {
|
|
3888
|
+
className: "ops-main",
|
|
3889
|
+
children: [
|
|
3890
|
+
tab === "overview" && activeServer && (overview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverviewTab, {
|
|
3891
|
+
serverId: activeServer.serverId,
|
|
3892
|
+
overview,
|
|
3893
|
+
syncing,
|
|
3894
|
+
offlineError,
|
|
3895
|
+
initialHistory: initialFixture?.resourceHistory,
|
|
3896
|
+
onReconnect: () => void handleReconnect(activeServer.serverId),
|
|
3897
|
+
onGoActivity: () => setTab("activity"),
|
|
3898
|
+
onGoTimeMachine: () => setTab("timemachine"),
|
|
3899
|
+
onOpenAgent: (topic) => void handleOpenAgent(topic)
|
|
3900
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
3901
|
+
className: "ops-card ops-empty-inline",
|
|
3902
|
+
children: offlineError ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3903
|
+
className: "is-text-bad",
|
|
3904
|
+
children: offlineError
|
|
3905
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3906
|
+
type: "button",
|
|
3907
|
+
className: "ops-btn ops-btn-secondary ops-btn-sm ops-mt-sm",
|
|
3908
|
+
onClick: () => void handleReconnect(activeServer.serverId),
|
|
3909
|
+
children: "重新连接"
|
|
3910
|
+
})] }) : "正在同步服务器最新快照…"
|
|
3911
|
+
})),
|
|
3912
|
+
tab === "timemachine" && activeServer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeMachineTab, {
|
|
3913
|
+
serverId: activeServer.serverId,
|
|
3914
|
+
capabilities: overview?.capabilities ?? initialFixture?.serviceInfo.capabilities ?? [],
|
|
3915
|
+
initialData: initialFixture ? {
|
|
3916
|
+
vaultStatus: initialFixture.vaultStatus,
|
|
3917
|
+
snapshotList: initialFixture.snapshotList,
|
|
3918
|
+
browse: initialFixture.browse,
|
|
3919
|
+
diff: initialFixture.diff,
|
|
3920
|
+
jobs: initialFixture.jobs,
|
|
3921
|
+
restorePreview: initialFixture.restorePreview
|
|
3922
|
+
} : void 0,
|
|
3923
|
+
onOpenAgent: (topic) => void handleOpenAgent(topic)
|
|
3924
|
+
}),
|
|
3925
|
+
tab === "activity" && activeServer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActivityTab, {
|
|
3926
|
+
serverId: activeServer.serverId,
|
|
3927
|
+
initialData: initialFixture ? {
|
|
3928
|
+
activityList: initialFixture.activityList,
|
|
3929
|
+
incidentDetail: initialFixture.incidentDetail,
|
|
3930
|
+
reportDetail: initialFixture.reportDetail
|
|
3931
|
+
} : void 0,
|
|
3932
|
+
onOpenAgent: (topic) => void handleOpenAgent(topic)
|
|
3933
|
+
})
|
|
3934
|
+
]
|
|
3935
|
+
})] })
|
|
3936
|
+
]
|
|
3937
|
+
}),
|
|
3938
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsDrawer, {
|
|
3939
|
+
open: settingsOpen,
|
|
3940
|
+
onClose: () => setSettingsOpen(false),
|
|
3941
|
+
servers,
|
|
3942
|
+
activeServerId: activeServer?.serverId ?? null,
|
|
3943
|
+
activeSyncedAt,
|
|
3944
|
+
onConnectionChange: handleConnectionChange,
|
|
3945
|
+
onReconnect: handleReconnect
|
|
3946
|
+
})
|
|
3947
|
+
]
|
|
3948
|
+
})
|
|
3949
|
+
});
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
function OpsWorkbenchPage(props = {}) {
|
|
3953
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpsApp, { ...props });
|
|
3954
|
+
}
|
|
3955
|
+
function SidebarIcon({ size = 18 }) {
|
|
3956
|
+
const badge = useSidebarBadge();
|
|
3957
|
+
const showDot = badge.unreadAlerts > 0 || badge.status === "bad" || badge.status === "warn";
|
|
3958
|
+
const dotColor = badge.status === "bad" || badge.unreadAlerts > 0 ? "var(--dsw-alias-state-error-primary, #ec1313)" : "var(--dsw-alias-state-warn-primary, #f59e0b)";
|
|
3959
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3960
|
+
className: "dsh-ops-sidebar-icon",
|
|
3961
|
+
style: {
|
|
3962
|
+
position: "relative",
|
|
3963
|
+
display: "inline-flex",
|
|
3964
|
+
alignItems: "center",
|
|
3965
|
+
justifyContent: "center",
|
|
3966
|
+
width: size,
|
|
3967
|
+
height: size
|
|
3968
|
+
},
|
|
3969
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
3970
|
+
width: size,
|
|
3971
|
+
height: size,
|
|
3972
|
+
viewBox: "0 0 20 20",
|
|
3973
|
+
fill: "none",
|
|
3974
|
+
stroke: "currentColor",
|
|
3975
|
+
strokeWidth: "1.6",
|
|
3976
|
+
strokeLinecap: "round",
|
|
3977
|
+
strokeLinejoin: "round",
|
|
3978
|
+
"aria-hidden": "true",
|
|
3979
|
+
children: [
|
|
3980
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
3981
|
+
x: "2.5",
|
|
3982
|
+
y: "3",
|
|
3983
|
+
width: "15",
|
|
3984
|
+
height: "5.5",
|
|
3985
|
+
rx: "1.5"
|
|
3986
|
+
}),
|
|
3987
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
3988
|
+
x: "2.5",
|
|
3989
|
+
y: "11.5",
|
|
3990
|
+
width: "15",
|
|
3991
|
+
height: "5.5",
|
|
3992
|
+
rx: "1.5"
|
|
3993
|
+
}),
|
|
3994
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
3995
|
+
cx: "5.75",
|
|
3996
|
+
cy: "5.75",
|
|
3997
|
+
r: "0.8",
|
|
3998
|
+
fill: "currentColor",
|
|
3999
|
+
stroke: "none"
|
|
4000
|
+
}),
|
|
4001
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
4002
|
+
cx: "5.75",
|
|
4003
|
+
cy: "14.25",
|
|
4004
|
+
r: "0.8",
|
|
4005
|
+
fill: "currentColor",
|
|
4006
|
+
stroke: "none"
|
|
4007
|
+
}),
|
|
4008
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
4009
|
+
x1: "9",
|
|
4010
|
+
y1: "5.75",
|
|
4011
|
+
x2: "14.5",
|
|
4012
|
+
y2: "5.75"
|
|
4013
|
+
}),
|
|
4014
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
4015
|
+
x1: "9",
|
|
4016
|
+
y1: "14.25",
|
|
4017
|
+
x2: "14.5",
|
|
4018
|
+
y2: "14.25"
|
|
4019
|
+
})
|
|
4020
|
+
]
|
|
4021
|
+
}), showDot && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4022
|
+
"aria-label": badge.unreadAlerts > 0 ? `${badge.unreadAlerts} 条未读告警` : "状态需关注",
|
|
4023
|
+
style: {
|
|
4024
|
+
position: "absolute",
|
|
4025
|
+
top: -1,
|
|
4026
|
+
right: -1,
|
|
4027
|
+
width: 7,
|
|
4028
|
+
height: 7,
|
|
4029
|
+
borderRadius: "999px",
|
|
4030
|
+
backgroundColor: dotColor,
|
|
4031
|
+
boxShadow: "0 0 0 1.5px var(--dsw-alias-bg-base, #ffffff)"
|
|
4032
|
+
}
|
|
4033
|
+
})]
|
|
4034
|
+
});
|
|
4035
|
+
}
|
|
4036
|
+
function SidebarTrailingBadge() {
|
|
4037
|
+
const badge = useSidebarBadge();
|
|
4038
|
+
if (badge.unreadAlerts <= 0) return null;
|
|
4039
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4040
|
+
style: {
|
|
4041
|
+
display: "inline-flex",
|
|
4042
|
+
alignItems: "center",
|
|
4043
|
+
justifyContent: "center",
|
|
4044
|
+
minWidth: 18,
|
|
4045
|
+
height: 18,
|
|
4046
|
+
padding: "0 5px",
|
|
4047
|
+
borderRadius: "999px",
|
|
4048
|
+
fontSize: 11,
|
|
4049
|
+
fontWeight: 600,
|
|
4050
|
+
lineHeight: 1,
|
|
4051
|
+
color: "var(--dsw-alias-label-on-color, #ffffff)",
|
|
4052
|
+
backgroundColor: "var(--dsw-alias-state-error-primary, #ec1313)"
|
|
4053
|
+
},
|
|
4054
|
+
children: badge.unreadAlerts > 99 ? "99+" : badge.unreadAlerts
|
|
4055
|
+
});
|
|
4056
|
+
}
|
|
4057
|
+
const name = "server-operations";
|
|
4058
|
+
const inject = [
|
|
4059
|
+
"slots",
|
|
4060
|
+
"layout",
|
|
4061
|
+
"sessions",
|
|
4062
|
+
"workspaces",
|
|
4063
|
+
"uiWorkspace"
|
|
4064
|
+
];
|
|
4065
|
+
const PANEL_KEY = "server-operations";
|
|
4066
|
+
function apply(ctx) {
|
|
4067
|
+
const dshClient = {
|
|
4068
|
+
sessions: ctx.sessions,
|
|
4069
|
+
workspaces: ctx.workspaces,
|
|
4070
|
+
uiWorkspace: ctx.uiWorkspace,
|
|
4071
|
+
layout: ctx.layout
|
|
4072
|
+
};
|
|
4073
|
+
ctx.slots.inject("main", () => ctx.slots.register({
|
|
4074
|
+
name: "main",
|
|
4075
|
+
key: PANEL_KEY
|
|
4076
|
+
}, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpsWorkbenchPage, { dshClient })));
|
|
4077
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
4078
|
+
name: "sidebar.panellist",
|
|
4079
|
+
id: PANEL_KEY,
|
|
4080
|
+
order: 42,
|
|
4081
|
+
label: () => "服务器运维"
|
|
4082
|
+
}, (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarIcon, {
|
|
4083
|
+
size: typeof props?.size === "number" ? props.size : 18,
|
|
4084
|
+
active: Boolean(props?.active)
|
|
4085
|
+
})));
|
|
4086
|
+
Promise.resolve().then(() => {
|
|
4087
|
+
try {
|
|
4088
|
+
ctx.slots.inject("sidebar.panellist.trailing", () => ctx.slots.register({
|
|
4089
|
+
name: "sidebar.panellist.trailing",
|
|
4090
|
+
only: PANEL_KEY
|
|
4091
|
+
}, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarTrailingBadge, {})));
|
|
4092
|
+
} catch {}
|
|
4093
|
+
});
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
exports.OpsApp = OpsApp;
|
|
4097
|
+
exports.OpsWorkbenchPage = OpsWorkbenchPage;
|
|
4098
|
+
exports.SidebarIcon = SidebarIcon;
|
|
4099
|
+
exports.apply = apply;
|
|
4100
|
+
exports.inject = inject;
|
|
4101
|
+
exports.name = name;
|
|
4102
|
+
return module.exports; } });
|