@rocket.chat/houston 0.27.0-next.3 → 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 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- 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,583 @@
|
|
|
1
|
+
import { ctx } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
// ---- home ------------------------------------------------------------------
|
|
4
|
+
// What the stage shows when nothing is selected. It used to say "Select a
|
|
5
|
+
// workspace", which answers a question nobody asked.
|
|
6
|
+
//
|
|
7
|
+
// It leads with CAPACITY because that is what actually limits this tool: `up`
|
|
8
|
+
// refuses without headroom, and seven concurrent stacks once OOM-killed a 10 GB
|
|
9
|
+
// host with every individual create having succeeded. "Room for about 2 more" is
|
|
10
|
+
// the sentence that decides what you do next; a row of totals would look like a
|
|
11
|
+
// dashboard and say nothing.
|
|
12
|
+
let HOME = { cap: null, at: 0 };
|
|
13
|
+
const HOME_EVERY = 15000;
|
|
14
|
+
|
|
15
|
+
async function refreshHome(force) {
|
|
16
|
+
if (!force && Date.now() - HOME.at < HOME_EVERY) return;
|
|
17
|
+
HOME.at = Date.now();
|
|
18
|
+
const cap = await ctx.api("/api/machine").catch(() => null);
|
|
19
|
+
if (cap) { HOME.cap = cap; ctx.MACHINE_ROOM = cap; }
|
|
20
|
+
// What an EKS cluster wants arrives with the overview, after Home is drawn.
|
|
21
|
+
if (ctx.loadClusterOverview) {
|
|
22
|
+
ctx.loadClusterOverview(!!force).then((ov) => {
|
|
23
|
+
if (ov && ctx.VIEW === "home" && !ctx.SELECTED) renderHome();
|
|
24
|
+
}).catch(() => {});
|
|
25
|
+
}
|
|
26
|
+
// `!SELECTED` is not the same question as "is Home on screen". Activity and
|
|
27
|
+
// Scenarios are stage views with no workspace selected, so this timer repainted
|
|
28
|
+
// the stage with Home underneath whatever you were reading -- the page appearing
|
|
29
|
+
// to navigate itself, seconds after you opened it. render() has always asked the
|
|
30
|
+
// right question (VIEW === "home"); this never got the same fix.
|
|
31
|
+
if (ctx.VIEW === "home" && !ctx.SELECTED) renderHome();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Where a workspace runs, in the words the Clusters page uses for the place.
|
|
35
|
+
function whereOf(r) {
|
|
36
|
+
if ((r.runtime || "docker") !== "kubernetes") return "Docker";
|
|
37
|
+
const row = ((ctx.CLUSTERS && ctx.CLUSTERS.contexts) || []).find((c) => c.context === r.context);
|
|
38
|
+
const short = (row && row.short) || String(r.context || r.cluster || "").split("/").pop();
|
|
39
|
+
if (row && ctx.clWhere(row, ctx.CLSTATE.status[row.context]) === "aws") return `${short} · EKS`;
|
|
40
|
+
return short ? `Kubernetes · ${short}` : "Kubernetes";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// One running workspace, on Home. The name opens the WORKSPACE (this tool's page about
|
|
44
|
+
// it); Open goes to Rocket.Chat itself -- two different places, so two targets.
|
|
45
|
+
function runningRow(r) {
|
|
46
|
+
const health = String(r.health || "").toLowerCase();
|
|
47
|
+
const bad = health && !["healthy", "running", "starting"].includes(health);
|
|
48
|
+
return ctx.el("div", { class: "drow" },
|
|
49
|
+
ctx.el("span", { class: "ldot" + (bad ? " bad" : "") }),
|
|
50
|
+
ctx.el("button", { class: "t-btn grow", type: "button", title: `Open ${r.name} in houston`, onclick: () => selectRepro(r.name) },
|
|
51
|
+
ctx.el("div", { class: "t" }, r.name),
|
|
52
|
+
ctx.el("div", { class: "m" }, [r.rc_version, r.preset || "default", whereOf(r)].filter(Boolean).join(" · "))),
|
|
53
|
+
ctx.el("span", { class: "m" + (bad ? " warn" : "") }, bad ? health : (r.uptime || "")),
|
|
54
|
+
ctx.el("a", { class: "btn sm", href: r.open_url || r.root_url, target: "_blank", rel: "noreferrer",
|
|
55
|
+
title: ctx.remoteLoopback(r.open_url || r.root_url) ? ctx.LOOPBACK_TITLE : "Open Rocket.Chat itself, in a new tab" }, "Open"));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// It leads with what limits this tool: `up` refuses without headroom, so "room for
|
|
59
|
+
// about 2 more" is the sentence that decides what you do next.
|
|
60
|
+
function capacityCard(cap) {
|
|
61
|
+
const box = ctx.el("div", { class: "hcard dash capcard" }, ctx.el("h3", {}, "Memory on this server"));
|
|
62
|
+
if (!cap || !cap.known) {
|
|
63
|
+
box.append(ctx.el("p", { class: "m", style: "margin:0;font-family:var(--sans);font-size:13px" },
|
|
64
|
+
"houston reads /proc/meminfo, which this server does not have — so it "
|
|
65
|
+
+ "cannot say how much room is left, and `up` will not refuse on memory here."));
|
|
66
|
+
return box;
|
|
67
|
+
}
|
|
68
|
+
const usedMb = Math.max(0, cap.total_mb - cap.available_mb);
|
|
69
|
+
const pct = (n) => Math.max(0, Math.min(100, (n / cap.total_mb) * 100));
|
|
70
|
+
const gb = (mb) => (mb / 1024).toFixed(1);
|
|
71
|
+
box.append(ctx.el("div", {}, ctx.el("span", { class: "big" }, `${gb(usedMb)} GB`), " ",
|
|
72
|
+
ctx.el("span", { class: "wh", style: "font-size:14px" }, `of ${gb(cap.total_mb)} GB in use`)));
|
|
73
|
+
box.append(ctx.el("div", { class: "bar" },
|
|
74
|
+
ctx.el("i", { class: "used", style: `width:${pct(usedMb)}%;background:var(--accent-fill)` }),
|
|
75
|
+
ctx.el("i", { class: "reserved", style: `width:${pct(cap.reserve_mb)}%;background:var(--line2)`, title: "kept back for the server itself" })));
|
|
76
|
+
const kube = (cap.room_by_runtime || {})["kubernetes-microservices"];
|
|
77
|
+
const tight = cap.room < 1;
|
|
78
|
+
box.append(ctx.el("div", { class: "wh" + (tight ? " warn" : ""), style: "font-size:13px" + (tight ? ";color:var(--amber)" : "") },
|
|
79
|
+
tight ? "Not enough room for another workspace on this server."
|
|
80
|
+
: `Room for about ${cap.room} more on Docker` + (typeof kube === "number" ? `, or ${kube} more on Kubernetes.` : ".")));
|
|
81
|
+
return box;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// What wants somebody, and only that. Amazon EKS comes from the overview Home already
|
|
85
|
+
// reads -- no call of its own.
|
|
86
|
+
function attentionItems() {
|
|
87
|
+
const out = [];
|
|
88
|
+
if (!ctx.DOCKER_OK) {
|
|
89
|
+
out.push(["Docker is not answering",
|
|
90
|
+
"Nothing can start, stop or report state until it is back.", ctx.openDoctor, "Check"]);
|
|
91
|
+
}
|
|
92
|
+
const broken = ((ctx.EDGE && ctx.EDGE.routes) || []).filter((r) => !r.reachable);
|
|
93
|
+
for (const r of broken) {
|
|
94
|
+
out.push([`${r.name}'s HTTPS address is not connected`,
|
|
95
|
+
"It answers 502 (Bad Gateway). The workspace may be fine; the shared HTTPS front "
|
|
96
|
+
+ "door has lost its connection to it.", ctx.openEdge, "HTTPS details"]);
|
|
97
|
+
}
|
|
98
|
+
// Not one with an action in flight: an unfinished create reads `down`, and Home asked
|
|
99
|
+
// for attention about a workspace that was still being made.
|
|
100
|
+
for (const r of ctx.ALL_REPROS.filter((x) => x.state === "down" && !ctx.pendingOn(x.name))) {
|
|
101
|
+
out.push([`${r.name} is down`,
|
|
102
|
+
`It still holds port :${r.host_port} and its data volume.`,
|
|
103
|
+
() => selectRepro(r.name), "Review"]);
|
|
104
|
+
}
|
|
105
|
+
// clRows, not the raw list: a cluster still being built is the build's item below, and
|
|
106
|
+
// listing its own warning beside it said the same cluster twice.
|
|
107
|
+
const aws = ctx.clRows("aws");
|
|
108
|
+
const sign = ctx.awsSignIn ? ctx.awsSignIn() : { state: "unknown" };
|
|
109
|
+
if (aws.length && sign.state === "expired") {
|
|
110
|
+
const names = aws.map((r) => r.short || r.context).join(", ");
|
|
111
|
+
out.push(["The server's AWS sign-in has expired",
|
|
112
|
+
`Houston can't check ${names} or what ${aws.length === 1 ? "it costs" : "they cost"} until someone signs in again on the server.`,
|
|
113
|
+
ctx.canAdmin() ? () => ctx.openEksSetup() : null, "Fix"]);
|
|
114
|
+
} else {
|
|
115
|
+
for (const r of aws) {
|
|
116
|
+
const st = ctx.CLSTATE.status[r.context];
|
|
117
|
+
const warn = ctx.placeWarn(st);
|
|
118
|
+
if (!warn) continue;
|
|
119
|
+
const name = `${r.short || r.context} (Amazon EKS)`;
|
|
120
|
+
const day = ctx.perDay(st);
|
|
121
|
+
const bills = day ? `It keeps billing ~$${day.toFixed(2)} a day until someone deletes it.` : "It keeps billing until someone deletes it.";
|
|
122
|
+
const d = st.expires_in_days;
|
|
123
|
+
// The DNS record is its own item with its own button: a first-time user does not know
|
|
124
|
+
// a built cluster needs one, and "Review" did not say that this was the next step.
|
|
125
|
+
if (/^Public names under/u.test(warn)) {
|
|
126
|
+
out.push([`${name} needs a DNS record`,
|
|
127
|
+
`Workspaces on it get public names under ${st.zone} once one record (a CNAME) answers. Add it once, at your DNS provider.`,
|
|
128
|
+
() => ctx.clOpenDns(r), "Set up DNS"]);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const [title, why] = !st.reachable ? [`${name} is not answering`, warn]
|
|
132
|
+
: typeof d === "number" && d < 0 ? [`${name} is past its reminder date`, bills]
|
|
133
|
+
: d === 0 ? [`${name} reaches its reminder date today`, bills]
|
|
134
|
+
: /^Holds no workspaces/u.test(warn) ? [`${name} holds no workspaces`, `It still bills ~$${(day || 0).toFixed(2)} a day until someone deletes it.`]
|
|
135
|
+
: [`${name} wants you`, warn];
|
|
136
|
+
out.push([title, why, () => ctx.openPlace(`eks:${r.context}`), "Review"]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const j of ctx.CLSTATE.jobs.filter((x) => x.kind === "cluster-create")) {
|
|
140
|
+
out.push([`${j.label || "A cluster"} is being built`, "About 20 minutes in all. It is already billing.",
|
|
141
|
+
() => ctx.openClusters(), "View"]);
|
|
142
|
+
}
|
|
143
|
+
for (const b of (ctx.CLSTATE.overview && ctx.CLSTATE.overview.failed) || []) {
|
|
144
|
+
if (b.present === false) continue;
|
|
145
|
+
out.push([`The build of ${b.name} failed part-way`, "It may still be billing. Delete what it left.",
|
|
146
|
+
() => ctx.openClusters(), "Review"]);
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function renderHome() {
|
|
152
|
+
const panel = ctx.$("#detail");
|
|
153
|
+
// The entrance plays once, when Home arrives -- not on every four-second repaint.
|
|
154
|
+
const fresh = !panel.querySelector(".pv.home");
|
|
155
|
+
panel.innerHTML = "";
|
|
156
|
+
const box = ctx.el("div", { class: "pv home" + (fresh ? " anim" : "") });
|
|
157
|
+
if (!ctx.SERVER_ONLINE) {
|
|
158
|
+
box.append(ctx.el("h1", {}, "Your workspaces"), ctx.el("p", { class: "banner warn" },
|
|
159
|
+
"Server unavailable — workspace state and available capacity are unknown."));
|
|
160
|
+
panel.append(box);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const hour = new Date().getHours();
|
|
164
|
+
const part = hour < 12 ? "morning" : hour < 18 ? "afternoon" : "evening";
|
|
165
|
+
box.append(ctx.el("h1", {}, ctx.ME ? `Good ${part}, ${ctx.ME}` : "Your workspaces"), ctx.el("p", { class: "sub" }));
|
|
166
|
+
if (!ctx.ALL_REPROS.length) {
|
|
167
|
+
box.append(ctx.canWrite()
|
|
168
|
+
? ctx.el("div", { class: "hcard dash welcome", id: "home-welcome" },
|
|
169
|
+
ctx.el("h2", {}, "Create your first workspace"),
|
|
170
|
+
ctx.el("p", {}, "A workspace is a Rocket.Chat of the version you choose, with its own MongoDB and any services it needs, such as LDAP, SAML or email."),
|
|
171
|
+
ctx.el("button", { class: "btn solid", type: "button", onclick: () => ctx.openCreate() }, "+ Create a workspace"),
|
|
172
|
+
ctx.el("p", { class: "small" }, "First you pick where it runs, then the Rocket.Chat version. Docker on this server is free and right for most workspaces."))
|
|
173
|
+
: ctx.el("div", { class: "hcard dash" }, ctx.el("p", { style: "margin:0;color:var(--muted)" },
|
|
174
|
+
"No workspaces yet. Workspaces your team creates appear here.")));
|
|
175
|
+
}
|
|
176
|
+
const items = attentionItems();
|
|
177
|
+
if (items.length) {
|
|
178
|
+
const card = ctx.el("div", { class: "hcard dash", id: "home-needs" },
|
|
179
|
+
ctx.el("h3", {}, ctx.el("span", { class: "need" }, "Needs you"), ctx.el("span", {}, String(items.length))));
|
|
180
|
+
for (const [title, why, fn, label] of items) {
|
|
181
|
+
card.append(ctx.el("div", { class: "drow att" },
|
|
182
|
+
ctx.el("span", { class: "need" }, "▲"),
|
|
183
|
+
ctx.el("div", { class: "grow" }, ctx.el("div", { class: "t" }, title), ctx.el("div", { class: "why" }, why)),
|
|
184
|
+
fn ? ctx.el("button", { class: "btn sm", type: "button", onclick: fn }, label) : ""));
|
|
185
|
+
}
|
|
186
|
+
box.append(card);
|
|
187
|
+
}
|
|
188
|
+
if (ctx.ALL_REPROS.length) {
|
|
189
|
+
const running = ctx.ALL_REPROS.filter((r) => r.state === "running");
|
|
190
|
+
const card = ctx.el("div", { class: "hcard dash", id: "home-running" },
|
|
191
|
+
ctx.el("h3", {}, "Running now", ctx.el("span", { class: "mono", style: "letter-spacing:0;text-transform:none" }, `${running.length} of ${ctx.ALL_REPROS.length}`)));
|
|
192
|
+
if (running.length) for (const r of running) card.append(runningRow(r));
|
|
193
|
+
else card.append(ctx.el("p", { style: "color:var(--muted);margin:0" }, "Nothing is running."));
|
|
194
|
+
box.append(card);
|
|
195
|
+
}
|
|
196
|
+
box.append(capacityCard(HOME.cap));
|
|
197
|
+
panel.append(box);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
// ---- scenarios --------------------------------------------------------------
|
|
202
|
+
// Where a preset's notes finally live. They were printed by `up` and `info` and
|
|
203
|
+
// shown nowhere in the browser -- which for `oidc` means a GUI-only user could
|
|
204
|
+
// not discover that the scenario does not work at all until an /etc/hosts line
|
|
205
|
+
// exists. The notes are pre-wrapped for an 80-column terminal, so they are set
|
|
206
|
+
// in a <pre> and allowed to scroll rather than re-flowed into a narrow column.
|
|
207
|
+
async function openScenarios() {
|
|
208
|
+
ctx.setView("scenarios");
|
|
209
|
+
ctx.$(".panes").classList.add("no-detail");
|
|
210
|
+
ctx.$("#actpane").innerHTML = "";
|
|
211
|
+
const panel = ctx.$("#detail");
|
|
212
|
+
panel.innerHTML = "";
|
|
213
|
+
const head = ctx.el("div", { class: "home-head" }, ctx.el("h1", {}, "Presets"),
|
|
214
|
+
ctx.el("p", {}, "What each one adds to a plain Rocket.Chat, and what you have to do to use it."));
|
|
215
|
+
const body = ctx.el("div", { class: "home-body" });
|
|
216
|
+
body.append(ctx.el("p", { class: "empty" }, "loading…"));
|
|
217
|
+
panel.append(head, body);
|
|
218
|
+
let list;
|
|
219
|
+
try { list = (await ctx.api("/api/presets")).presets || []; }
|
|
220
|
+
catch (e) { body.innerHTML = ""; body.append(ctx.el("p", { class: "empty" }, e.message)); return; }
|
|
221
|
+
if (ctx.VIEW !== "scenarios") return; // a newer view won the race
|
|
222
|
+
body.innerHTML = "";
|
|
223
|
+
for (const s of list) {
|
|
224
|
+
const card = ctx.el("div", { class: "hcard scen" });
|
|
225
|
+
const h = ctx.el("div", { class: "hcard-h" }, ctx.el("b", {}, s.name));
|
|
226
|
+
if (s.requires_license) h.append(ctx.el("span", { class: "pill small" }, "needs a license"));
|
|
227
|
+
card.append(h);
|
|
228
|
+
const inner = ctx.el("div", { class: "scen-b" });
|
|
229
|
+
if (s.description) inner.append(ctx.el("p", { class: "scen-d" }, s.description));
|
|
230
|
+
if (s.notes && s.notes.length) {
|
|
231
|
+
inner.append(ctx.el("div", { class: "section-label" }, "Using this preset"));
|
|
232
|
+
inner.append(ctx.noteBlock(s.notes));
|
|
233
|
+
}
|
|
234
|
+
card.append(inner);
|
|
235
|
+
const foot = ctx.el("div", { class: "scen-f" },
|
|
236
|
+
ctx.el("span", {}, s.ports && s.ports.length
|
|
237
|
+
? (s.ports.length > 1 ? "Prefers ports " : "Prefers port ") + s.ports.join(", ")
|
|
238
|
+
+ (s.ports.length > 1 ? ", or the next free ones" : ", or the next free one")
|
|
239
|
+
: "No extra ports"));
|
|
240
|
+
if (ctx.canWrite()) {
|
|
241
|
+
foot.append(ctx.el("button", { class: "btn small", onclick: () => ctx.openCreate(s.name) },
|
|
242
|
+
"Create a workspace with this"));
|
|
243
|
+
}
|
|
244
|
+
card.append(foot);
|
|
245
|
+
body.append(card);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
// One grouped note, as a card. Three kinds of content and each gets the treatment
|
|
251
|
+
// it needs rather than all three arriving as bullets:
|
|
252
|
+
//
|
|
253
|
+
// rows facts. A key/value table -- "Cluster: kind-x" was three facts welded
|
|
254
|
+
// into a sentence, and a sentence is the wrong shape for a lookup.
|
|
255
|
+
// body what a reader needs to KNOW. Still read through the notes pattern's
|
|
256
|
+
// three shapes, so a place line is still a link row and an indented
|
|
257
|
+
// line is still a copyable box.
|
|
258
|
+
// commands what a reader has to PASTE. Its own block with a Copy button, never
|
|
259
|
+
// prose -- these were buried mid-paragraph.
|
|
260
|
+
function noteGroupCard(g, items, shown) {
|
|
261
|
+
const rows = g.rows || [], cmds = g.commands || [];
|
|
262
|
+
// A place this workspace's link table ALREADY lists is not a second place: the
|
|
263
|
+
// monitoring notes name Grafana and Prometheus, and both are link rows, so without
|
|
264
|
+
// this the same two urls appear once as rows and again as prose one card below.
|
|
265
|
+
const body = (items || []).filter((i) => !(shown && shown.has(i)));
|
|
266
|
+
if (!rows.length && !body.length && !cmds.length) return null;
|
|
267
|
+
const card = ctx.el("div", { class: "panelcard" });
|
|
268
|
+
if (g.title) {
|
|
269
|
+
card.append(ctx.el("div", { class: "panelcard-h" },
|
|
270
|
+
ctx.el("span", { class: "section-label flat" }, g.title)));
|
|
271
|
+
}
|
|
272
|
+
if (rows.length) {
|
|
273
|
+
const t = ctx.el("table", { class: "notetable" });
|
|
274
|
+
for (const [k, v] of rows) {
|
|
275
|
+
t.append(ctx.el("tr", {}, ctx.el("th", {}, k), ctx.el("td", {}, String(v))));
|
|
276
|
+
}
|
|
277
|
+
card.append(t);
|
|
278
|
+
}
|
|
279
|
+
if (body.length || cmds.length) {
|
|
280
|
+
const box = ctx.el("div", { class: "panelcard-b notes" });
|
|
281
|
+
// The body went through the SAME parser the ungrouped notes use, so the three
|
|
282
|
+
// shapes hold inside a group and nothing about that pattern is re-decided here.
|
|
283
|
+
if (body.length) ctx.renderNoteItems(box, body);
|
|
284
|
+
for (const c of cmds) {
|
|
285
|
+
box.append(ctx.el("div", { class: "note-cmd" },
|
|
286
|
+
ctx.el("code", {}, c),
|
|
287
|
+
ctx.el("button", { class: "cp", onclick: () => ctx.copy(c) }, "Copy")));
|
|
288
|
+
}
|
|
289
|
+
card.append(box);
|
|
290
|
+
}
|
|
291
|
+
return card;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Every note this workspace has, parsed once, group by group. Parsed HERE rather
|
|
295
|
+
// than inside each card because the link rows are enriched from these: a note naming
|
|
296
|
+
// a place the links already list is the rest of what is known about that one row, not
|
|
297
|
+
// a second row -- and the notes it can come from are no longer all in one group.
|
|
298
|
+
function noteItemsByGroup(d) {
|
|
299
|
+
const groups = d.note_groups || [];
|
|
300
|
+
// A workspace whose record has no groups keeps its whole story in the scenario
|
|
301
|
+
// card, exactly as before groups existed.
|
|
302
|
+
if (!groups.length) {
|
|
303
|
+
return [{ g: { kind: "scenario" }, items: ctx.parseNotes(d.notes || []) }];
|
|
304
|
+
}
|
|
305
|
+
return groups.map((g) => ({ g, items: ctx.parseNotes(g.body || []) }));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
// The Scenario card: what this workspace adds beyond a plain Rocket.Chat, where
|
|
311
|
+
// those things are, and what you have to do to use them — in one block instead of
|
|
312
|
+
// a "Where things are" list and a "Using this scenario" list that never referred
|
|
313
|
+
// to each other.
|
|
314
|
+
function scenarioCard(d, parsed, shown) {
|
|
315
|
+
const card = ctx.el("div", { class: "panelcard" });
|
|
316
|
+
// Title it by what is actually IN it. A plain workspace with monitoring
|
|
317
|
+
// attached has links and notes but no scenario, and calling that block
|
|
318
|
+
// "Scenario · default" described the preset field rather than the contents.
|
|
319
|
+
const scenario = d.preset && d.preset !== "default" ? d.preset : "";
|
|
320
|
+
const head = ctx.el("div", { class: "panelcard-h" },
|
|
321
|
+
ctx.el("span", { class: "section-label flat" },
|
|
322
|
+
scenario
|
|
323
|
+
? "Preset · " + (Array.isArray(d.presets) && d.presets.length > 1 ? d.presets.join(" + ") : scenario)
|
|
324
|
+
: "What is in this workspace"));
|
|
325
|
+
if (scenario) {
|
|
326
|
+
head.append(ctx.el("button", { class: "linkbtn", onclick: openScenarios },
|
|
327
|
+
"About this preset ↗"));
|
|
328
|
+
}
|
|
329
|
+
card.append(head);
|
|
330
|
+
|
|
331
|
+
// A command that is NOT a url is something you must set up before the scenario
|
|
332
|
+
// works at all -- `oidc` is broken until 127.0.0.1 keycloak is in /etc/hosts.
|
|
333
|
+
// A command that IS a url is just a place to go, and colouring that as a warning
|
|
334
|
+
// would be crying wolf.
|
|
335
|
+
//
|
|
336
|
+
// But "not a url" was not narrow enough either, and this block makes two specific
|
|
337
|
+
// CLAIMS -- that the scenario cannot work until the line exists, and that it needs
|
|
338
|
+
// sudo. `ldap`'s notes indent a phpLDAPadmin credential, so the panel was telling
|
|
339
|
+
// an ldap reader to sudo their way through "log in with DN cn=admin,dc=example,
|
|
340
|
+
// dc=com / admin" before the scenario would work, which is not true of anything.
|
|
341
|
+
// The discriminator is the sentence that INTRODUCES the line, and it is already in
|
|
342
|
+
// the note above it: a hosts entry is the only setup step any preset has.
|
|
343
|
+
// Grouped or not, this card's prose is the SCENARIO's prose. Ungrouped that is
|
|
344
|
+
// the whole flat list; grouped it is the one group marked as the scenario, and the
|
|
345
|
+
// rest are cards of their own below. Reading d.notes in the grouped case would put
|
|
346
|
+
// every Kubernetes fact through here a second time.
|
|
347
|
+
const own = parsed.find((x) => x.g.kind === "scenario");
|
|
348
|
+
const items = own ? own.items : [];
|
|
349
|
+
// Presets that wrote a guide (every one of this workspace's, or none): the card reads
|
|
350
|
+
// the guide, with its own setup box, instead of their prose.
|
|
351
|
+
const guides = own ? (own.g.guides || []) : [];
|
|
352
|
+
const introduced = (item) => {
|
|
353
|
+
const before = items[items.indexOf(item) - 1];
|
|
354
|
+
const text = before && before.kind === "prose" ? (before.lines || []).join(" ") : "";
|
|
355
|
+
return /\/etc\/hosts/i.test(text);
|
|
356
|
+
};
|
|
357
|
+
const setup = guides.length ? null : items.find((i) => i.kind === "cmd"
|
|
358
|
+
&& !/^https?:\/\//.test(i.value)
|
|
359
|
+
&& introduced(i));
|
|
360
|
+
if (setup) {
|
|
361
|
+
card.append(ctx.el("div", { class: "setup" },
|
|
362
|
+
ctx.el("span", { class: "setup-i" }, "▲"),
|
|
363
|
+
ctx.el("span", { class: "setup-t" },
|
|
364
|
+
ctx.el("b", {}, "For a browser on this server: do this once"),
|
|
365
|
+
ctx.el("span", { class: "setup-w" },
|
|
366
|
+
"This preset cannot work until the line below exists. Needs sudo."),
|
|
367
|
+
ctx.el("code", {}, setup.value)),
|
|
368
|
+
ctx.el("button", { class: "cp", onclick: () => ctx.copy(setup.value) }, "Copy")));
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// A note that names a place the link table ALREADY lists is not a second place,
|
|
372
|
+
// it is the rest of what is known about that one. Monitoring is the plain case:
|
|
373
|
+
// the links say where Grafana is, and the notes say the same thing again plus
|
|
374
|
+
// the password — which is how the same three urls came to be on screen twice,
|
|
375
|
+
// once as rows and once as prose.
|
|
376
|
+
const key = (u) => String(u || "").replace(/\/+$/, "");
|
|
377
|
+
const byUrl = new Map();
|
|
378
|
+
// Across EVERY group, not just this card's own prose. Monitoring's Grafana line
|
|
379
|
+
// lives in the Monitoring group now, and it is still the same row as the Grafana
|
|
380
|
+
// link -- password included, which is the part the link row does not know.
|
|
381
|
+
for (const { items: its } of parsed) {
|
|
382
|
+
for (const it of its) if (it.kind === "place") byUrl.set(key(it.url), it);
|
|
383
|
+
}
|
|
384
|
+
for (const l of d.links || []) {
|
|
385
|
+
const note = byUrl.get(key(l.url));
|
|
386
|
+
if (note) shown.add(note);
|
|
387
|
+
card.append(ctx.placeRow({ label: l.label, url: l.url, kind: l.kind,
|
|
388
|
+
what: note ? note.what : "", creds: note ? note.creds : "",
|
|
389
|
+
sub: note ? note.sub : "" }));
|
|
390
|
+
}
|
|
391
|
+
// Read from another computer, a localhost link opens there, where nothing runs.
|
|
392
|
+
if ([d.open_url || d.root_url, d.grafana_url, ...(d.links || []).map((l) => l.url),
|
|
393
|
+
...items.filter((i) => i.kind === "place").map((i) => i.url)].some(ctx.remoteLoopback)) {
|
|
394
|
+
card.append(ctx.el("div", { class: "panelcard-b" }, ctx.el("p", { class: "hint", id: "links-loopback" },
|
|
395
|
+
"Links to localhost open on YOUR computer; only a browser on this server can open them. "
|
|
396
|
+
+ "A workspace created with HTTPS gets public links (Mailpit at /mailpit/, and so on).")));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (guides.length) {
|
|
400
|
+
// Every place the notes name stays a link row, as before; only the prose moves to the guide.
|
|
401
|
+
const places = items.filter((i) => i.kind === "place" && !shown.has(i));
|
|
402
|
+
if (places.length) card.append(ctx.renderNoteItems(ctx.el("div", { class: "panelcard-b notes" }), places));
|
|
403
|
+
card.append(guideBlock(d, guides));
|
|
404
|
+
return card;
|
|
405
|
+
}
|
|
406
|
+
const rest = items.filter((i) => i !== setup && !shown.has(i));
|
|
407
|
+
if (rest.length) {
|
|
408
|
+
card.append(ctx.renderNoteItems(ctx.el("div", { class: "panelcard-b notes" }), rest));
|
|
409
|
+
}
|
|
410
|
+
return card;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// ---- the guide: one preset at a time, in three parts ---------------------------------
|
|
414
|
+
// The notes were one list of paragraphs across every preset of a combined workspace, a
|
|
415
|
+
// wall nobody read (owner, 2026-10-19). Each preset now says who to sign in as, what to
|
|
416
|
+
// try and what to know; a tab strip picks the preset, one pane shows it. The pane keeps
|
|
417
|
+
// the tallest guide's height so the card never jumps, and the next guide fades in.
|
|
418
|
+
function guideText(d, text) {
|
|
419
|
+
return String(text).split("<name>").join(d.name || "<name>")
|
|
420
|
+
.split("<workspace-url>").join(d.open_url || d.root_url || "<workspace-url>")
|
|
421
|
+
.split("<repro-url>").join(d.open_url || d.root_url || "<repro-url>"); // an older server's
|
|
422
|
+
}
|
|
423
|
+
function guidePane(d, g) {
|
|
424
|
+
const wrap = ctx.el("div", { class: "guide" });
|
|
425
|
+
wrap.append(ctx.el("p", { class: "guide-one" }, guideText(d, g.summary)));
|
|
426
|
+
if (g.setup) {
|
|
427
|
+
wrap.append(ctx.el("div", { class: "setup" },
|
|
428
|
+
ctx.el("span", { class: "setup-i" }, "▲"),
|
|
429
|
+
ctx.el("span", { class: "setup-t" },
|
|
430
|
+
ctx.el("b", {}, "For a browser on this server: do this once"),
|
|
431
|
+
ctx.el("span", { class: "setup-w" }, g.setup.why),
|
|
432
|
+
ctx.el("code", {}, g.setup.line)),
|
|
433
|
+
ctx.el("button", { class: "cp", onclick: () => ctx.copy(g.setup.line) }, "Copy")));
|
|
434
|
+
}
|
|
435
|
+
const parts = [];
|
|
436
|
+
if ((g.signIn || []).length) {
|
|
437
|
+
const t = ctx.el("table", { class: "notetable" });
|
|
438
|
+
for (const [user, password, where] of g.signIn) {
|
|
439
|
+
t.append(ctx.el("tr", {}, ctx.el("th", {}, user), ctx.el("td", { class: "pw" }, guideText(d, password)),
|
|
440
|
+
ctx.el("td", { class: "w" }, guideText(d, where))));
|
|
441
|
+
}
|
|
442
|
+
parts.push(ctx.el("div", { class: "guide-part" }, ctx.el("span", { class: "section-label flat" }, "Sign in as"), t));
|
|
443
|
+
}
|
|
444
|
+
if ((g.steps || []).length) {
|
|
445
|
+
parts.push(ctx.el("div", { class: "guide-part" }, ctx.el("span", { class: "section-label flat" }, "Try it"),
|
|
446
|
+
ctx.el("ol", {}, ...g.steps.map((s) => ctx.el("li", {}, ctx.linkify(guideText(d, s)))))));
|
|
447
|
+
}
|
|
448
|
+
wrap.append(ctx.el("div", { class: "guide-cols" + (parts.length === 1 ? " one" : "") }, ...parts));
|
|
449
|
+
if ((g.know || []).length) {
|
|
450
|
+
wrap.append(ctx.el("div", { class: "guide-part guide-know" }, ctx.el("span", { class: "section-label flat" }, "Good to know"),
|
|
451
|
+
ctx.el("ul", {}, ...g.know.map((s) => ctx.el("li", {}, ctx.linkify(guideText(d, s)))))));
|
|
452
|
+
}
|
|
453
|
+
return wrap;
|
|
454
|
+
}
|
|
455
|
+
function guideBlock(d, guides) {
|
|
456
|
+
const names = guides.map((g) => g.name);
|
|
457
|
+
if (!names.includes(ctx.dstate.guideTab)) ctx.dstate.guideTab = names[0];
|
|
458
|
+
const block = ctx.el("div", { class: "guide-block" },
|
|
459
|
+
ctx.el("div", { class: "guide-h" }, ctx.el("span", { class: "section-label flat" }, "Using this preset")));
|
|
460
|
+
const pane = ctx.el("div", { class: "guide-pane", role: "tabpanel" });
|
|
461
|
+
const show = (name, animate) => {
|
|
462
|
+
ctx.dstate.guideTab = name;
|
|
463
|
+
for (const b of block.querySelectorAll(".guide-tabs button")) {
|
|
464
|
+
const on = b.dataset.tab === name;
|
|
465
|
+
b.setAttribute("aria-selected", String(on)); b.tabIndex = on ? 0 : -1;
|
|
466
|
+
}
|
|
467
|
+
const next = guidePane(d, guides.find((g) => g.name === name) || guides[0]);
|
|
468
|
+
if (animate) next.classList.add("entering");
|
|
469
|
+
pane.replaceChildren(next);
|
|
470
|
+
if (animate) requestAnimationFrame(() => next.classList.remove("entering"));
|
|
471
|
+
};
|
|
472
|
+
if (names.length > 1) {
|
|
473
|
+
const strip = ctx.el("div", { class: "guide-tabs", role: "tablist", "aria-label": "Presets" },
|
|
474
|
+
...names.map((n) => ctx.el("button", { type: "button", role: "tab", "data-tab": n,
|
|
475
|
+
"aria-selected": String(n === ctx.dstate.guideTab), tabIndex: n === ctx.dstate.guideTab ? 0 : -1,
|
|
476
|
+
onclick: () => show(n, true) }, n)));
|
|
477
|
+
strip.addEventListener("keydown", (e) => {
|
|
478
|
+
const i = names.indexOf(ctx.dstate.guideTab);
|
|
479
|
+
const to = e.key === "ArrowRight" ? i + 1 : e.key === "ArrowLeft" ? i - 1
|
|
480
|
+
: e.key === "Home" ? 0 : e.key === "End" ? names.length - 1 : -1;
|
|
481
|
+
if (to < 0 || to >= names.length) return;
|
|
482
|
+
e.preventDefault(); show(names[to], true);
|
|
483
|
+
const b = strip.querySelector(`button[data-tab="${names[to]}"]`);
|
|
484
|
+
if (b) b.focus();
|
|
485
|
+
});
|
|
486
|
+
block.append(strip);
|
|
487
|
+
}
|
|
488
|
+
block.append(pane);
|
|
489
|
+
show(ctx.dstate.guideTab, false);
|
|
490
|
+
// The tallest guide sets the pane's height once the card is on screen, measured off-screen
|
|
491
|
+
// at the card's width, so switching presets never moves what is below the card.
|
|
492
|
+
if (names.length > 1) {
|
|
493
|
+
requestAnimationFrame(() => {
|
|
494
|
+
const width = pane.getBoundingClientRect().width;
|
|
495
|
+
if (!width) return;
|
|
496
|
+
const probe = ctx.el("div", { class: "guide-pane", style: `position:absolute;visibility:hidden;left:-9999px;width:${width}px` });
|
|
497
|
+
document.body.append(probe);
|
|
498
|
+
let tallest = 0;
|
|
499
|
+
for (const g of guides) { probe.replaceChildren(guidePane(d, g)); tallest = Math.max(tallest, probe.getBoundingClientRect().height); }
|
|
500
|
+
probe.remove();
|
|
501
|
+
pane.style.minHeight = `${Math.ceil(tallest)}px`;
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
return block;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// ---- detail panel -----------------------------------------------------------
|
|
508
|
+
// WHAT THE LIST ALREADY KNOWS, drawn at once. The full panel waits for the workspace's own
|
|
509
|
+
// read -- on a cluster several round trips -- and until then this showed only "Loading…",
|
|
510
|
+
// for as long as a minute on a slow EKS cluster.
|
|
511
|
+
function detailShell(r) {
|
|
512
|
+
const open = r.open_url || r.root_url;
|
|
513
|
+
const kube = (r.runtime || "docker") === "kubernetes";
|
|
514
|
+
return [
|
|
515
|
+
ctx.el("div", { class: "d-head" },
|
|
516
|
+
ctx.el("span", { class: "dot " + ctx.stateClass(r.state || "?") }, "●"),
|
|
517
|
+
ctx.el("span", { class: "name" }, r.name),
|
|
518
|
+
ctx.el("span", { class: "pill " + ctx.stateClass(r.state || "?") }, r.state || "?"),
|
|
519
|
+
ctx.el("button", { class: "close", onclick: ctx.closeDetail }, "×")),
|
|
520
|
+
ctx.el("div", { class: "d-sub" }, ctx.el("b", {}, r.rc_version || "?"), ctx.el("i", {}, "/"),
|
|
521
|
+
`mongo ${r.mongo_tag || "?"}`, ctx.el("i", {}, "·"), whereOf(r)),
|
|
522
|
+
open && r.state !== "?" ? ctx.el("div", { class: "d-actions" },
|
|
523
|
+
ctx.el("a", { href: open, target: "_blank", rel: "noreferrer", style: "text-decoration:none",
|
|
524
|
+
...(ctx.remoteLoopback(open) ? { title: ctx.LOOPBACK_TITLE } : {}) },
|
|
525
|
+
ctx.el("button", { class: "btn primary" }, "↗ Open RC"))) : "",
|
|
526
|
+
ctx.el("div", { class: "placeholder", id: "detail-reading" },
|
|
527
|
+
kube ? `Reading ${r.name} from its cluster…` : `Loading ${r.name}…`),
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
async function selectRepro(name, tab = "overview") {
|
|
531
|
+
ctx.SELECTED = name; ctx.dstate.tab = tab; ctx.dstate.points = []; ctx.dstate.statsRefused = ""; ctx.dstate.guideTab = "";
|
|
532
|
+
ctx.setView("workspace");
|
|
533
|
+
// Tear the PREVIOUS repro's panel down first. Leaving it up meant that while the
|
|
534
|
+
// fetch was in flight -- and permanently if it failed -- the list highlighted B
|
|
535
|
+
// while the panel still showed A, with A's destructive Down button wired to A.
|
|
536
|
+
ctx.closeLogs();
|
|
537
|
+
if (ctx.dstate.statsTimer) { clearInterval(ctx.dstate.statsTimer); ctx.dstate.statsTimer = null; }
|
|
538
|
+
ctx.dstate.detail = null;
|
|
539
|
+
ctx.render();
|
|
540
|
+
const panel = ctx.$("#detail");
|
|
541
|
+
panel.innerHTML = "";
|
|
542
|
+
const found = (ctx.ALL_REPROS || []).find((r) => r.name === name);
|
|
543
|
+
const row = found && ctx.displayRepro(found);
|
|
544
|
+
panel.append(...(row ? detailShell(row) : [ctx.el("div", { class: "placeholder" }, `Loading ${name}…`)]));
|
|
545
|
+
let detail;
|
|
546
|
+
try { detail = await ctx.api(`/api/repros/${name}/detail`); }
|
|
547
|
+
catch (e) {
|
|
548
|
+
if (ctx.SELECTED !== name || ctx.VIEW !== "workspace") return;
|
|
549
|
+
ctx.toast(e.message);
|
|
550
|
+
panel.innerHTML = "";
|
|
551
|
+
panel.append(ctx.el("div", { class: "placeholder" }, `Could not load ${name}.`));
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (ctx.SELECTED !== name || ctx.VIEW !== "workspace") return; // a newer view won the race
|
|
555
|
+
ctx.dstate.detail = detail;
|
|
556
|
+
ctx.renderDetail();
|
|
557
|
+
}
|
|
558
|
+
function closeDetail() {
|
|
559
|
+
ctx.setView("home");
|
|
560
|
+
ctx.SELECTED = null; ctx.dstate.detail = null;
|
|
561
|
+
if (ctx.dstate.statsTimer) { clearInterval(ctx.dstate.statsTimer); ctx.dstate.statsTimer = null; }
|
|
562
|
+
ctx.closeLogs();
|
|
563
|
+
ctx.render();
|
|
564
|
+
}
|
|
565
|
+
function switchTab(t) { ctx.dstate.tab = t; ctx.saveLocation(); ctx.renderDetail(); }
|
|
566
|
+
|
|
567
|
+
Object.defineProperties(ctx, {
|
|
568
|
+
"HOME": { enumerable: true, get: () => HOME, set: value => { HOME = value; } },
|
|
569
|
+
"HOME_EVERY": { enumerable: true, get: () => HOME_EVERY },
|
|
570
|
+
"refreshHome": { enumerable: true, get: () => refreshHome },
|
|
571
|
+
"runningRow": { enumerable: true, get: () => runningRow },
|
|
572
|
+
"capacityCard": { enumerable: true, get: () => capacityCard },
|
|
573
|
+
"attentionItems": { enumerable: true, get: () => attentionItems },
|
|
574
|
+
"renderHome": { enumerable: true, get: () => renderHome },
|
|
575
|
+
"openScenarios": { enumerable: true, get: () => openScenarios },
|
|
576
|
+
"noteGroupCard": { enumerable: true, get: () => noteGroupCard },
|
|
577
|
+
"noteItemsByGroup": { enumerable: true, get: () => noteItemsByGroup },
|
|
578
|
+
"scenarioCard": { enumerable: true, get: () => scenarioCard },
|
|
579
|
+
"selectRepro": { enumerable: true, get: () => selectRepro },
|
|
580
|
+
"closeDetail": { enumerable: true, get: () => closeDetail },
|
|
581
|
+
"switchTab": { enumerable: true, get: () => switchTab },
|
|
582
|
+
});
|
|
583
|
+
export { HOME, HOME_EVERY, refreshHome, runningRow, capacityCard, attentionItems, renderHome, openScenarios, noteGroupCard, noteItemsByGroup, scenarioCard, selectRepro, closeDetail, switchTab };
|