create-pmos 0.397.0 → 0.398.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +101 -52
- package/workspace/briefing-premium-board-test.js +252 -128
- package/workspace/briefing-premium-calendar-2-test.js +135 -198
- package/workspace/briefing-premium-calendar-3-test.js +143 -418
- package/workspace/briefing-premium-calendar-test.js +86 -196
- package/workspace/briefing-premium-doc-edit-test.js +95 -83
- package/workspace/briefing-premium-initiative-test.js +159 -296
- package/workspace/briefing-premium-insights-test.js +337 -219
- package/workspace/briefing-premium-metrics-test.js +53 -97
- package/workspace/briefing-premium-products-test.js +40 -27
- package/workspace/briefing-premium-sources-test.js +66 -48
- package/workspace/briefing-premium-test.js +150 -647
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +12 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +47 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-premium.js +85 -19
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +62 -14
- package/workspace/lib/insights-records.js +101 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-insights-premium.js +12 -3
- package/workspace/lib/routes-insights-records.js +129 -0
- package/workspace/lib/routes-notes.js +1 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/transcript-steps.js +123 -0
- package/workspace/lib/viewer-meeting.js +205 -0
- package/workspace/lib/viewer-report.js +89 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +85 -75
- package/workspace/premium-briefing-depth-test.js +66 -53
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +35 -37
- package/workspace/premium-chat-context-test.js +19 -18
- package/workspace/premium-chat-goal-view-test.js +23 -23
- package/workspace/premium-chat-notes-test.js +26 -31
- package/workspace/premium-chat-report-tab-test.js +32 -28
- package/workspace/premium-chat-term-test.js +16 -16
- package/workspace/premium-chat-viewer-test.js +60 -59
- package/workspace/premium-core-doc-issue-test.js +50 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +7 -2
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +115 -197
- package/workspace/premium-viewer-download-test.js +19 -22
- package/workspace/premium-viewer-flicker-test.js +11 -16
- package/workspace/premium-viewer-share-test.js +6 -9
- package/workspace/premium-viewer-test.js +41 -60
- package/workspace/premium-vw-backlog-test.js +53 -33
- package/workspace/premium-vw-cal-test.js +82 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +11 -10
- package/workspace/premium-vw-item-test.js +50 -49
- package/workspace/premium-vw-jira-test.js +53 -27
- package/workspace/premium-vw-meet-test.js +118 -187
- package/workspace/premium-vw-notes-test.js +85 -108
- package/workspace/premium-vw-rec-test.js +72 -194
- package/workspace/premium-vw-slides-test.js +46 -50
- package/workspace/premium-welcome-test.js +3 -2
- package/workspace/premium-work-depth-test.js +61 -53
- package/workspace/public/pm/bd-acts.js +305 -0
- package/workspace/public/pm/bd-span.js +186 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/c3-doc-sheet.js +1 -1
- package/workspace/public/pm/c3-md.js +3 -395
- package/workspace/public/pm/c3-phone-detail.js +1 -1
- package/workspace/public/pm/c3-phone-model.js +3 -68
- package/workspace/public/pm/chat-term.js +3 -3
- package/workspace/public/pm/cozy-board.css +497 -230
- package/workspace/public/pm/cozy-home.css +570 -142
- package/workspace/public/pm/cozy-home.js +5 -3
- package/workspace/public/pm/cozy-insights.css +296 -167
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +17 -6
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +144 -0
- package/workspace/public/pm/cozy-vw.css +485 -0
- package/workspace/public/pm/cozy.css +83 -1
- package/workspace/public/pm/home-adddoc.js +48 -0
- package/workspace/public/pm/home-app.js +905 -0
- package/workspace/public/pm/home-around.js +515 -0
- package/workspace/public/pm/home-chat.js +459 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-more.js +249 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-work.js +519 -0
- package/workspace/public/pm/phone-moment.js +69 -0
- package/workspace/public/pm/pm-work-view.js +1 -1
- package/workspace/public/pm/premium-attach.js +4 -0
- package/workspace/public/pm/premium-board.js +423 -394
- package/workspace/public/pm/premium-chart-tab.js +110 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +25 -21
- package/workspace/public/pm/premium-insights.js +792 -568
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-notes.js +1 -1
- package/workspace/public/pm/premium-report-frame.css +20 -0
- package/workspace/public/pm/premium-report-read.js +509 -480
- package/workspace/public/pm/premium-report-tab.js +87 -63
- package/workspace/public/pm/premium-shell.js +72 -119
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +187 -48
- package/workspace/public/pm/premium-vw-doc.css +6 -0
- package/workspace/public/pm/premium-vw-doc.js +40 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-meet.js +6 -83
- package/workspace/public/pm/premium-vw-mtg.js +731 -0
- package/workspace/public/pm/premium-vw-notes.js +56 -69
- package/workspace/public/pm/premium-vw-open.js +35 -0
- package/workspace/public/pm/premium-vw-page.js +16 -0
- package/workspace/public/pm/premium-vw-rec.js +11 -218
- package/workspace/public/pm/premium-vw-slides.css +5 -0
- package/workspace/public/pm/premium-vw-slides.js +44 -8
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +28 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +22 -60
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +16 -107
- package/workspace/server.js +18 -3
- package/workspace/test-files.json +1 -0
- package/workspace/test-lists/home-libs.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
/* pm/premium-chart-tab.js —
|
|
2
|
-
*
|
|
3
|
-
* (public/pm/report-chat.js), and this
|
|
1
|
+
/* pm/premium-chart-tab.js — a chart or a dashboard from a chat, in the Viewer card (initiative premium-reports-from-chat, slice C; PRD C1–C3;
|
|
2
|
+
* re-drawn for premium-agreed-design, area viewer: Main.dc.html viewer "metrics"). The PM asks in the chat, Claude ends its answer with a
|
|
3
|
+
* `pmos-report` block of kind chart or dashboard (public/pm/report-chat.js), and this view draws it from the KR metric records.
|
|
4
4
|
*
|
|
5
|
-
* A CHART (block.kind 'chart'): the
|
|
6
|
-
*
|
|
7
|
-
* asks once
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* A CHART (block.kind 'chart'): the design's metrics view: three stat tiles (now, since the last reading, the target), then the readings as a
|
|
6
|
+
* chart with the newest one in ember. Below it, the parts the design does not draw yet ("Waiting for design"): the four forms to pick from
|
|
7
|
+
* (Line, Bars, Number, Meter), Save chart (POST /api/premium-charts/save), and Delete chart, which asks once in the card ({ id, remove: true }).
|
|
8
|
+
* A saved chart (block.id) shows as saved; a change Claude proposes to it shows drawn, and Save the change posts the whole chart.
|
|
9
|
+
* A DASHBOARD (block.kind 'dashboard'): its charts in order as small tiles (a measure with fewer than two readings is named, not drawn), then
|
|
10
|
+
* Save dashboard (POST /api/premium-dashboards/save) and Delete dashboard, Waiting for design. Pinning stays on the Insights page.
|
|
10
11
|
*
|
|
11
|
-
* The model is GET /api/insights-premium (the board
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* The model is GET /api/insights-premium (the board Insights shows). Every value drawn is a reading of a record. Every write is a press here,
|
|
13
|
+
* behind the launch nonce (http.js pmPost). Claude writes nothing: the routes refuse an agent session. Nothing is sent outward.
|
|
14
|
+
* The view draws in the czViewer card (cozy-viewer.js): no #dlg, no old tab, no premium.css. */
|
|
14
15
|
import { pmGet, pmPost } from './http.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { open as vOpen, current as vCur, body as vBody } from './cozy-viewer.js';
|
|
17
|
+
import { vzStyle } from './premium-vw-open.js';
|
|
18
|
+
import { deriveChart, unitTxt } from './premium-chart-draw.js';
|
|
17
19
|
|
|
18
20
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
21
|
const FORMS = [['line', 'Line'], ['bars', 'Bars'], ['number', 'Number'], ['meter', 'Meter']];
|
|
20
22
|
const ws = () => new URLSearchParams(location.search).get('ws') || '';
|
|
21
23
|
const post = (p, body) => pmPost(p, Object.assign(ws() ? { ws: ws() } : {}, body)).catch(() => null);
|
|
22
|
-
const
|
|
24
|
+
const WAIT = (f) => `<span class="vz-wait" data-cz-placeholder="${esc(f)}">Waiting for design</span>`;
|
|
25
|
+
const btn = (a, label, o = {}) => `<button type="button" class="${o.sec ? 'vz-sec2' : 'vz-issue'} vz-hv${o.cls ? ' ' + o.cls : ''}" data-ct="${esc(a)}"${o.off ? ' disabled' : ''}>${esc(label)}</button>`;
|
|
23
26
|
|
|
24
|
-
const T = new Map(); //
|
|
25
|
-
/** Open (or refresh) the
|
|
27
|
+
const T = new Map(); // view id → its state
|
|
28
|
+
/** Open (or refresh) the view of a checked chart or dashboard block (report-chat.js cleanBlock). */
|
|
26
29
|
export function openChartTab(block) {
|
|
27
30
|
if (!block || (block.kind !== 'chart' && block.kind !== 'dashboard')) return null;
|
|
28
|
-
|
|
31
|
+
vzStyle();
|
|
29
32
|
const P = block.proposal || {};
|
|
30
33
|
const id = block.kind + ':' + String(block.id || P.measure || P.name || 'new').toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 60);
|
|
31
34
|
let t = T.get(id);
|
|
32
35
|
if (!t || JSON.stringify(t.block) !== JSON.stringify(block)) {
|
|
33
|
-
t = { id, block, M: null, loaded: false, busy: false, msg: '', d: null, gone: false, removed: false };
|
|
36
|
+
t = { id, block, M: null, loaded: false, busy: false, msg: '', d: null, gone: false, removed: false, ask: null };
|
|
34
37
|
T.set(id, t);
|
|
35
38
|
load(t);
|
|
36
39
|
}
|
|
37
|
-
return
|
|
40
|
+
return vOpen({ id, kind: block.kind === 'chart' ? 'Chart' : 'Dashboard', title: titleOf(t), icon: 'chart', render: (el) => { el.onclick = (e) => press(t, e); draw(t, el); } });
|
|
38
41
|
}
|
|
39
|
-
const
|
|
42
|
+
const titleOf = (t) => { const P = t.block.proposal || {}, d = t.d || {}; return t.block.kind === 'chart' ? d.title || P.title || P.measure || t.block.id || 'Chart' : d.name || P.name || t.block.id || 'Dashboard'; };
|
|
43
|
+
const paneOf = (t) => (vCur() && vCur().id === t.id ? vBody() : null);
|
|
40
44
|
const redraw = (t) => { const el = paneOf(t); if (el) draw(t, el); };
|
|
41
45
|
|
|
42
46
|
async function load(t) {
|
|
@@ -59,18 +63,43 @@ async function load(t) {
|
|
|
59
63
|
redraw(t);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
/* ── drawing (Main.dc.html viewer "metrics") ── */
|
|
67
|
+
const shortDay = (s) => String(s || '').replace(/^\d{4}-/, '').replace(/^(\d{2})-(\d{2}).*$/, (m, a, b) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+a - 1] + ' ' + +b);
|
|
68
|
+
const labelOf = (p) => shortDay(String(p.at || p.d || '').slice(0, 10)) || String(p.d || '');
|
|
69
|
+
/** The three stat tiles: the reading now, the step since the last one, and the target. */
|
|
70
|
+
function kpisHtml(c, d) {
|
|
71
|
+
const u = c.unit && /^[%°]/.test(c.unit) ? c.unit : c.unit ? ' ' + c.unit : '';
|
|
72
|
+
const step = c.step === 0 ? 'No change' : (c.step > 0 ? 'Up ' : 'Down ') + Math.abs(c.step) + u;
|
|
73
|
+
const K = [['Now', c.v, 'on ' + c.at], ['Since the last reading', step, c.good === null ? 'Same as before' : c.good ? 'The right way' : 'The wrong way'],
|
|
74
|
+
['Target', c.target !== null ? unitTxt(c, c.target) : 'None set', d.better === 'lower' ? 'Lower is better' : 'Higher is better']];
|
|
75
|
+
return `<div class="vz-kpis">${K.map(([l, v, n]) => `<div class="vz-kpi"><p>${esc(l)}</p><b>${esc(v)}</b><small>${esc(n)}</small></div>`).join('')}</div>`;
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
/** The readings drawn in the picked form, the newest in ember. Bars and a meter start at zero; a value below zero is drawn as a line. */
|
|
78
|
+
function figHtml(c, form, cap) {
|
|
79
|
+
const pts = c.pts, n = pts.length, neg = pts.some((p) => p.v < 0) || (c.target !== null && c.target < 0);
|
|
80
|
+
const f = form === 'bars' && !neg ? 'bars' : form === 'meter' && !neg && c.target !== null ? 'meter' : form === 'number' ? 'number' : 'line';
|
|
81
|
+
const alt = `${c.title}: ${n} readings from ${pts[0].txt} on ${pts[0].d} to ${c.v} on ${c.at}${c.targetTxt ? ', ' + c.targetTxt : ''}`;
|
|
82
|
+
if (f === 'number') return `<figure class="vz-mx-fig" data-form="number"><figcaption>${esc(cap)}</figcaption><p class="vz-mx-big" role="img" aria-label="${esc(alt)}">${esc(c.v)}</p></figure>`;
|
|
83
|
+
const W = 440, H = 150, B = 128, top = 22;
|
|
84
|
+
const hi = Math.max(...pts.map((p) => p.v), c.target !== null ? c.target : 0) || 1;
|
|
85
|
+
if (f === 'meter') {
|
|
86
|
+
const v = pts[n - 1].v, mx = Math.max(v, c.target) * 1.15 || 1, x = (k) => (k / mx * W).toFixed(1);
|
|
87
|
+
return `<figure class="vz-mx-fig" data-form="meter"><figcaption>${esc(cap)}</figcaption><svg class="vz-mx-svg" viewBox="0 0 ${W} 44" role="img" aria-label="${esc(alt)}"><rect class="vz-trk0" x="0" y="14" width="${W}" height="14" rx="7"/><rect class="vz-bar now" x="0" y="14" width="${x(v)}" height="14" rx="7"/><line class="vz-tgt" x1="${x(c.target)}" x2="${x(c.target)}" y1="6" y2="36"/></svg><p class="vz-note">${esc(c.v)} against ${esc(c.targetTxt)}</p></figure>`;
|
|
71
88
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
89
|
+
const slot = W / n, bw = Math.min(36, slot * 0.6), yOf = (v) => B - (v / hi) * (B - top);
|
|
90
|
+
const ty = c.target !== null ? yOf(c.target) : null;
|
|
91
|
+
let g = `<line class="vz-ax" x1="0" x2="${W}" y1="${B}" y2="${B}"/>`;
|
|
92
|
+
if (f === 'bars') g += pts.map((p, i) => { const y = yOf(Math.max(0, p.v)); return `<text class="vz-bv" x="${(slot * i + slot / 2).toFixed(1)}" y="${(y - 6).toFixed(1)}">${esc(p.txt)}</text><rect class="vz-bar${i === n - 1 ? ' now' : ''}" x="${(slot * i + (slot - bw) / 2).toFixed(1)}" y="${y.toFixed(1)}" width="${bw.toFixed(1)}" height="${Math.max(1, B - y).toFixed(1)}" rx="6"/>`; }).join('');
|
|
93
|
+
else {
|
|
94
|
+
const lo = Math.min(...pts.map((p) => p.v), c.target !== null ? c.target : Infinity), rg = (hi - lo) || 1, yL = (v) => B - ((v - lo) / rg) * (B - top);
|
|
95
|
+
const P = pts.map((p, i) => [slot * i + slot / 2, yL(p.v)]);
|
|
96
|
+
g += `<polyline class="vz-ln" points="${P.map((q) => q[0].toFixed(1) + ',' + q[1].toFixed(1)).join(' ')}"/>` + P.map((q, i) => `<circle class="vz-pt${i === n - 1 ? ' now' : ''}" cx="${q[0].toFixed(1)}" cy="${q[1].toFixed(1)}" r="${i === n - 1 ? 6 : 4}"/><text class="vz-bv" x="${q[0].toFixed(1)}" y="${(q[1] - 10).toFixed(1)}">${esc(pts[i].txt)}</text>`).join('');
|
|
97
|
+
if (c.target !== null) g += `<line class="vz-tgt" x1="0" x2="${W}" y1="${yL(c.target).toFixed(1)}" y2="${yL(c.target).toFixed(1)}"/>`;
|
|
98
|
+
}
|
|
99
|
+
if (f === 'bars' && ty !== null) g += `<line class="vz-tgt" x1="0" x2="${W}" y1="${ty.toFixed(1)}" y2="${ty.toFixed(1)}"/>`;
|
|
100
|
+
g += pts.map((p, i) => `<text class="vz-bx" x="${(slot * i + slot / 2).toFixed(1)}" y="${H - 4}">${esc(labelOf(p))}</text>`).join('');
|
|
101
|
+
const why = form !== f ? (neg ? 'A value is below zero, so it is drawn as a line.' : 'No target is set, so it is drawn as a line.') : '';
|
|
102
|
+
return `<figure class="vz-mx-fig" data-form="${f}"><figcaption>${esc(cap)}</figcaption><svg class="vz-mx-svg" viewBox="0 0 ${W} ${H}" role="img" aria-label="${esc(alt)}">${g}</svg>${c.target !== null ? '<p class="vz-note">The dashed line is the target.</p>' : ''}${why ? `<p class="vz-note">${esc(why)}</p>` : ''}</figure>`;
|
|
74
103
|
}
|
|
75
104
|
const sameChart = (a, b) => ['measure', 'title', 'question', 'form', 'range', 'target', 'better', 'note'].every((k) => (a[k] == null ? '' : String(a[k])) === (b[k] == null ? '' : String(b[k])));
|
|
76
105
|
|
|
@@ -78,46 +107,62 @@ function chartHtml(t) {
|
|
|
78
107
|
const d = t.d, s = t.saved, base = (t.M.charts || []).find((c) => c.id === d.measure);
|
|
79
108
|
const changed = !s || !sameChart(s, d);
|
|
80
109
|
const eye = !s ? 'New chart · from this chat' : changed ? 'Chart change · from this chat' : 'Saved chart';
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
+ `<p class="
|
|
88
|
-
|
|
110
|
+
const form = d.form || 'line';
|
|
111
|
+
let shown;
|
|
112
|
+
if (!base) { const m = (t.M.measures || []).find((x) => x.id === d.measure); shown = `<p class="vz-msg">${esc(m ? m.title + ' has fewer than two readings, so it has no chart yet.' : 'No KR metric record is called ' + d.measure + ' in this workspace.')}</p>`; }
|
|
113
|
+
else {
|
|
114
|
+
const c = deriveChart(base, { title: d.title || base.title, form, range: d.range || null, target: d.target, better: d.better || 'higher', note: d.note || '' });
|
|
115
|
+
const cap = (d.question || c && c.title || base.title) + (d.better === 'lower' ? ' (lower is better)' : '');
|
|
116
|
+
shown = c ? kpisHtml(c, d) + figHtml(c, form, cap) + (d.note ? `<p class="vz-note">${esc(d.note)}</p>` : '') : '<p class="vz-msg">The range holds fewer than two readings, so nothing is drawn.</p>';
|
|
117
|
+
}
|
|
118
|
+
const meter = form === 'meter' && (d.target === null || d.target === undefined) ? '<p class="vz-note">A meter needs a target. Say one in the chat, or pick another form.</p>' : '';
|
|
119
|
+
return shown
|
|
120
|
+
+ `<section class="vz-blk" aria-label="${esc(eye)}"><div class="vz-r1"><h3>${esc(eye)}</h3>${WAIT('Chart setup from a chat')}</div>`
|
|
121
|
+
+ `<p class="vz-note">${esc(base ? base.title : d.measure)}${d.range ? ' · last ' + d.range + ' readings' : ' · every reading'}${d.target != null ? ' · target ' + esc(d.target) : ''}</p>`
|
|
122
|
+
+ `<div class="vz-sg" role="group" aria-label="Form">${FORMS.map(([f, l]) => `<button type="button" data-ct="form|${f}" aria-pressed="${form === f}">${l}</button>`).join('')}</div>${meter}`
|
|
123
|
+
+ (changed ? `<div class="vz-r1">${btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save chart', { off: t.busy || !base || !!meter })}</div>` : '')
|
|
124
|
+
+ `<p class="vz-note">${s ? 'It shows on Insights under Your charts.' : 'Saved, it shows on Insights under Your charts and can go on a dashboard.'} Ask in the chat to change it.</p>`
|
|
125
|
+
+ (s ? `<div class="vz-r1">${btn('remove', 'Delete chart', { sec: true, off: t.busy })}</div>` : '') + '</section>';
|
|
126
|
+
}
|
|
127
|
+
/** A dashboard's chart as a small tile: its name, the reading now and its readings as small bars. */
|
|
128
|
+
function tileHtml(c) {
|
|
129
|
+
const pts = c.pts, n = pts.length, hi = Math.max(...pts.map((p) => Math.max(0, p.v))) || 1, slot = 200 / n, bw = Math.min(16, slot * 0.6);
|
|
130
|
+
return `<div class="vz-mx-tile"><p>${esc(c.title)}</p><b>${esc(c.v)}</b><small>on ${esc(c.at)}${c.targetTxt ? ' · ' + esc(c.targetTxt) : ''}</small>`
|
|
131
|
+
+ `<svg class="vz-mx-svg" viewBox="0 0 200 44" role="img" aria-label="${esc(c.title + ': ' + n + ' readings, now ' + c.v)}">${pts.map((p, i) => { const h = Math.max(1, Math.max(0, p.v) / hi * 40); return `<rect class="vz-bar${i === n - 1 ? ' now' : ''}" x="${(slot * i + (slot - bw) / 2).toFixed(1)}" y="${(44 - h).toFixed(1)}" width="${bw.toFixed(1)}" height="${h.toFixed(1)}" rx="3"/>`; }).join('')}</svg></div>`;
|
|
89
132
|
}
|
|
90
133
|
function dashHtml(t) {
|
|
91
134
|
const d = t.d, s = t.saved, M = t.M;
|
|
92
135
|
const changed = !s || d.name !== s.name || d.purpose !== s.purpose || d.charts.join() !== s.charts.join();
|
|
93
136
|
const eye = !s ? 'New dashboard · from this chat' : changed ? 'Dashboard change · from this chat' : 'Saved dashboard';
|
|
94
137
|
const tiles = d.charts.map((ref) => {
|
|
95
|
-
const c =
|
|
96
|
-
if (c) return
|
|
138
|
+
const c = (M.mine || []).find((x) => x.id === ref) || (M.charts || []).find((x) => x.id === ref);
|
|
139
|
+
if (c) return tileHtml(c);
|
|
97
140
|
const m = (M.measures || []).find((x) => x.id === ref);
|
|
98
|
-
return `<div class="
|
|
141
|
+
return `<div class="vz-mx-none"><p><b>${esc(m ? m.title : ref)}</b></p><small>${esc(m ? 'It has fewer than two readings, so it has no chart yet.' : 'No KR metric record or saved chart is called ' + ref + '.')}</small></div>`;
|
|
99
142
|
}).join('');
|
|
100
|
-
const many = d.charts.length > 6 ? '<p class="
|
|
101
|
-
return
|
|
102
|
-
+ `<
|
|
103
|
-
+ `<
|
|
104
|
-
+ `<div class="
|
|
105
|
-
+ `<p class="
|
|
106
|
-
+ (s ? `<div class="
|
|
143
|
+
const many = d.charts.length > 6 ? '<p class="vz-note">This dashboard holds more than six charts. A dashboard that serves one routine usually holds six or fewer.</p>' : '';
|
|
144
|
+
return `${d.purpose ? `<p class="vz-sum">${esc(d.purpose)}</p>` : ''}<div class="vz-mx-grid">${tiles}</div>${many}`
|
|
145
|
+
+ `<section class="vz-blk" aria-label="${esc(eye)}"><div class="vz-r1"><h3>${esc(eye)}</h3>${WAIT('Dashboard setup from a chat')}</div>`
|
|
146
|
+
+ `<p class="vz-note">${d.charts.length} ${d.charts.length === 1 ? 'chart' : 'charts'}${s && s.main ? ' · pinned on Insights' : ''}</p>`
|
|
147
|
+
+ (changed ? `<div class="vz-r1">${btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save dashboard', { off: t.busy })}</div>` : '')
|
|
148
|
+
+ `<p class="vz-note">${s ? 'It is in the list on Insights.' : 'Saved, it is in the list on Insights, where you can pin it.'} Ask in the chat to change it.</p>`
|
|
149
|
+
+ (s ? `<div class="vz-r1">${btn('remove', 'Delete dashboard', { sec: true, off: t.busy })}</div>` : '') + '</section>';
|
|
107
150
|
}
|
|
108
151
|
function bodyHtml(t) {
|
|
109
152
|
const noun = t.block.kind;
|
|
110
|
-
if (!t.loaded) return `<p class="
|
|
111
|
-
if (!t.M) return `<p class="
|
|
112
|
-
if (t.removed) return
|
|
113
|
-
if (t.gone) return `<p class="
|
|
114
|
-
if (!t.M.board.id) return '<p class="
|
|
153
|
+
if (!t.loaded) return `<p class="vz-empty" role="status">Reading the ${noun}.</p>`;
|
|
154
|
+
if (!t.M) return `<p class="vz-msg">The Insights records could not be read, so the ${noun} cannot be drawn. Try again in a moment.</p>`;
|
|
155
|
+
if (t.removed) return '<p class="vz-msg">Deleted. Ask in the chat for a new one.</p>';
|
|
156
|
+
if (t.gone) return `<p class="vz-msg">This ${noun} (${esc(t.block.id)}) is deleted, or it is not saved on this board.</p>`;
|
|
157
|
+
if (!t.M.board.id) return '<p class="vz-msg">This workspace has no board to save on, so nothing can be saved here.</p>';
|
|
115
158
|
return noun === 'chart' ? chartHtml(t) : dashHtml(t);
|
|
116
159
|
}
|
|
160
|
+
function askHtml(t) {
|
|
161
|
+
const A = t.ask; if (!A) return '';
|
|
162
|
+
return `<div class="vz-ask2" role="group" aria-label="${esc(A.yes)}"><span>${esc(A.text)}</span><div><button type="button" class="vz-issue vz-hv vz-h36" data-ct="askyes" data-k="bad">${esc(A.yes)}</button><button type="button" class="vz-sec2 vz-hv vz-h36" data-ct="askno">${esc(A.no)}</button></div></div>`;
|
|
163
|
+
}
|
|
117
164
|
function draw(t, el) {
|
|
118
|
-
|
|
119
|
-
el.innerHTML = `<div class="rt">${bodyHtml(t)}${t.msg ? `<p class="rt-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
|
|
120
|
-
if (ask) el.prepend(ask);
|
|
165
|
+
el.innerHTML = `<div class="vz vz-mx" data-vw="${esc(t.id)}">${askHtml(t)}${bodyHtml(t)}${t.msg ? `<p class="vz-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
|
|
121
166
|
}
|
|
122
167
|
|
|
123
168
|
async function act(t, fn) { t.busy = true; t.msg = ''; redraw(t); const m = await fn(); t.busy = false; if (m != null) t.msg = m; redraw(t); }
|
|
@@ -127,6 +172,8 @@ async function press(t, e) {
|
|
|
127
172
|
const [a, v] = [b.dataset.ct.split('|')[0], b.dataset.ct.slice(b.dataset.ct.indexOf('|') + 1)];
|
|
128
173
|
const board = t.M && t.M.board.id, kind = t.block.kind;
|
|
129
174
|
if (a === 'form') { t.d = Object.assign({}, t.d, { form: v }); t.msg = ''; redraw(t); return; }
|
|
175
|
+
if (a === 'askno') { t.ask = null; redraw(t); return; }
|
|
176
|
+
if (a === 'askyes') { const A = t.ask; t.ask = null; if (A) await A.run(); return; }
|
|
130
177
|
if (a === 'save') {
|
|
131
178
|
await act(t, async () => {
|
|
132
179
|
if (kind === 'chart') {
|
|
@@ -147,11 +194,12 @@ async function press(t, e) {
|
|
|
147
194
|
}
|
|
148
195
|
if (a === 'remove') {
|
|
149
196
|
const noun = kind === 'chart' ? 'chart' : 'dashboard';
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
197
|
+
t.ask = { text: kind === 'chart' ? 'Delete this chart? A dashboard that holds it shows it as removed.' : 'Delete this dashboard? Its charts and records stay.', yes: 'Delete ' + noun, no: 'Keep it',
|
|
198
|
+
run: () => act(t, async () => {
|
|
199
|
+
const r = await post(kind === 'chart' ? '/api/premium-charts/save' : '/api/premium-dashboards/save', { board, id: t.saved.id, remove: true });
|
|
200
|
+
if (!r || !r.ok) return 'It was not deleted: ' + why(r, 'the page could not reach PMOS') + '.';
|
|
201
|
+
t.removed = true; return null;
|
|
202
|
+
}) };
|
|
203
|
+
redraw(t);
|
|
156
204
|
}
|
|
157
205
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export const W = 960, H = 540;
|
|
16
16
|
export const LAYOUTS = [['title', 'Title'], ['content', 'Title and text'], ['two', 'Two columns'], ['chart', 'Chart and text'], ['big', 'Big number'], ['image', 'Image and text'], ['quote', 'Quote'], ['section', 'Section break']];
|
|
17
17
|
export const ROLES = [['title', 'Title'], ['heading', 'Heading'], ['body', 'Body'], ['small', 'Small'], ['kicker', 'Kicker'], ['big', 'Big number'], ['quote', 'Quote']];
|
|
18
|
-
export const THEMES = [['ember', 'Ember'], ['paper', 'Paper'], ['sky', 'Sky']];
|
|
18
|
+
export const THEMES = [['report', 'Report blue'], ['ember', 'Ember'], ['paper', 'Paper'], ['sky', 'Sky']]; // report: the report panel's slide (ReportPanel.dc.html), the default
|
|
19
19
|
export const COLORS = [['', 'Theme text'], ['acc', 'Accent'], ['mut', 'Muted']];
|
|
20
20
|
export const FILLS = [['acc', 'Accent'], ['fg', 'Text colour'], ['soft', 'Soft']];
|
|
21
21
|
const has = (list, k) => list.some((x) => x[0] === k);
|
|
@@ -108,7 +108,7 @@ export function mkLayout(l, c = {}) {
|
|
|
108
108
|
const T = (k, role, x, y, w, h, html, align) => ({ t: 'text', k, role, x, y, w, h, html, align: align || 'left' });
|
|
109
109
|
const ti = c.title != null ? c.title : '', bo = c.body != null ? c.body : '';
|
|
110
110
|
switch (l) {
|
|
111
|
-
case 'title': return [T('kicker', 'kicker',
|
|
111
|
+
case 'title': return [T('kicker', 'kicker', 48, 44, 816, 36, c.kicker || ''), T('title', 'title', 48, 96, 640, 150, ti), T('body', 'body', 48, 420, 816, 80, bo)]; // the report's title slide: tag, title, then the lines at the foot
|
|
112
112
|
case 'two': return [T('title', 'heading', 72, 60, 816, 56, ti), T('body', 'body', 72, 150, 390, 330, bo), T('body2', 'body', 498, 150, 390, 330, c.body2 || '')];
|
|
113
113
|
case 'chart': return [T('title', 'heading', 72, 60, 816, 56, ti), c.chart ? { ...c.chart, k: 'chart', x: 72, y: 150, w: 520, h: 320 } : { t: 'chart', k: 'chart', x: 72, y: 150, w: 520, h: 320, kind: 'bar', data: [['', 0]] }, T('body', 'body', 624, 160, 264, 310, bo)];
|
|
114
114
|
case 'big': return [T('big', 'big', 72, 96, 816, 170, c.big || ''), T('body', 'body', 72, 300, 700, 140, bo), ...(ti ? [T('title', 'small', 72, 470, 700, 40, ti)] : [])];
|
|
@@ -158,7 +158,7 @@ function fromSection(head, body, l) {
|
|
|
158
158
|
/** The file as a deck. A file with no blocks (a report) is read as its title slide and one slide per section, as the report reader does. */
|
|
159
159
|
export function parseDeck(md, fallbackTitle) {
|
|
160
160
|
const { front, rest } = splitFront(String(md || '').replace(/\r\n/g, '\n'));
|
|
161
|
-
const theme = has(THEMES, frontVal(front, 'deck_theme')) ? frontVal(front, 'deck_theme') : '
|
|
161
|
+
const theme = has(THEMES, frontVal(front, 'deck_theme')) ? frontVal(front, 'deck_theme') : 'report';
|
|
162
162
|
const secs = []; let cur = null, pre = [];
|
|
163
163
|
for (const line of rest.split('\n')) {
|
|
164
164
|
const h1 = /^# (?!#)(.*)/.exec(line), h2 = /^## (?!#)(.*)/.exec(line);
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
/* pm/premium-first.js — the "Your first Briefing" card on
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
1
|
+
/* pm/premium-first.js — the "Your first Briefing" card on Home (initiative premium-welcome; rebuilt for the Agreed design, initiative
|
|
2
|
+
* premium-agreed-design, Home). The Agreed design does not draw a first-run card, so this is a plain minimal cozy card with a
|
|
3
|
+
* "Waiting for design" marker. It shows only when Home was opened with first=<import id>, which the premium Welcome sets after an import.
|
|
4
|
+
* It reads GET /api/onboarding/briefing, lists each item, the state of the tools the PM ticked (what Welcome recorded in this browser) and
|
|
5
|
+
* Undo this import (POST /api/onboarding/undo), which goes back to Welcome's found step.
|
|
6
|
+
* mountFirst() → the card element (a <section id="wlFirst">), or null when the address has no first=. Home puts it at the top of its list.
|
|
7
|
+
* Text from the scanned folder is untrusted and goes through esc(). */
|
|
5
8
|
import { pmGet, pmPost } from './http.js';
|
|
6
9
|
import { firstView, FIRST_KEY } from './premium-welcome-model.js';
|
|
7
10
|
|
|
8
11
|
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
9
|
-
const
|
|
12
|
+
const WAIT = '<p class="hx-wait"><i aria-hidden="true"></i>Waiting for design</p>';
|
|
10
13
|
|
|
11
14
|
function toolState() {
|
|
12
15
|
try { return JSON.parse(sessionStorage.getItem(FIRST_KEY) || '{}'); } catch { return {}; }
|
|
13
16
|
}
|
|
14
|
-
export
|
|
17
|
+
export function mountFirst() {
|
|
15
18
|
const q = new URLSearchParams(location.search), id = q.get('first'), ws = q.get('ws') || '';
|
|
16
|
-
|
|
17
|
-
if (!id || !cols || document.getElementById('wlFirst')) return;
|
|
18
|
-
const r = await pmGet(`/api/onboarding/briefing?ws=${encodeURIComponent(ws)}`);
|
|
19
|
-
const v = firstView(r, toolState());
|
|
19
|
+
if (!id) return null;
|
|
20
20
|
const sec = document.createElement('section');
|
|
21
|
-
sec.className = '
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
sec.className = 'hm-first hx'; sec.id = 'wlFirst'; sec.setAttribute('aria-labelledby', 'hWl');
|
|
22
|
+
sec.innerHTML = `${WAIT}<h2 id="hWl">Your first Briefing</h2><p class="hx-n">Reading what the scan found.</p>`;
|
|
23
|
+
pmGet(`/api/onboarding/briefing?ws=${encodeURIComponent(ws)}`).then((r) => {
|
|
24
|
+
const v = firstView(r, toolState());
|
|
25
|
+
const items = v.items.map((f) => `<li class="hx-row"><span class="hx-t"><b>${esc(f.title)}</b>${f.why ? `<em>${esc(f.why)}</em>` : ''}<small>${f.ini ? esc(f.ini) + ' · ' : ''}${esc(f.ref)}</small></span></li>`).join('');
|
|
26
|
+
const tools = v.tools.map((t) => `<li class="hx-row"><span class="hx-t"><b>${esc(t.name)}</b><em${t.started ? '' : ' class="bad"'}>${t.started ? `${esc(t.name)} is being read in an agent session. Its items join your list when it finishes.` : esc(t.error || 'It did not start.')}</em></span></li>`).join('');
|
|
27
|
+
const lede = r && r.ok ? (v.calm ? 'Your portfolio is in. Nothing needs you right now.' : 'Your portfolio is in. These need you first.') : esc((r && r.error) || 'The scan\'s Briefing could not be read.');
|
|
28
|
+
sec.innerHTML = `${WAIT}<h2 id="hWl">Your first Briefing</h2><p class="hx-n">${lede}</p>`
|
|
29
|
+
+ (items ? `<ol class="hm-first-l">${items}</ol>` : '') + (tools ? `<h4>Your tools</h4><ul class="hm-first-l">${tools}</ul>` : '')
|
|
30
|
+
+ '<div class="hx-top"><button class="hx-b" type="button" id="wlUndo">Undo this import</button></div><p class="hx-n" id="wlUndoErr" role="alert" hidden></p>';
|
|
31
|
+
});
|
|
32
|
+
sec.onclick = async (e) => {
|
|
30
33
|
const b = e.target.closest('#wlUndo'); if (!b || b.disabled) return;
|
|
31
34
|
b.disabled = true;
|
|
32
35
|
const u = await pmPost('/api/onboarding/undo', { ws, import_id: id });
|
|
33
|
-
if (!u || !u.ok) { b.disabled = false; const
|
|
36
|
+
if (!u || !u.ok) { b.disabled = false; const m = sec.querySelector('#wlUndoErr'); m.textContent = (u && u.error) || 'Undo did not work.'; m.hidden = false; return; }
|
|
34
37
|
location.assign('/premium-welcome.html?ws=' + encodeURIComponent(ws) + '&step=found');
|
|
35
|
-
}
|
|
38
|
+
};
|
|
39
|
+
return sec;
|
|
36
40
|
}
|