carlos / platform Public

console: Metrics, Economics and Architecture in the operator shell

Metrics, Economics, Economics' Accounts and Architecture render with
opPage in the operator shell: the page header with its rail label and
subhead, banners as callouts, tiles as rst-stats, tables in cards (low-value
columns hidden at 800px and below), chips as status pills. Both economics
pages carry Overview/Accounts tabs keeping the period; the accounts page's
search and position links are one list bar. The inline scripts stay, with
the utilization meter, the zero-selection note and the free-tier pill
updated without style writes. Reads are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9cce49337cb112502235effb81b7a420ae1ad586 parent 486b4fa
18 files changed, +831 −358
  • approved_operator_pages_copy_test.go +5 −0
  • internal/console/archpage.go +2 −2
  • internal/console/archpage_test.go +16 −16
  • internal/console/claim_invariant_probes_read_test.go +3 −3
  • internal/console/economicspage_test.go +25 −25
  • internal/console/opeconomics.go +95 −0
  • internal/console/opeconomics_test.go +226 −0
  • internal/console/opparts.go +9 −6
  • internal/console/opshell_test.go +11 −7
  • internal/console/opshots_test.go +36 −0
  • internal/console/server.go +26 −10
  • internal/console/server_test.go +1 −1
  • internal/console/static/ops.css +86 −0
  • internal/console/templates/architecture.html +42 −43
  • internal/console/templates/economics.html +138 −133
  • internal/console/templates/economics_accounts.html +64 −66
  • internal/console/templates/metrics.html +37 −44
  • internal/console/templates/opparts.html +9 −2

CI failed — run details

