@rocket.chat/houston 0.27.0-next.2 → 2.1.8
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/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import { ctx } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
// ---- the edge ---------------------------------------------------------------
|
|
4
|
+
// One Traefik serves every https name on the box. It is NOT a workspace, so it
|
|
5
|
+
// never appears in the grid and cannot be stopped from here -- but it holds :443
|
|
6
|
+
// for everyone, and something invisible that can take every name down at once is
|
|
7
|
+
// worse than one more chip.
|
|
8
|
+
let EDGE = null;
|
|
9
|
+
// Docker's last known state, so the home page can lead with it being down —
|
|
10
|
+
// nothing can start, stop or report while it is, and that outranks every other
|
|
11
|
+
// thing the page might say.
|
|
12
|
+
let DOCKER_OK = true;
|
|
13
|
+
|
|
14
|
+
async function refreshEdgeBadge() {
|
|
15
|
+
const badge = ctx.$("#edge-badge");
|
|
16
|
+
try { EDGE = await ctx.api("/api/edge"); }
|
|
17
|
+
catch (_) { badge.hidden = true; return; } // no gui extra / no permission
|
|
18
|
+
if (!EDGE.installed) { badge.hidden = true; return; }
|
|
19
|
+
|
|
20
|
+
// A route the edge cannot reach answers 502 rather than erroring, so it would
|
|
21
|
+
// otherwise look like a broken workspace. Surfaced ahead of "running".
|
|
22
|
+
const broken = (EDGE.routes || []).filter((r) => !r.reachable).length;
|
|
23
|
+
const n = (EDGE.routes || []).length;
|
|
24
|
+
badge.hidden = false;
|
|
25
|
+
if (!EDGE.running) {
|
|
26
|
+
badge.textContent = `HTTPS: stopped`;
|
|
27
|
+
badge.className = "chip down";
|
|
28
|
+
} else if (broken) {
|
|
29
|
+
badge.textContent = `HTTPS: ${broken} unreachable`;
|
|
30
|
+
badge.className = "chip down";
|
|
31
|
+
} else {
|
|
32
|
+
badge.textContent = `HTTPS: ${n} name${n === 1 ? "" : "s"}`;
|
|
33
|
+
badge.className = "chip up";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function openEdge() {
|
|
38
|
+
const body = ctx.$("#edge-body");
|
|
39
|
+
body.innerHTML = "";
|
|
40
|
+
if (!EDGE || !EDGE.installed) {
|
|
41
|
+
body.append(ctx.el("p", { class: "kv" },
|
|
42
|
+
"No HTTPS yet — it starts with the first workspace created with HTTPS."));
|
|
43
|
+
} else {
|
|
44
|
+
body.append(ctx.el("div", { class: "kv" },
|
|
45
|
+
EDGE.running ? "Running — holds :80 and :443 for every https name"
|
|
46
|
+
: "STOPPED — every https name on this server is unreachable"));
|
|
47
|
+
if (EDGE.domain) body.append(ctx.el("div", { class: "kv" }, `GUI name: ${EDGE.domain}`));
|
|
48
|
+
if (!(EDGE.routes || []).length) {
|
|
49
|
+
body.append(ctx.el("p", { class: "kv" }, "No names registered yet."));
|
|
50
|
+
}
|
|
51
|
+
for (const r of EDGE.routes || []) {
|
|
52
|
+
// The KIND of route is worth saying: one is terminated here and one is not, and
|
|
53
|
+
// a reader looking at this list is usually asking which.
|
|
54
|
+
body.append(ctx.el("div", { class: "dcheck " + (r.reachable ? "ok" : "warn") },
|
|
55
|
+
ctx.el("span", { class: "dmark" }, r.reachable ? "✓" : "!"),
|
|
56
|
+
ctx.el("span", {}, `${r.host || r.name} → ${r.name}`
|
|
57
|
+
+ (r.passthrough ? " (passed through to the cluster, not decrypted)" : "")
|
|
58
|
+
+ (r.reachable ? "" : " (unreachable — answers 502)"))));
|
|
59
|
+
}
|
|
60
|
+
// Only a container-backed route is fixed by re-attaching; a passthrough has no
|
|
61
|
+
// network to join, so advising it would send someone to restart a healthy edge.
|
|
62
|
+
if ((EDGE.routes || []).some((r) => !r.reachable && !r.passthrough)) {
|
|
63
|
+
body.append(ctx.el("p", { class: "banner warn" },
|
|
64
|
+
"An admin with a shell on the server re-attaches them with `houston edge restart`; "
|
|
65
|
+
+ "there is no button for it here."));
|
|
66
|
+
}
|
|
67
|
+
// Certificates nothing points at. `down --volumes` removes a workspace's ROUTE
|
|
68
|
+
// and walks past the certificate, which is keyed by hostname -- so a Let's
|
|
69
|
+
// Encrypt certificate AND private key for a name you are finished with stays on
|
|
70
|
+
// this disk. Amber, not red: the row is telling you something wants attention;
|
|
71
|
+
// the button that destroys is the red one.
|
|
72
|
+
const stale = EDGE.stale_certs || [];
|
|
73
|
+
if (stale.length) {
|
|
74
|
+
const many = stale.length > 1;
|
|
75
|
+
body.append(ctx.el("p", { class: "banner warn" },
|
|
76
|
+
`${stale.length} certificate${many ? "s" : ""} held with no route — `
|
|
77
|
+
+ (many ? "each is a certificate and private key"
|
|
78
|
+
: "a certificate and private key")
|
|
79
|
+
+ " on this server for a name nothing serves."));
|
|
80
|
+
for (const host of stale) {
|
|
81
|
+
const row = ctx.el("div", { class: "dcheck warn" },
|
|
82
|
+
ctx.el("span", { class: "dmark" }, "!"),
|
|
83
|
+
ctx.el("span", {}, host));
|
|
84
|
+
// Admin only, and ABSENT rather than disabled for everyone else -- the rule
|
|
85
|
+
// this GUI uses everywhere: a control you cannot use should not be there to
|
|
86
|
+
// wonder about.
|
|
87
|
+
if (ctx.canAdmin()) {
|
|
88
|
+
row.append(ctx.el("button", { class: "btn danger small", onclick: () => forgetHost(host) },
|
|
89
|
+
"Delete"));
|
|
90
|
+
}
|
|
91
|
+
body.append(row);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!ctx.$("#edge-dialog").open) ctx.$("#edge-dialog").showModal();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function forgetHost(host) {
|
|
99
|
+
// The prompt names the private key on purpose. "Delete rc-rpro-test.example.org"
|
|
100
|
+
// reads like removing a route, and it is removing a key that cannot be recovered.
|
|
101
|
+
if (!confirm(`Delete ${host}?\n\nThis removes its route, its certificate and its `
|
|
102
|
+
+ `PRIVATE KEY, and its Let's Encrypt entry.\n\nThis cannot be undone.`)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const gone = await ctx.api(`/api/edge/hosts/${encodeURIComponent(host)}?confirm=true`,
|
|
107
|
+
{ method: "DELETE" });
|
|
108
|
+
// What actually went, not what was asked for -- the same reason the CLI reports
|
|
109
|
+
// per kind. A restart happens only for an ACME deletion, and it is worth saying
|
|
110
|
+
// because every other name on the box blinked.
|
|
111
|
+
const bits = [];
|
|
112
|
+
if (gone.routes && gone.routes.length) bits.push(`route ${gone.routes.join(", ")}`);
|
|
113
|
+
if (gone.certificate) bits.push("certificate and key");
|
|
114
|
+
if (gone.acme && gone.acme.length) bits.push(`Let's Encrypt entry (${gone.acme.join(", ")})`);
|
|
115
|
+
ctx.toast(bits.length ? `${host}: removed ${bits.join(", ")}`
|
|
116
|
+
: `${host}: nothing here to remove`, "ok");
|
|
117
|
+
} catch (e) {
|
|
118
|
+
ctx.toast(`Could not delete ${host}: ${e.message}`);
|
|
119
|
+
}
|
|
120
|
+
// Re-read before re-rendering: the dialog is drawn from EDGE, and after a delete
|
|
121
|
+
// that object is stale by exactly the row the user just acted on.
|
|
122
|
+
await refreshEdgeBadge();
|
|
123
|
+
await ctx.refreshClusterBadge();
|
|
124
|
+
openEdge();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const railRows = new Map();
|
|
128
|
+
const railHeadings = new Map();
|
|
129
|
+
function render() {
|
|
130
|
+
const grid = ctx.$("#repros");
|
|
131
|
+
const focused = grid.contains(document.activeElement) ? document.activeElement : null;
|
|
132
|
+
const records = ctx.ALL_REPROS.map(ctx.displayRepro);
|
|
133
|
+
const desired = [];
|
|
134
|
+
const running = records.filter((r) => r.state === "running").length;
|
|
135
|
+
// With docker unreachable every state is "?", so "0 running" would be a claim we
|
|
136
|
+
// cannot support (and #running-pill is styled green).
|
|
137
|
+
const unknown = !ctx.SERVER_ONLINE || (records.length > 0 && records.every((r) => r.state === "?"));
|
|
138
|
+
const pill = ctx.$("#running-pill");
|
|
139
|
+
pill.textContent = unknown ? "state unknown" : `${running} running`;
|
|
140
|
+
pill.className = "pill " + (unknown ? "unknown" : "running");
|
|
141
|
+
const n = ctx.ALL_REPROS.length;
|
|
142
|
+
ctx.$("#sb-count").textContent = `${n} workspace${n === 1 ? "" : "s"} · ` +
|
|
143
|
+
(unknown ? "state unknown" : `${running} running`);
|
|
144
|
+
ctx.$("#sb-refreshed").textContent = (!ctx.SERVER_ONLINE ? "Server unavailable · " : "")
|
|
145
|
+
+ (ctx.LAST_REPROS_AT ? "Last refreshed: " + new Date(ctx.LAST_REPROS_AT).toLocaleTimeString() : "Not read yet");
|
|
146
|
+
// `no-detail` HIDES THE ACTION PANE, and a cluster's own view has one. Without the second
|
|
147
|
+
// clause this line -- which runs on the four-second poll -- put the class back four
|
|
148
|
+
// seconds after the view was opened, so the build button and the permissions
|
|
149
|
+
// documents disappeared while you were reading them. The identical mistake is
|
|
150
|
+
// guarded two lines below for the pane's CONTENTS; this one governs whether the
|
|
151
|
+
// column is displayed at all, and fixing only the other half looked correct in
|
|
152
|
+
// every screenshot taken inside four seconds.
|
|
153
|
+
ctx.$(".panes").classList.toggle(
|
|
154
|
+
"no-detail", ctx.VIEW !== "cluster" && (ctx.VIEW !== "workspace" || !ctx.SELECTED));
|
|
155
|
+
// render() runs on the four-second poll, so it must redraw the RAIL without
|
|
156
|
+
// touching a stage it does not own. Activity and Scenarios paint themselves and
|
|
157
|
+
// then stay put; anything else here reset them to home within four seconds of
|
|
158
|
+
// opening, which is how the Scenarios page shipped in v0.40.0 and vanished
|
|
159
|
+
// while you were reading it.
|
|
160
|
+
if (ctx.VIEW === "home" && !ctx.SELECTED) ctx.renderHome();
|
|
161
|
+
// A cluster's view paints its own pane and must keep it, for the reason the note above
|
|
162
|
+
// gives about the stage: this line reset it within four seconds of opening, so the
|
|
163
|
+
// build button and the permissions documents vanished while you were reading them.
|
|
164
|
+
if (ctx.VIEW !== "workspace" && ctx.VIEW !== "cluster") ctx.$("#actpane").innerHTML = "";
|
|
165
|
+
|
|
166
|
+
let list = records.filter((r) =>
|
|
167
|
+
(!ctx.view.filter || r.name.toLowerCase().includes(ctx.view.filter)) &&
|
|
168
|
+
(!ctx.view.status || r.state === ctx.view.status) &&
|
|
169
|
+
(ctx.view.scope !== "mine" || !ctx.ME || (r.owner || r.created_by) === ctx.ME));
|
|
170
|
+
const key = ctx.view.sort;
|
|
171
|
+
list.sort((a, b) => key === "port" ? a.host_port - b.host_port
|
|
172
|
+
: String(a[key]).localeCompare(String(b[key])));
|
|
173
|
+
|
|
174
|
+
if (!ctx.ALL_REPROS.length) desired.push(ctx.el("p", { class: "empty" }, "No workspaces yet. Start with “+ New workspace”."));
|
|
175
|
+
else if (!list.length) desired.push(ctx.el("p", { class: "empty" }, "Nothing matches this filter."));
|
|
176
|
+
|
|
177
|
+
// GROUPED BY WHAT IT WANTS FROM YOU. A flat list is fine with two workspaces and
|
|
178
|
+
// is the wrong shape for a shared box running eight to twelve: "which one is
|
|
179
|
+
// unhappy" was a question you answered by reading every row, and the unhappy one
|
|
180
|
+
// could be anywhere in an alphabetical list.
|
|
181
|
+
//
|
|
182
|
+
// With docker unreachable every state is "?" -- there is nothing to distinguish, so
|
|
183
|
+
// grouping would sort them into one bucket with a heading that says nothing.
|
|
184
|
+
for (const [title, tone, rows] of unknown ? [["", "", list]] : railGroups(list)) {
|
|
185
|
+
if (!rows.length) continue;
|
|
186
|
+
// The heading is suppressed when there is only one group: with everything in one
|
|
187
|
+
// state the rail-head pill above already says which, and a heading over the whole
|
|
188
|
+
// list is a label for the thing it is inside.
|
|
189
|
+
if (title && !unknown) {
|
|
190
|
+
let heading = railHeadings.get(title);
|
|
191
|
+
if (!heading) {
|
|
192
|
+
heading = ctx.el("div", { class: "rgrp" }, ctx.el("span", { class: "rdot " + tone }),
|
|
193
|
+
ctx.el("span", { class: "rgrp-t" }, title), ctx.el("span", { class: "rgrp-n" }));
|
|
194
|
+
railHeadings.set(title, heading);
|
|
195
|
+
}
|
|
196
|
+
const count = heading.querySelector(".rgrp-n");
|
|
197
|
+
if (count.textContent !== String(rows.length)) count.textContent = String(rows.length);
|
|
198
|
+
desired.push(heading);
|
|
199
|
+
}
|
|
200
|
+
for (const r of rows) {
|
|
201
|
+
let saved = railRows.get(r.name);
|
|
202
|
+
const signature = JSON.stringify([r, ctx.SELECTED === r.name, pendingOn(r.name), railWhy(r)]);
|
|
203
|
+
if (!saved) {
|
|
204
|
+
saved = { node: card(r), signature };
|
|
205
|
+
railRows.set(r.name, saved);
|
|
206
|
+
} else if (saved.signature !== signature) {
|
|
207
|
+
const updated = card(r);
|
|
208
|
+
for (const attr of updated.attributes) saved.node.setAttribute(attr.name, attr.value);
|
|
209
|
+
saved.node.replaceChildren(...updated.childNodes);
|
|
210
|
+
saved.signature = signature;
|
|
211
|
+
}
|
|
212
|
+
desired.push(saved.node);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Leave nodes that are already in place attached. Only moves, additions and
|
|
216
|
+
// removals change the rail, so an unchanged poll preserves keyboard focus.
|
|
217
|
+
for (let i = 0; i < desired.length; i += 1) {
|
|
218
|
+
if (grid.childNodes[i] !== desired[i]) grid.insertBefore(desired[i], grid.childNodes[i] || null);
|
|
219
|
+
}
|
|
220
|
+
while (grid.childNodes.length > desired.length) grid.lastChild.remove();
|
|
221
|
+
if (focused && focused.isConnected && document.activeElement !== focused) focused.focus({ preventScroll: true });
|
|
222
|
+
const names = new Set(ctx.ALL_REPROS.map((r) => r.name));
|
|
223
|
+
for (const name of railRows.keys()) if (!names.has(name)) railRows.delete(name);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Three buckets, in the order you need them. "Wants you" is not "not running": a
|
|
227
|
+
// stopped workspace is doing exactly what it was told, and a restart-looping one is
|
|
228
|
+
// not, so they cannot share a group without the group meaning nothing.
|
|
229
|
+
const RAIL_ORDER = [["Wants you", "warn"], ["Running", "ok"], ["Not running", "off"]];
|
|
230
|
+
function wantsYou(r) {
|
|
231
|
+
// States nothing is going to fix on its own.
|
|
232
|
+
if (["restarting", "dead", "paused"].includes(r.state)) return true;
|
|
233
|
+
// Running, answering, and failing the healthcheck it sets for itself.
|
|
234
|
+
if (r.state === "running" && ctx.healthClass(r) === "bad") return true;
|
|
235
|
+
// Its https name resolves and answers 502, which looks like a broken workspace
|
|
236
|
+
// rather than a broken route -- so the rail has to be the thing that says so.
|
|
237
|
+
const route = ((EDGE && EDGE.routes) || []).find((x) => x.name === r.name);
|
|
238
|
+
return !!(route && route.reachable === false);
|
|
239
|
+
}
|
|
240
|
+
function railGroups(list) {
|
|
241
|
+
const buckets = [[], [], []];
|
|
242
|
+
for (const r of list) {
|
|
243
|
+
buckets[wantsYou(r) ? 0 : r.state === "running" ? 1 : 2].push(r);
|
|
244
|
+
}
|
|
245
|
+
const live = buckets.filter((b) => b.length).length;
|
|
246
|
+
return RAIL_ORDER.map(([title, tone], i) =>
|
|
247
|
+
[live > 1 ? title : "", tone, buckets[i]]);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// A row, not a card. The old card was 130px tall and carried six buttons; six
|
|
251
|
+
// workspaces meant 36 buttons on screen and 4.5 of them visible. This is 52px, has no
|
|
252
|
+
// buttons at all, and shows the whole name -- which is the thing anyone is actually
|
|
253
|
+
// scanning for. Everything you can DO lives in the stage, next to the workspace it
|
|
254
|
+
// acts on.
|
|
255
|
+
//
|
|
256
|
+
// One line was tried and reverted. It fits more rows, and it pays for them with the
|
|
257
|
+
// port, the owner and the scenario -- which is what people search a rail BY on a
|
|
258
|
+
// shared box. The grouping above is what "which one is unhappy" needed; the row did
|
|
259
|
+
// not have to shrink as well.
|
|
260
|
+
function card(r) {
|
|
261
|
+
const busy = pendingOn(r.name);
|
|
262
|
+
const state = busy ? "working" : ctx.stateClass(r.state || "?");
|
|
263
|
+
const row = ctx.el("button", {
|
|
264
|
+
class: "wrow",
|
|
265
|
+
"data-state": state,
|
|
266
|
+
"aria-current": r.name === ctx.SELECTED ? "true" : "false",
|
|
267
|
+
title: r.name,
|
|
268
|
+
onclick: () => ctx.selectRepro(r.name),
|
|
269
|
+
});
|
|
270
|
+
const r1 = ctx.el("span", { class: "r1" }, ctx.el("span", { class: "nm" }, r.name));
|
|
271
|
+
if (r.default) r1.append(ctx.el("span", { class: "star", title: "used by CLI commands with no --name" }, "★"));
|
|
272
|
+
r1.append(ctx.el("span", { class: "ver" }, r.rc_version || "?"));
|
|
273
|
+
const bits = [r.preset, ":" + r.host_port, r.created_by].filter(Boolean);
|
|
274
|
+
// Runtime is shown only when it is NOT the default. Compose is the overwhelming
|
|
275
|
+
// majority, so labelling every row "docker" would be noise on the common case and
|
|
276
|
+
// make the rare one harder to spot rather than easier. What matters is that a
|
|
277
|
+
// Kubernetes workspace never looks like a Compose one: which commands refuse,
|
|
278
|
+
// where the data lives and how to reach it all differ, and the list was the one
|
|
279
|
+
// place the two were indistinguishable.
|
|
280
|
+
if (r.runtime && r.runtime !== "docker") bits.push(r.runtime === "kubernetes" ? "k8s" : r.runtime);
|
|
281
|
+
if (r.monitoring) bits.push("monitored");
|
|
282
|
+
row.append(r1, ctx.el("span", { class: "meta" }, bits.join(" · ")));
|
|
283
|
+
// The third line stays even under a group heading that names the same state: the
|
|
284
|
+
// heading is a boundary you scroll past, this is on the row you are looking at --
|
|
285
|
+
// and for the group that wants you it says WHY, which the heading cannot.
|
|
286
|
+
row.append(ctx.el("span", { class: "r3" },
|
|
287
|
+
ctx.el("span", { class: "wstate " + (busy ? "working" : ctx.stateClass(r.state)) },
|
|
288
|
+
busy ? (BUSY_VERB[busy] || busy) : (r.state === "?" ? "state unknown" : r.state)),
|
|
289
|
+
ctx.el("span", { class: "wage" }, railWhy(r) || r.uptime || "")));
|
|
290
|
+
return row;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// What the state word does not say, on the rows where there is something: the reason
|
|
294
|
+
// this row is in the group that wants you. Empty everywhere else, where the age it
|
|
295
|
+
// replaces is the more useful thing.
|
|
296
|
+
function railWhy(r) {
|
|
297
|
+
if (!wantsYou(r)) return "";
|
|
298
|
+
const route = ((EDGE && EDGE.routes) || []).find((x) => x.name === r.name);
|
|
299
|
+
const bits = [];
|
|
300
|
+
if (r.state === "running" && ctx.healthClass(r) === "bad") bits.push(r.health || "unhealthy");
|
|
301
|
+
if (route && route.reachable === false) bits.push("https 502");
|
|
302
|
+
return bits.join(" · ");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const PENDING = new Map();
|
|
306
|
+
const BUSY_VERB = {
|
|
307
|
+
Stop: "Stopping", Start: "Starting", Restart: "Restarting", Down: "Removing",
|
|
308
|
+
"Make default": "Setting default", "API token": "Minting",
|
|
309
|
+
"Check the certificate": "Checking", Env: "Applying",
|
|
310
|
+
};
|
|
311
|
+
const pendingOn = (name) => PENDING.get(name) || "";
|
|
312
|
+
|
|
313
|
+
// A workspace job still running when this page loaded. PENDING lives in the page, so after
|
|
314
|
+
// a reload during a create the rail said `down` beside a create in progress. Read once at
|
|
315
|
+
// load; each one is shown as working until its job ends.
|
|
316
|
+
// A take down and a delete are one job kind, and Stop, Start and Restart another: the job's
|
|
317
|
+
// `verb` says which. A job from a server without it keeps the combined word (a state job: none).
|
|
318
|
+
const JOB_VERB = { create: "Creating", up: "Bringing up", teardown: "Taking down or deleting",
|
|
319
|
+
restore: "Restoring", upgrade: "Upgrading", rollback: "Rolling back" };
|
|
320
|
+
const VERB_ING = { delete: "Deleting", "take down": "Taking down", stop: "Stopping",
|
|
321
|
+
start: "Starting", restart: "Restarting" };
|
|
322
|
+
const jobVerb = (j) => VERB_ING[j.verb] || JOB_VERB[j.kind];
|
|
323
|
+
async function adoptRunningJobs() {
|
|
324
|
+
let jobs;
|
|
325
|
+
try { jobs = (await ctx.api("/api/jobs")).jobs || []; } catch (_) { return; }
|
|
326
|
+
const adopted = jobs.filter((j) => ctx.jobActive(j.status) && jobVerb(j) && j.label
|
|
327
|
+
&& !PENDING.has(j.label));
|
|
328
|
+
for (const j of adopted) PENDING.set(j.label, jobVerb(j));
|
|
329
|
+
if (adopted.length) render();
|
|
330
|
+
await Promise.all(adopted.map(async (j) => {
|
|
331
|
+
for (;;) {
|
|
332
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
333
|
+
let state;
|
|
334
|
+
try { state = await ctx.api(`/api/jobs/${j.id}`); } catch (_) { break; }
|
|
335
|
+
if (!ctx.jobActive(state.status)) break;
|
|
336
|
+
}
|
|
337
|
+
if (PENDING.get(j.label) === jobVerb(j)) PENDING.delete(j.label);
|
|
338
|
+
await ctx.loadRepros();
|
|
339
|
+
if (ctx.SELECTED === j.label) await ctx.refreshDetail({ force: true });
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// One builder for the card and the detail panel so a pending action looks the
|
|
344
|
+
// same in both. `pending` is the label of whatever is running on this repro:
|
|
345
|
+
// every button is disabled while it is set, because these are compose commands
|
|
346
|
+
// against a single project and Restart on top of an in-flight Stop raced them.
|
|
347
|
+
function actionButton(label, fn, { cls = "", small = false, pending = "", title = "" } = {}) {
|
|
348
|
+
const klass = "btn" + (small ? " small" : "") + (cls ? " " + cls : "");
|
|
349
|
+
const attrs = title ? { title } : {};
|
|
350
|
+
if (!ctx.SERVER_ONLINE) return ctx.el("button", { ...attrs, class: klass, disabled: "", title: "Server unavailable — changes disabled" }, label);
|
|
351
|
+
if (!pending) return ctx.el("button", { ...attrs, class: klass, onclick: () => fn() }, label);
|
|
352
|
+
if (pending !== label) return ctx.el("button", { ...attrs, class: klass, disabled: "" }, label);
|
|
353
|
+
return ctx.el("button", { ...attrs, class: klass + " working", disabled: "" },
|
|
354
|
+
ctx.el("span", { class: "spin" }), (BUSY_VERB[label] || label) + "…");
|
|
355
|
+
}
|
|
356
|
+
const actBtn = (label, fn, cls = "", pending = "") =>
|
|
357
|
+
stop(actionButton(label, fn, { cls, small: true, pending }));
|
|
358
|
+
|
|
359
|
+
// Run a slow synchronous action, keeping the UI honest about it from click to
|
|
360
|
+
// completion. The state lives in PENDING so both re-render paths (poll -> render,
|
|
361
|
+
// job callbacks -> renderDetail) redraw it instead of wiping it.
|
|
362
|
+
async function runAction(name, label, fn) {
|
|
363
|
+
if (PENDING.has(name)) return; // a second click while one is in flight
|
|
364
|
+
PENDING.set(name, label);
|
|
365
|
+
render();
|
|
366
|
+
if (ctx.SELECTED === name) ctx.renderDetail();
|
|
367
|
+
try { await fn(); }
|
|
368
|
+
catch (e) { ctx.toast(e.message); }
|
|
369
|
+
finally {
|
|
370
|
+
PENDING.delete(name);
|
|
371
|
+
await ctx.loadRepros(); // re-renders with the real new state
|
|
372
|
+
if (ctx.SELECTED === name) await ctx.refreshDetail({ force: true });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
// The action pane: everything you can do TO this workspace, grouped by intent.
|
|
378
|
+
//
|
|
379
|
+
// It used to be thirteen buttons in one row of the panel, in one weight -- "Open
|
|
380
|
+
// RC", which you press ninety times out of a hundred, sat next to "Capacity",
|
|
381
|
+
// which takes forty minutes, next to "Down", which destroys a customer
|
|
382
|
+
// reproduction. The row was read every single time because nothing in it was
|
|
383
|
+
// ranked.
|
|
384
|
+
//
|
|
385
|
+
// The grouping is not decoration, it is the teaching: "put data in it" explains
|
|
386
|
+
// what Seed does to somebody who never read the CLI's help. That only works if
|
|
387
|
+
// they can SEE it, which is why this is a pane and not a menu.
|
|
388
|
+
// The suggestion ladder, stated in order. Only ever the FIRST TWO that qualify, and
|
|
389
|
+
// every reason is a fact about THIS workspace rather than a guess about intent --
|
|
390
|
+
// guessing "next" wrongly is worse than not guessing, which is why nothing here reads
|
|
391
|
+
// a name, an age or a preset.
|
|
392
|
+
//
|
|
393
|
+
// Nothing is suggested for a workspace that is not running: what its state admits is
|
|
394
|
+
// "start it", which the panel's own action row and the triage block above both offer.
|
|
395
|
+
const NEXT_LADDER = [
|
|
396
|
+
["seed", (d) => !d.seed,
|
|
397
|
+
"It has no sample data yet — no users, rooms or messages beyond the admin account."],
|
|
398
|
+
["call", () => true,
|
|
399
|
+
"Send a REST request to this workspace and read the response here."],
|
|
400
|
+
["backup", (d) => !!d.seed,
|
|
401
|
+
"It has data now, and a backup can be restored into a new workspace."],
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
function renderActionPane(d, busyLabel) {
|
|
405
|
+
const pane = ctx.$("#actpane");
|
|
406
|
+
pane.innerHTML = "";
|
|
407
|
+
if (!ctx.SERVER_ONLINE) {
|
|
408
|
+
pane.append(ctx.el("p", { class: "apnote" }, "Server unavailable — changes are disabled until it returns."));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (!ctx.canWrite()) {
|
|
412
|
+
pane.append(ctx.el("p", { class: "apnote", title: ctx.READONLY_WHY },
|
|
413
|
+
"You have the readonly role, so nothing here is available to you. "
|
|
414
|
+
+ "Opening the workspace and reading this panel are."));
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (!ctx.canChange(d)) {
|
|
418
|
+
const owner = ctx.ownerOf(d);
|
|
419
|
+
pane.append(ctx.el("p", { class: "apnote" },
|
|
420
|
+
`This is ${owner}'s workspace. You can look at it; only ${owner} or an admin can change it, `
|
|
421
|
+
+ `or read its logs, env vars and login. Ask ${owner} to hand it over if you need it.`));
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const running = d.state === "running";
|
|
425
|
+
// `on: false` means "this runtime refuses it". The load test and the capacity search
|
|
426
|
+
// are Compose-only and the server says so with a 400 -- rendering them on a
|
|
427
|
+
// Kubernetes workspace could only produce a red toast, which is the same reason the
|
|
428
|
+
// logs and env tabs are kept off a readonly panel. Not "unimplemented": both would
|
|
429
|
+
// be measuring the `kubectl port-forward` rather than Rocket.Chat.
|
|
430
|
+
// See services/perf.require_compose_for_perf.
|
|
431
|
+
const kube = d.runtime === "kubernetes";
|
|
432
|
+
// ONE FLAT LIST, in the order the four headings used to impose. Four titled groups
|
|
433
|
+
// over eleven items is a taxonomy, and a taxonomy is what you need when you do not
|
|
434
|
+
// know what you are looking for -- but the question people arrive with is "what do I
|
|
435
|
+
// do with this workspace now", and a heading called "Keep or move it" does not answer
|
|
436
|
+
// it. The two that DO are lifted out above, with the reason they were chosen.
|
|
437
|
+
const items = [
|
|
438
|
+
{ id: "seed", label: "Add sample data", fn: () => ctx.openSeed(d.name), ok: running },
|
|
439
|
+
{ id: "import", label: "Import settings", fn: () => ctx.openImport(d.name), ok: running },
|
|
440
|
+
{ id: "call", label: "Send an API call", fn: () => ctx.openCall(d.name), ok: running },
|
|
441
|
+
{ id: "pat", label: "PAT and Token", fn: () => ctx.doPat(d.name), ok: running },
|
|
442
|
+
{ id: "backup", label: "Back up now", fn: () => ctx.doBackup(d.name), ok: running },
|
|
443
|
+
{ id: "upgrade", label: "Upgrade version",
|
|
444
|
+
fn: () => ctx.openUpgrade(d.name, d.rc_version), ok: running },
|
|
445
|
+
// Only when one can be made (the pre-upgrade backup is recorded and still there) and
|
|
446
|
+
// the ownership gate lets this viewer: it replaces the database. Not "running only":
|
|
447
|
+
// an upgrade whose migrations left Rocket.Chat restarting is when it is wanted most.
|
|
448
|
+
{ id: "rollback", label: `Roll back to ${d.rollback_to}`, fn: () => ctx.openRollback(d),
|
|
449
|
+
ok: true, on: !!d.rollback_to && !!d.may_destroy },
|
|
450
|
+
// Named for the thing rather than for one of its parts: it attaches Prometheus,
|
|
451
|
+
// Grafana, Loki and the exporters, and "stream to Grafana" described the last hop.
|
|
452
|
+
{ id: "monitor", label: d.monitoring ? "Detach monitoring" : "Attach monitoring",
|
|
453
|
+
fn: () => ctx.doMonitor(d.name, !!d.monitoring), ok: running },
|
|
454
|
+
{ id: "loadtest", label: "Run a load test",
|
|
455
|
+
fn: () => ctx.openPerf(d.name, d.monitoring), ok: running, on: !kube },
|
|
456
|
+
{ id: "capacity", label: "Find capacity", fn: () => ctx.openCap(d.name), ok: running,
|
|
457
|
+
on: !kube },
|
|
458
|
+
// Greyed until there is a public name. On Kubernetes it was hidden outright, on the
|
|
459
|
+
// reasoning that `up --https` is refused there; but `--domain` gives a cluster
|
|
460
|
+
// workspace a real certificate, and the TLS route answers for it.
|
|
461
|
+
{ id: "tls", label: "Check the certificate", fn: () => ctx.doTlsStatus(d.name),
|
|
462
|
+
ok: running && !!d.public_url, on: !kube || !!d.public_url },
|
|
463
|
+
// The CLI's default for everybody on the box, so an admin's to set.
|
|
464
|
+
{ id: "default", label: "Use for CLI commands", fn: () => ctx.doDefault(d.name),
|
|
465
|
+
ok: !d.is_default, on: !ctx.ACCOUNTS || ctx.canAdmin() },
|
|
466
|
+
// Whoever the server's ownership gate lets: the owner, an admin, or anyone under
|
|
467
|
+
// `gui.destroy_policy anyone` -- the panel's read carries this viewer's answer. On a
|
|
468
|
+
// box without accounts there is nobody to hand it to.
|
|
469
|
+
{ id: "owner", label: "Hand over…", fn: () => ctx.openHandOver(d), ok: true,
|
|
470
|
+
on: ctx.ACCOUNTS && !!d.may_destroy },
|
|
471
|
+
].filter((it) => it.on !== false);
|
|
472
|
+
|
|
473
|
+
const byId = new Map(items.map((it) => [it.id, it]));
|
|
474
|
+
const next = [];
|
|
475
|
+
if (running && !busyLabel) {
|
|
476
|
+
for (const [id, when, why] of NEXT_LADDER) {
|
|
477
|
+
if (next.length === 2) break;
|
|
478
|
+
const it = byId.get(id);
|
|
479
|
+
if (it && it.ok && when(d)) next.push([it, why]);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (next.length) {
|
|
483
|
+
pane.append(ctx.el("div", { class: "apgroup" }, "Next, probably"));
|
|
484
|
+
const box = ctx.el("div", { class: "apnext" });
|
|
485
|
+
// The label, and nothing else. The reason each one was chosen was a sentence under
|
|
486
|
+
// it, and a sentence under a suggestion is a thing to read before you can act: the
|
|
487
|
+
// heading already says these are suggestions, and the item says what it does.
|
|
488
|
+
for (const [it] of next) {
|
|
489
|
+
box.append(ctx.el("button", { class: "apn", onclick: it.fn }, ctx.el("b", {}, it.label)));
|
|
490
|
+
}
|
|
491
|
+
pane.append(box);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const rest = items.filter((it) => !next.some(([n]) => n === it.id || n.id === it.id));
|
|
495
|
+
if (rest.length) {
|
|
496
|
+
pane.append(ctx.el("div", { class: "apgroup" },
|
|
497
|
+
next.length ? "Everything else" : "What you can do with it"));
|
|
498
|
+
const listEl = ctx.el("div", { class: "aplist" });
|
|
499
|
+
for (const it of rest) {
|
|
500
|
+
const b = ctx.el("button", { onclick: it.fn }, it.label);
|
|
501
|
+
if (!it.ok || busyLabel) b.disabled = true;
|
|
502
|
+
listEl.append(b);
|
|
503
|
+
}
|
|
504
|
+
pane.append(listEl);
|
|
505
|
+
}
|
|
506
|
+
if (kube) {
|
|
507
|
+
pane.append(ctx.el("p", { class: "apnote" },
|
|
508
|
+
"Load testing and the capacity search are Docker-only: a Kubernetes "
|
|
509
|
+
+ "workspace is reached through a port-forward, which would be what the "
|
|
510
|
+
+ "numbers measured."));
|
|
511
|
+
}
|
|
512
|
+
if (!running) {
|
|
513
|
+
pane.append(ctx.el("p", { class: "apnote" },
|
|
514
|
+
`Most of these need the workspace running. It is ${d.state === "?" ? "unreachable" : d.state}.`));
|
|
515
|
+
}
|
|
516
|
+
// Pinned to the bottom, not trailing the last group, and apart from Stop: it is not the
|
|
517
|
+
// eleventh item on a menu, it is the thing you have to travel to. TWO buttons, each saying
|
|
518
|
+
// what it removes: one "Take this workspace down" behind two confirm boxes left "stop",
|
|
519
|
+
// "down" and "delete" for the reader to tell apart. A workspace already down has only the
|
|
520
|
+
// delete left.
|
|
521
|
+
const danger = ctx.el("div", { class: "apdanger" });
|
|
522
|
+
if (d.state !== "down") {
|
|
523
|
+
const down = ctx.el("button", { class: "keep", onclick: () => ctx.doDown(d.name) }, "Take down…");
|
|
524
|
+
if (busyLabel) down.disabled = true;
|
|
525
|
+
danger.append(down, ctx.el("p", {},
|
|
526
|
+
(kube ? "Uninstalls its release and keeps its data. " : "Removes its containers and keeps its data. ")
|
|
527
|
+
+ "Bring up starts it again."));
|
|
528
|
+
}
|
|
529
|
+
const del = ctx.el("button", { onclick: () => ctx.doDown(d.name, true) }, "Delete workspace…");
|
|
530
|
+
if (busyLabel) del.disabled = true;
|
|
531
|
+
danger.append(del, ctx.el("p", {},
|
|
532
|
+
(d.state === "down" ? "Deletes its data and record. " : "Deletes it with its data and record. ")
|
|
533
|
+
+ "This cannot be undone."));
|
|
534
|
+
pane.append(danger);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
Object.defineProperties(ctx, {
|
|
540
|
+
"EDGE": { enumerable: true, get: () => EDGE, set: value => { EDGE = value; } },
|
|
541
|
+
"DOCKER_OK": { enumerable: true, get: () => DOCKER_OK, set: value => { DOCKER_OK = value; } },
|
|
542
|
+
"refreshEdgeBadge": { enumerable: true, get: () => refreshEdgeBadge },
|
|
543
|
+
"openEdge": { enumerable: true, get: () => openEdge },
|
|
544
|
+
"forgetHost": { enumerable: true, get: () => forgetHost },
|
|
545
|
+
"render": { enumerable: true, get: () => render },
|
|
546
|
+
"RAIL_ORDER": { enumerable: true, get: () => RAIL_ORDER },
|
|
547
|
+
"wantsYou": { enumerable: true, get: () => wantsYou },
|
|
548
|
+
"railGroups": { enumerable: true, get: () => railGroups },
|
|
549
|
+
"card": { enumerable: true, get: () => card },
|
|
550
|
+
"railWhy": { enumerable: true, get: () => railWhy },
|
|
551
|
+
"PENDING": { enumerable: true, get: () => PENDING },
|
|
552
|
+
"BUSY_VERB": { enumerable: true, get: () => BUSY_VERB },
|
|
553
|
+
"pendingOn": { enumerable: true, get: () => pendingOn },
|
|
554
|
+
"adoptRunningJobs": { enumerable: true, get: () => adoptRunningJobs },
|
|
555
|
+
"actionButton": { enumerable: true, get: () => actionButton },
|
|
556
|
+
"actBtn": { enumerable: true, get: () => actBtn },
|
|
557
|
+
"runAction": { enumerable: true, get: () => runAction },
|
|
558
|
+
"NEXT_LADDER": { enumerable: true, get: () => NEXT_LADDER },
|
|
559
|
+
"renderActionPane": { enumerable: true, get: () => renderActionPane },
|
|
560
|
+
});
|
|
561
|
+
export { EDGE, DOCKER_OK, refreshEdgeBadge, openEdge, forgetHost, render, RAIL_ORDER, wantsYou, railGroups, card, railWhy, PENDING, BUSY_VERB, pendingOn, adoptRunningJobs, actionButton, actBtn, runAction, NEXT_LADDER, renderActionPane };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ctx } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
try {
|
|
4
|
+
document.documentElement.dataset.theme = localStorage.getItem("houston-theme") || "light";
|
|
5
|
+
} catch (_) {
|
|
6
|
+
document.documentElement.dataset.theme = "light";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function whenReady(name, invoke) {
|
|
10
|
+
const ready = () => typeof ctx[name] === "function"
|
|
11
|
+
? invoke(ctx[name]) : setTimeout(ready, 0);
|
|
12
|
+
ready();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
document.addEventListener("click", (event) => {
|
|
16
|
+
const target = event.target.closest(
|
|
17
|
+
"#btn-jobs, #btn-clusters, #btn-scenarios, #btn-backups, #btn-home, #btn-new",
|
|
18
|
+
);
|
|
19
|
+
if (!target) return;
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
const names = {
|
|
22
|
+
"btn-jobs": "openJobs", "btn-clusters": "openClusters",
|
|
23
|
+
"btn-scenarios": "openScenarios", "btn-backups": "openBackups", "btn-home": "goHome",
|
|
24
|
+
"btn-new": "openCreate",
|
|
25
|
+
};
|
|
26
|
+
whenReady(names[target.id], (fn) => target.id === "btn-jobs" ? fn("running") : fn());
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
document.addEventListener("click", (event) => {
|
|
30
|
+
const target = event.target.closest("#doctor-badge, #edge-badge");
|
|
31
|
+
if (!target) return;
|
|
32
|
+
whenReady(target.id === "doctor-badge" ? "openDoctor" : "openEdge", (fn) => fn());
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
document.addEventListener("click", (event) => {
|
|
36
|
+
if (!event.target.closest("#theme-toggle")) return;
|
|
37
|
+
whenReady("applyTheme", (applyTheme) => {
|
|
38
|
+
const next = document.documentElement.dataset.theme === "dark" ? "light" : "dark";
|
|
39
|
+
applyTheme(next);
|
|
40
|
+
try { localStorage.setItem(ctx.THEME_KEY, next); } catch (_) { /* private mode */ }
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await import("./main.js");
|