pisha-server 0.0.0-stage → 0.0.12
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 +21 -0
- package/README.md +40 -2
- package/accounts/accounts.js +754 -0
- package/accounts/index.js +1 -0
- package/accounts/passwords.js +41 -0
- package/accounts/totp.js +54 -0
- package/boards/boards.js +1087 -0
- package/boards/github.js +212 -0
- package/boards/index.js +1 -0
- package/boards/sync.js +980 -0
- package/companies.js +294 -0
- package/company-export.js +101 -0
- package/company.js +82 -0
- package/dashboard/dashboard.js +408 -0
- package/dashboard/index.js +1 -0
- package/data-upgrade.js +69 -0
- package/install/linux.sh +181 -0
- package/install/macos.sh +121 -0
- package/install/windows.bat +54 -0
- package/machines/index.js +3 -0
- package/machines/machines.js +910 -0
- package/messaging/inbox.js +252 -0
- package/messaging/index.js +3 -0
- package/messaging/messaging.js +551 -0
- package/messaging/plans.js +67 -0
- package/observation/index.js +1 -0
- package/observation/observation.js +231 -0
- package/organization/index.js +1 -0
- package/organization/organization.js +218 -0
- package/package.json +55 -4
- package/permissions/index.js +1 -0
- package/permissions/permissions.js +211 -0
- package/pisha-host.mjs +3303 -0
- package/pisha-host.mjs.sig +1 -0
- package/platform/acme.js +207 -0
- package/platform/basics.js +14 -0
- package/platform/config.js +154 -0
- package/platform/control.js +93 -0
- package/platform/credentials.js +151 -0
- package/platform/database.js +251 -0
- package/platform/errors.js +13 -0
- package/platform/files.js +50 -0
- package/platform/http.js +207 -0
- package/platform/index.js +58 -0
- package/platform/limits.js +122 -0
- package/platform/listen.js +183 -0
- package/platform/roles.js +6 -0
- package/platform/stream.js +19 -0
- package/platform/text.js +83 -0
- package/platform/ws.js +186 -0
- package/routes.js +405 -0
- package/server.js +65 -0
- package/sessions/index.js +1 -0
- package/sessions/sessions.js +533 -0
- package/ui/LICENSE-affectui.txt +26 -0
- package/ui/addmachine.js +151 -0
- package/ui/api.js +20 -0
- package/ui/app.js +143 -0
- package/ui/attention.js +78 -0
- package/ui/back.js +168 -0
- package/ui/boards.js +958 -0
- package/ui/chat.js +388 -0
- package/ui/content.js +157 -0
- package/ui/dialogs.js +135 -0
- package/ui/doing.js +112 -0
- package/ui/dom.js +6 -0
- package/ui/ds-base.css +146 -0
- package/ui/ds-components.css +229 -0
- package/ui/fonts/LICENSE-space-grotesk.txt +93 -0
- package/ui/fonts/space-grotesk-latin-700-normal.woff2 +0 -0
- package/ui/fonts/space-grotesk-latin-ext-700-normal.woff2 +0 -0
- package/ui/format.js +25 -0
- package/ui/i18n.js +2145 -0
- package/ui/icons/apple-touch-icon.png +0 -0
- package/ui/icons/icon-192.png +0 -0
- package/ui/icons/icon-512.png +0 -0
- package/ui/icons/maskable-512.png +0 -0
- package/ui/icons.js +41 -0
- package/ui/inbox.js +535 -0
- package/ui/index.html +105 -0
- package/ui/machines.js +261 -0
- package/ui/manifest.webmanifest +16 -0
- package/ui/mosaic.js +189 -0
- package/ui/nav.js +142 -0
- package/ui/newteam.js +223 -0
- package/ui/org.js +669 -0
- package/ui/overlays.css +126 -0
- package/ui/palette.js +180 -0
- package/ui/people.js +371 -0
- package/ui/permissions.js +202 -0
- package/ui/qr.js +158 -0
- package/ui/router.js +173 -0
- package/ui/routes.js +47 -0
- package/ui/screen-boards.css +241 -0
- package/ui/screen-inbox.css +201 -0
- package/ui/screen-machines.css +76 -0
- package/ui/screen-mosaic.css +26 -0
- package/ui/screen-newteam.css +90 -0
- package/ui/screen-org.css +119 -0
- package/ui/screen-session.css +99 -0
- package/ui/screen-signin.css +28 -0
- package/ui/screen-team.css +80 -0
- package/ui/screen-teams.css +41 -0
- package/ui/screen-usage.css +60 -0
- package/ui/session.js +42 -0
- package/ui/shell.css +122 -0
- package/ui/signin.js +120 -0
- package/ui/squads.js +371 -0
- package/ui/state.js +59 -0
- package/ui/stream.js +269 -0
- package/ui/styles.css +343 -0
- package/ui/team.js +115 -0
- package/ui/teams.js +58 -0
- package/ui/terminal.js +261 -0
- package/ui/theme.js +32 -0
- package/ui/timeline.js +163 -0
- package/ui/topbar.js +211 -0
- package/ui/usage.js +175 -0
- package/ui/voice-parse.js +98 -0
- package/ui/voice.js +320 -0
- package/usage/index.js +1 -0
- package/usage/usage.js +127 -0
- package/vendor/InterVariable.woff2 +0 -0
- package/vendor/LICENSE-inter +92 -0
- package/vendor/LICENSE-xterm +21 -0
- package/vendor/README.md +8 -0
- package/vendor/addon-fit.js +2 -0
- package/vendor/xterm.css +218 -0
- package/vendor/xterm.js +2 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* Signing in, and making the first owner: one card in the middle. */
|
|
2
|
+
|
|
3
|
+
#login, #splash { background: var(--bg); }
|
|
4
|
+
.login-card { width: min(420px, 100%); padding: 32px; border: 0; border-radius: var(--r-xl); background: var(--panel); box-shadow: var(--shadow-dialog); }
|
|
5
|
+
.login-card .brand { gap: 10px; margin-bottom: 8px; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.015em; }
|
|
6
|
+
.login-card .brand .logo { width: 30px; height: 30px; }
|
|
7
|
+
.login-card .brand .wordmark { font-size: 26px; }
|
|
8
|
+
.login-card > p { margin: 4px 0 20px; color: var(--muted); line-height: 1.55; }
|
|
9
|
+
.login-card .field { margin-bottom: 12px; }
|
|
10
|
+
.login-card .field input { height: 38px; font-family: var(--sans); }
|
|
11
|
+
.login-card .field input[name=token], .login-card .field input[name=code], .login-card .field input[name=recovery] { font-family: var(--mono); letter-spacing: .02em; }
|
|
12
|
+
/* (The main action: as .btn.primary, a dark gradient with a light edge.) */
|
|
13
|
+
.login-card button[type=submit] {
|
|
14
|
+
width: 100%; height: 40px; margin-top: 8px; border: 1px solid transparent; border-radius: var(--r-md); font-weight: 500; letter-spacing: -.01em; color: var(--on-ink);
|
|
15
|
+
background: linear-gradient(var(--fill-top), var(--fill-bottom)) padding-box, linear-gradient(var(--fill-edge-top), var(--fill-edge-bottom)) border-box;
|
|
16
|
+
box-shadow: 0 0 0 1px var(--fill-ring), 0 2px 4px rgba(0, 0, 0, .1); transition: transform var(--t-fast) var(--ease);
|
|
17
|
+
}
|
|
18
|
+
.login-card button[type=submit]:hover { background: linear-gradient(var(--fill-hover-top), var(--fill-hover-bottom)) padding-box, linear-gradient(var(--fill-edge-top), var(--fill-edge-bottom)) border-box; }
|
|
19
|
+
.login-card button[type=submit]:active { transform: scale(.98); }
|
|
20
|
+
.login-card .linkish { width: auto; height: auto; margin: 2px 0 0; padding: 0; border: 0; background: none; color: var(--text); font-weight: 400; font-size: var(--fs-sm); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
|
|
21
|
+
.login-err { min-height: 1.4em; margin-top: 10px; color: var(--err); font-size: var(--fs-sm); }
|
|
22
|
+
.login-card .foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); font-size: var(--fs-xs); }
|
|
23
|
+
.login-card .theme-btn, .theme-btn { display: inline-grid; place-items: center; width: 26px; height: 22px; padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: none; color: var(--muted); }
|
|
24
|
+
.login-card .theme-btn .ic, .theme-btn .ic { width: 13px; height: 13px; }
|
|
25
|
+
.login-card .theme-btn:hover, .theme-btn:hover { background: var(--raised); color: var(--text); }
|
|
26
|
+
.lang { border-color: var(--line-2); border-radius: var(--r-sm); }
|
|
27
|
+
.login-card .lang button, .lang button { height: 22px; }
|
|
28
|
+
.login-card .lang button.on, .lang button.on { background: var(--raised); color: var(--text); font-weight: 600; }
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* One team: what it is for and what it reported, beside who is in it. */
|
|
2
|
+
|
|
3
|
+
#team { flex: 1; min-height: 0; overflow-y: auto; }
|
|
4
|
+
.tq { display: flex; flex-wrap: wrap; align-items: flex-start; min-height: 100%; }
|
|
5
|
+
.tq-main { flex: 3 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 20px; }
|
|
6
|
+
.tq-aside { flex: 1 1 260px; min-width: 0; align-self: stretch; display: flex; flex-direction: column; gap: 18px; padding: 20px; border-left: 1px solid var(--line); }
|
|
7
|
+
|
|
8
|
+
.tq-card { overflow: hidden; }
|
|
9
|
+
.tq-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; min-height: 46px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
|
|
10
|
+
.tq-h h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
|
|
11
|
+
.tq-sub { font-size: var(--fs-sm); color: var(--muted); }
|
|
12
|
+
.tq-body { padding: 14px 16px; }
|
|
13
|
+
.tq-goal { margin: 0; font-size: var(--fs-lg); line-height: 1.5; text-wrap: pretty; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
14
|
+
.tq-quiet { margin: 0; padding: 14px 16px; color: var(--muted); }
|
|
15
|
+
.tq-body .tq-quiet { padding: 0; }
|
|
16
|
+
|
|
17
|
+
.tq-reports { list-style: none; margin: 0; padding: 4px 0; }
|
|
18
|
+
.tq-reports li + li { border-top: 1px solid var(--line); }
|
|
19
|
+
.tq-report { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; min-height: 44px; padding: 9px 16px; color: inherit; text-decoration: none; }
|
|
20
|
+
.tq-report:hover { background: var(--raised); }
|
|
21
|
+
.tq-report .tag.ok { color: var(--ok); border-color: currentColor; }
|
|
22
|
+
.tq-report .tag.err { color: var(--err); border-color: currentColor; }
|
|
23
|
+
.tq-report .tag.warn { color: var(--warn); border-color: currentColor; }
|
|
24
|
+
.tq-name { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
|
|
25
|
+
.tq-text { flex: 1 1 200px; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
26
|
+
.tq-when { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
|
|
27
|
+
|
|
28
|
+
.tq-label { margin: 0 0 8px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
|
|
29
|
+
.tq-aside section + section { padding-top: 16px; border-top: 1px solid var(--line); }
|
|
30
|
+
.tq-members { list-style: none; margin: 0; padding: 0; }
|
|
31
|
+
.tq-member { display: flex; align-items: center; gap: 8px; min-height: 34px; margin: 0 -8px; padding: 4px 8px; border-radius: var(--r); color: inherit; text-decoration: none; }
|
|
32
|
+
.tq-member:hover { background: var(--raised); }
|
|
33
|
+
.tq-member.offline .tq-name { opacity: .62; }
|
|
34
|
+
.tq-where { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
|
|
35
|
+
.tq-small { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--muted); }
|
|
36
|
+
.tq-act.quiet { padding-left: 0; }
|
|
37
|
+
|
|
38
|
+
#team .empty { min-height: 60vh; justify-content: center; }
|
|
39
|
+
|
|
40
|
+
@media (max-width: 900px) {
|
|
41
|
+
.tq-main, .tq-aside { padding: 12px; }
|
|
42
|
+
.tq-aside { border-left: 0; border-top: 1px solid var(--line); }
|
|
43
|
+
.tq-member, .tq-report { min-height: 48px; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* The plan: how far it is, then each task. */
|
|
47
|
+
.pl-sum { display: flex; flex-direction: column; gap: 10px; }
|
|
48
|
+
.pl-meter { display: flex; gap: 2px; height: 6px; border-radius: var(--r-pill); overflow: hidden; background: var(--raised); }
|
|
49
|
+
.pl-meter.big { height: 8px; }
|
|
50
|
+
.pl-meter i, .pl-key { display: block; }
|
|
51
|
+
.pl-done { background: var(--ok); } .pl-doing { background: var(--info); } .pl-blocked { background: var(--err); } .pl-waiting { background: var(--warn); }
|
|
52
|
+
.pl-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-sm); color: var(--muted); }
|
|
53
|
+
.pl-legend span { display: inline-flex; align-items: center; gap: 6px; }
|
|
54
|
+
.pl-key { width: 8px; height: 8px; border-radius: 2px; }
|
|
55
|
+
.pl-table { width: 100%; min-width: 560px; border-collapse: collapse; border-top: 1px solid var(--line); }
|
|
56
|
+
.pl-table th { padding: 8px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
|
|
57
|
+
.pl-table td { padding: 9px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
58
|
+
.pl-table tr:last-child td { border-bottom: 0; }
|
|
59
|
+
.pl-t { display: block; }
|
|
60
|
+
.pl-row-done .pl-t { color: var(--muted); }
|
|
61
|
+
.pl-note { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); }
|
|
62
|
+
.pl-who { display: inline-flex; align-items: center; gap: 5px; color: var(--text); text-decoration: none; font-family: var(--mono); font-size: 12.5px; }
|
|
63
|
+
.pl-who .role { width: 12px; height: 12px; }
|
|
64
|
+
.tq-quiet0 { color: var(--muted); font-size: var(--fs-sm); }
|
|
65
|
+
.pl-foot { padding: 10px 16px 12px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
|
|
66
|
+
|
|
67
|
+
/* A phone: each task on its own lines (what, then state, who and reference),
|
|
68
|
+
and the team's live view, made for a wide screen, isn't offered. */
|
|
69
|
+
@media (max-width: 900px) {
|
|
70
|
+
.pl-table, .pl-table tbody { display: block; min-width: 0; }
|
|
71
|
+
.pl-table thead { display: none; }
|
|
72
|
+
.pl-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
|
|
73
|
+
.pl-table tr:last-child { border-bottom: 0; }
|
|
74
|
+
.pl-table td { padding: 0; border: 0; }
|
|
75
|
+
.pl-table td:first-child { flex: 1 0 100%; }
|
|
76
|
+
.pl-table td:last-child { margin-left: auto; }
|
|
77
|
+
.pl-table td:last-child:empty { display: none; }
|
|
78
|
+
.pl-table .mc-state { font-size: var(--fs-sm); }
|
|
79
|
+
.wide-only { display: none; }
|
|
80
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* Teams: one card per team, side by side as they fit. */
|
|
2
|
+
|
|
3
|
+
#teams { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
|
|
4
|
+
.tm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 16px; align-items: start; max-width: 1600px; }
|
|
5
|
+
|
|
6
|
+
.tm-card { display: flex; flex-direction: column; overflow: hidden; }
|
|
7
|
+
.tm-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
|
|
8
|
+
.tm-h h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; letter-spacing: -.005em; }
|
|
9
|
+
.tm-h h2 a { color: var(--text); text-decoration: none; }
|
|
10
|
+
.tm-h h2 a:hover { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
|
|
11
|
+
/* (The whole header leads to the team, not just its name.) */
|
|
12
|
+
.tm-h { position: relative; transition: background-color var(--t-fast) ease; }
|
|
13
|
+
.tm-h h2 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
|
|
14
|
+
.tm-h:has(h2 a):hover { background: var(--raised); }
|
|
15
|
+
.tm-h:has(h2 a):hover h2 a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
|
|
16
|
+
.tm-h h2 a:focus-visible { outline: none; }
|
|
17
|
+
.tm-h h2 a:focus-visible::after { outline: 2px solid var(--focus); outline-offset: -2px; }
|
|
18
|
+
.tm-sub { font-size: var(--fs-sm); color: var(--muted); }
|
|
19
|
+
|
|
20
|
+
.tm-people { list-style: none; margin: 0; padding: 4px 0; }
|
|
21
|
+
.tm-person { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; min-height: 40px; padding: 7px 16px; color: inherit; text-decoration: none; transition: background-color var(--t-fast) var(--ease); }
|
|
22
|
+
.tm-person:hover { background: var(--raised); }
|
|
23
|
+
.tm-person.sub { padding-left: 38px; }
|
|
24
|
+
.tm-person.offline .tm-who { opacity: .62; }
|
|
25
|
+
.tm-who { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
|
|
26
|
+
.tm-person:not(.sub) .tm-who { color: var(--text); }
|
|
27
|
+
.tm-what { flex: 1 1 160px; min-width: 0; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
28
|
+
.tm-person .persona-tag { font-size: var(--fs-xs); }
|
|
29
|
+
|
|
30
|
+
.tm-foot { padding: 11px 16px 13px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
|
|
31
|
+
.tm-goal { color: var(--text); }
|
|
32
|
+
.tm-none { color: var(--muted); }
|
|
33
|
+
|
|
34
|
+
#teams .empty { min-height: 60vh; justify-content: center; }
|
|
35
|
+
#teams .empty span { max-width: 380px; }
|
|
36
|
+
|
|
37
|
+
@media (max-width: 900px) {
|
|
38
|
+
#teams { padding: 12px; }
|
|
39
|
+
.tm-person { min-height: 48px; }
|
|
40
|
+
}
|
|
41
|
+
.tm-plan { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* Usage: what the agents spent, in tokens. The four kinds keep one colour
|
|
2
|
+
each everywhere on the screen (tiles, chart, bars). */
|
|
3
|
+
|
|
4
|
+
#usage { padding: 20px; }
|
|
5
|
+
.u-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 1400px; margin: 0 auto; }
|
|
6
|
+
[data-k="input"] { --k: var(--info); }
|
|
7
|
+
[data-k="cache_write"] { --k: var(--warn); }
|
|
8
|
+
[data-k="cache_read"] { --k: color-mix(in srgb, var(--info) 38%, var(--panel)); }
|
|
9
|
+
[data-k="output"] { --k: var(--coord); }
|
|
10
|
+
|
|
11
|
+
.u-filters { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
12
|
+
.u-filter select { height: 34px; padding: 0 30px 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); color: var(--text); font: inherit; font-size: var(--fs-md); }
|
|
13
|
+
|
|
14
|
+
.u-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
|
|
15
|
+
.u-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-card); }
|
|
16
|
+
.u-tl { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--fs-sm); }
|
|
17
|
+
.u-tl i { width: 9px; height: 9px; border-radius: 3px; background: var(--k); }
|
|
18
|
+
.u-tile b { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
|
|
19
|
+
.u-tn { color: var(--muted); font-size: var(--fs-xs); }
|
|
20
|
+
|
|
21
|
+
.u-card { padding: 14px 16px 16px; border-radius: 14px; }
|
|
22
|
+
.u-ch { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
|
|
23
|
+
.u-ch h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
|
|
24
|
+
.u-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: var(--fs-sm); }
|
|
25
|
+
.u-legend span { display: inline-flex; align-items: center; gap: 6px; }
|
|
26
|
+
.u-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--k); }
|
|
27
|
+
|
|
28
|
+
.u-chart { position: relative; padding: 18px 0 22px; }
|
|
29
|
+
.u-chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
|
|
30
|
+
.u-chart rect[data-k] { fill: var(--k); }
|
|
31
|
+
.u-chart .u-hit { fill: transparent; }
|
|
32
|
+
.u-chart .u-bar:hover rect[data-k] { opacity: .8; }
|
|
33
|
+
.u-max { position: absolute; top: 0; left: 0; color: var(--faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
|
|
34
|
+
.u-axis { position: relative; height: 16px; margin-top: 6px; color: var(--muted); font-size: var(--fs-xs); }
|
|
35
|
+
.u-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
|
|
36
|
+
|
|
37
|
+
.u-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
|
|
38
|
+
.u-card.wide { grid-column: 1 / -1; }
|
|
39
|
+
.u-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
|
|
40
|
+
.u-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
|
|
41
|
+
.u-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
42
|
+
.u-name .agent { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; flex: none; }
|
|
43
|
+
.u-nt { display: flex; flex-direction: column; min-width: 0; }
|
|
44
|
+
.u-nt b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
45
|
+
.u-nt b a, .u-nt b .linkish { color: var(--text); text-decoration: none; font: inherit; }
|
|
46
|
+
.u-nt b .linkish { padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
|
|
47
|
+
.u-nt b a:hover, .u-nt b .linkish:hover { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
|
|
48
|
+
.u-nt span { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
49
|
+
.u-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
|
|
50
|
+
.u-val small { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
|
|
51
|
+
.u-stack { grid-column: 1 / -1; display: flex; height: 6px; border-radius: 4px; background: var(--tray); overflow: hidden; }
|
|
52
|
+
.u-stack i { display: block; height: 100%; background: var(--k); }
|
|
53
|
+
.u-empty { padding: 60px 20px; }
|
|
54
|
+
|
|
55
|
+
@media (max-width: 900px) {
|
|
56
|
+
#usage { padding: 14px; }
|
|
57
|
+
.u-tiles { grid-template-columns: repeat(2, 1fr); }
|
|
58
|
+
.u-tiles > :first-child { grid-column: 1 / -1; }
|
|
59
|
+
.u-chart svg { height: 160px; }
|
|
60
|
+
}
|
package/ui/session.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { $ } from './dom.js'
|
|
2
|
+
import { T, LOCALE } from './i18n.js'
|
|
3
|
+
import { state, sessions, hosts } from './state.js'
|
|
4
|
+
import { esc, kfmt } from './format.js'
|
|
5
|
+
import { sortedSessions, status, agentMark } from './content.js'
|
|
6
|
+
import { setHtml } from './nav.js'
|
|
7
|
+
import { currentRoute } from './router.js'
|
|
8
|
+
import { permissionsSection } from './permissions.js'
|
|
9
|
+
|
|
10
|
+
// Beside a session's conversation: its team, and where and how it runs.
|
|
11
|
+
|
|
12
|
+
const when = t => new Date(t).toLocaleString(LOCALE, { dateStyle: 'medium', timeStyle: 'short' })
|
|
13
|
+
|
|
14
|
+
function member(s, here) {
|
|
15
|
+
const st = status(s)
|
|
16
|
+
const role = s.role === 'coordinator' ? 'coord' : 'worker'
|
|
17
|
+
return `<li><a href="#/s/${encodeURIComponent(s.name)}" class="sv-member${s.name === here ? ' on' : ''}${s.online ? '' : ' offline'}"${s.name === here ? ' aria-current="page"' : ''}><span class="role ${role}" aria-hidden="true"></span>${agentMark(s)}<span class="sr-only">${esc(T.roleName[s.role] ?? '')}</span><span class="sv-mname">${esc(s.name)}</span><span class="dot ${st.dot || 'off'}" aria-hidden="true"></span><span class="sv-mwhat">${esc(st.text)}</span></a></li>`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function renderSessionAside() {
|
|
21
|
+
const box = $('session').querySelector('.sv-info')
|
|
22
|
+
const r = currentRoute()
|
|
23
|
+
if (!box || r.view !== 'session') return
|
|
24
|
+
const s = sessions.get(r.name)
|
|
25
|
+
if (!s) { setHtml(box, ''); return }
|
|
26
|
+
const a = s.activity ?? {}
|
|
27
|
+
const team = s.role === 'coordinator' ? s.name : s.coordinator
|
|
28
|
+
const members = team ? sortedSessions().filter(x => x.name === team || x.coordinator === team) : []
|
|
29
|
+
const h = hosts.get(s.host_id)
|
|
30
|
+
const facts = [
|
|
31
|
+
[T.svMachine, h ? `<a class="ibx-link" href="#/h/${encodeURIComponent(h.id)}">${esc(h.name)}</a>` : ''],
|
|
32
|
+
[T.svFolder, a.cwd ? `<span class="sv-mono">${esc(a.cwd)}</span>` : ''],
|
|
33
|
+
[T.svContext, a.context_tokens ? esc(T.context(kfmt(a.context_tokens)) + (a.context_pct != null ? ` (${T.contextPct(a.context_pct)})` : '')) : ''],
|
|
34
|
+
[T.svPersona, s.persona?.name ? esc(s.persona.name) : ''],
|
|
35
|
+
[T.svOpened, s.created_at ? esc(when(s.created_at * 1000)) : ''],
|
|
36
|
+
].filter(f => f[1])
|
|
37
|
+
setHtml(box, `${members.length ? `<section><h2 class="tq-label">${esc(T.svTeam)}</h2><ul class="sv-members">${members.map(m => member(m, s.name)).join('')}</ul><a class="ibx-link sv-small" href="#/q/${encodeURIComponent(team)}">${esc(T.svSeeTeam)}</a></section>` : ''}
|
|
38
|
+
${facts.length ? `<section><h2 class="tq-label">${esc(T.svDetails)}</h2><dl class="ibx-facts sv-facts">${facts.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${v}</dd>`).join('')}</dl></section>` : ''}
|
|
39
|
+
${s.role !== 'solo' && s.opened_role !== 'solo' ? permissionsSection({ session: s.name }) : ''}
|
|
40
|
+
${a.observe === 'off' ? `<p class="sv-small sv-quiet">${esc(T.svNotObserved)}</p>` : ''}`)
|
|
41
|
+
}
|
|
42
|
+
export const refreshSessionAside = () => { if (currentRoute().view === 'session' && !$('session').hidden) renderSessionAside() }
|
package/ui/shell.css
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* The shell: the sidebar on the left, and on the right a header over the view. */
|
|
2
|
+
|
|
3
|
+
#app { height: 100%; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); background: var(--bg); }
|
|
4
|
+
#main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
|
|
5
|
+
|
|
6
|
+
/* --- sidebar --------------------------------------------------------------- */
|
|
7
|
+
.rail { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
|
|
8
|
+
.rail-top { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px 10px; }
|
|
9
|
+
.rail-brand { display: flex; align-items: center; gap: 9px; padding: 0 4px; font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
|
|
10
|
+
.rail-brand .logo { width: 22px; height: 22px; flex: none; }
|
|
11
|
+
/* The logotype: the face and «pisha», as the brand writes it. */
|
|
12
|
+
.wordmark { font-family: var(--brand-font); font-weight: 700; color: var(--brand-ink); letter-spacing: -.02em; line-height: 1; }
|
|
13
|
+
.rail-brand .wordmark { font-size: 19px; }
|
|
14
|
+
|
|
15
|
+
/* The company: a native select, drawn as a quiet button. */
|
|
16
|
+
.rail-co { position: relative; display: flex; }
|
|
17
|
+
.rail-co select {
|
|
18
|
+
appearance: none; width: 100%; min-height: 32px; padding: 5px 30px 5px 10px;
|
|
19
|
+
border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--text);
|
|
20
|
+
font-weight: 500; text-overflow: ellipsis; cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
.rail-co select:hover { background: var(--raised); }
|
|
23
|
+
.rail-co .ic { position: absolute; right: 9px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%) rotate(90deg); pointer-events: none; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 2; }
|
|
24
|
+
.rail-co-name { padding: 0 4px; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
25
|
+
|
|
26
|
+
.rail-search {
|
|
27
|
+
display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 6px 4px 9px;
|
|
28
|
+
border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--muted); text-align: left;
|
|
29
|
+
transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
|
|
30
|
+
}
|
|
31
|
+
.rail-search:hover { border-color: var(--line-2); color: var(--text); }
|
|
32
|
+
.rail-search span { flex: 1; }
|
|
33
|
+
|
|
34
|
+
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 12px; display: flex; flex-direction: column; gap: 14px; }
|
|
35
|
+
.rail-group { display: flex; flex-direction: column; gap: 1px; }
|
|
36
|
+
|
|
37
|
+
.rail-item {
|
|
38
|
+
position: relative; display: flex; align-items: center; gap: 9px; min-height: 30px; padding: 4px 8px;
|
|
39
|
+
border-radius: var(--r); color: var(--muted); text-decoration: none; min-width: 0;
|
|
40
|
+
transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
|
|
41
|
+
}
|
|
42
|
+
.rail-item:hover { background: var(--raised); color: var(--text); }
|
|
43
|
+
.rail-item.on { background: var(--raised); color: var(--text); font-weight: 500; }
|
|
44
|
+
.rail-item .ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
|
|
45
|
+
.rail-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
46
|
+
.rail-item .badge, .rail-item .rail-count { margin-left: auto; }
|
|
47
|
+
.rail-count { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
48
|
+
/* A row with a link and its own small action (add a machine, a team). */
|
|
49
|
+
.rail-row { display: flex; align-items: center; gap: 2px; }
|
|
50
|
+
.rail-row > .rail-item { flex: 1; }
|
|
51
|
+
.rail-row > .icon-btn, .rail-label .icon-btn { width: 24px; height: 24px; }
|
|
52
|
+
.rail-row > .icon-btn .ic, .rail-label .icon-btn .ic { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
|
|
53
|
+
|
|
54
|
+
.rail-label { display: flex; align-items: center; justify-content: space-between; min-height: 24px; padding: 0 2px 2px 8px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
|
|
55
|
+
|
|
56
|
+
/* A team: its name, its coordinator, and its workers under a line. */
|
|
57
|
+
.rail-team { display: flex; flex-direction: column; gap: 1px; }
|
|
58
|
+
.rail-team + .rail-team { margin-top: 6px; }
|
|
59
|
+
.rail-team-h { display: flex; align-items: center; gap: 2px; min-height: 26px; }
|
|
60
|
+
.rail-fold { display: grid; place-items: center; flex: none; width: 20px; height: 24px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); }
|
|
61
|
+
.rail-fold:hover { color: var(--text); background: var(--raised); }
|
|
62
|
+
.rail-fold .ic { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--t) var(--ease); }
|
|
63
|
+
.rail-team.open .rail-fold .ic { transform: rotate(90deg); }
|
|
64
|
+
.rail-team-name { flex: 1; min-width: 0; padding: 3px 6px; border-radius: var(--r); color: var(--text); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
65
|
+
.rail-team-name:hover, .rail-team-name.on { background: var(--raised); }
|
|
66
|
+
.rail-team-h .badge { margin-right: 6px; }
|
|
67
|
+
.rail-team-body { display: flex; flex-direction: column; gap: 1px; padding-left: 14px; }
|
|
68
|
+
.rail-team:not(.open) .rail-team-body { display: none; }
|
|
69
|
+
.rail-workers { display: flex; flex-direction: column; gap: 1px; margin-left: 15px; padding-left: 4px; border-left: 1px solid var(--line); }
|
|
70
|
+
.rail-sess { min-height: 28px; }
|
|
71
|
+
.rail-sess .name { font-family: var(--mono); font-size: 12.5px; }
|
|
72
|
+
.rail-sess.coord .name { color: var(--text); }
|
|
73
|
+
.rail-sess .dot { margin-left: 2px; }
|
|
74
|
+
.rail-sess.offline .name { opacity: .62; }
|
|
75
|
+
.rail-empty { padding: 3px 8px 4px 23px; font-size: var(--fs-sm); color: var(--muted); }
|
|
76
|
+
.rail-item.quiet { font-size: var(--fs-sm); }
|
|
77
|
+
|
|
78
|
+
.rail-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
|
|
79
|
+
.rail-conn { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
80
|
+
.rail-settings { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 4px 9px; border: 0; border-radius: var(--r); background: none; color: var(--muted); font-weight: 500; }
|
|
81
|
+
.rail-settings:hover { background: var(--raised); color: var(--text); }
|
|
82
|
+
.rail-settings .ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
|
|
83
|
+
|
|
84
|
+
/* --- header ---------------------------------------------------------------- */
|
|
85
|
+
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: var(--head-h); padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
|
|
86
|
+
.head h1 { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; }
|
|
87
|
+
.head-sub { min-width: 0; flex-shrink: 10; color: var(--muted); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
88
|
+
.head-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-sm); }
|
|
89
|
+
/* Back, where the user came from: named on a wide screen, an arrow on a phone. */
|
|
90
|
+
.head-back { display: inline-flex; align-items: center; gap: 2px; min-width: 0; max-width: 220px; height: 32px; margin-left: -8px; padding: 0 10px 0 4px; border: 0; border-radius: var(--r-md); background: none; color: var(--muted); font: inherit; font-size: var(--fs-md); cursor: pointer; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
|
|
91
|
+
.head-back[hidden] { display: none; }
|
|
92
|
+
.head-back:hover { background: var(--panel-2); color: var(--text); }
|
|
93
|
+
.head-back .ic { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
94
|
+
.head-back-to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
95
|
+
.head-conn { display: none; }
|
|
96
|
+
|
|
97
|
+
/* --- narrow screens: no sidebar, the bar at the bottom instead ------------- */
|
|
98
|
+
@media (min-width: 901px) {
|
|
99
|
+
.head-back.narrow-only { display: none; }
|
|
100
|
+
}
|
|
101
|
+
@media (max-width: 900px) {
|
|
102
|
+
#app { grid-template-columns: minmax(0, 1fr); }
|
|
103
|
+
.rail { display: none; }
|
|
104
|
+
.head { padding: 8px 12px; }
|
|
105
|
+
.head-back { width: 40px; height: 40px; margin: 0 -8px 0 -10px; padding: 0; justify-content: center; color: var(--text); }
|
|
106
|
+
.head-back .ic { width: 22px; height: 22px; }
|
|
107
|
+
.head-back-to { display: none; }
|
|
108
|
+
.head-conn:not([hidden]) { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
|
|
109
|
+
}
|
|
110
|
+
.head-tabs:empty { display: none; }
|
|
111
|
+
.rail-search .ic { width: 14px; height: 14px; stroke-width: 2; }
|
|
112
|
+
|
|
113
|
+
/* A phone: the places at the bottom. */
|
|
114
|
+
.tabbar { display: none; }
|
|
115
|
+
@media (max-width: 900px) {
|
|
116
|
+
#main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
|
|
117
|
+
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 40; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid var(--line); }
|
|
118
|
+
.tabbar > * { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 4px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: var(--fs-xs); text-decoration: none; }
|
|
119
|
+
.tabbar > .on { color: var(--text); font-weight: 600; background: none; }
|
|
120
|
+
.tabbar .ic { width: 20px; height: 20px; }
|
|
121
|
+
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 6px); }
|
|
122
|
+
}
|
package/ui/signin.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { $, store } from './dom.js'
|
|
2
|
+
import { T } from './i18n.js'
|
|
3
|
+
import { state } from './state.js'
|
|
4
|
+
import { call } from './api.js'
|
|
5
|
+
import { esc } from './format.js'
|
|
6
|
+
import { qrSvg } from './qr.js'
|
|
7
|
+
|
|
8
|
+
// The screens before the dashboard: the first owner, signing in, codes, and the
|
|
9
|
+
// links of an invitation or a new password. Each is a form; what comes next
|
|
10
|
+
// depends on what the server answers.
|
|
11
|
+
let onSubmit = null
|
|
12
|
+
let enter = () => {}
|
|
13
|
+
|
|
14
|
+
function screen(intro, fields, button, submit) {
|
|
15
|
+
$('loginIntro').innerHTML = intro
|
|
16
|
+
$('loginFields').innerHTML = fields
|
|
17
|
+
$('loginBtn').textContent = button
|
|
18
|
+
$('loginBtn').hidden = !submit
|
|
19
|
+
$('loginErr').textContent = ''
|
|
20
|
+
onSubmit = submit
|
|
21
|
+
$('loginFields').querySelector('input')?.focus()
|
|
22
|
+
}
|
|
23
|
+
const input = (name, label, type = 'text', autocomplete = 'off', extra = '') => `<label class="field"><span>${esc(label)}</span><input name="${name}" type="${type}" autocomplete="${autocomplete}" required ${extra}></label>`
|
|
24
|
+
const values = () => Object.fromEntries(new FormData($('loginForm')))
|
|
25
|
+
|
|
26
|
+
$('loginForm').addEventListener('submit', async e => {
|
|
27
|
+
e.preventDefault()
|
|
28
|
+
if (!onSubmit) return
|
|
29
|
+
$('loginBtn').disabled = true
|
|
30
|
+
$('loginErr').textContent = ''
|
|
31
|
+
try { await onSubmit(values()) } catch (err) {
|
|
32
|
+
$('loginErr').textContent = err.status === 429 ? T.tooManyTries : err.message.replace(/^(Unauthorized|Bad Request|Not Found|Conflict|Forbidden): /, '')
|
|
33
|
+
} finally {
|
|
34
|
+
$('loginBtn').disabled = false
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Whatever stage the server says this sign-in is at.
|
|
39
|
+
function next(me) {
|
|
40
|
+
if (me.stage === 'totp') return codeScreen()
|
|
41
|
+
if (me.stage === 'totp_setup') return setupScreen()
|
|
42
|
+
return enter(me)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function ownerScreen() {
|
|
46
|
+
screen(T.ownerIntro, input('token', T.tokenPlaceholder, 'password') + input('name', T.yourName, 'text', 'name') + input('email', T.email, 'email', 'username') + input('password', T.newPassword, 'password', 'new-password', 'minlength="12"'), T.createOwner, async v => {
|
|
47
|
+
const { token, ...fields } = v
|
|
48
|
+
next(await call('/bootstrap', fields, { Authorization: `Bearer ${token.trim()}` }))
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function loginScreen(err = '') {
|
|
53
|
+
screen(T.loginIntro, input('email', T.email, 'email', 'username') + input('password', T.password, 'password', 'current-password'), T.enter, async v => next(await call('/auth/login', v)))
|
|
54
|
+
$('loginErr').textContent = err
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function codeScreen(recovery = false) {
|
|
58
|
+
screen(recovery ? T.recoveryIntro : T.codeIntro,
|
|
59
|
+
(recovery ? input('recovery', T.recoveryCode) : input('code', T.code, 'text', 'one-time-code', 'inputmode="numeric" maxlength="6"')) +
|
|
60
|
+
`<button type="button" class="linkish" id="codeSwitch">${esc(recovery ? T.useCode : T.useRecovery)}</button>`,
|
|
61
|
+
T.enter, async v => next(await call('/auth/totp', v)))
|
|
62
|
+
$('codeSwitch').onclick = () => codeScreen(!recovery)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function setupScreen() {
|
|
66
|
+
const { secret, uri } = await call('/auth/totp/setup', {})
|
|
67
|
+
// (Made here: the key goes to no service. The page's only images are its own.)
|
|
68
|
+
screen(T.setupIntro, `${qrSvg(uri, T.setupQr) ?? ''}<p class="note">${esc(T.setupKey)}</p><p class="secret"><code>${esc(secret)}</code></p><p class="note"><a href="${esc(uri)}">${esc(T.setupLink)}</a></p>${input('code', T.code, 'text', 'one-time-code', 'inputmode="numeric" maxlength="6"')}`, T.setupConfirm, async v => {
|
|
69
|
+
const done = await call('/auth/totp/enable', v)
|
|
70
|
+
screen(T.recoveryShow, `<pre class="codes">${esc(done.recovery_codes.join('\n'))}</pre>`, T.recoverySaved, async () => next(done))
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function inviteScreen(token) {
|
|
75
|
+
const info = await call('/auth/invite/info', { token })
|
|
76
|
+
const where = info.company ? T.inviteTo(esc(info.company), esc(T.roles[info.role] ?? info.role)) : T.inviteServer
|
|
77
|
+
const fields = info.known
|
|
78
|
+
? input('password', T.password, 'password', 'current-password')
|
|
79
|
+
: input('name', T.yourName, 'text', 'name') + input('password', T.newPassword, 'password', 'new-password', 'minlength="12"')
|
|
80
|
+
screen(`${where} <b>${esc(info.email)}</b>`, fields, T.acceptInvite, async v => {
|
|
81
|
+
const me = await call('/auth/invite/accept', { ...v, token })
|
|
82
|
+
history.replaceState(null, '', location.pathname + location.search)
|
|
83
|
+
next(me)
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function resetScreen(token) {
|
|
88
|
+
screen(T.resetIntro, input('password', T.newPassword, 'password', 'new-password', 'minlength="12"'), T.setPassword, async v => {
|
|
89
|
+
await call('/auth/reset', { ...v, token })
|
|
90
|
+
history.replaceState(null, '', location.pathname + location.search)
|
|
91
|
+
loginScreen(T.passwordSet)
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// What to show on opening the page. (Tokens of a link go in the part of the
|
|
96
|
+
// address the browser doesn't send anywhere.)
|
|
97
|
+
export async function begin(onEnter) {
|
|
98
|
+
enter = onEnter
|
|
99
|
+
const link = location.hash.match(/^#\/(invite|reset)\/([A-Za-z0-9_-]+)$/)
|
|
100
|
+
if (link) {
|
|
101
|
+
try { return await (link[1] === 'invite' ? inviteScreen(link[2]) : resetScreen(link[2])) } catch (err) {
|
|
102
|
+
history.replaceState(null, '', location.pathname + location.search)
|
|
103
|
+
loginScreen(err.status === 404 ? T.linkGone : T.cannotConnect(err.message))
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
next(await call('/api/me'))
|
|
109
|
+
} catch (err) {
|
|
110
|
+
if (err.status !== 401) throw err
|
|
111
|
+
const { needs_owner } = await call('/auth/status')
|
|
112
|
+
if (needs_owner) ownerScreen(); else loginScreen()
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const signOut = () => call('/auth/logout', {}).catch(() => {})
|
|
117
|
+
export const noCompany = () => {
|
|
118
|
+
state.me = null
|
|
119
|
+
screen(T.noCompany, '', T.logout, async () => { await signOut(); loginScreen() })
|
|
120
|
+
}
|