diff --git a/approved_operator_pages_copy_test.go b/approved_operator_pages_copy_test.go
index f4eaaf7ce..aa8555ba5 100644
--- a/approved_operator_pages_copy_test.go
+++ b/approved_operator_pages_copy_test.go
@@ -79,6 +79,11 @@ var operatorPagesCopyBuilt = []string{
// Newest and Older are built in opactivity.go (feedView's data).
"OPS-119", "OPS-120@opactivity.go", "OPS-121", "OPS-122", "OPS-123", "OPS-124", "OPS-125",
"OPS-126", "OPS-127", "OPS-128@opactivity.go", "OPS-129@opactivity.go", "OPS-130", "OPS-148",
+ // Task 12: Metrics, Economics and Architecture in the shell. The
+ // economics tabs and the accounts filter's accessible name are built
+ // in opeconomics.go (econTabs, econListBar).
+ "OPS-139", "OPS-140", "OPS-141@opeconomics.go", "OPS-142@opeconomics.go",
+ "OPS-143@opeconomics.go", "OPS-144@opeconomics.go", "OPS-145",
}
// operatorPagesBuiltRows is entryBuiltRows for operatorPagesCopyBuilt.
diff --git a/internal/console/archpage.go b/internal/console/archpage.go
index eeab80750..6701e2656 100644
--- a/internal/console/archpage.go
+++ b/internal/console/archpage.go
@@ -99,8 +99,8 @@ func (s *Server) handleArchitecture(w http.ResponseWriter, r *http.Request) {
// template ranges over the bands and each draws itself (ArchBand.SVG).
// The SVG is still built in Go, which is what keeps it deterministic
// and testable as a whole.
- p := page{Title: "Architecture", Address: addr, CSRF: raw,
- Arch: &v, ArchBoxesUnread: boxesUnread}
+ p := s.opPage(addr, raw, "architecture")
+ p.Arch, p.ArchBoxesUnread = &v, boxesUnread
p.Flash, p.FlashErr = s.takeFlash(w, r)
s.render(w, http.StatusOK, "architecture", p)
}
diff --git a/internal/console/archpage_test.go b/internal/console/archpage_test.go
index 54b27ac56..60d06a25b 100644
--- a/internal/console/archpage_test.go
+++ b/internal/console/archpage_test.go
@@ -256,7 +256,7 @@ func TestArchitectureDrawsBothEstates(t *testing.T) {
// estate. That is what makes the page scroll down instead of across, so
// a page that had quietly gone back to one picture per estate would draw
// the same content and be the bug this shape exists to fix.
- bands := strings.Count(body, `<h4 class="archband">`)
+ bands := strings.Count(body, `<h4 co-band>`)
if bands < 2 {
t.Fatalf("page draws %d bands — a page back to one picture per estate is the bug this shape exists to fix:\n%s", bands, body)
}
@@ -422,21 +422,21 @@ func TestArchitectureBoxCardShowsEstateAndDrift(t *testing.T) {
t.Fatalf("= %d, want 200", st)
}
for _, want := range []string{
- "ada-stargazing", // the card is there at all
- "eu-west-1", // region
- "t4g.medium", // discovered instance type
- "running", // discovered state
- "2 cores", // rate-card cores (spec §7: cores/memory)
- "4 GB", // rate-card memory
- "40 GB disk", // discovered disk
- "/mo", // rate-card price
- "<code>kass</code>", // the app, joined through the registry
- "static 2", // fleet counts
- "resident 1", //
- "<code>v9.9.9-test</code>", // the release the box reports
- "chip chip-stale", // drift wears the fact-to-watch chip
- "rate card says 30 GB of EB", // and says what disagrees
- "the estate has 40 GB", //
+ "ada-stargazing", // the card is there at all
+ "eu-west-1", // region
+ "t4g.medium", // discovered instance type
+ "running", // discovered state
+ "2 cores", // rate-card cores (spec §7: cores/memory)
+ "4 GB", // rate-card memory
+ "40 GB disk", // discovered disk
+ "/mo", // rate-card price
+ "<code>kass</code>", // the app, joined through the registry
+ "static 2", // fleet counts
+ "resident 1", //
+ "<code>v9.9.9-test</code>", // the release the box reports
+ `<span rst-status rst-tone="warning">`, // drift wears the fact-to-watch pill
+ "rate card says 30 GB of EB", // and says what disagrees
+ "the estate has 40 GB", //
} {
if !strings.Contains(body, want) {
t.Errorf("box card is missing %q in:\n%s", want, body)
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go
index 9b272356a..908135758 100644
--- a/internal/console/claim_invariant_probes_read_test.go
+++ b/internal/console/claim_invariant_probes_read_test.go
@@ -171,10 +171,10 @@ var claimReadProbes = map[string]claimProbe{
"route GET /fleet": claimPageRead(nil, "/fleet", "<h1>Dashboard</h1>"),
"route GET /fleet/activity": claimPageRead(nil, "/fleet/activity", "<h1>Activity</h1>"),
"route GET /fleet/boxes": claimPageRead(nil, "/fleet/boxes", "<h1>Boxes</h1>"),
- "route GET /fleet/economics": claimPageRead(nil, "/fleet/economics", "<h1>Fleet economics</h1>"),
- "route GET /fleet/economics/accounts": claimPageRead(nil, "/fleet/economics/accounts", "<h1>Fleet economics: accounts</h1>"),
+ "route GET /fleet/economics": claimPageRead(nil, "/fleet/economics", "<h1>Economics</h1>"),
+ "route GET /fleet/economics/accounts": claimPageRead(nil, "/fleet/economics/accounts", "<h1>Economics</h1>"),
"route GET /fleet/index": claimPageRead(nil, "/fleet/index", "rst-shell-console=\"index\""),
- "route GET /fleet/metrics": claimPageRead(nil, "/fleet/metrics", "<h1>Fleet metrics</h1>"),
+ "route GET /fleet/metrics": claimPageRead(nil, "/fleet/metrics", "<h1>Metrics</h1>"),
"route GET /fleet/people": claimPageRead(nil, "/fleet/people", "<h1>People and accounts</h1>"),
"route GET /fleet/store": claimPageRead(claimWorldApply, "/fleet/store", "<h1>Storage requests</h1>"),
"route GET /healthz": claimPageRead(nil, "/healthz", "ok"),
diff --git a/internal/console/economicspage_test.go b/internal/console/economicspage_test.go
index 520990836..44350b3a7 100644
--- a/internal/console/economicspage_test.go
+++ b/internal/console/economicspage_test.go
@@ -147,7 +147,7 @@ func TestEconomicsPageMTDShowsProjection(t *testing.T) {
// are exactly the one account's own numbers: revenue 200, cost 100,
// profit 100 — easy to hand-check economics.Project's daysInMonth/10
// scale-up against.
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
@@ -178,7 +178,7 @@ func TestEconomicsPageMTDShowsProjection(t *testing.T) {
PeriodDays: 7,
Accounts: []economics.AccountEconomics{{Account: fixtureAcct, CostUSD: 100, RevenueUSD: 200}},
}
- p7d := page{Title: "Fleet economics", CSRF: "tok", Economics: view7d}
+ p7d := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view7d}
var buf7d bytes.Buffer
if err := templates.ExecuteTemplate(&buf7d, "economics", p7d); err != nil {
t.Fatalf("render economics (7d): %v", err)
@@ -392,8 +392,8 @@ func TestEconomicsAccountsPageContent(t *testing.T) {
}
for _, want := range []string{
fixtureAcct,
- ">2.00<", // the egress-GB meter cell (2e9 bytes seeded)
- `class="chip chip-freetier-partial"`, // the free-tier chip, this fixture's position
+ ">2.00<", // the egress-GB meter cell (2e9 bytes seeded)
+ `<span rst-status rst-tone="neutral">partial</span>`, // the free-tier pill, this fixture's position
`id="econ-data"`,
} {
if !strings.Contains(body, want) {
@@ -423,8 +423,8 @@ func TestEconomicsAccountsPageRendersPooledChip(t *testing.T) {
t.Fatalf("/fleet/economics/accounts = %d, want 200:\n%s", status, body)
}
for _, want := range []string{
- `class="chip chip-freetier-pooled"`, // the row's own free-tier chip
- ">pooled 1<", // the header filter chip, count 1
+ `<span rst-status rst-tone="neutral">pooled</span>`, // the row's own free-tier pill
+ ">pooled 1<", // the header filter chip, count 1
} {
if !strings.Contains(body, want) {
t.Fatalf("/fleet/economics/accounts missing %q in:\n%s", want, body)
@@ -551,7 +551,7 @@ func TestEconomicsAccountsPageShowsAccountName(t *testing.T) {
t.Fatalf("%s unterminated row for %q in:\n%s", path, fixtureAcct, body)
}
fixtureRow := body[fixtureRowStart : fixtureRowStart+fixtureRowEnd]
- if !strings.Contains(fixtureRow, "ops <span class=\"small\">"+fixtureAcct+"</span>") {
+ if !strings.Contains(fixtureRow, "ops <span co-note>"+fixtureAcct+"</span>") {
t.Fatalf("%s: known-name row missing NAME %q as primary text with the sqid muted+small beside it:\n%s", path, "ops", fixtureRow)
}
@@ -567,7 +567,7 @@ func TestEconomicsAccountsPageShowsAccountName(t *testing.T) {
if !strings.Contains(ghostRow, ">"+ghostAcct+"<") {
t.Fatalf("%s: ghost row missing the bare sqid %q:\n%s", path, ghostAcct, ghostRow)
}
- if strings.Contains(ghostRow, `<span class="small">`) {
+ if strings.Contains(ghostRow, `<span co-note>`) {
t.Fatalf("%s: ghost row (no console name) must not render a muted-sqid span:\n%s", path, ghostRow)
}
}
@@ -586,7 +586,7 @@ func TestEconomicsPagePoolTile(t *testing.T) {
Period: "mtd",
Pool: PoolLedger{PoolUSD: 123.45, DrawUSD: 50, HeadroomUSD: 73.45, PayingRevenueUSD: 1000},
}
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
@@ -618,7 +618,7 @@ func TestEconomicsPagePoolTileNegativeHeadroomWarns(t *testing.T) {
Period: "mtd",
Pool: PoolLedger{PoolUSD: 10, DrawUSD: 50, HeadroomUSD: -40},
}
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
@@ -633,7 +633,7 @@ func TestEconomicsPagePoolTileNegativeHeadroomWarns(t *testing.T) {
// Positive headroom: no warning class at all.
viewOK := &EconomicsView{Period: "mtd", Pool: PoolLedger{PoolUSD: 50, DrawUSD: 10, HeadroomUSD: 40}}
- pOK := page{Title: "Fleet economics", CSRF: "tok", Economics: viewOK}
+ pOK := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: viewOK}
var bufOK bytes.Buffer
if err := templates.ExecuteTemplate(&bufOK, "economics", pOK); err != nil {
t.Fatalf("render economics (positive headroom): %v", err)
@@ -653,27 +653,27 @@ func TestEconomicsPagePooledMarginIsDash(t *testing.T) {
pooledRow := economics.AccountEconomics{Account: fixtureAcct, CostUSD: 5, RevenueUSD: 0, MarginFrac: 0, FreeTierPos: "pooled"}
view := &EconomicsView{Period: "mtd", Accounts: []economics.AccountEconomics{pooledRow}}
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
}
html := buf.String()
- if !strings.Contains(html, `class="js-acct-margin">—<`) {
+ if !strings.Contains(html, `class="js-acct-margin" co-m-hide>—<`) {
t.Fatalf("/fleet/economics: pooled row's margin cell must be an em-dash, not a percentage:\n%s", html)
}
- if strings.Contains(html, `class="js-acct-margin">0%<`) {
+ if strings.Contains(html, `class="js-acct-margin" co-m-hide>0%<`) {
t.Fatalf("/fleet/economics: pooled row's margin cell must not render \"0%%\":\n%s", html)
}
rows := pageEconAccounts([]econAccountRow{{Account: fixtureAcct, Meters: map[string]float64{}, Econ: pooledRow}}, econAccountQuery{}, econAccountPageSize)
- pAcct := page{Title: "Fleet economics: accounts", CSRF: "tok", Economics: view, EconAccounts: rows, EconQuery: econAccountQuery{}}
+ pAcct := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view, EconAccounts: rows, EconQuery: econAccountQuery{}}
var bufAcct bytes.Buffer
if err := templates.ExecuteTemplate(&bufAcct, "economics_accounts", pAcct); err != nil {
t.Fatalf("render economics_accounts: %v", err)
}
htmlAcct := bufAcct.String()
- if !strings.Contains(htmlAcct, `class="js-acct-margin">—<`) {
+ if !strings.Contains(htmlAcct, `class="js-acct-margin" co-m-hide>—<`) {
t.Fatalf("/fleet/economics/accounts: pooled row's margin cell must be an em-dash, not a percentage:\n%s", htmlAcct)
}
}
@@ -697,7 +697,7 @@ func TestEconomicsPageFleetMarginLegend(t *testing.T) {
row := economics.AccountEconomics{Account: fixtureAcct, CostUSD: 0, RevenueUSD: 10, MarginFrac: 1, FreeTierPos: "paying"}
view := &EconomicsView{Period: "mtd", Accounts: []economics.AccountEconomics{row}}
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
@@ -706,12 +706,12 @@ func TestEconomicsPageFleetMarginLegend(t *testing.T) {
if !strings.Contains(html, `title="Pooled rows`) {
t.Fatalf("/fleet/economics missing the Margin header's title= tooltip:\n%s", html)
}
- if !strings.Contains(html, `<p class="small">Margin: pooled rows show an em-dash`) {
+ if !strings.Contains(html, `<p co-note>Margin: pooled rows show an em-dash`) {
t.Fatalf("/fleet/economics missing the VISIBLE margin legend line (MINOR 3 — tooltips alone are invisible on touch/keyboard):\n%s", html)
}
rows := pageEconAccounts([]econAccountRow{{Account: fixtureAcct, Meters: map[string]float64{}, Econ: row}}, econAccountQuery{}, econAccountPageSize)
- pAcct := page{Title: "Fleet economics: accounts", CSRF: "tok", Economics: view, EconAccounts: rows, EconQuery: econAccountQuery{}}
+ pAcct := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view, EconAccounts: rows, EconQuery: econAccountQuery{}}
var bufAcct bytes.Buffer
if err := templates.ExecuteTemplate(&bufAcct, "economics_accounts", pAcct); err != nil {
t.Fatalf("render economics_accounts: %v", err)
@@ -720,7 +720,7 @@ func TestEconomicsPageFleetMarginLegend(t *testing.T) {
if !strings.Contains(htmlAcct, `title="Pooled rows`) {
t.Fatalf("/fleet/economics/accounts missing the Margin header's title= tooltip:\n%s", htmlAcct)
}
- if !strings.Contains(htmlAcct, `<p class="small">Margin: pooled rows show an em-dash`) {
+ if !strings.Contains(htmlAcct, `<p co-note>Margin: pooled rows show an em-dash`) {
t.Fatalf("/fleet/economics/accounts missing the VISIBLE margin legend line (MINOR 3):\n%s", htmlAcct)
}
}
@@ -741,7 +741,7 @@ func TestEconomicsKnobDrawerHasV2Knobs(t *testing.T) {
sc.Pool.TopupUSD = 250
view := &EconomicsView{Period: "mtd", Scenario: sc}
- p := page{Title: "Fleet economics", CSRF: "tok", Economics: view}
+ p := page{Title: "Economics", Op: &opShell{Rail: "economics", View: "page"}, CSRF: "tok", Economics: view}
var buf bytes.Buffer
if err := templates.ExecuteTemplate(&buf, "economics", p); err != nil {
t.Fatalf("render economics: %v", err)
@@ -852,10 +852,10 @@ func TestEconomicsAccountsPageTierChipAndForm(t *testing.T) {
t.Fatalf("/fleet/economics/accounts = %d, want 200:\n%s", status, body)
}
for _, want := range []string{
- `class="chip chip-tier-hosted"`,
+ `<span rst-status rst-tone="positive">hosted</span>`,
`action="/fleet/economics/tier"`,
fmt.Sprintf(`name="account" value="%s"`, fixtureAcct),
- `<select name="tier">`,
+ `<select rst-input name="tier">`,
`value="hosted" selected`,
} {
if !strings.Contains(body, want) {
@@ -915,7 +915,7 @@ func TestEconomicsAccountsPageTierFormOnlyForConsoleRows(t *testing.T) {
t.Fatalf("unterminated row for %q in:\n%s", ghostAcct, body)
}
ghostRow := body[rowStart : rowStart+rowEnd]
- if !strings.Contains(ghostRow, `class="chip chip-tier-unassigned"`) {
+ if !strings.Contains(ghostRow, `<span rst-status rst-tone="neutral">unassigned</span>`) {
t.Fatalf("usage-only account %q row missing the unassigned chip:\n%s", ghostAcct, ghostRow)
}
if strings.Contains(ghostRow, "<form") {
@@ -933,7 +933,7 @@ func TestEconomicsAccountsPageTierFormOnlyForConsoleRows(t *testing.T) {
t.Fatalf("unterminated row for %q in:\n%s", fixtureAcct, body)
}
fixtureRow := body[fixtureRowStart : fixtureRowStart+fixtureRowEnd]
- if !strings.Contains(fixtureRow, `class="chip chip-tier-unassigned"`) {
+ if !strings.Contains(fixtureRow, `<span rst-status rst-tone="neutral">unassigned</span>`) {
t.Fatalf("console-row account %q (untiered) row missing the unassigned chip:\n%s", fixtureAcct, fixtureRow)
}
if !strings.Contains(fixtureRow, "<form") || !strings.Contains(fixtureRow, "/fleet/economics/tier") {
diff --git a/internal/console/opeconomics.go b/internal/console/opeconomics.go
new file mode 100644
index 000000000..6147c061c
--- /dev/null
+++ b/internal/console/opeconomics.go
@@ -0,0 +1,95 @@
+package console
+
+import (
+ "fmt"
+ "math"
+ "net/url"
+)
+
+// Economics in the operator shell (Task 12): the Overview/Accounts tabs
+// both economics pages carry under their header, the accounts page's list
+// bar, and the tones its status pills wear. Every link keeps the period on
+// screen.
+
+// econTabs is the seg-tabs under both economics pages' header: Overview
+// (/fleet/economics) and Accounts (/fleet/economics/accounts), current
+// marking the page being viewed, each carrying period. Period "mtd" is what
+// an absent period already means, so it is left off, as econLinkURL does.
+func econTabs(current, period string) opTabs {
+ href := func(path string) string {
+ if period == "" || period == "mtd" {
+ return path
+ }
+ return path + "?" + url.Values{"period": {period}}.Encode()
+ }
+ return opTabs{Label: "Economics sections", Items: []opTab{
+ {Label: "Overview", Href: href("/fleet/economics"), Current: current == "overview"},
+ {Label: "Accounts", Href: href("/fleet/economics/accounts"), Current: current == "accounts"},
+ }}
+}
+
+// econListBar is the accounts page's one list bar: the search form today's
+// page had (its placeholder and its submit text kept), carrying the
+// position filter and a non-default period as hidden fields, and a dropdown
+// of the position links (All first) labelled with the active one.
+func econListBar(q econAccountQuery, pg econAccountsPage) opListBar {
+ const action = "/fleet/economics/accounts"
+ var hidden [][2]string
+ if q.Pos != "" {
+ hidden = append(hidden, [2]string{"pos", q.Pos})
+ }
+ if q.Period != "" && q.Period != "mtd" {
+ hidden = append(hidden, [2]string{"period", q.Period})
+ }
+ f := &opDropdown{Label: "All", Items: []opTab{{Label: "All", Href: pg.AllURL, Current: q.Pos == ""}}}
+ word := "All"
+ for _, l := range pg.Links {
+ label := fmt.Sprintf("%s %d", l.Word, l.Count)
+ f.Items = append(f.Items, opTab{Label: label, Href: l.Href, Current: l.Active})
+ if l.Active {
+ f.Label, word = label, l.Word
+ }
+ }
+ f.Aria = fmt.Sprintf("Filter by free-tier position: %s", word)
+ return opListBar{
+ Action: action, Query: q.Q, Placeholder: "Filter accounts", Submit: "Filter",
+ Hidden: hidden, Filter: f,
+ }
+}
+
+// freeTierTone is the status pill tone of a free-tier position: "inside"
+// (all usage free, no revenue) is the one worth a second look; "paying" is
+// good; "partial" and "pooled" are ordinary. economics_accounts.html's
+// script carries a twin of the same name for a re-priced row.
+func freeTierTone(pos string) string {
+ switch pos {
+ case "inside":
+ return "warning"
+ case "paying":
+ return "positive"
+ }
+ return "neutral"
+}
+
+// tierTone is the status pill tone of a fleet-pool tier word (tierWord):
+// the individually priced tiers apart from the pooled ones, which read as
+// nothing to act on.
+func tierTone(word string) string {
+ switch word {
+ case "hosted":
+ return "positive"
+ case "dedicated":
+ return "warning"
+ }
+ return "neutral"
+}
+
+// opFracMeter is op_meter's data for a 0..1 fraction: the fill rounded to
+// a whole percent, text beside it, and the text's class.
+func opFracMeter(frac float64, text, numClass string) opMeter {
+ p := 0
+ if !math.IsNaN(frac) && !math.IsInf(frac, 0) {
+ p = int(math.Round(frac * 100))
+ }
+ return opMeter{Percent: p, Text: text, NumClass: numClass}
+}
diff --git a/internal/console/opeconomics_test.go b/internal/console/opeconomics_test.go
new file mode 100644
index 000000000..37079f483
--- /dev/null
+++ b/internal/console/opeconomics_test.go
@@ -0,0 +1,226 @@
+package console
+
+import (
+ "net/http"
+ "regexp"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/economics"
+ "github.com/carlosframework/platform/internal/usage"
+)
+
+// econOperator is Paul, signed in and made an operator, on fx.
+func econOperator(t *testing.T, fx *consoleFixture) *http.Client {
+ t.Helper()
+ c := signInPaul(t, fx)
+ if err := fx.st.SetOperator("paul@keymail.dev", true); err != nil {
+ t.Fatal(err)
+ }
+ return c
+}
+
+// econGet is GET path as c, which must answer 200.
+func econGet(t *testing.T, fx *consoleFixture, c *http.Client, path string) string {
+ t.Helper()
+ status, _, body := get(t, c, fx.ts.URL+path)
+ if status != http.StatusOK {
+ t.Fatalf("%s = %d:\n%s", path, status, body)
+ }
+ return body
+}
+
+// TestEconomicsTabs: both economics pages carry the Overview/Accounts
+// seg-tabs under their header, the page being viewed marked current, and
+// both links keep the period on screen ("mtd", the default, is left off).
+func TestEconomicsTabs(t *testing.T) {
+ fx := newConsoleFixture(t)
+ c := econOperator(t, fx)
+ for _, tc := range []struct {
+ path, query, overview, accounts string
+ current string
+ }{
+ {"/fleet/economics", "", "/fleet/economics", "/fleet/economics/accounts", "Overview"},
+ {"/fleet/economics", "?period=last", "/fleet/economics?period=last", "/fleet/economics/accounts?period=last", "Overview"},
+ {"/fleet/economics/accounts", "?period=7d", "/fleet/economics?period=7d", "/fleet/economics/accounts?period=7d", "Accounts"},
+ {"/fleet/economics/accounts", "?period=mtd", "/fleet/economics", "/fleet/economics/accounts", "Accounts"},
+ } {
+ body := econGet(t, fx, c, tc.path+tc.query)
+ if n := strings.Count(body, "<nav rst-seg-tabs"); n != 1 {
+ t.Errorf("%s%s: %d seg-tabs, want 1", tc.path, tc.query, n)
+ }
+ cur := map[string]string{"Overview": "", "Accounts": ""}
+ cur[tc.current] = ` aria-current="page"`
+ want := `<nav rst-seg-tabs aria-label="Economics sections">` +
+ `<a href="` + tc.overview + `"` + cur["Overview"] + `>Overview</a>` +
+ `<a href="` + tc.accounts + `"` + cur["Accounts"] + `>Accounts</a></nav>`
+ if !strings.Contains(body, want) {
+ t.Errorf("%s%s: no %s in:\n%s", tc.path, tc.query, want, body)
+ }
+ // The tabs sit directly under the page header.
+ if tabs := strings.Index(body, "<nav rst-seg-tabs"); tabs < 0 || strings.TrimSpace(body[strings.LastIndex(body[:tabs], "</header>")+len("</header>"):tabs]) != "" {
+ t.Errorf("%s%s: the tabs are not directly under the page header", tc.path, tc.query)
+ }
+ }
+}
+
+// TestEconomicsAccountsListBar: the accounts page has one list bar holding
+// today's search (its placeholder and submit text) and a dropdown of All
+// and each position link, labelled with the active one. A position filter
+// survives a search: pos rides in the form as a hidden field. The old
+// "Back to the dashboard" link and the search form of its own are gone.
+func TestEconomicsAccountsListBar(t *testing.T) {
+ fx := newConsoleFixture(t)
+ seedEconomicsGolden(t, fx)
+ // Tiered "hosted", so the fixture prices to "partial" (see
+ // TestEconomicsAccountsPageContent).
+ if err := fx.st.SetAccountTier(OpsAccountID, "hosted"); err != nil {
+ t.Fatal(err)
+ }
+ c := econOperator(t, fx)
+
+ body := econGet(t, fx, c, "/fleet/economics/accounts?period=7d&pos=partial&q=op")
+ if n := strings.Count(body, "<div rst-lbar>"); n != 1 {
+ t.Fatalf("%d list bars, want 1:\n%s", n, body)
+ }
+ bar := dashCut(t, body, "<div rst-lbar>", "</details>")
+ for _, want := range []string{
+ `<form rst-search method="get" action="/fleet/economics/accounts">`,
+ `<input type="search" name="q" value="op" placeholder="Filter accounts" aria-label="Filter accounts">`,
+ `<input type="hidden" name="pos" value="partial">`,
+ `<input type="hidden" name="period" value="7d">`,
+ `<button class="rst-sr-only" type="submit">Filter</button>`,
+ `<summary rst-btn aria-label="Filter by free-tier position: partial">partial 1 `,
+ `<a href="?period=7d&amp;q=op">All</a>`,
+ `<a href="?period=7d&amp;pos=partial&amp;q=op" aria-current="true">partial 1 `,
+ } {
+ if !strings.Contains(bar, want) {
+ t.Errorf("the list bar lacks %s in:\n%s", want, bar)
+ }
+ }
+ // The clear link drops q and keeps the filter and the period.
+ if !strings.Contains(bar, `<a rst-search-clear href="/fleet/economics/accounts?period=7d&amp;pos=partial"`) {
+ t.Errorf("the clear link does not keep pos and period:\n%s", bar)
+ }
+ for _, gone := range []string{"Back to the dashboard", `class="listctl"`, "<button>Filter</button>"} {
+ if strings.Contains(body, gone) {
+ t.Errorf("the accounts page still carries %q", gone)
+ }
+ }
+
+ // No filter: the dropdown reads All, and All is the current item.
+ body = econGet(t, fx, c, "/fleet/economics/accounts")
+ bar = dashCut(t, body, "<div rst-lbar>", "</details>")
+ for _, want := range []string{
+ `<summary rst-btn aria-label="Filter by free-tier position: All">All `,
+ `<a href="?" aria-current="true">All `,
+ `<a href="?pos=partial">partial 1</a>`,
+ } {
+ if !strings.Contains(bar, want) {
+ t.Errorf("unfiltered: the list bar lacks %s in:\n%s", want, bar)
+ }
+ }
+ if strings.Contains(bar, `name="pos"`) || strings.Contains(bar, `name="period"`) {
+ t.Errorf("unfiltered on mtd: the bar carries a hidden pos or period:\n%s", bar)
+ }
+}
+
+var (
+ econScriptBlock = regexp.MustCompile(`(?s)<script>(.*?)</script>`)
+ econIDLookups = regexp.MustCompile(`(?:getElementById|setText|numVal)\("([^"]+)"`)
+ econSelLookups = regexp.MustCompile(`(?:querySelector(?:All)?\(|setCellText\(row, )"([^"]+)"[),]`)
+ econRadioLookup = regexp.MustCompile(`radioVal\("([^"]+)"\)`)
+ econSelClass = regexp.MustCompile(`\.([A-Za-z0-9_-]+)`)
+ econSelAttr = regexp.MustCompile(`\[([A-Za-z0-9_-]+)\]`)
+)
+
+// econScriptLookups is every element the inline script in body looks up by
+// a literal: ids (getElementById, and the setText and numVal helpers over
+// it), selectors (querySelector, querySelectorAll, and setCellText over
+// it), and radio groups by name (radioVal). It fails when body has no
+// inline script.
+func econScriptLookups(t *testing.T, body string) (ids, sels, radios []string, html string) {
+ t.Helper()
+ m := econScriptBlock.FindAllStringSubmatch(body, -1)
+ if len(m) == 0 {
+ t.Fatal("no inline script")
+ }
+ html = econScriptBlock.ReplaceAllString(body, "")
+ for _, s := range m {
+ for _, l := range econIDLookups.FindAllStringSubmatch(s[1], -1) {
+ ids = append(ids, l[1])
+ }
+ for _, l := range econSelLookups.FindAllStringSubmatch(s[1], -1) {
+ sels = append(sels, l[1])
+ }
+ for _, l := range econRadioLookup.FindAllStringSubmatch(s[1], -1) {
+ radios = append(radios, l[1])
+ }
+ }
+ return ids, sels, radios, html
+}
+
+// TestEconomicsScriptsStillFindTheirElements: every element the two
+// economics pages' inline scripts look up by a literal (an id, a class, an
+// attribute, a radio group) is still in the rendered page, script aside.
+// The world renders every conditional part a script reaches: a bill on
+// file for this month, a box, an account row, and month to date with a
+// metered day.
+func TestEconomicsScriptsStillFindTheirElements(t *testing.T) {
+ fx := newConsoleFixture(t)
+ seedEconomicsGolden(t, fx)
+ month := usage.MonthOf(time.Now().UTC())
+ putStoreJSON(t, fx.rel, economics.BillKey(month), economics.Bill{Schema: 1, Month: month, TotalUSD: 12.5,
+ Services: map[string]float64{"EC2": 10, "S3": 2.5}, Source: economics.SourceManual})
+ c := econOperator(t, fx)
+
+ // The bill table is only on the overview: on the accounts page the
+ // shared maths finds no checkbox, and its own guard says so.
+ for _, tc := range []struct {
+ path string
+ minIDs int
+ minSels int
+ absent map[string]bool
+ }{
+ {"/fleet/economics", 30, 10, nil},
+ {"/fleet/economics/accounts", 20, 5, map[string]bool{".bill-service-checkbox": true}},
+ } {
+ body := econGet(t, fx, c, tc.path)
+ ids, sels, radios, html := econScriptLookups(t, body)
+ if len(ids) < tc.minIDs || len(sels) < tc.minSels || len(radios) == 0 {
+ t.Fatalf("%s: found %d ids, %d selectors and %d radio groups; the lookup patterns no longer match the script", tc.path, len(ids), len(sels), len(radios))
+ }
+ for _, id := range ids {
+ if !strings.Contains(html, ` id="`+id+`"`) {
+ t.Errorf("%s: the script looks up #%s, which the page does not carry", tc.path, id)
+ }
+ }
+ for _, sel := range sels {
+ if tc.absent[sel] {
+ continue
+ }
+ parts := 0
+ for _, cl := range econSelClass.FindAllStringSubmatch(sel, -1) {
+ parts++
+ if !regexp.MustCompile(`class="(?:[^"]* )?` + regexp.QuoteMeta(cl[1]) + `(?: [^"]*)?"`).MatchString(html) {
+ t.Errorf("%s: the script's %q needs class %s, which the page does not carry", tc.path, sel, cl[1])
+ }
+ }
+ for _, at := range econSelAttr.FindAllStringSubmatch(sel, -1) {
+ parts++
+ if !regexp.MustCompile(`<[a-z]+\s[^>]*\b` + regexp.QuoteMeta(at[1]) + `[\s=>]`).MatchString(html) {
+ t.Errorf("%s: the script's %q needs attribute %s, which the page does not carry", tc.path, sel, at[1])
+ }
+ }
+ if parts == 0 {
+ t.Errorf("%s: the script's selector %q has no class or attribute this test reads", tc.path, sel)
+ }
+ }
+ for _, name := range radios {
+ if !strings.Contains(html, `<input type="radio" name="`+name+`"`) {
+ t.Errorf("%s: the script reads radio group %q, which the page does not carry", tc.path, name)
+ }
+ }
+ }
+}
diff --git a/internal/console/opparts.go b/internal/console/opparts.go
index d0161dc6a..dce16c4ed 100644
--- a/internal/console/opparts.go
+++ b/internal/console/opparts.go
@@ -30,9 +30,11 @@ type opStat struct {
type opEmpty struct{ Title, Body string }
// opMeter is op_meter's data: a fill clamped to 0..100 beside its text.
+// NumClass, when set, is a class on the text, for a page script that
+// rewrites it in place (economics.html's js-util-pct).
type opMeter struct {
- Percent int
- Text string
+ Percent int
+ Text, NumClass string
}
// opTab is one link of a tab strip or a dropdown.
@@ -57,11 +59,12 @@ type opDropdown struct {
// opListBar is op_list_bar's data: a GET search form (Action, the current
// Query, the field's Placeholder, the Hidden pairs carried across) and an
// optional filter dropdown. ClearHref, when set, is where the search's clear
-// link goes; otherwise Clear computes it.
+// link goes; otherwise Clear computes it. Submit is the visually hidden
+// submit button's text, "Search" when empty.
type opListBar struct {
- Action, Query, Placeholder, ClearHref string
- Hidden [][2]string
- Filter *opDropdown
+ Action, Query, Placeholder, ClearHref, Submit string
+ Hidden [][2]string
+ Filter *opDropdown
}
// Clear is where the search's clear link goes: ClearHref, or Action with
diff --git a/internal/console/opshell_test.go b/internal/console/opshell_test.go
index 221a645ad..5388e4007 100644
--- a/internal/console/opshell_test.go
+++ b/internal/console/opshell_test.go
@@ -44,13 +44,8 @@ func operatorScreens(fx *consoleFixture) []string {
}
// opShellPending is the operator screens not yet moved into the shell.
-// Later tasks delete entries; none adds one.
-var opShellPending = map[string]bool{
- "/fleet/metrics": true,
- "/fleet/economics": true,
- "/fleet/economics/accounts": true,
- "/fleet/architecture": true,
-}
+// Task 12 moved the last of them; it stays empty.
+var opShellPending = map[string]bool{}
// opRailKeyFor is the rail item a page sits under: the longest rail href
// that prefixes path. The index sits under none.
@@ -143,8 +138,14 @@ func assertOpShell(t *testing.T, path, body string) {
if strings.Contains(body, "data-poll") {
t.Errorf("%s: carries data-poll", path)
}
+ // A stylesheet or script loads from /static/. An inline <script> (the
+ // economics pages' payload and recompute script) loads nothing, so it
+ // is held only to having no src.
for _, tag := range append(opLinkTag.FindAllString(body, -1), opScriptTag.FindAllString(body, -1)...) {
u := opURLAttr.FindStringSubmatch(tag)
+ if u == nil && strings.HasPrefix(tag, "<script") && !strings.Contains(tag, "src=") {
+ continue
+ }
if u == nil || !strings.HasPrefix(u[1], "/static/") {
t.Errorf("%s: %s does not load from /static/", path, tag)
}
@@ -179,6 +180,9 @@ func TestEveryOperatorPageRendersInTheShell(t *testing.T) {
}
func TestOperatorShellPendingShrinks(t *testing.T) {
+ if len(opShellPending) != 0 {
+ t.Errorf("opShellPending holds %d screens; every operator page is in the shell", len(opShellPending))
+ }
fx := newConsoleFixture(t)
screens := operatorScreens(fx)
for path := range opShellPending {
diff --git a/internal/console/opshots_test.go b/internal/console/opshots_test.go
index 14cabb26c..af1e02e20 100644
--- a/internal/console/opshots_test.go
+++ b/internal/console/opshots_test.go
@@ -15,6 +15,10 @@ import (
"strings"
"testing"
"time"
+
+ "github.com/carlosframework/platform/internal/economics"
+ "github.com/carlosframework/platform/internal/metrics"
+ "github.com/carlosframework/platform/internal/usage"
)
// opShotPages is every operator page built so far, by its shot name.
@@ -27,6 +31,37 @@ var opShotPages = []struct{ name, path string }{
{"people", "/fleet/people"},
{"accounts", "/fleet/people?show=accounts"},
{"activity", "/fleet/activity"},
+ {"metrics", "/fleet/metrics"},
+ {"economics", "/fleet/economics"},
+ {"economics-accounts", "/fleet/economics/accounts"},
+ {"architecture", "/fleet/architecture"},
+}
+
+// seedOperatorShotExtras gives the moved pages something to show: an
+// hour of one box's metrics with a unit, the economics fixture
+// (seedEconomicsGolden) and a bill on file for this month.
+func seedOperatorShotExtras(t *testing.T, fx *consoleFixture) {
+ t.Helper()
+ ctx := context.Background()
+ now := time.Now().UTC()
+ chunk := metrics.RawChunk{V: 1, Box: "box-1", Hour: metrics.HourOf(now)}
+ for i := 0; i < 12; i++ {
+ f := float64(i)
+ chunk.Samples = append(chunk.Samples, metrics.Sample{
+ At: now.Add(-time.Duration(12-i) * 4 * time.Minute),
+ Host: metrics.HostSample{CPUFrac: p(0.2 + 0.03*f), MemFrac: p(0.4 + 0.01*f), DiskFrac: p(0.55)},
+ Units: map[string]metrics.UnitSample{
+ "carlos-app@shop.example.com.service": {CPUFrac: p(0.05 + 0.01*f), MemBytes: pi64(180 << 20)},
+ },
+ })
+ }
+ if err := metrics.WriteRaw(ctx, fx.rel, chunk); err != nil {
+ t.Fatal(err)
+ }
+ seedEconomicsGolden(t, fx)
+ month := usage.MonthOf(now)
+ putStoreJSON(t, fx.rel, economics.BillKey(month), economics.Bill{Schema: 1, Month: month, TotalUSD: 12.5,
+ Services: map[string]float64{"EC2": 10, "S3": 2.5}, Source: economics.SourceManual})
}
// TestOperatorScreenshots is a review aid, not acceptance: it renders every
@@ -50,6 +85,7 @@ func TestOperatorScreenshots(t *testing.T) {
}
fx := newConsoleFixture(t)
w := seedOperatorWorld(t, fx)
+ seedOperatorShotExtras(t, fx)
target, err := url.Parse(fx.ts.URL)
if err != nil {
t.Fatal(err)
diff --git a/internal/console/server.go b/internal/console/server.go
index 8a8868c14..318d208b1 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -220,9 +220,15 @@ var templates = template.Must(template.New("").Funcs(template.FuncMap{
"opStat": func(label, value, note string, lead bool) opStat {
return opStat{Label: label, Value: value, Note: note, Lead: lead}
},
- "opMeter": func(percent int, text string) opMeter { return opMeter{Percent: percent, Text: text} },
- "memUsedPct": memUsedPercent,
- "memUsed": memUsedBytes,
+ "opMeter": func(percent int, text string) opMeter { return opMeter{Percent: percent, Text: text} },
+ // opFracMeter is op_meter's data for a 0..1 fraction with a class on
+ // its text; freeTierTone and tierTone are the economics accounts
+ // page's pill tones (opeconomics.go).
+ "opFracMeter": opFracMeter,
+ "freeTierTone": freeTierTone,
+ "tierTone": tierTone,
+ "memUsedPct": memUsedPercent,
+ "memUsed": memUsedBytes,
// join renders fleetPageBox.Tags back into the tag form's editable
// text input, comma-separated — the exact grammar SetFleetBoxTags
// expects back, so an owner opening the form sees the same string they'd
@@ -2316,6 +2322,11 @@ type page struct {
// shared knob drawer recomputes this page's rows too.
EconAccounts econAccountsPage
EconQuery econAccountQuery
+ // EconTabs is the Overview/Accounts switch both economics pages carry,
+ // and EconBar the accounts page's search and position filter
+ // (opeconomics.go).
+ EconTabs opTabs
+ EconBar opListBar
// App page, "Resources": this app's OWN instances' unit readings (Task
// 12), one row per route host. Nil renders no section at all — metrics
@@ -3478,11 +3489,11 @@ func (s *Server) handleFleetMetrics(w http.ResponseWriter, r *http.Request) {
}
// The Console speed table reads the recorder before this request is in
// it: a request is recorded once it has rendered.
- s.render(w, http.StatusOK, "metrics", page{
- Title: "Fleet metrics", Address: addr, CSRF: raw, Metrics: boxes, MetricAlerts: alerts,
- ConsoleSpeed: consoleSpeedRows(s.PerfGroups()),
- ConsoleS3Background: s.PerfBackground()["s3"],
- })
+ p := s.opPage(addr, raw, "metrics")
+ p.Metrics, p.MetricAlerts = boxes, alerts
+ p.ConsoleSpeed = consoleSpeedRows(s.PerfGroups())
+ p.ConsoleS3Background = s.PerfBackground()["s3"]
+ s.render(w, http.StatusOK, "metrics", p)
}
// handleEconomics serves the operator unit-economics dashboard (Task 13) —
@@ -3504,7 +3515,9 @@ func (s *Server) handleEconomics(w http.ResponseWriter, r *http.Request) {
s.renderMessage(w, r, http.StatusInternalServerError, "Unavailable", "Economics could not be read.")
return
}
- p := page{Title: "Fleet economics", Address: addr, CSRF: raw, Economics: view}
+ p := s.opPage(addr, raw, "economics")
+ p.Economics = view
+ p.EconTabs = econTabs("overview", view.Period)
p.Flash, p.FlashErr = s.takeFlash(w, r)
s.render(w, http.StatusOK, "economics", p)
}
@@ -3551,7 +3564,10 @@ func (s *Server) handleEconomicsAccounts(w http.ResponseWriter, r *http.Request)
// row order. See econAccountQuery.Period's doc comment.
q.Period = view.Period
pg := pageEconAccounts(rows, q, econAccountPageSize)
- p := page{Title: "Fleet economics: accounts", Address: addr, CSRF: raw, Economics: view, EconAccounts: pg, EconQuery: q}
+ p := s.opPage(addr, raw, "economics")
+ p.Economics, p.EconAccounts, p.EconQuery = view, pg, q
+ p.EconTabs = econTabs("accounts", view.Period)
+ p.EconBar = econListBar(q, pg)
p.Flash, p.FlashErr = s.takeFlash(w, r)
s.render(w, http.StatusOK, "economics_accounts", p)
}
diff --git a/internal/console/server_test.go b/internal/console/server_test.go
index a8706d245..0bbd95682 100644
--- a/internal/console/server_test.go
+++ b/internal/console/server_test.go
@@ -2137,7 +2137,7 @@ func TestFleetMetricsEmptyState(t *testing.T) {
t.Fatal(err)
}
status, _, body := get(t, c, fx.ts.URL+"/fleet/metrics")
- if status != 200 || !strings.Contains(body, "Fleet metrics") {
+ if status != 200 || !strings.Contains(body, "<h1>Metrics</h1>") || !strings.Contains(body, "No boxes have published metrics yet.") {
t.Fatalf("empty /fleet/metrics: %d %s", status, body)
}
}
diff --git a/internal/console/static/ops.css b/internal/console/static/ops.css
index 10de9ccc5..b131ba009 100644
--- a/internal/console/static/ops.css
+++ b/internal/console/static/ops.css
@@ -105,3 +105,89 @@
[co-h="18"] { block-size: 90%; }
[co-h="19"] { block-size: 95%; }
[co-h="20"] { block-size: 100%; }
+
+/* A data table's low-value columns on a phone: the operator lists above
+ keep two cells a row at 800px and below, and a table drops the columns
+ marked co-m-hide the same way, head included, so what stays fits: such
+ a table also tightens its cells and lets its headings and its first
+ (name) column wrap. A table with no such column scrolls as before. A
+ cell that holds a sentence may wrap (co-wrap) rather than widen its
+ table. */
+@media (max-width: 800px) {
+ [co-table] [co-m-hide] { display: none; }
+ [co-table]:has([co-m-hide]) :is(th, td) { padding-inline: 0.6rem; }
+ [co-table]:has([co-m-hide]) :is(th, td:first-child) { overflow-wrap: anywhere; white-space: normal; }
+}
+[co-table] [co-wrap] { white-space: normal; }
+
+/* A table too wide for the column at any width (the economics accounts
+ list, thirteen columns): tighter cells, and headings that may wrap. */
+[co-dense] th, [co-dense] td { padding-inline: 0.45rem; }
+[co-dense] th { white-space: normal; }
+[co-dense] th[co-nowrap] { white-space: nowrap; }
+
+/* Stacked parts that would otherwise touch: two table cards in a row, a
+ box's readings and its units, and a section after a table. */
+.co-table-wrap + .co-table-wrap, [co-spark-stats] + * { margin-block-start: var(--rst-sp-3); }
+[co-section] { margin-block-start: 1.5rem; }
+
+/* Links in a quiet note: the accent, not the browser's default blue. */
+[co-note] a { color: var(--rst-accent); }
+
+/* A figure or line that says something is wrong: an alert's value, the
+ bill note no selection can save. The economics pool tile's headroom
+ wears the class the page's script toggles (.error) instead. */
+[co-neg], [co-econ] .error { color: var(--rst-tone-negative-fg); }
+
+/* The economics pages' period switch: a quiet line of three links, the
+ current one in the text colour. */
+[co-period] { color: var(--rst-text-muted); font-size: var(--rst-fs-sm); margin: var(--rst-sp-2) 0 var(--rst-sp-4); }
+[co-period] a { color: var(--rst-accent); }
+[co-period] a[aria-current] { color: var(--rst-text); font-weight: 600; text-decoration: none; }
+
+/* The economics pool tile reads as a sentence of three figures, smaller
+ than a lone number. */
+[rst-stats] [rst-stat-num][co-pool] { font-size: var(--rst-fs-lg); line-height: 1.4; }
+
+/* A metric's sparkline under its reading, in the accent. */
+[co-spark] { block-size: auto; color: var(--rst-accent); display: block; inline-size: 100%; margin-block-start: var(--rst-sp-2); max-inline-size: 15rem; }
+
+/* A heading inside a section: Architecture's resource groups, the
+ economics knob drawer's parts. */
+[co-h3] { font-size: var(--rst-fs-base); margin: var(--rst-sp-5) 0 var(--rst-sp-2); }
+
+/* The economics knob drawer and the bill form: one row per number, its
+ label then its control. The drawer is a card that opens. */
+[co-knobs] > summary { cursor: pointer; font-weight: 600; }
+[co-knobs] > summary + * { margin-block-start: var(--rst-sp-4); }
+[co-knob] { align-items: center; display: flex; flex-wrap: wrap; gap: var(--rst-sp-2) var(--rst-sp-3); margin: 0 0 var(--rst-sp-2); }
+[co-knob] > label:first-child { color: var(--rst-text-muted); font-size: var(--rst-fs-sm); min-inline-size: 16rem; }
+[co-knobs] [rst-input] { inline-size: 8rem; }
+[co-knobs] input[type=range] { inline-size: 12rem; }
+[co-knobs] [rst-textarea] { max-inline-size: 32rem; }
+[co-knobs] .co-table-wrap { border: 1px solid var(--rst-line); border-radius: var(--rst-radius-sm); }
+
+/* The economics accounts page's tier form, under the tier's pill. */
+[co-tier] { align-items: center; display: flex; flex-wrap: wrap; gap: var(--rst-sp-2); margin-block-start: var(--rst-sp-2); }
+[co-tier] [rst-input] { font-size: var(--rst-fs-sm); inline-size: auto; min-block-size: 0; padding: 0.2rem 0.4rem; }
+
+/* Architecture: each region band's heading, quiet and in the mono face,
+ then its diagram in a card that scrolls sideways when the window is
+ narrower than the drawing. The SVG carries its own size and renders
+ 1:1; its parts are themed from the same tokens as the page. */
+[co-band] { border-block-start: 1px solid var(--rst-line); color: var(--rst-text-muted); font: 600 0.8rem ui-monospace, monospace; letter-spacing: 0.02em; margin: var(--rst-sp-5) 0 var(--rst-sp-2); padding-block-start: var(--rst-sp-2); }
+[co-arch] { overflow-x: auto; padding: var(--rst-sp-3); }
+[co-arch] .archsvg { display: block; }
+[co-arch] .archsvg rect { fill: var(--rst-accent-soft); stroke: var(--rst-line-strong); }
+[co-arch] .archsvg .archnode-box rect { stroke: var(--rst-accent); }
+[co-arch] .archsvg .archtitle { fill: var(--rst-text); font: 600 13px var(--rst-font); }
+[co-arch] .archsvg .archsub { fill: var(--rst-text-muted); font: 400 11px var(--rst-font); }
+[co-arch] .archsvg .archedge { fill: none; stroke: var(--rst-text-muted); stroke-width: 1.5; }
+[co-arch] .archsvg .archalarm { fill: var(--rst-tone-positive-fg); }
+[co-arch] .archsvg .archalarm-firing { fill: var(--rst-tone-negative-fg); }
+
+/* Architecture's box cards: every fact on the fact line is independently
+ absent, so the separator is drawn between surviving neighbours. */
+[co-archbox] h4 { font-size: var(--rst-fs-base); }
+[co-archbox] p { margin-block: var(--rst-sp-1) 0; }
+[co-fact] + [co-fact]::before { color: var(--rst-text-faint); content: " · "; }
diff --git a/internal/console/templates/architecture.html b/internal/console/templates/architecture.html
index 1ae423930..3b76e1872 100644
--- a/internal/console/templates/architecture.html
+++ b/internal/console/templates/architecture.html
@@ -8,10 +8,9 @@
boxes, the resource tables and the failed-reads footer each appear only
when their own read produced something, so one bad read costs its own
section and never the page. */}}
-{{define "architecture"}}{{template "top" .}}
-<h1>Architecture</h1>
-{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}}
-{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}}
+{{define "architecture"}}{{template "op_top" .}}
+{{template "op_page_header" (opHeader .Title "The deployment's parts and connections.")}}
+{{template "op_flash" .}}
{{/* The page's only control, at the top with the inventory timestamp it acts
on. It used to sit below every resource table, several thousand pixels
from the line telling you the inventory was stale (discussion #9).
@@ -20,7 +19,7 @@
there. */}}
<form method="post" action="/fleet/architecture/refresh">
<input type="hidden" name="csrf" value="{{.CSRF}}">
- <button type="submit">Refresh inventory</button>
+ <button rst-btn type="submit">Refresh inventory</button>
</form>
{{/* A firing alarm, said where the reader already is. The marks ride the
nodes they watch, which is right, but that put them off to the right of
@@ -29,23 +28,23 @@
nothing above the fold. Spans both estates: the reader wants to know
something is firing, not which half of the page to look in. */}}
{{with .Arch}}{{if .Firing}}
-<p class="banner error">{{icon "triangle-alert"}}
+<div rst-callout rst-tone="negative"><span rst-callout-ic aria-hidden="true">{{icon "triangle-alert"}}</span><div rst-callout-body><p>
{{len .Firing}} alarm{{if ne (len .Firing) 1}}s{{end}} firing:
{{range $i, $a := .Firing}}{{if $i}}, {{end}}{{$a}}{{end}}
-</p>
+</p></div></div>
{{end}}{{end}}
{{with .Arch}}
{{/* The three missing states are named apart, never collapsed into one
"nothing here": never-taken, ungranted and unreadable are three
different facts about the deployment and only one of them is normal. */}}
{{if .Missing}}
-<p class="banner">{{icon "triangle-alert"}}
+<div rst-callout rst-tone="info"><span rst-callout-ic aria-hidden="true">{{icon "triangle-alert"}}</span><div rst-callout-body><p>
{{if eq .Missing "never"}}No inventory has been taken yet — the first pass runs within the hour. The boxes below are what CARLOS itself reports.
{{else if eq .Missing "ungranted"}}This deployment has no infrastructure read grant, so the cloud half of this page is unavailable. The boxes below are what CARLOS itself reports.
{{else}}The inventory snapshot could not be read. The boxes below are what CARLOS itself reports.{{end}}
-</p>
+</p></div></div>
{{else}}
-<p class="small">Estate {{.Account}} &middot; inventoried {{fmtTime .TakenAt}}</p>
+<p co-note>Estate {{.Account}} &middot; inventoried {{fmtTime .TakenAt}}</p>
{{end}}
{{/* Two estates, one above the other, never one picture with a line
@@ -58,7 +57,7 @@
NOTHING IS FILTERED. Every node and every resource on the old single
page is still here, under one of the two headings — the split groups,
it does not hide (archestate.go). */}}
-<h2>CARLOS</h2>
+<div rst-box-head><h2>CARLOS</h2></div>
{{/* One picture per region, stacked down the page. Region is the
STRUCTURE here, not a word on a card: a box is the only thing on this
diagram that is really in a region, and everything else is drawn in the
@@ -66,44 +65,44 @@
each picture inside the 64rem column — a band is at most four nodes
wide — so this page scrolls down and never across. */}}
{{range .CARLOS.Bands}}
-<h4 class="archband">{{.Label}}</h4>
-<div class="archwrap">{{.SVG}}</div>
+<h4 co-band>{{.Label}}</h4>
+<div rst-card co-arch>{{.SVG}}</div>
{{end}}
-<h3>Boxes</h3>
+<h3 co-h3>Boxes</h3>
{{range .Boxes}}
-<section class="archbox">
- <h4>{{.Label}}{{if .Region}} <span class="small">{{.Region}}</span>{{end}}</h4>
+<section rst-card co-pad co-archbox>
+ <h4>{{.Label}}{{if .Region}} <span co-note>{{.Region}}</span>{{end}}</h4>
{{/* Each fact is its own span and the separators are drawn by CSS
- (.fact + .fact::before), because every one of these is independently
+ ([co-fact] + [co-fact]::before, static/ops.css), because every one of these is independently
absent — a deployment with no rate card entry has no size and no
price, and a hand-written separator would leave a dangling middot on
the commonest page of all. */}}
- <p class="small">
- {{if .InstanceType}}<span class="fact">{{.InstanceType}}</span>{{end}}
- {{if .State}}<span class="fact">{{.State}}</span>{{end}}
- {{if .Cores}}<span class="fact">{{printf "%.0f" .Cores}} cores</span>{{end}}
- {{if .MemGB}}<span class="fact">{{printf "%.0f" .MemGB}} GB</span>{{end}}
- {{if .DiscoveredDiskGB}}<span class="fact">{{printf "%.0f" .DiscoveredDiskGB}} GB disk</span>{{end}}
- {{if .USDMonth}}<span class="fact">${{printf "%.0f" .USDMonth}}/mo</span>{{end}}
- {{if not .CloudID}}<span class="fact">no cloud machine (bring-your-own box)</span>{{end}}
+ <p co-note>
+ {{if .InstanceType}}<span co-fact>{{.InstanceType}}</span>{{end}}
+ {{if .State}}<span co-fact>{{.State}}</span>{{end}}
+ {{if .Cores}}<span co-fact>{{printf "%.0f" .Cores}} cores</span>{{end}}
+ {{if .MemGB}}<span co-fact>{{printf "%.0f" .MemGB}} GB</span>{{end}}
+ {{if .DiscoveredDiskGB}}<span co-fact>{{printf "%.0f" .DiscoveredDiskGB}} GB disk</span>{{end}}
+ {{if .USDMonth}}<span co-fact>${{printf "%.0f" .USDMonth}}/mo</span>{{end}}
+ {{if not .CloudID}}<span co-fact>no cloud machine (bring-your-own box)</span>{{end}}
</p>
- <p class="small">Apps: {{if .Apps}}{{range .Apps}}<code>{{.}}</code> {{end}}{{else}}none reported{{end}}</p>
+ <p co-note>Apps: {{if .Apps}}{{range .Apps}}<code>{{.}}</code> {{end}}{{else}}none reported{{end}}</p>
{{/* The counts come from the fleet aggregate and nowhere else, so a box
that read never described has NO counts — printing three zeroes here
would state a read that never happened, beside an awake/asleep that
correctly says it does not know. */}}
- <p class="small">
+ <p co-note>
{{if .CountsKnown}}static {{.Static}} &middot; resident {{.Resident}} &middot; hibernating {{.Hibernating}} &middot;
awake {{intOrDash .Awake}} &middot; asleep {{intOrDash .Asleep}}
{{else}}counts unknown{{end}}
{{with .Release}}&middot; <code>{{.}}</code>{{end}}
</p>
- {{if .Stale}}<p><span class="chip chip-stale">dark{{if .Dark}} {{.Dark}}{{end}}</span></p>{{end}}
+ {{if .Stale}}<p>{{if .Dark}}{{template "op_status" (opPill (printf "dark %s" .Dark) "warning")}}{{else}}{{template "op_status" (opPill "dark" "warning")}}{{end}}</p>{{end}}
{{/* Drift is where the rate card and the estate disagree — a fact to
- watch, not an outage, so it wears chip-stale's bordered warn tone
- rather than a filled marker. */}}
- {{range .Drift}}<p><span class="chip chip-stale">{{.}}</span></p>{{end}}
+ watch, not an outage, so it wears the warning tone a dark box wears,
+ never the negative one. */}}
+ {{range .Drift}}<p>{{template "op_status" (opPill . "warning")}}</p>{{end}}
</section>
{{else}}
{{/* An empty box list has two causes and they are not the same fact: no box
@@ -115,7 +114,7 @@
{{end}}
{{range .CARLOS.Groups}}
-<h3>{{.Title}}</h3>
+<h3 co-h3>{{.Title}}</h3>
{{template "archtable" .}}
{{end}}
@@ -123,8 +122,8 @@
not for what it happens to be here. This console serves every CARLOS
estate; "legacy" describes Tito's Kubernetes cluster and would be
wrong, and unexplained, on the next account. */}}
-<h2>Also in this account</h2>
-<p class="small">Everything else the account is carrying. The console has no
+<div rst-box-head><h2>Also in this account</h2></div>
+<p co-note>Everything else the account is carrying. The console has no
first-hand knowledge of these — it can see them, and it cannot trace a path
to any of them from a box it runs or the bucket it deploys from.</p>
{{/* One picture per region, stacked down the page. Region is the
@@ -134,11 +133,11 @@ to any of them from a box it runs or the bucket it deploys from.</p>
each picture inside the 64rem column — a band is at most four nodes
wide — so this page scrolls down and never across. */}}
{{range .Rest.Bands}}
-<h4 class="archband">{{.Label}}</h4>
-<div class="archwrap">{{.SVG}}</div>
+<h4 co-band>{{.Label}}</h4>
+<div rst-card co-arch>{{.SVG}}</div>
{{end}}
{{range .Rest.Groups}}
-<h3>{{.Title}}</h3>
+<h3 co-h3>{{.Title}}</h3>
{{template "archtable" .}}
{{end}}
@@ -146,16 +145,16 @@ to any of them from a box it runs or the bucket it deploys from.</p>
estate read could not see. A page that quietly dropped these would be
claiming the estate is smaller than it is. */}}
{{if .Partial}}
-<h2>Reads that failed</h2>
-<ul class="small">{{range .Partial}}<li>{{.}}</li>{{end}}</ul>
+<div rst-box-head><h2>Reads that failed</h2></div>
+<ul co-note>{{range .Partial}}<li>{{.}}</li>{{end}}</ul>
{{end}}
{{end}}
-{{template "bottom" .}}{{end}}
+{{template "op_bottom" .}}{{end}}
{{/* One resource table, rendered identically in both banks — the two halves
of this page differ in what they contain and in nothing else. */}}
-{{define "archtable"}}<div class="tablewrap"><table>
- <tr><th>Name</th><th>Type</th><th>Region</th><th>Detail</th></tr>
- {{range .Rows}}<tr><td>{{.Name}}</td><td><code>{{.NativeType}}</code></td><td>{{.Region}}</td><td class="small">{{.Detail}}</td></tr>{{end}}
+{{define "archtable"}}<div rst-card class="co-table-wrap"><table co-table>
+ <tr><th>Name</th><th co-m-hide>Type</th><th co-m-hide>Region</th><th>Detail</th></tr>
+ {{range .Rows}}<tr><td>{{.Name}}</td><td co-m-hide><code>{{.NativeType}}</code></td><td co-m-hide>{{.Region}}</td><td co-note>{{.Detail}}</td></tr>{{end}}
</table></div>{{end}}
diff --git a/internal/console/templates/economics.html b/internal/console/templates/economics.html
index ff3107a94..08259f92c 100644
--- a/internal/console/templates/economics.html
+++ b/internal/console/templates/economics.html
@@ -33,22 +33,21 @@
Σ 1/daysInMonth(d) over the period; econ_maths_js's poolLedger scales
it by the live pool.topup_usd knob rather than re-deriving the per-day
sum client-side — see that field's own doc comment for why). */}}
-{{define "economics"}}{{template "top" .}}
-<h1>Fleet economics</h1>
-{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}}
-{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}}
-{{if .Economics.Warning}}<p class="banner error">{{icon "triangle-alert"}} {{.Economics.Warning}}</p>{{end}}
-{{if .Economics.ScenarioWarning}}<p class="banner error">{{icon "triangle-alert"}} {{.Economics.ScenarioWarning}}</p>{{end}}
+{{define "economics"}}{{template "op_top" .}}
+{{template "op_page_header" (opHeader .Title "Platform costs and revenue.")}}
+{{template "op_seg_tabs" .EconTabs}}
+{{template "op_flash" .}}
+{{template "econ_warnings" .}}
-<p class="small">Generated {{fmtTime .Economics.GeneratedAt}} &middot; scenario <strong>{{.Economics.Scenario.Name}}</strong> ({{.Economics.Scenario.Mode}}) &middot; {{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
+<p co-note>Generated {{fmtTime .Economics.GeneratedAt}} &middot; scenario <strong>{{.Economics.Scenario.Name}}</strong> ({{.Economics.Scenario.Mode}}) &middot; {{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
-<nav class="small" aria-label="Period">
+<nav co-period aria-label="Period">
Period:
<a href="?period=mtd"{{if eq .Economics.Period "mtd"}} aria-current="page"{{end}}>Month to date</a> &middot;
<a href="?period=last"{{if eq .Economics.Period "last"}} aria-current="page"{{end}}>Last month</a> &middot;
<a href="?period=7d"{{if eq .Economics.Period "7d"}} aria-current="page"{{end}}>Last 7 days</a>
</nav>
-<p class="small"><a href="/fleet/economics/accounts">Every account, searchable →</a></p>
+<p co-note><a href="/fleet/economics/accounts">Every account, searchable →</a></p>
{{/* Headline tiles: EconomicsView.Accounts (allocated+metered cost and
revenue per tenant) plus every box's unallocated idle headroom plus
@@ -68,49 +67,52 @@
the line). The margin tile has no projected line — a ratio doesn't
project the way a dollar total does. */}}
{{$showProjection := and (eq .Economics.Period "mtd") (gt .Economics.CoveredDays 0)}}
-<section class="tiles" aria-label="Headline economics">
- <div class="tile">
- <h2>Would-be revenue</h2>
- <p class="tile-value" id="tile-revenue">{{usd $revenue}}</p>
- <p class="tile-detail">{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
- {{if $showProjection}}<p class="tile-detail" id="tile-revenue-projected">projected {{usd (project $revenue .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</p>{{end}}
+{{/* The tiles are op_stat's markup written out: the inline script finds
+ each figure by its id, and op_stat's data has no place for one. */}}
+<section rst-stats co-econ aria-label="Headline economics">
+ <div rst-stat>
+ <span rst-stat-label>Would-be revenue</span>
+ <span rst-stat-num id="tile-revenue">{{usd $revenue}}</span>
+ <span rst-stat-note>{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</span>
+ {{if $showProjection}}<span rst-stat-note id="tile-revenue-projected">projected {{usd (project $revenue .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</span>{{end}}
</div>
- <div class="tile">
- <h2>Cost</h2>
- <p class="tile-value" id="tile-cost">{{usd $cost}}</p>
- <p class="tile-detail">{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
- {{if $showProjection}}<p class="tile-detail" id="tile-cost-projected">projected {{usd (project $cost .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</p>{{end}}
+ <div rst-stat>
+ <span rst-stat-label>Cost</span>
+ <span rst-stat-num id="tile-cost">{{usd $cost}}</span>
+ <span rst-stat-note>{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</span>
+ {{if $showProjection}}<span rst-stat-note id="tile-cost-projected">projected {{usd (project $cost .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</span>{{end}}
</div>
- <div class="tile">
- <h2>Profit</h2>
- <p class="tile-value" id="tile-profit">{{usd $profit}}</p>
- <p class="tile-detail">{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
- {{if $showProjection}}<p class="tile-detail" id="tile-profit-projected">projected {{usd (project $profit .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</p>{{end}}
+ <div rst-stat>
+ <span rst-stat-label>Profit</span>
+ <span rst-stat-num id="tile-profit">{{usd $profit}}</span>
+ <span rst-stat-note>{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</span>
+ {{if $showProjection}}<span rst-stat-note id="tile-profit-projected">projected {{usd (project $profit .Economics.CoveredDays .Economics.DaysInMonth)}} for the month</span>{{end}}
</div>
- <div class="tile">
- <h2>Achieved margin</h2>
- <p class="tile-value" id="tile-margin">{{pctf $margin}}</p>
- <p class="tile-detail">{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
+ <div rst-stat>
+ <span rst-stat-label>Achieved margin</span>
+ <span rst-stat-num id="tile-margin">{{pctf $margin}}</span>
+ <span rst-stat-note>{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</span>
</div>
{{/* Fleet pool tile (Task 6): PoolLedger's own doc comment (economicsview.go)
for the exact formula — a share of paying revenue plus a day-accrued
monthly top-up, against the pool-tier accounts' own real spend. Headroom
MAY be negative (the pool is overdrawn this period) and renders honestly,
never clamped — the negative case carries the page's existing warning
- styling (.error, same class every other on-page warning uses) on the
- headroom figure alone, not the whole tile. */}}
- <div class="tile" id="tile-pool">
- <h2>Fleet pool</h2>
- <p class="tile-value">POOL <span id="tile-pool-usd">{{usd .Economics.Pool.PoolUSD}}</span> &middot; draw <span id="tile-pool-draw">{{usd .Economics.Pool.DrawUSD}}</span> &middot; headroom <span id="tile-pool-headroom"{{if lt .Economics.Pool.HeadroomUSD 0.0}} class="error"{{end}}>{{usd .Economics.Pool.HeadroomUSD}}</span></p>
- <p class="tile-detail">{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
+ styling (.error, the class the inline script toggles; [co-econ]
+ .error in static/ops.css) on the headroom figure alone, not the
+ whole tile. */}}
+ <div rst-stat="lead" id="tile-pool">
+ <span rst-stat-label>Fleet pool</span>
+ <span rst-stat-num co-pool>POOL <span id="tile-pool-usd">{{usd .Economics.Pool.PoolUSD}}</span> &middot; draw <span id="tile-pool-draw">{{usd .Economics.Pool.DrawUSD}}</span> &middot; headroom <span id="tile-pool-headroom"{{if lt .Economics.Pool.HeadroomUSD 0.0}} class="error"{{end}}>{{usd .Economics.Pool.HeadroomUSD}}</span></span>
+ <span rst-stat-note>{{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</span>
</div>
</section>
-<h2>Accounts</h2>
+<div rst-box-head><h2>Accounts</h2></div>
{{if .Economics.Accounts}}
-<div class="tablewrap">
-<table>
- <tr><th>Account</th><th>Cost</th><th>Revenue</th><th title="Pooled rows (free-tier position &quot;pooled&quot;) show an em-dash: their revenue is shared through the fleet pool, not individually priced, so a margin fraction has nothing to divide. Fleet-tier rows can legitimately show 100%: fleet boxes are customer-owned hardware, zero cost to the platform, by design.">Margin</th><th>Free tier</th></tr>
+<div rst-card class="co-table-wrap">
+<table co-table>
+ <tr><th>Account</th><th>Cost</th><th>Revenue</th><th co-m-hide title="Pooled rows (free-tier position &quot;pooled&quot;) show an em-dash: their revenue is shared through the fleet pool, not individually priced, so a margin fraction has nothing to divide. Fleet-tier rows can legitimately show 100%: fleet boxes are customer-owned hardware, zero cost to the platform, by design.">Margin</th><th co-m-hide>Free tier</th></tr>
{{range .Economics.Accounts}}
{{$name := index $.Economics.Names .Account}}
<tr data-account="{{.Account}}">
@@ -118,11 +120,11 @@
row (see that template's comment on this exact markup) — this page
has no econAccountRow, so the name is looked up straight from
EconomicsView.Names by sqid rather than carried on the row. */}}
- <td>{{if $name}}{{$name}} <span class="small">{{.Account}}</span>{{else}}{{.Account}}{{end}}</td>
+ <td>{{if $name}}{{$name}} <span co-note>{{.Account}}</span>{{else}}{{.Account}}{{end}}</td>
<td class="js-acct-cost">{{usd .CostUSD}}</td>
<td class="js-acct-revenue">{{usd .RevenueUSD}}</td>
- <td class="js-acct-margin">{{marginCell .MarginFrac .FreeTierPos}}</td>
- <td class="js-acct-freetier">{{.FreeTierPos}}</td>
+ <td class="js-acct-margin" co-m-hide>{{marginCell .MarginFrac .FreeTierPos}}</td>
+ <td class="js-acct-freetier" co-m-hide>{{.FreeTierPos}}</td>
</tr>
{{end}}
</table>
@@ -130,35 +132,32 @@
{{/* MINOR 3 (fix round, Task 6 review): the Margin column's title=
tooltip is invisible on touch/keyboard — this legend carries the
same two notes visibly, for everyone. */}}
-<p class="small">Margin: pooled rows show an em-dash — their revenue is shared through the fleet pool, not individually priced. Fleet-tier rows can legitimately show 100% margin — fleet boxes are customer-owned hardware, zero cost to the platform, by design.</p>
-{{else}}<p class="small">No accounts to price this period.</p>{{end}}
-<p class="small"><a href="/fleet/economics/accounts">Every account, searchable →</a></p>
+<p co-note>Margin: pooled rows show an em-dash — their revenue is shared through the fleet pool, not individually priced. Fleet-tier rows can legitimately show 100% margin — fleet boxes are customer-owned hardware, zero cost to the platform, by design.</p>
+{{else}}<p co-note>No accounts to price this period.</p>{{end}}
+<p co-note><a href="/fleet/economics/accounts">Every account, searchable →</a></p>
-<h2>Boxes</h2>
+<div rst-box-head><h2>Boxes</h2></div>
{{if .Economics.Boxes}}
-<div class="tablewrap">
-<table>
- <tr><th>Box</th><th>Hours</th><th>Cost</th><th>Idle</th><th>Utilization</th><th>Egress</th><th>Revenue</th><th>Profit</th></tr>
+<div rst-card class="co-table-wrap">
+<table co-table>
+ <tr><th>Box</th><th co-m-hide>Hours</th><th>Cost</th><th co-m-hide>Idle</th><th>Utilization</th><th co-m-hide>Egress</th><th co-m-hide>Revenue</th><th co-m-hide>Profit</th></tr>
{{range .Economics.Boxes}}
<tr data-box="{{.Box}}">
<td>{{.Box}}</td>
- <td class="js-hours">{{printf "%.2f" .Hours}}</td>
+ <td class="js-hours" co-m-hide>{{printf "%.2f" .Hours}}</td>
<td class="js-cost">{{usd .CostUSD}}</td>
- <td class="js-idle">{{usd .IdleUSD}}</td>
- <td>
- <span class="bar"><span class="bar-fill" style="width:{{printf "%.0f" (mul .Utilization 100.0)}}%"></span></span>
- <span class="js-util-pct">{{pctf .Utilization}}</span>
- </td>
- <td>{{if .EgressMetered}}<span class="js-egress">metered</span>{{else}}<span class="js-egress chip chip-stale">unmetered</span>{{end}}</td>
- <td class="js-revenue">{{usd .RevenueUSD}}</td>
- <td class="js-profit">{{usd (sub .RevenueUSD .CostUSD)}}</td>
+ <td class="js-idle" co-m-hide>{{usd .IdleUSD}}</td>
+ <td>{{template "op_meter" (opFracMeter .Utilization (pctf .Utilization) "js-util-pct")}}</td>
+ <td co-m-hide>{{if .EgressMetered}}<span class="js-egress">metered</span>{{else}}<span class="js-egress">{{template "op_status" (opPill "unmetered" "warning")}}</span>{{end}}</td>
+ <td class="js-revenue" co-m-hide>{{usd .RevenueUSD}}</td>
+ <td class="js-profit" co-m-hide>{{usd (sub .RevenueUSD .CostUSD)}}</td>
</tr>
{{end}}
</table>
</div>
-{{else}}<p class="small">No box has published metrics this period.</p>{{end}}
+{{else}}<p co-note>No box has published metrics this period.</p>{{end}}
-<div id="econ-live">
+<div co-section id="econ-live">
{{$ec2 := sumBoxesEC2 .Economics.Boxes .Economics.Scenario.RateCard}}
{{$ebs := sumBoxesEBS .Economics.Boxes .Economics.Scenario.RateCard}}
{{$s3storage := mul (sumMeter .Economics.Meters "storage_gb_month") .Economics.Scenario.RateCard.StorageGBMonthUSD}}
@@ -168,16 +167,16 @@
{{$backhaul := mul $backhaulGB .Economics.Scenario.RateCard.InterRegionGBUSD}}
{{$overheads := overheadUSD .Economics.Scenario .Economics.PeriodDays}}
{{$modelTotal := add $ec2 $ebs $s3storage $s3requests $egress $backhaul $overheads}}
-<h2>Model vs. bill</h2>
-<div class="tablewrap">
-<table>
+<div rst-box-head><h2>Model vs. bill</h2></div>
+<div rst-card class="co-table-wrap">
+<table co-table>
<tr><th>Model component</th><th>USD</th></tr>
<tr><td>EC2 (box hours)</td><td id="model-ec2">{{usd $ec2}}</td></tr>
<tr><td>EBS</td><td id="model-ebs">{{usd $ebs}}</td></tr>
<tr><td>S3 storage</td><td id="model-s3-storage">{{usd $s3storage}}</td></tr>
<tr><td>S3 requests</td><td id="model-s3-requests">{{usd $s3requests}}</td></tr>
<tr><td>Egress</td><td id="model-egress">{{usd $egress}}</td></tr>
- <tr><td>Backhaul (inter-region leg) <span class="small">{{printf "%.2f" $backhaulGB}} GB{{with sumMeter .Economics.Meters "egress_gb"}}{{if gt . 0.0}} · {{printf "%.1f" (mul (div $backhaulGB .) 100.0)}}% of egress{{end}}{{end}} · absorbed, in no account's bill{{if and (gt $backhaulGB 0.0) (eq .Economics.Scenario.RateCard.InterRegionGBUSD 0.0)}} · <strong>rate unset</strong> — set "Inter-region $/GB" in the knobs{{end}}</span></td><td id="model-backhaul">{{usd $backhaul}}</td></tr>
+ <tr><td co-wrap>Backhaul (inter-region leg) <span co-note>{{printf "%.2f" $backhaulGB}} GB{{with sumMeter .Economics.Meters "egress_gb"}}{{if gt . 0.0}} · {{printf "%.1f" (mul (div $backhaulGB .) 100.0)}}% of egress{{end}}{{end}} · absorbed, in no account's bill{{if and (gt $backhaulGB 0.0) (eq .Economics.Scenario.RateCard.InterRegionGBUSD 0.0)}} · <strong>rate unset</strong> — set "Inter-region $/GB" in the knobs{{end}}</span></td><td id="model-backhaul">{{usd $backhaul}}</td></tr>
<tr><td>Overheads</td><td id="model-overheads">{{usd $overheads}}</td></tr>
<tr><th>Model total</th><th id="model-total">{{usd $modelTotal}}</th></tr>
</table>
@@ -209,8 +208,8 @@
a note that the all-unchecked view is live-only, not saveable. */}}
{{$billChecked := sumBillServicesChecked $curBill.Services .Economics.Scenario.BillServices}}
{{$delta := sub $billChecked $modelTotal}}
-<div class="tablewrap">
-<table>
+<div rst-card class="co-table-wrap">
+<table co-table>
<tr><th>Bill service ({{$curBill.Month}}, {{$curBill.Source}})</th><th>USD</th><th>Counts as CARLOS</th></tr>
{{range $svc, $amt := $curBill.Services}}
<tr>
@@ -224,22 +223,22 @@
</div>
<p>Delta, bill minus model: <strong id="breakdown-delta">{{usd $delta}}</strong></p>
{{else}}
-<p class="small">No bill on file for {{periodMonth .Economics.Period}} — enter one manually.</p>
-<form method="post" action="/fleet/economics/bill">
+<p co-note>No bill on file for {{periodMonth .Economics.Period}} — enter one manually.</p>
+<form rst-card co-pad co-knobs method="post" action="/fleet/economics/bill">
<input type="hidden" name="csrf" value="{{.CSRF}}">
- <div class="knob-row">
+ <div co-knob>
<label for="bill-month">Month</label>
- <input type="text" id="bill-month" name="month" pattern="\d{4}-\d{2}" value="{{periodMonth .Economics.Period}}" required>
+ <input rst-input type="text" id="bill-month" name="month" pattern="\d{4}-\d{2}" value="{{periodMonth .Economics.Period}}" required>
</div>
- <div class="knob-row">
+ <div co-knob>
<label for="bill-total">Total USD</label>
- <input type="number" step="0.01" min="0" id="bill-total" name="total" required>
+ <input rst-input type="number" step="0.01" min="0" id="bill-total" name="total" required>
</div>
- <div class="knob-row">
+ <div co-knob>
<label for="bill-lines">Services, one "Service=USD" per line</label>
</div>
- <p><textarea id="bill-lines" name="lines" rows="6" cols="48" placeholder="EC2=120.50&#10;S3=42.10"></textarea></p>
- <button type="submit">Save bill</button>
+ <p><textarea rst-textarea id="bill-lines" name="lines" rows="6" cols="48" placeholder="EC2=120.50&#10;S3=42.10"></textarea></p>
+ <button rst-btn type="submit">Save bill</button>
</form>
{{end}}
@@ -363,8 +362,8 @@
setCellText(row, ".js-cost", usd(alloc.totalUSD));
setCellText(row, ".js-idle", usd(alloc.idleUSD));
setCellText(row, ".js-util-pct", pctf(util));
- var fill = row.querySelector(".bar-fill");
- if (fill) { fill.style.width = Math.round(util * 100) + "%"; }
+ var fill = row.querySelector("[rst-meter-bar]");
+ if (fill) { fill.value = Math.round(util * 100); }
setCellText(row, ".js-revenue", usd(revenue));
setCellText(row, ".js-profit", usd(revenue - alloc.totalUSD));
});
@@ -411,7 +410,7 @@
}
})();
</script>
-{{template "bottom" .}}{{end}}
+{{template "op_bottom" .}}{{end}}
{{/* econ_knob_drawer: the "Pricing knobs" <details> — every rate-card,
allocation, mode/margin, rate-sheet and free-tier input, plus the
@@ -424,108 +423,108 @@
— reads .Economics.Scenario and .CSRF, exactly as when this was inline
in "economics". */}}
{{define "econ_knob_drawer"}}
-<details class="reveal" id="knob-drawer">
+<details rst-card co-pad co-knobs id="knob-drawer">
<summary>Pricing knobs</summary>
-<h3>Rate card &mdash; boxes</h3>
-<div class="tablewrap">
-<table>
+<h3 co-h3>Rate card &mdash; boxes</h3>
+<div class="co-table-wrap">
+<table co-table>
<tr><th>Box</th><th>$/hour</th><th>Cores</th><th>Mem GB</th><th>EBS GB</th></tr>
{{range $boxKey, $spec := .Economics.Scenario.RateCard.Boxes}}
<tr>
<td>{{if eq $boxKey ""}}default{{else}}{{$boxKey}}{{end}}</td>
- <td><input type="number" step="0.0001" min="0" data-box-key="{{$boxKey}}" data-field="hour_usd" value="{{$spec.HourUSD}}"></td>
- <td><input type="number" step="0.1" min="0" data-box-key="{{$boxKey}}" data-field="cores" value="{{$spec.Cores}}"></td>
- <td><input type="number" step="0.1" min="0" data-box-key="{{$boxKey}}" data-field="mem_gb" value="{{$spec.MemGB}}"></td>
- <td><input type="number" step="1" min="0" data-box-key="{{$boxKey}}" data-field="ebs_gb" value="{{$spec.EBSGB}}"></td>
+ <td><input rst-input type="number" step="0.0001" min="0" data-box-key="{{$boxKey}}" data-field="hour_usd" value="{{$spec.HourUSD}}"></td>
+ <td><input rst-input type="number" step="0.1" min="0" data-box-key="{{$boxKey}}" data-field="cores" value="{{$spec.Cores}}"></td>
+ <td><input rst-input type="number" step="0.1" min="0" data-box-key="{{$boxKey}}" data-field="mem_gb" value="{{$spec.MemGB}}"></td>
+ <td><input rst-input type="number" step="1" min="0" data-box-key="{{$boxKey}}" data-field="ebs_gb" value="{{$spec.EBSGB}}"></td>
</tr>
{{end}}
</table>
</div>
-<h3>Rate card &mdash; storage &amp; transfer</h3>
-<div class="knob-row"><label for="knob-ebs-gb-month-usd">EBS $/GB-month</label><input type="number" step="0.001" min="0" id="knob-ebs-gb-month-usd" value="{{.Economics.Scenario.RateCard.EBSGBMonthUSD}}"></div>
-<div class="knob-row"><label for="knob-storage-gb-month-usd">S3 storage $/GB-month</label><input type="number" step="0.001" min="0" id="knob-storage-gb-month-usd" value="{{.Economics.Scenario.RateCard.StorageGBMonthUSD}}"></div>
-<div class="knob-row"><label for="knob-requests-per-1k-usd">S3 requests $/1k</label><input type="number" step="0.001" min="0" id="knob-requests-per-1k-usd" value="{{.Economics.Scenario.RateCard.RequestsPer1kUSD}}"></div>
-<div class="knob-row"><label for="knob-egress-gb-usd">Egress $/GB</label><input type="number" step="0.001" min="0" id="knob-egress-gb-usd" value="{{.Economics.Scenario.RateCard.EgressGBUSD}}"></div>
-<div class="knob-row"><label for="knob-inter-region-gb-usd">Inter-region $/GB (backhaul leg)</label><input type="number" step="0.001" min="0" id="knob-inter-region-gb-usd" value="{{.Economics.Scenario.RateCard.InterRegionGBUSD}}"></div>
+<h3 co-h3>Rate card &mdash; storage &amp; transfer</h3>
+<div co-knob><label for="knob-ebs-gb-month-usd">EBS $/GB-month</label><input rst-input type="number" step="0.001" min="0" id="knob-ebs-gb-month-usd" value="{{.Economics.Scenario.RateCard.EBSGBMonthUSD}}"></div>
+<div co-knob><label for="knob-storage-gb-month-usd">S3 storage $/GB-month</label><input rst-input type="number" step="0.001" min="0" id="knob-storage-gb-month-usd" value="{{.Economics.Scenario.RateCard.StorageGBMonthUSD}}"></div>
+<div co-knob><label for="knob-requests-per-1k-usd">S3 requests $/1k</label><input rst-input type="number" step="0.001" min="0" id="knob-requests-per-1k-usd" value="{{.Economics.Scenario.RateCard.RequestsPer1kUSD}}"></div>
+<div co-knob><label for="knob-egress-gb-usd">Egress $/GB</label><input rst-input type="number" step="0.001" min="0" id="knob-egress-gb-usd" value="{{.Economics.Scenario.RateCard.EgressGBUSD}}"></div>
+<div co-knob><label for="knob-inter-region-gb-usd">Inter-region $/GB (backhaul leg)</label><input rst-input type="number" step="0.001" min="0" id="knob-inter-region-gb-usd" value="{{.Economics.Scenario.RateCard.InterRegionGBUSD}}"></div>
-<h3>Overheads</h3>
-<div class="tablewrap">
-<table>
+<h3 co-h3>Overheads</h3>
+<div class="co-table-wrap">
+<table co-table>
<tr><th>Line item</th><th>$/month</th></tr>
{{range $i, $li := .Economics.Scenario.RateCard.Overheads}}
- <tr><td>{{$li.Name}}</td><td><input type="number" step="0.01" min="0" class="knob-overhead" data-index="{{$i}}" value="{{$li.USDMonth}}"></td></tr>
+ <tr><td>{{$li.Name}}</td><td><input rst-input type="number" step="0.01" min="0" class="knob-overhead" data-index="{{$i}}" value="{{$li.USDMonth}}"></td></tr>
{{end}}
</table>
</div>
-<h3>Allocation</h3>
-<div class="knob-row">
+<h3 co-h3>Allocation</h3>
+<div co-knob>
<label>Policy</label>
<label><input type="radio" name="alloc-policy" value="cpu"{{if eq .Economics.Scenario.Allocation.Policy "cpu"}} checked{{end}}> CPU</label>
<label><input type="radio" name="alloc-policy" value="mem"{{if eq .Economics.Scenario.Allocation.Policy "mem"}} checked{{end}}> Memory</label>
<label><input type="radio" name="alloc-policy" value="blend"{{if eq .Economics.Scenario.Allocation.Policy "blend"}} checked{{end}}> Blend</label>
</div>
-<div class="knob-row"><label for="knob-cpu-weight">Blend CPU weight</label><input type="number" step="0.05" min="0" max="1" id="knob-cpu-weight" value="{{.Economics.Scenario.Allocation.CPUWeight}}"></div>
+<div co-knob><label for="knob-cpu-weight">Blend CPU weight</label><input rst-input type="number" step="0.05" min="0" max="1" id="knob-cpu-weight" value="{{.Economics.Scenario.Allocation.CPUWeight}}"></div>
-<h3>Mode &amp; margin</h3>
-<div class="knob-row">
+<h3 co-h3>Mode &amp; margin</h3>
+<div co-knob>
<label>Pricing mode</label>
<label><input type="radio" name="mode" value="cost-plus"{{if eq .Economics.Scenario.Mode "cost-plus"}} checked{{end}}> Cost-plus</label>
<label><input type="radio" name="mode" value="rate-sheet"{{if eq .Economics.Scenario.Mode "rate-sheet"}} checked{{end}}> Rate sheet</label>
</div>
-<div class="knob-row">
+<div co-knob>
<label for="knob-margin">Margin (cost-plus)</label>
<input type="range" id="knob-margin" min="0" max="0.95" step="0.01" value="{{.Economics.Scenario.Margin}}">
<span id="margin-multiple">{{marginMultiple .Economics.Scenario.Margin}}</span>
</div>
-<h3>Rate sheet</h3>
-<div class="knob-row"><label for="knob-sheet-app-month-usd">$/app-month</label><input type="number" step="0.01" min="0" id="knob-sheet-app-month-usd" value="{{.Economics.Scenario.Sheet.AppMonthUSD}}"></div>
-<div class="knob-row"><label for="knob-sheet-egress-gb-usd">$/GB egress</label><input type="number" step="0.01" min="0" id="knob-sheet-egress-gb-usd" value="{{.Economics.Scenario.Sheet.EgressGBUSD}}"></div>
-<div class="knob-row"><label for="knob-sheet-storage-gb-month-usd">$/GB-month storage</label><input type="number" step="0.01" min="0" id="knob-sheet-storage-gb-month-usd" value="{{.Economics.Scenario.Sheet.StorageGBMonthUSD}}"></div>
-<div class="knob-row"><label for="knob-sheet-instance-hour-usd">$/instance-hour</label><input type="number" step="0.001" min="0" id="knob-sheet-instance-hour-usd" value="{{.Economics.Scenario.Sheet.InstanceHourUSD}}"></div>
+<h3 co-h3>Rate sheet</h3>
+<div co-knob><label for="knob-sheet-app-month-usd">$/app-month</label><input rst-input type="number" step="0.01" min="0" id="knob-sheet-app-month-usd" value="{{.Economics.Scenario.Sheet.AppMonthUSD}}"></div>
+<div co-knob><label for="knob-sheet-egress-gb-usd">$/GB egress</label><input rst-input type="number" step="0.01" min="0" id="knob-sheet-egress-gb-usd" value="{{.Economics.Scenario.Sheet.EgressGBUSD}}"></div>
+<div co-knob><label for="knob-sheet-storage-gb-month-usd">$/GB-month storage</label><input rst-input type="number" step="0.01" min="0" id="knob-sheet-storage-gb-month-usd" value="{{.Economics.Scenario.Sheet.StorageGBMonthUSD}}"></div>
+<div co-knob><label for="knob-sheet-instance-hour-usd">$/instance-hour</label><input rst-input type="number" step="0.001" min="0" id="knob-sheet-instance-hour-usd" value="{{.Economics.Scenario.Sheet.InstanceHourUSD}}"></div>
{{/* economics-v2 (Task 6): fleet box + mem-overage rate-sheet knobs — the
same three RateSheet fields compute.go's PriceAccount reads under
fleetRevenue and the rate-sheet mem-overage term, both modes. */}}
-<div class="knob-row"><label for="knob-sheet-box-month-server-usd">$/box-month (server)</label><input type="number" step="0.01" min="0" id="knob-sheet-box-month-server-usd" value="{{.Economics.Scenario.Sheet.BoxMonthServerUSD}}"></div>
-<div class="knob-row"><label for="knob-sheet-box-month-device-usd">$/box-month (device)</label><input type="number" step="0.01" min="0" id="knob-sheet-box-month-device-usd" value="{{.Economics.Scenario.Sheet.BoxMonthDeviceUSD}}"></div>
-<div class="knob-row"><label for="knob-sheet-mem-gb-hour-usd">$/GB-hour mem overage (rate-sheet)</label><input type="number" step="0.001" min="0" id="knob-sheet-mem-gb-hour-usd" value="{{.Economics.Scenario.Sheet.MemGBHourUSD}}"></div>
-
-<h3>Fleet volume break</h3>
-<div class="knob-row"><label for="knob-fleet-break-min-boxes">Min avg boxes/month</label><input type="number" step="0.1" min="0" id="knob-fleet-break-min-boxes" value="{{.Economics.Scenario.FleetBreak.MinBoxes}}"></div>
-<div class="knob-row"><label for="knob-fleet-break-discount">Discount at/above min</label><input type="number" step="0.01" min="0" max="0.99" id="knob-fleet-break-discount" value="{{.Economics.Scenario.FleetBreak.Discount}}"></div>
-
-<h3>Fleet pool</h3>
-<div class="knob-row"><label for="knob-pool-revenue-frac">Revenue share to pool</label><input type="number" step="0.01" min="0" max="1" id="knob-pool-revenue-frac" value="{{.Economics.Scenario.Pool.RevenueFrac}}"></div>
-<div class="knob-row"><label for="knob-pool-topup-usd">Monthly top-up $</label><input type="number" step="0.01" min="0" id="knob-pool-topup-usd" value="{{.Economics.Scenario.Pool.TopupUSD}}"></div>
-
-<h3>Free tier</h3>
-<div class="knob-row"><label for="knob-ft-apps">Apps</label><input type="number" step="1" min="0" id="knob-ft-apps" value="{{.Economics.Scenario.FreeTier.Apps}}"></div>
-<div class="knob-row"><label for="knob-ft-egress-gb">Egress GB</label><input type="number" step="1" min="0" id="knob-ft-egress-gb" value="{{.Economics.Scenario.FreeTier.EgressGB}}"></div>
-<div class="knob-row"><label for="knob-ft-mem-gb-hours">Mem GB-hours</label><input type="number" step="1" min="0" id="knob-ft-mem-gb-hours" value="{{.Economics.Scenario.FreeTier.MemGBHours}}"></div>
-<div class="knob-row"><label for="knob-ft-storage-gb">Storage GB</label><input type="number" step="1" min="0" id="knob-ft-storage-gb" value="{{.Economics.Scenario.FreeTier.StorageGB}}"></div>
-
-<h3>Save as scenario</h3>
-<p class="small">With JavaScript on, this saves the knobs above exactly as tweaked. With it off, this round-trips the currently active scenario unchanged, under a new name and/or activated. Saving from either page lands back on the dashboard (/fleet/economics) — the one save door both pages share.</p>
+<div co-knob><label for="knob-sheet-box-month-server-usd">$/box-month (server)</label><input rst-input type="number" step="0.01" min="0" id="knob-sheet-box-month-server-usd" value="{{.Economics.Scenario.Sheet.BoxMonthServerUSD}}"></div>
+<div co-knob><label for="knob-sheet-box-month-device-usd">$/box-month (device)</label><input rst-input type="number" step="0.01" min="0" id="knob-sheet-box-month-device-usd" value="{{.Economics.Scenario.Sheet.BoxMonthDeviceUSD}}"></div>
+<div co-knob><label for="knob-sheet-mem-gb-hour-usd">$/GB-hour mem overage (rate-sheet)</label><input rst-input type="number" step="0.001" min="0" id="knob-sheet-mem-gb-hour-usd" value="{{.Economics.Scenario.Sheet.MemGBHourUSD}}"></div>
+
+<h3 co-h3>Fleet volume break</h3>
+<div co-knob><label for="knob-fleet-break-min-boxes">Min avg boxes/month</label><input rst-input type="number" step="0.1" min="0" id="knob-fleet-break-min-boxes" value="{{.Economics.Scenario.FleetBreak.MinBoxes}}"></div>
+<div co-knob><label for="knob-fleet-break-discount">Discount at/above min</label><input rst-input type="number" step="0.01" min="0" max="0.99" id="knob-fleet-break-discount" value="{{.Economics.Scenario.FleetBreak.Discount}}"></div>
+
+<h3 co-h3>Fleet pool</h3>
+<div co-knob><label for="knob-pool-revenue-frac">Revenue share to pool</label><input rst-input type="number" step="0.01" min="0" max="1" id="knob-pool-revenue-frac" value="{{.Economics.Scenario.Pool.RevenueFrac}}"></div>
+<div co-knob><label for="knob-pool-topup-usd">Monthly top-up $</label><input rst-input type="number" step="0.01" min="0" id="knob-pool-topup-usd" value="{{.Economics.Scenario.Pool.TopupUSD}}"></div>
+
+<h3 co-h3>Free tier</h3>
+<div co-knob><label for="knob-ft-apps">Apps</label><input rst-input type="number" step="1" min="0" id="knob-ft-apps" value="{{.Economics.Scenario.FreeTier.Apps}}"></div>
+<div co-knob><label for="knob-ft-egress-gb">Egress GB</label><input rst-input type="number" step="1" min="0" id="knob-ft-egress-gb" value="{{.Economics.Scenario.FreeTier.EgressGB}}"></div>
+<div co-knob><label for="knob-ft-mem-gb-hours">Mem GB-hours</label><input rst-input type="number" step="1" min="0" id="knob-ft-mem-gb-hours" value="{{.Economics.Scenario.FreeTier.MemGBHours}}"></div>
+<div co-knob><label for="knob-ft-storage-gb">Storage GB</label><input rst-input type="number" step="1" min="0" id="knob-ft-storage-gb" value="{{.Economics.Scenario.FreeTier.StorageGB}}"></div>
+
+<h3 co-h3>Save as scenario</h3>
+<p co-note>With JavaScript on, this saves the knobs above exactly as tweaked. With it off, this round-trips the currently active scenario unchanged, under a new name and/or activated. Saving from either page lands back on the dashboard (/fleet/economics) — the one save door both pages share.</p>
<form method="post" action="/fleet/economics/scenarios">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<input type="hidden" name="scenario" id="scenario-json-field" value="{{scenarioJSON .Economics.Scenario}}">
- <div class="knob-row">
+ <div co-knob>
<label for="scenario-name">Name</label>
- <input type="text" id="scenario-name" name="name" pattern="[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?" required>
+ <input rst-input type="text" id="scenario-name" name="name" pattern="[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?" required>
</div>
<label><input type="checkbox" name="activate" value="1"> Activate</label>
- <button type="submit">Save scenario</button>
- {{/* Hidden by default; the inline script shows it (display:"") exactly
+ <button rst-btn type="submit">Save scenario</button>
+ {{/* Hidden by default; the inline script shows it (.hidden = false) exactly
when every "counts as CARLOS" checkbox is unchecked — the state the
save field refuses to persist (see the template comment by the bill
table). Only /fleet/economics ever has bill checkboxes on screen, so
this note only ever becomes visible there — but the element must
exist on both pages: setBillServicesZeroNote (econ_maths_js) looks
it up by id and simply no-ops via its `if (el)` guard when absent. */}}
- <p class="small error" id="bill-services-zero-note" style="display:none">At least one service must count — unchecking all shows a zero model line but is not saveable as a selection.</p>
+ <p co-note co-neg id="bill-services-zero-note" hidden>At least one service must count — unchecking all shows a zero model line but is not saveable as a selection.</p>
</form>
</details>
{{end}}
@@ -557,7 +556,7 @@
: null;
function setBillServicesZeroNote(show) {
var el = document.getElementById("bill-services-zero-note");
- if (el) { el.style.display = show ? "" : "none"; }
+ if (el) { el.hidden = !show; }
}
// HoursPerMonth mirrors internal/economics/compute.go's exported constant
@@ -888,3 +887,9 @@
return sc;
}
{{end}}
+
+{{/* econ_warnings: the economics view's two warnings, as negative
+ callouts, on both economics pages. Takes the page. */}}
+{{define "econ_warnings"}}{{if .Economics.Warning}}<div rst-callout rst-tone="negative"><span rst-callout-ic aria-hidden="true">{{icon "triangle-alert"}}</span><div rst-callout-body><p>{{.Economics.Warning}}</p></div></div>
+{{end}}{{if .Economics.ScenarioWarning}}<div rst-callout rst-tone="negative"><span rst-callout-ic aria-hidden="true">{{icon "triangle-alert"}}</span><div rst-callout-body><p>{{.Economics.ScenarioWarning}}</p></div></div>
+{{end}}{{end}}
diff --git a/internal/console/templates/economics_accounts.html b/internal/console/templates/economics_accounts.html
index 5456560a7..69ef7d537 100644
--- a/internal/console/templates/economics_accounts.html
+++ b/internal/console/templates/economics_accounts.html
@@ -32,68 +32,54 @@
Tier column (Task 6) — an account's fleet-pool tier is an operator
assignment via the per-row form below, not something a scenario knob
can move. */}}
-{{define "economics_accounts"}}{{template "top" .}}
-<h1>Fleet economics: accounts</h1>
-{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}}
-{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}}
-{{if .Economics.Warning}}<p class="banner error">{{icon "triangle-alert"}} {{.Economics.Warning}}</p>{{end}}
-{{if .Economics.ScenarioWarning}}<p class="banner error">{{icon "triangle-alert"}} {{.Economics.ScenarioWarning}}</p>{{end}}
+{{define "economics_accounts"}}{{template "op_top" .}}
+{{template "op_page_header" (opHeader .Title "Platform costs and revenue.")}}
+{{template "op_seg_tabs" .EconTabs}}
+{{template "op_flash" .}}
+{{template "econ_warnings" .}}
-<p class="small">Generated {{fmtTime .Economics.GeneratedAt}} &middot; scenario <strong>{{.Economics.Scenario.Name}}</strong> ({{.Economics.Scenario.Mode}}) &middot; {{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
+<p co-note>Generated {{fmtTime .Economics.GeneratedAt}} &middot; scenario <strong>{{.Economics.Scenario.Name}}</strong> ({{.Economics.Scenario.Mode}}) &middot; {{.Economics.CoveredDays}}/{{.Economics.PeriodDays}} days metered</p>
{{/* Period nav: switching period keeps the operator's search/filter
(Q/Pos) — econPeriodURL — but drops any cursor, since a cursor resumes
an account-name position computed against ONE period's row order and
means nothing against another period's. */}}
-<nav class="small" aria-label="Period">
+<nav co-period aria-label="Period">
Period:
<a href="{{econPeriodURL .EconQuery "mtd"}}"{{if eq .Economics.Period "mtd"}} aria-current="page"{{end}}>Month to date</a> &middot;
<a href="{{econPeriodURL .EconQuery "last"}}"{{if eq .Economics.Period "last"}} aria-current="page"{{end}}>Last month</a> &middot;
<a href="{{econPeriodURL .EconQuery "7d"}}"{{if eq .Economics.Period "7d"}} aria-current="page"{{end}}>Last 7 days</a>
</nav>
-<p class="small"><a href="/fleet/economics">&larr; Back to the dashboard</a></p>
+{{/* One card: the list bar (econListBar, opeconomics.go: the search, the
+ position filter and a non-default period carried as hidden fields,
+ "mtd" being what an absent "period" param already means, and the
+ position dropdown), then the table or the no-match line. With no
+ rows and no filter there is no card, only the no-accounts note. */}}
{{if or .EconAccounts.Rows .EconQuery.Q .EconQuery.Pos}}
-{{/* The hidden period field only needs to exist for a non-default period:
- "mtd" is what an absent "period" param already means, matching
- econLinkURL/econPeriodURL's own "omit when mtd" rule — so a search
- submitted on the default period doesn't grow a redundant ?period=mtd
- into every subsequent link. */}}
-<form method="get" class="listctl">
- <input type="search" name="q" value="{{.EconQuery.Q}}" placeholder="Filter accounts" aria-label="Filter accounts">
- {{if .EconQuery.Pos}}<input type="hidden" name="pos" value="{{.EconQuery.Pos}}">{{end}}
- {{if ne .EconQuery.Period "mtd"}}<input type="hidden" name="period" value="{{.EconQuery.Period}}">{{end}}
- <button>Filter</button>
-</form>
-<p class="small">
- <a href="{{.EconAccounts.AllURL}}"{{if not .EconQuery.Pos}} aria-current="true"{{end}}>All</a>
- {{range .EconAccounts.Links}}
- &middot; <a href="{{.Href}}"{{if .Active}} aria-current="true"{{end}}>{{.Word}} {{.Count}}</a>
- {{end}}
-</p>
-{{end}}
-
+<div rst-card>
+{{template "op_list_bar" .EconBar}}
{{if .EconAccounts.Rows}}
-<div class="tablewrap">
-<table>
+<div class="co-table-wrap">
+<table co-table co-dense>
<tr>
<th scope="col">Account</th>
- <th scope="col">App-months</th>
- <th scope="col">Instance-hours</th>
- <th scope="col">CPU-h</th>
- <th scope="col">GB-h</th>
- <th scope="col">Egress GB</th>
- <th scope="col" title="the part of Egress GB that left its home box for a region edge first — the inter-region leg is a platform cost, absorbed, in no account's bill">Backhaul GB</th>
- <th scope="col">Storage GB-month</th>
+ <th scope="col" co-m-hide>App-months</th>
+ <th scope="col" co-m-hide>Instance-hours</th>
+ <th scope="col" co-m-hide co-nowrap>CPU-h</th>
+ <th scope="col" co-m-hide co-nowrap>GB-h</th>
+ <th scope="col" co-m-hide>Egress GB</th>
+ <th scope="col" co-m-hide title="the part of Egress GB that left its home box for a region edge first — the inter-region leg is a platform cost, absorbed, in no account's bill">Backhaul GB</th>
+ <th scope="col" co-m-hide>Storage GB-month</th>
<th scope="col">Cost</th>
<th scope="col">Would-be revenue</th>
- <th scope="col" title="Pooled rows (free-tier position &quot;pooled&quot;) show an em-dash: their revenue is shared through the fleet pool, not individually priced, so a margin fraction has nothing to divide. Fleet-tier rows can legitimately show 100%: fleet boxes are customer-owned hardware, zero cost to the platform, by design.">Margin</th>
- <th scope="col">Free tier</th>
+ <th scope="col" co-m-hide title="Pooled rows (free-tier position &quot;pooled&quot;) show an em-dash: their revenue is shared through the fleet pool, not individually priced, so a margin fraction has nothing to divide. Fleet-tier rows can legitimately show 100%: fleet boxes are customer-owned hardware, zero cost to the platform, by design.">Margin</th>
+ <th scope="col" co-m-hide>Free tier</th>
{{/* Tier (Task 6): the operator's fleet-pool ASSIGNMENT for this
account (store.go's validAccountTiers), distinct from the Free
tier column's PRICED POSITION — "pooled" over there can come from
any of try/pool/"" here. */}}
- <th scope="col">Tier</th>
+ <th scope="col" co-m-hide>Tier</th>
</tr>
{{range .EconAccounts.Rows}}
{{$tier := index $.Economics.Tiers .Account}}
@@ -113,34 +99,34 @@
already IS the muted treatment (layout.html: font-size 0.9rem,
color var(--muted); there is no separate ".muted" class anywhere in
these templates, so this reuses ".small" rather than inventing
- one). A usage-only ghost row (no console account row at all, so
+ one; in the operator shell it is the [co-note] attribute). A usage-only ghost row (no console account row at all, so
.Name is "") or an explicitly empty name renders the bare sqid
alone, exactly as before this batch. The row's data-account
attribute above and every other field on this row (the tier form
below) still key off .Account, the sqid — display only. */}}
- <td>{{if .Name}}{{.Name}} <span class="small">{{.Account}}</span>{{else}}{{.Account}}{{end}}</td>
- <td>{{printf "%.2f" (index .Meters "app_months")}}</td>
- <td>{{printf "%.2f" (index .Meters "instance_hours")}}</td>
- <td>{{printf "%.2f" (index .Meters "cpu_core_hours")}}</td>
- <td>{{printf "%.2f" (index .Meters "mem_gb_hours")}}</td>
- <td>{{printf "%.2f" (index .Meters "egress_gb")}}</td>
- <td>{{printf "%.2f" (index .Meters "backhaul_gb")}}</td>
- <td>{{printf "%.2f" (index .Meters "storage_gb_month")}}</td>
+ <td>{{if .Name}}{{.Name}} <span co-note>{{.Account}}</span>{{else}}{{.Account}}{{end}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "app_months")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "instance_hours")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "cpu_core_hours")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "mem_gb_hours")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "egress_gb")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "backhaul_gb")}}</td>
+ <td co-m-hide>{{printf "%.2f" (index .Meters "storage_gb_month")}}</td>
<td class="js-acct-cost">{{usd .Econ.CostUSD}}</td>
<td class="js-acct-revenue">{{usd .Econ.RevenueUSD}}</td>
- <td class="js-acct-margin">{{marginCell .Econ.MarginFrac .Econ.FreeTierPos}}</td>
- <td class="js-acct-freetier"><span class="chip chip-freetier-{{.Econ.FreeTierPos}}">{{.Econ.FreeTierPos}}</span></td>
- <td>
- <span class="chip chip-tier-{{tierWord $tier}}">{{tierWord $tier}}</span>
+ <td class="js-acct-margin" co-m-hide>{{marginCell .Econ.MarginFrac .Econ.FreeTierPos}}</td>
+ <td class="js-acct-freetier" co-m-hide>{{template "op_status" (opPill .Econ.FreeTierPos (freeTierTone .Econ.FreeTierPos))}}</td>
+ <td co-m-hide>
+ {{template "op_status" (opPill (tierWord $tier) (tierTone (tierWord $tier)))}}
{{if $known}}
{{/* Progressive: a plain <select> + submit button, no JS required —
the door (POST /fleet/economics/tier, handleEconomicsTierSave)
already exists (Task 4/5). Only rendered for a REAL console
account (see $known's doc comment above). */}}
- <form method="post" action="/fleet/economics/tier">
+ <form co-tier method="post" action="/fleet/economics/tier">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<input type="hidden" name="account" value="{{.Account}}">
- <select name="tier">
+ <select rst-input name="tier">
<option value=""{{if eq $tier ""}} selected{{end}}>unassigned</option>
<option value="try"{{if eq $tier "try"}} selected{{end}}>try</option>
<option value="pool"{{if eq $tier "pool"}} selected{{end}}>pool</option>
@@ -148,7 +134,7 @@
<option value="fleet"{{if eq $tier "fleet"}} selected{{end}}>fleet</option>
<option value="dedicated"{{if eq $tier "dedicated"}} selected{{end}}>dedicated</option>
</select>
- <button type="submit">Set</button>
+ <button rst-btn="sm" type="submit">Set</button>
</form>
{{end}}
</td>
@@ -156,7 +142,13 @@
{{end}}
</table>
</div>
-<p class="small">App-months and instance-hours are accumulators, not live counts —
+{{else}}
+{{template "op_empty" (opEmpty "" "No accounts match.")}}
+{{end}}
+</div>
+{{end}}
+{{if .EconAccounts.Rows}}
+<p co-note>App-months and instance-hours are accumulators, not live counts —
a fraction of a calendar month and a sum of hours run, the meters this platform
actually keeps. CPU-h/GB-h are box-side compute meters; egress and storage are
edge/S3 meters. Cost and would-be revenue are this account's own share plus its
@@ -164,12 +156,10 @@ allocated box cost, under the active scenario.</p>
{{/* MINOR 3 (fix round, Task 6 review): the Margin column's title=
tooltip is invisible on touch/keyboard — this legend carries the
same two notes visibly, for everyone. */}}
-<p class="small">Margin: pooled rows show an em-dash — their revenue is shared through the fleet pool, not individually priced. Fleet-tier rows can legitimately show 100% margin — fleet boxes are customer-owned hardware, zero cost to the platform, by design.</p>
-{{if .EconAccounts.NextURL}}<p class="small"><a href="{{.EconAccounts.NextURL}}">Next {{len .EconAccounts.Rows}} shown of {{.EconAccounts.Total}} &rarr;</a></p>{{end}}
-{{else if or .EconQuery.Q .EconQuery.Pos}}
-<p>No accounts match.</p>
-{{else}}
-<p class="small">No accounts to price this period.</p>
+<p co-note>Margin: pooled rows show an em-dash — their revenue is shared through the fleet pool, not individually priced. Fleet-tier rows can legitimately show 100% margin — fleet boxes are customer-owned hardware, zero cost to the platform, by design.</p>
+{{if .EconAccounts.NextURL}}<p co-note><a href="{{.EconAccounts.NextURL}}">Next {{len .EconAccounts.Rows}} shown of {{.EconAccounts.Total}} &rarr;</a></p>{{end}}
+{{else if not (or .EconQuery.Q .EconQuery.Pos)}}
+<p co-note>No accounts to price this period.</p>
{{end}}
<div id="econ-live">
@@ -189,6 +179,14 @@ allocated box cost, under the active scenario.</p>
{{template "econ_maths_js" .}}
+ // freeTierTone is the Go function of the same name (opeconomics.go):
+ // the tone of a re-priced row's free-tier pill.
+ function freeTierTone(pos) {
+ if (pos === "inside") { return "warning"; }
+ if (pos === "paying") { return "positive"; }
+ return "neutral";
+ }
+
// recompute re-prices only the account rows THIS page rendered (its one
// page of up to econAccountPageSize accounts) — allocateBox still runs
// over the FULL payload.boxLoads/totalAllocated (a row's allocated cost
@@ -223,10 +221,10 @@ allocated box cost, under the active scenario.</p>
setCellText(row, ".js-acct-cost", usd(a.costUSD));
setCellText(row, ".js-acct-revenue", usd(a.revenueUSD));
setCellText(row, ".js-acct-margin", marginCell(a.marginFrac, a.freeTierPos));
- var chip = row.querySelector(".js-acct-freetier .chip");
+ var chip = row.querySelector(".js-acct-freetier [rst-status]");
if (chip) {
chip.textContent = a.freeTierPos;
- chip.className = "chip chip-freetier-" + a.freeTierPos;
+ chip.setAttribute("rst-tone", freeTierTone(a.freeTierPos));
}
});
@@ -241,4 +239,4 @@ allocated box cost, under the active scenario.</p>
}
})();
</script>
-{{template "bottom" .}}{{end}}
+{{template "op_bottom" .}}{{end}}
diff --git a/internal/console/templates/metrics.html b/internal/console/templates/metrics.html
index 3ca1b8b2d..3c977a3dc 100644
--- a/internal/console/templates/metrics.html
+++ b/internal/console/templates/metrics.html
@@ -1,17 +1,22 @@
-{{define "metrics"}}{{template "top" .}}
-<h1>Fleet metrics</h1>
+{{/* /fleet/metrics (server.go's handleFleetMetrics): the firing alerts,
+ each box's headline readings and units, and the console's own speed,
+ in the operator shell. The words are the page's from before the shell.
+ Each box's readings are op_stat's markup written out, because each
+ carries its sparkline, which op_stat has no place for. */}}
+{{define "metrics"}}{{template "op_top" .}}
+{{template "op_page_header" (opHeader .Title "How each box is doing and how quickly this console responds.")}}
{{if .MetricAlerts}}
-<h2 class="error">Alerts</h2>
-<div class="tablewrap">
-<table>
- <tr><th>Box</th><th>Rule</th><th>Value</th><th>Fired</th></tr>
+<div rst-box-head><h2 co-neg>Alerts</h2></div>
+<div rst-card class="co-table-wrap">
+<table co-table>
+ <tr><th>Box</th><th>Rule</th><th>Value</th><th co-m-hide>Fired</th></tr>
{{range .MetricAlerts}}
<tr>
<td>{{.Box}}</td>
<td>{{.Rule}}</td>
- <td class="error">{{alertVal .Rule .Value}}</td>
- <td>{{fmtTime .FiredAt}}</td>
+ <td co-neg>{{alertVal .Rule .Value}}</td>
+ <td co-m-hide>{{fmtTime .FiredAt}}</td>
</tr>
{{end}}
</table>
@@ -20,65 +25,53 @@
{{if .Metrics}}
{{range .Metrics}}
-<h2>{{.Box}}</h2>
-<p class="small">Latest {{fmtTime .At}}</p>
-<section class="tiles" aria-label="{{.Box}} headline metrics">
- <div class="tile">
- <h2>CPU</h2>
- <p class="tile-value">{{pct .CPU}}</p>
- <svg viewBox="0 0 240 40"><polyline fill="none" stroke="currentColor" points="{{.SparkCPU}}"/></svg>
- </div>
- <div class="tile">
- <h2>Memory</h2>
- <p class="tile-value">{{pct .Mem}}</p>
- <svg viewBox="0 0 240 40"><polyline fill="none" stroke="currentColor" points="{{.SparkMem}}"/></svg>
- </div>
- <div class="tile">
- <h2>Disk</h2>
- <p class="tile-value">{{pct .Disk}}</p>
- <svg viewBox="0 0 240 40"><polyline fill="none" stroke="currentColor" points="{{.SparkDisk}}"/></svg>
- </div>
+<div rst-box-head><h2>{{.Box}}</h2></div>
+<p co-note>Latest {{fmtTime .At}}</p>
+<section rst-stats co-spark-stats aria-label="{{.Box}} headline metrics">
+ <div rst-stat><span rst-stat-label>CPU</span><span rst-stat-num>{{pct .CPU}}</span><svg co-spark viewBox="0 0 240 40" aria-hidden="true"><polyline fill="none" stroke="currentColor" points="{{.SparkCPU}}"/></svg></div>
+ <div rst-stat><span rst-stat-label>Memory</span><span rst-stat-num>{{pct .Mem}}</span><svg co-spark viewBox="0 0 240 40" aria-hidden="true"><polyline fill="none" stroke="currentColor" points="{{.SparkMem}}"/></svg></div>
+ <div rst-stat><span rst-stat-label>Disk</span><span rst-stat-num>{{pct .Disk}}</span><svg co-spark viewBox="0 0 240 40" aria-hidden="true"><polyline fill="none" stroke="currentColor" points="{{.SparkDisk}}"/></svg></div>
</section>
{{if .Units}}
-<div class="tablewrap">
-<table>
- <tr><th>Unit</th><th>CPU</th><th>Memory</th><th>IO</th></tr>
+<div rst-card class="co-table-wrap">
+<table co-table>
+ <tr><th>Unit</th><th>CPU</th><th>Memory</th><th co-m-hide>IO</th></tr>
{{range .Units}}
<tr>
<td>{{.Unit}}</td>
<td>{{pct .CPUFrac}}</td>
<td>{{bytesOrDash .MemBytes}}</td>
- <td>R {{bytesOrDash .ReadBytes}} &middot; W {{bytesOrDash .WriteBytes}}</td>
+ <td co-m-hide>R {{bytesOrDash .ReadBytes}} &middot; W {{bytesOrDash .WriteBytes}}</td>
</tr>
{{end}}
</table>
</div>
-{{else}}<p class="small">No units reporting for this box.</p>{{end}}
+{{else}}<p co-note>No units reporting for this box.</p>{{end}}
{{end}}
{{else}}
-<p>No boxes have published metrics yet.</p>
+{{template "op_empty" (opEmpty "" "No boxes have published metrics yet.")}}
{{end}}
-<section aria-labelledby="console-speed">
-<h2 id="console-speed">Console speed</h2>
-<p class="small">How long the console took to send the first byte of each page over its last 2,048 requests. Pages should answer within 150 ms.</p>
+<section co-section aria-labelledby="console-speed">
+<div rst-box-head><h2 id="console-speed">Console speed</h2></div>
+<p co-note>How long the console took to send the first byte of each page over its last 2,048 requests. Pages should answer within 150 ms.</p>
{{if .ConsoleSpeed}}
-<div class="tablewrap">
-<table>
- <tr><th>Route</th><th>Requests</th><th>Over 150 ms</th><th>p50</th><th>p95</th><th>S3 requests</th></tr>
+<div rst-card class="co-table-wrap">
+<table co-table>
+ <tr><th>Route</th><th co-m-hide>Requests</th><th>Over 150 ms</th><th co-m-hide>p50</th><th>p95</th><th co-m-hide>S3 requests</th></tr>
{{range .ConsoleSpeed}}
<tr>
<td>{{.Route}}</td>
- <td>{{.Requests}}</td>
+ <td co-m-hide>{{.Requests}}</td>
<td>{{.Over}}</td>
- <td>{{.P50}}</td>
+ <td co-m-hide>{{.P50}}</td>
<td>{{.P95}}</td>
- <td>{{.S3}}</td>
+ <td co-m-hide>{{.S3}}</td>
</tr>
{{end}}
</table>
</div>
-{{else}}<p>No requests measured since the console started.</p>{{end}}
-<p class="small">The console has made {{.ConsoleS3Background}} S3 requests that no page request caused since it started.</p>
+{{else}}{{template "op_empty" (opEmpty "" "No requests measured since the console started.")}}{{end}}
+<p co-note>The console has made {{.ConsoleS3Background}} S3 requests that no page request caused since it started.</p>
</section>
-{{template "bottom" .}}{{end}}
+{{template "op_bottom" .}}{{end}}
diff --git a/internal/console/templates/opparts.html b/internal/console/templates/opparts.html
index 29ab36068..b9e019ce4 100644
--- a/internal/console/templates/opparts.html
+++ b/internal/console/templates/opparts.html
@@ -32,7 +32,7 @@
{{/* meter: a capacity bar beside its text. The text is what a reader gets;
the bar is decoration over it, hence aria-hidden. */}}
-{{define "op_meter"}}{{$p := .Percent}}{{if lt $p 0}}{{$p = 0}}{{end}}{{if gt $p 100}}{{$p = 100}}{{end}}<span rst-meter><meter rst-meter-bar value="{{$p}}" min="0" max="100" aria-hidden="true"></meter><span rst-meter-num>{{.Text}}</span></span>{{end}}
+{{define "op_meter"}}{{$p := .Percent}}{{if lt $p 0}}{{$p = 0}}{{end}}{{if gt $p 100}}{{$p = 100}}{{end}}<span rst-meter><meter rst-meter-bar value="{{$p}}" min="0" max="100" aria-hidden="true"></meter><span rst-meter-num{{with .NumClass}} class="{{.}}"{{end}}>{{.Text}}</span></span>{{end}}
{{/* seg-tabs: a segmented control of server-rendered links. */}}
{{define "op_seg_tabs"}}<nav rst-seg-tabs aria-label="{{.Label}}">{{range .Items}}<a href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{.Label}}</a>{{end}}</nav>{{end}}
@@ -61,13 +61,20 @@
{{- range .Hidden}}
<input type="hidden" name="{{index . 0}}" value="{{index . 1}}">
{{- end}}
- <button class="rst-sr-only" type="submit">Search</button>
+ <button class="rst-sr-only" type="submit">{{if .Submit}}{{.Submit}}{{else}}Search{{end}}</button>
</form></search>
{{- with .Filter}}
{{template "op_dropdown" .}}
{{- end}}
</div>{{end}}
+{{/* flash: the page's one-shot notice and error, as Rastrillo callouts
+ (info and negative), from the page's Flash and FlashErr. Takes the
+ page. */}}
+{{define "op_flash"}}{{if .Flash}}<div rst-callout rst-tone="info"><span rst-callout-ic aria-hidden="true">{{icon "info"}}</span><div rst-callout-body><p>{{.Flash}}</p></div></div>
+{{end}}{{if .FlashErr}}<div rst-callout rst-tone="negative"><span rst-callout-ic aria-hidden="true">{{icon "triangle-alert"}}</span><div rst-callout-body><p>{{.FlashErr}}</p></div></div>
+{{end}}{{end}}
+
{{/* pagination: a strip of ordinary page links. The current page is
aria-current and filled; a disabled item is a plain span. */}}
{{define "op_pagination"}}<nav rst-pagination aria-label="{{if .Label}}{{.Label}}{{else}}Pages{{end}}">