create-pmos 0.328.0 → 0.329.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.
@@ -5,7 +5,8 @@
5
5
  * PRD D2 to D6) and the report presses of the console's Reports workspace (POST /api/report-setups/ask | change | cancel | setup | dismiss | pause | resume |
6
6
  * draft, PRD R2 to R4). premium-studio-chart adds a saved chart (POST /api/premium-charts/save, PRD C1, C10) and its four forms (C3). premium-studio-report
7
7
  * adds New report and Shape it in the Studio, whose presses are POST /api/report-setups/setup | from-dashboard and POST /api/report-structure/turn | remove |
8
- * revert | accept (PRD R5 to R8). Nothing else posts, and nothing is sent outward. */
8
+ * revert | accept (PRD R5 to R8). insights-one-list puts the insight first, the pinned dashboard on top and one paged list of dashboards and reports below
9
+ * (PRD L1 to L6); its one new press is Pin, POST /api/premium-dashboards/pin. Nothing else posts, and nothing is sent outward. */
9
10
  import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv, setPageGaps } from './premium-shell.js';
10
11
  import { pmPost, pmGet } from './http.js';
11
12
  import { openStudio } from './premium-studio.js';
@@ -13,11 +14,15 @@ import { openReport } from './premium-report-read.js';
13
14
  import * as MT from './premium-metric-tiles.js';
14
15
 
15
16
  let M = null; // the model
16
- let dash = 'all'; // the dashboard on screen
17
+ let dash = null; // the dashboard in the top card: the pinned one until a list row opens another
18
+ let listF = 'all', listP = 1; // the list's filter and page
19
+ const PER = 6; // rows to a page (insights-one-list L5)
17
20
  wireRail('rep');
18
21
  const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
19
22
  const DOCI = '<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>';
20
23
  const CHV2 = '<svg class="i" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></svg>';
24
+ const PINI = '<path d="M9 3h6l-1 6 4 3v2H6v-2l4-3z"/><path d="M12 14v7"/>';
25
+ const DASHI = '<path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/>';
21
26
  const AIC = '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>';
22
27
  const byKey = (k) => (M && (M.charts || []).concat(M.mine || []) || []).find((c) => c.key === k) || null;
23
28
  const savedDash = () => (M.dashboards || []).filter((d) => d.saved);
@@ -34,9 +39,28 @@ function drawHead() {
34
39
  $('#snap').textContent = M.header.text;
35
40
  setPageGaps(((M.header && M.header.missing) || []).length);
36
41
  $('#snap').title = 'Every figure on this page comes from a KR metric record. A measure with fewer than two readings is listed, not drawn.';
37
- $('#brief').textContent = M.empty || '';
42
+ drawHero();
38
43
  }
39
44
 
45
+ /* ── the insight (insights-one-list L1, L2): the strongest finding across the board's measures, its reason, two more, and a press to the measure ── */
46
+ function drawHero() {
47
+ const I = M.insight;
48
+ $('#insEye').innerHTML = ICO(AIC) + esc(I.none ? 'Insight' : 'Insight · ' + I.off + ' of ' + I.total + ' behind their line · readings to ' + I.asOf);
49
+ $('#brief').textContent = I.text;
50
+ $('#insWhy').textContent = I.why || '';
51
+ $('#insMore').innerHTML = (I.more || []).map((x) => `<li><button class="imr" data-open="${esc(x.chart)}" aria-haspopup="dialog">${esc(x.text)}${CHV2}</button></li>`).join('');
52
+ $('#insAct').innerHTML = I.chart ? `<button class="dmcta" data-askwhy="${esc(I.chart)}" aria-haspopup="dialog">Ask PMOS why</button><button class="dmcta alt" data-open="${esc(I.chart)}" aria-haspopup="dialog">See the chart</button>` : '';
53
+ $('#insNote').textContent = I.proj || (I.more || []).length ? 'A sentence that says where a measure lands by its target date is a straight line through its last four readings, carried to that date. It is not drawn on a chart.' : '';
54
+ $('#insHero').classList.toggle('calm', !!(I.none || I.calm));
55
+ }
56
+ $('#insHero').addEventListener('click', (e) => {
57
+ const o = e.target.closest('[data-open]'); if (o) { openChart(byKey(o.dataset.open)); return; }
58
+ const a = e.target.closest('[data-askwhy]'); if (!a) return;
59
+ openChart(byKey(a.dataset.askwhy));
60
+ const t = $('#dTabs [data-t="chat"]'); if (t) t.click();
61
+ const inp = $('#askIn'); if (inp) { inp.value = 'Why is this happening, and what would change it?'; inp.focus(); }
62
+ });
63
+
40
64
  /* ── charts ───────────────────────────────────────────────────────────────────────────────────────────────────── */
41
65
  const W = 220, H = 60, P = 5;
42
66
  const X = (fx) => P + fx * (W - 2 * P), Y = (fy) => P + (1 - fy) * (H - 2 * P);
@@ -107,21 +131,25 @@ function chartAt(t, j) {
107
131
  t.setAttribute('aria-label', c.title + ', ' + (last ? 'now ' : '') + val + ', ' + cap + '. Use the arrow keys to read each reading.');
108
132
  }
109
133
 
110
- /* ── the dashboards card ──────────────────────────────────────────────────────────────────────────────────────── */
134
+ /* ── the top card: the pinned dashboard (insights-one-list L4) ─────────────────────────────────────────────────── */
111
135
  const curDash = () => M.dashboards.find((d) => d.id === dash) || M.dashboards[0];
112
- function findingsHtml() {
113
- const F = M.findings.filter((f) => f.text);
114
- if (!F.length) return '';
115
- return `<div class="nfd" role="region" aria-label="What stands out"><p class="label">What stands out</p><ul>${F.map((f) => `<li class="${esc(f.kind)}">${f.chart
116
- ? `<button class="nfr" data-open="${esc(f.chart)}" aria-haspopup="dialog"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span>${CHV2}</button>`
117
- : `<div class="nfr"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span></div>`}</li>`).join('')}</ul></div>`;
136
+ const pinnable = (D) => !!M.board.id && (D.id === 'all' || D.saved);
137
+ /* The dashboard's insight band. The finding the page already leads with is skipped, so the band says what else is on this dashboard. */
138
+ function findingsHtml(D) {
139
+ const I = D.insight; if (!I || I.none) return '';
140
+ const all = I.finds, F = all.filter((f) => f.chart !== M.insight.chart), also = F.length < all.length;
141
+ const label = also ? 'Also on this dashboard' : 'Insight';
142
+ const rows = F.length ? F.map((f) => `<li class="${esc(f.kind)}"><button class="nfr" data-open="${esc(f.chart)}" aria-haspopup="dialog"><i class="nfdot" aria-hidden="true"></i><span class="nft"><b>${esc(f.text)}</b> ${esc(f.why)}</span>${CHV2}</button></li>`).join('')
143
+ : `<li class="calm"><div class="nfr"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(also ? 'Nothing else stands out here.' : I.calmText)}</span></div></li>`;
144
+ return `<div class="nfd" role="region" aria-label="${esc(label)}"><p class="label">${esc(label)}</p><ul>${rows}</ul></div>`;
118
145
  }
119
146
  function drawDash() {
120
- const D = curDash(), L = D.keys.map(byKey).filter(Boolean);
121
- $('#dashCap').textContent = M.counts.total ? M.counts.charts + ' drawn · ' + M.counts.noSeries + ' without a series' : '';
122
- const tabs = $('#dashTabs'); tabs.hidden = M.dashboards.length < 2;
123
- if (!tabs.hidden) { tabs.innerHTML = '<i class="pill"></i>' + M.dashboards.map((d) => `<button data-d="${esc(d.id)}" aria-pressed="${d.id === D.id}"${d.main ? ' title="The main dashboard"' : ''}>${esc(d.name)}${d.main ? ' · Main' : ''}</button>`).join(''); pillOf(tabs); }
124
- drawDashBar(D);
147
+ const D = curDash(), L = D.keys.map(byKey).filter(Boolean), isPin = M.pinned === D.id;
148
+ $('#hDash').textContent = D.name;
149
+ $('#dashTag').textContent = isPin ? 'Pinned' : 'Not pinned';
150
+ $('#dashTag').className = 'ptag' + (isPin ? ' on' : '');
151
+ $('#dashCap').textContent = L.length ? (L.length - D.off) + ' of ' + L.length + ' on their line' : '';
152
+ drawDashBar(D, isPin);
125
153
  if (D.saved) { drawSaved(D, L); return; }
126
154
  if (!M.charts.length) {
127
155
  $('#dashBody').innerHTML = `<div class="nempty" style="margin-top:14px"><p><b>${esc(M.counts.total ? 'No KR metric holds two readings yet.' : 'No KR metric is recorded for this workspace.')}</b> ${esc(M.counts.total ? 'A chart needs a series, so nothing is drawn.' : 'There is nothing to chart. Add one where the KR metrics are kept.')}</p></div>` + noSeriesHtml();
@@ -129,22 +157,27 @@ function drawDash() {
129
157
  }
130
158
  const off = D.off, tot = L.length;
131
159
  $('#dashBody').innerHTML = `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
132
- + findingsHtml()
160
+ + findingsHtml(D)
133
161
  + `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} Each chart is one KR metric, drawn at the dates of its readings. A gap between readings is left as a gap. The dashed line is the target.</p>`
134
- + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>` + mineHtml() + noSeriesHtml();
162
+ + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>` + (D.id === 'all' ? mineHtml() + noSeriesHtml() : '');
135
163
  }
136
- /* The bar under the switch: a saved dashboard's purpose and Edit, and New dashboard (PRD D3/D4). Hidden when the page has no board to save on. */
137
- function drawDashBar(D) {
164
+ /* The bar under the heading: Pin or Unpin, Back to the pinned one, a saved dashboard's purpose and Edit, and New chart. Hidden with no board to save on. */
165
+ function drawDashBar(D, isPin) {
138
166
  const bar = $('#dashBar'); bar.hidden = !M.board.id;
139
167
  if (bar.hidden) return;
140
- bar.innerHTML = (D.saved ? `<p class="note pdp">${D.main ? '<b>Main dashboard.</b> ' : ''}${esc(D.purpose)}</p><button class="dmcta alt" id="pdEdit" aria-haspopup="dialog">Edit</button>` : '')
141
- + '<button class="dmcta alt" id="pdNew" aria-haspopup="dialog">New dashboard</button>' + (M.charts.length ? '<button class="dmcta alt" id="pcNew" aria-haspopup="dialog">New chart</button>' : '');
168
+ const P = M.pinned ? M.dashboards.find((d) => d.id === M.pinned) : null;
169
+ bar.innerHTML = (D.saved ? `<p class="note pdp">${esc(D.purpose)}</p>` : `<p class="note pdp">${esc(D.id === 'all' ? 'Every KR metric of this board. PMOS makes it, so it cannot be deleted.' : 'The measures of the ' + D.name + ' pillar.')}</p>`)
170
+ + (pinnable(D) ? `<button class="dmcta${isPin ? ' alt' : ''}" id="pdPin" data-pin="${esc(isPin ? '' : D.id)}" aria-pressed="${isPin}">${ICO(PINI)}${isPin ? 'Unpin' : 'Pin'}</button>` : '')
171
+ + (P && !isPin ? `<button class="dmcta alt" id="pdBack">Back to ${esc(P.name)}</button>` : '')
172
+ + (D.saved ? '<button class="dmcta alt" id="pdEdit" aria-haspopup="dialog">Edit</button>' : '')
173
+ + (M.charts.length ? '<button class="dmcta alt" id="pcNew" aria-haspopup="dialog">New chart</button>' : '');
142
174
  }
143
175
  function drawSaved(D, L) {
144
176
  const off = D.off, tot = L.length;
145
177
  const gone = D.gone.length ? `<p class="label ngl">Not drawn · ${D.gone.length}</p><div class="dplist" role="list">${D.gone.map((g) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(g.title)}</b><br>${esc(g.why)}</p></div>`).join('')}</div>` : '';
146
178
  const checks = D.checks.length ? `<p class="note pdck">${D.checks.map(esc).join(' ')}</p>` : '';
147
179
  $('#dashBody').innerHTML = (tot ? `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
180
+ + findingsHtml(D)
148
181
  + `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} The charts are drawn in the order you saved. The dashed line is the target.</p>`
149
182
  + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>`
150
183
  : `<div class="nempty" style="margin-top:14px"><p><b>This dashboard draws no chart yet.</b> Press Edit to add a measure with a series.</p></div>`) + checks + gone;
@@ -162,8 +195,21 @@ function noSeriesHtml() {
162
195
  const N = M.noSeries; if (!N.length) return '';
163
196
  return `<p class="label ngl">No series recorded · ${N.length}</p><div class="dplist" role="list">${N.map((n) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(n.title)}</b>${n.pillar ? ' · ' + esc(n.pillar) : ''}<br>${esc(n.why)} It is not drawn.</p></div>`).join('')}</div>`;
164
197
  }
165
- $('#dashTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-d]'); if (!b) return; dash = b.dataset.d; drawDash(); });
166
- $('#dashBar').addEventListener('click', (e) => { if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pdNew')) openDashEdit(null); else if (e.target.closest('#pcNew')) openChartEdit(null); });
198
+ /* Pin or unpin (PRD L4): one `pin` line in the dashboards ledger. The pinned dashboard shows in the top card of this page, and nowhere else. */
199
+ async function pinDash(id, from) {
200
+ const res = await pmPost('/api/premium-dashboards/pin', { ws: M.board.ws, board: M.board.id, id: id || null });
201
+ if (!res || res.ok !== true) { toast((res && res.error) || 'The pin could not be saved. Nothing changed.'); return; }
202
+ const D = M.dashboards.find((d) => d.id === id);
203
+ dash = res.pinned || 'all';
204
+ toast(res.pinned ? 'Pinned ' + (D ? D.name : 'the dashboard') + '. It shows at the top of Insights.' : 'Unpinned. All measures shows at the top.');
205
+ await load();
206
+ if (from === 'list') { try { $('#cDash').scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch { /* no scroll */ } }
207
+ }
208
+ $('#dashBar').addEventListener('click', (e) => {
209
+ const pin = e.target.closest('#pdPin'); if (pin) { pin.disabled = true; pinDash(pin.dataset.pin || null, 'card'); return; }
210
+ if (e.target.closest('#pdBack')) { dash = M.pinned; drawDash(); drawList(); return; }
211
+ if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pcNew')) openChartEdit(null);
212
+ });
167
213
 
168
214
  /* ── a dashboard is made and edited in the Insight Studio (initiative premium-studio-dashboard). Its one press posts POST /api/premium-dashboards/save. ── */
169
215
  async function saveDash(body) { return pmPost('/api/premium-dashboards/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
@@ -177,8 +223,8 @@ const design = {
177
223
  post: (sub, id, body) => pmPost('/api/report-design/' + sub, Object.assign({ ws: M.board.ws, id }, body)),
178
224
  };
179
225
  const studioOf = (o) => openStudio(Object.assign({ M, tile: tileHtml, derive: deriveChart, save: saveDash, saveChart, setup: (sub, body) => repPost(sub, body), structure, design, reportsChanged: () => load(),
180
- done: async (id) => { dash = id || dash; if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; await load(); } }, o));
181
- function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || 'all'; await load(); } }); }
226
+ done: async (id) => { dash = id || dash; await load(); } }, o));
227
+ function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || null; await load(); } }); }
182
228
  /* A chart is made and edited in the Studio's Chart mode (initiative premium-studio-chart). Save posts POST /api/premium-charts/save. */
183
229
  function openChartEdit(id) { studioOf({ mode: 'chart', C: id ? (M.mineSaved || []).find((x) => x.id === id) || null : null }); }
184
230
  /* A report is set up and shaped in the Studio's Report mode (initiative premium-studio-report). */
@@ -196,45 +242,77 @@ $('#dashBody').addEventListener('pointermove', (e) => {
196
242
  });
197
243
  $('#dashBody').addEventListener('pointerleave', () => $$('#dashBody .mch.hv').forEach((x) => chartAt(x)));
198
244
 
199
- /* ── reports ──────────────────────────────────────────────────────────────────────────────────────────────────── */
245
+ /* ── the list: dashboards, then reports, filtered and paged (insights-one-list L5, L6) ──────────────────────────── */
200
246
  let askTimer = 0;
201
247
  const dismissing = new Map(); // finding id → timer: "Not a report" waits 5 s for an Undo before it is sent
202
248
  const ASKST = { running: ['Working', 'draft'], ready: ['Ready to review', 'issued'], failed: ['Failed', 'none'] };
249
+ const insLine = (t, q) => `<span class="nil${q ? ' q' : ''}">${ICO(AIC)}<span>${esc(t)}</span></span>`;
250
+ function dashRow(D) {
251
+ const I = D.insight || {}, f = I.finds && I.finds[0], on = M.pinned === D.id, shown = curDash().id === D.id;
252
+ const line = I.none ? '' : insLine(f ? f.text : I.calmText);
253
+ const meta = `<span class="t">Dashboard</span>${on ? '<span class="s issued">Pinned</span>' : ''}${shown ? '<span>Shown above</span>' : ''}<span>${D.total} ${D.total === 1 ? 'chart' : 'charts'}</span>${D.off ? `<span class="s none">${D.off} behind</span>` : D.total ? '<span>All on their line</span>' : ''}`;
254
+ return `<div class="dmr" role="listitem"><button class="dmo" data-d="${esc(D.id)}"><span class="dmi c-Dash">${ICO(DASHI)}</span><span class="dmn"><b>${esc(D.name)}</b>${line || `<small>${esc(I.none ? 'No chart is drawn on it yet.' : '')}</small>`}<span class="dmm">${meta}</span></span></button>`
255
+ + (pinnable(D) ? `<button class="npin" data-pin="${esc(D.id)}" aria-pressed="${on}" aria-label="${on ? 'Unpin' : 'Pin'} ${esc(D.name)}" title="${on ? 'Unpin' : 'Pin to the top of Insights'}">${ICO(PINI)}</button>` : '') + '</div>';
256
+ }
257
+ /* A report row's insight is the opening sentence of its latest file, marked as quoted from it. With no file it says no draft is written yet. */
258
+ function setupRow(s) {
259
+ const L = s.latest, line = L && L.lead ? insLine('“' + L.lead + '”', true) : '';
260
+ const from = L ? (L.lead ? 'From the ' + L.date + ' file' : 'The ' + L.date + ' file has no sentence to quote') : 'No draft is written yet';
261
+ return `<div class="dmr" role="listitem"><button class="dmo" data-setup="${esc(s.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(s.name)}</b>${line}<small>${esc([from, s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small><span class="dmm"><span class="t">Report</span><span class="s ${s.paused ? 'none' : 'issued'}">${s.paused ? 'Paused' : s.drafting ? 'Drafting' : 'Set up'}</span>${s.next && !s.paused ? `<span>Next draft ${esc(s.next)}</span>` : ''}</span></span></button></div>`;
262
+ }
203
263
  function repRow(r) {
204
- return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="${esc(r.key)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Deck, present, download, print</span></span></span></button></div>`;
264
+ return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="${esc(r.key)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b>${r.lead ? insLine('“' + r.lead + '”', true) : ''}<small>${esc(r.path)}</small><span class="dmm"><span class="t">Report</span><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Deck, present, download, print</span></span></span></button></div>`;
205
265
  }
206
266
  const foundRow = (f) => `<div class="dmr" role="listitem"><button class="dmo" data-found="${esc(f.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(f.name)}</b><small>${esc(f.why)}</small><span class="dmm">${f.confidence ? `<span>${esc(f.confidence)}</span>` : ''}<span>${f.evidence.length} ${f.evidence.length === 1 ? 'sign' : 'signs'} in your work</span></span></span></button></div>`;
207
267
  const askRow = (a) => `<div class="dmr" role="listitem"><button class="dmo" data-ask="${esc(a.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(a.proposal && a.proposal.name ? a.proposal.name : a.text)}</b><small>You asked: ${esc(a.text)}</small><span class="dmm"><span class="s ${ASKST[a.state][1]}">${ASKST[a.state][0]}</span>${a.changed ? '<span>Changed once</span>' : ''}</span></span></button></div>`;
208
- const setupRow = (s) => `<div class="dmr" role="listitem"><button class="dmo" data-setup="${esc(s.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(s.name)}</b><small>${esc([s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small><span class="dmm"><span class="s ${s.paused ? 'none' : 'issued'}">${s.paused ? 'Paused' : s.drafting ? 'Drafting' : 'Set up'}</span>${s.next && !s.paused ? `<span>Next draft ${esc(s.next)}</span>` : ''}</span></span></button></div>`;
209
- function drawReps() {
210
- const R = M.reports, found = (R.found || []).filter((f) => !dismissing.has(f.id)), asks = R.asks || [], setups = R.setups || [];
211
- $('#repCap').textContent = R.rows.length ? String(R.rows.length) : '';
212
- const group = (id, label, L, row) => L.length ? `<div class="dmg ngrp" id="${id}" role="list"><p class="label">${esc(label)} · ${L.length}</p>${L.map(row).join('')}</div>` : '';
213
- $('#repBody').innerHTML = `<p class="mhint">A report is a file in the repository. PMOS drafts it, you read it. <b>Nothing is sent from here.</b></p>`
214
- + '<div class="nact"><button class="dmcta" id="repNew" aria-haspopup="dialog">New report</button></div>'
215
- + `<form class="nask" id="repAsk"><input id="repAskIn" maxlength="500" autocomplete="off" placeholder="Ask PMOS to set up a report" aria-label="Ask PMOS to set up a report"><button class="dmcta" id="repAskGo" type="submit">Ask</button></form>`
216
- + '<p class="note nask-n">This starts a background run that only proposes a report. Nothing is set up until you press Set it up.</p>'
217
- + (R.setupsOk === false ? '<div class="nempty"><p><b>The report setups could not be read</b>, so what PMOS found and what you set up are not listed.</p></div>'
218
- : group('repAsks', 'Your requests', asks, askRow) + group('repFound', 'Found in your work', found, foundRow) + group('repSetups', 'Set up', setups, setupRow))
219
- + (R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
220
- : R.rows.length ? `<div class="dmg ngrp" id="repDocs" role="list"><p class="label">Documents · <b>${R.counts.draft}</b> ${R.counts.draft === 1 ? 'draft' : 'drafts'} · <b>${R.counts.issued}</b> issued</p>${R.rows.map(repRow).join('')}</div>`
221
- : '<div class="nempty"><p><b>No report file is on record.</b> Set one up above, or ask PMOS for one.</p></div>')
222
- + `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to edit or issue a document.</p>`;
268
+ function listItems() {
269
+ const R = M.reports, d = M.dashboards.map((x) => ({ kind: 'dash', x }));
270
+ const r = (R.setupsOk === false ? [] : (R.setups || []).map((x) => ({ kind: 'setup', x }))).concat(R.missing ? [] : R.rows.map((x) => ({ kind: 'file', x })));
271
+ return { d, r, all: d.concat(r) };
272
+ }
273
+ function drawList() {
274
+ const R = M.reports, found = (R.found || []).filter((f) => !dismissing.has(f.id)), asks = R.asks || [];
275
+ const I = listItems(), L = listF === 'dash' ? I.d : listF === 'rep' ? I.r : I.all, pages = Math.max(1, Math.ceil(L.length / PER));
276
+ listP = Math.min(Math.max(1, listP), pages);
277
+ $('#repCap').textContent = String(I.all.length);
278
+ const seg = $('#listSeg');
279
+ seg.innerHTML = '<i class="pill"></i>' + [['all', 'All', I.all.length], ['dash', 'Dashboards', I.d.length], ['rep', 'Reports', I.r.length]].map(([k, t, n]) => `<button data-f="${k}" aria-pressed="${listF === k}">${t}<em>${n}</em></button>`).join('');
280
+ pillOf(seg);
281
+ const group = (id, label, G, row) => G.length ? `<div class="dmg ngrp" id="${id}" role="list"><p class="label">${esc(label)} · ${G.length}</p>${G.map(row).join('')}</div>` : '';
282
+ const row = (it) => it.kind === 'dash' ? dashRow(it.x) : it.kind === 'setup' ? setupRow(it.x) : repRow(it.x);
283
+ const empty = listF !== 'dash' && R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
284
+ : listF !== 'dash' && R.setupsOk === false ? '<div class="nempty"><p><b>The report setups could not be read</b>, so what PMOS found and what you set up are not listed.</p></div>' : '';
285
+ const none = listF === 'rep' && !L.length && !R.missing ? '<div class="nempty"><p><b>No report is set up and no report file is on record.</b> Press New, then Report, or ask PMOS for one.</p></div>' : '';
286
+ $('#repBody').innerHTML = (listF === 'dash' ? '' : group('repAsks', 'Your requests', asks, askRow) + group('repFound', 'Found in your work', found, foundRow))
287
+ + empty + none
288
+ + `<div class="dmg" id="listRows" role="list" aria-label="Dashboards and reports">${L.slice((listP - 1) * PER, listP * PER).map(row).join('')}</div>`;
289
+ const from = (listP - 1) * PER + 1, to = Math.min(listP * PER, L.length);
290
+ $('#listPager').innerHTML = pages < 2 ? `<span class="note">${L.length} shown</span>`
291
+ : `<span class="note">${from}–${to} of ${L.length}</span><span class="pg" role="group" aria-label="Pages"><button data-pg="${listP - 1}" ${listP === 1 ? 'disabled' : ''} aria-label="Previous page">‹</button>${Array.from({ length: pages }, (_, i) => `<button data-pg="${i + 1}"${i + 1 === listP ? ' aria-current="page"' : ''} aria-label="Page ${i + 1}">${i + 1}</button>`).join('')}<button data-pg="${listP + 1}" ${listP === pages ? 'disabled' : ''} aria-label="Next page">›</button></span>`;
223
292
  clearTimeout(askTimer);
224
293
  if (asks.some((a) => a.state === 'running')) askTimer = setTimeout(load, 5000);
225
294
  }
295
+ $('#listSeg').addEventListener('click', (e) => { const b = e.target.closest('[data-f]'); if (!b || b.dataset.f === listF) return; listF = b.dataset.f; listP = 1; drawList(); });
296
+ $('#listPager').addEventListener('click', (e) => { const b = e.target.closest('[data-pg]'); if (!b || b.disabled) return; listP = +b.dataset.pg; drawList(); $('#cRep').scrollIntoView({ block: 'nearest' }); });
297
+ const menu = (open) => { $('#listMenu').hidden = !open; $('#listNew').setAttribute('aria-expanded', String(open)); };
298
+ $('#listNew').addEventListener('click', () => { const open = $('#listMenu').hidden; menu(open); if (open) $('#listMenu button').focus(); });
299
+ $('#listMenu').addEventListener('click', (e) => { const b = e.target.closest('button'); if (!b) return; menu(false); if (b.id === 'pdNew') openDashEdit(null); else if (b.id === 'repNew') openReportEdit(null); });
300
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !$('#listMenu').hidden) { menu(false); $('#listNew').focus(); } });
301
+ document.addEventListener('click', (e) => { if (!$('#listMenu').hidden && !e.target.closest('.newm')) menu(false); });
226
302
  $('#repBody').addEventListener('click', (e) => {
303
+ const pin = e.target.closest('[data-pin]');
304
+ if (pin) { pin.disabled = true; pinDash(M.pinned === pin.dataset.pin ? null : pin.dataset.pin, 'list'); return; }
305
+ const d = e.target.closest('[data-d]');
306
+ if (d) { dash = d.dataset.d; drawDash(); drawList(); try { $('#cDash').scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch { /* no scroll */ } return; }
227
307
  const rp = e.target.closest('[data-rep]');
228
308
  if (rp) { const row = M.reports.rows.find((x) => x.key === rp.dataset.rep), su = row && (M.reports.setups || []).find((x) => x.id === row.cadence); openReport(row, { ws: M.board.ws, name: su ? su.name : null }); return; }
229
- if (e.target.closest('#repOpen')) { location.assign('/console.html?tab=rep'); return; }
230
- if (e.target.closest('#repNew')) { openReportEdit(null); return; }
231
309
  const f = e.target.closest('[data-found]'), a = e.target.closest('[data-ask]'), s = e.target.closest('[data-setup]');
232
310
  if (f) openFound((M.reports.found || []).find((x) => x.id === f.dataset.found));
233
311
  else if (a) openAsk((M.reports.asks || []).find((x) => x.id === a.dataset.ask));
234
312
  else if (s) openSetup((M.reports.setups || []).find((x) => x.id === s.dataset.setup));
235
313
  });
236
- $('#repBody').addEventListener('submit', async (e) => {
237
- if (e.target.id !== 'repAsk') return;
314
+ $('#repOpen').addEventListener('click', () => location.assign('/console.html?tab=rep'));
315
+ $('#repAsk').addEventListener('submit', async (e) => {
238
316
  e.preventDefault();
239
317
  const inp = $('#repAskIn'), text = inp.value.trim(), go = $('#repAskGo');
240
318
  if (!text) { toast('Say what the report is for, then press Ask.'); inp.focus(); return; }
@@ -286,9 +364,9 @@ function openFound(f) {
286
364
  set: press('setup', { finding: f.id, name: f.name }, setupSaid),
287
365
  no: (m) => {
288
366
  const t = setTimeout(async () => { dismissing.delete(f.id); const res = await repPost('dismiss', { finding: f.id, name: f.name }); if (!res || res.ok !== true) toast(pressFailed(res, 'Not a report did not go through.')); await load(); }, 5000);
289
- dismissing.set(f.id, t); drawReps();
367
+ dismissing.set(f.id, t); drawList();
290
368
  m.innerHTML = 'Hidden. It is recorded as not a report in 5 seconds. <button class="lk" id="rxUndo">Undo</button>';
291
- $('#rxUndo').onclick = () => { clearTimeout(dismissing.get(f.id)); dismissing.delete(f.id); drawReps(); m.textContent = 'Undone. Nothing was recorded.'; $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); };
369
+ $('#rxUndo').onclick = () => { clearTimeout(dismissing.get(f.id)); dismissing.delete(f.id); drawList(); m.textContent = 'Undone. Nothing was recorded.'; $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); };
292
370
  return 'keep-off';
293
371
  },
294
372
  } });
@@ -335,7 +413,7 @@ function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textConten
335
413
  function cardHtml(c) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(c.dialog.hold)} The switches under On your dashboards save a dashboard and change no record.</p></div>`; }
336
414
  function paneHtml(c) {
337
415
  const p = c.dialog.pane;
338
- return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p><h3 class="d1">${esc(c.title)}</h3><p>${esc(c.dialog.say)}</p><div class="ntw pdchart">${tileHtml(c)}</div><div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>${onDashHtml(c)}<p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Nothing here is a forecast.</p></article>`;
416
+ return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p><h3 class="d1">${esc(c.title)}</h3><p>${esc(c.dialog.say)}</p><div class="ntw pdchart">${tileHtml(c)}</div><div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>${onDashHtml(c)}<p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Where this page says where a measure lands by its target date, that is a straight line through its last four readings, carried to that date. It is not drawn.</p></article>`;
339
417
  }
340
418
  /* Add to a dashboard (PRD D6): one switch per saved dashboard of the board. A press saves that dashboard with the chart added or taken off. */
341
419
  function onDashHtml(c) {
@@ -417,13 +495,14 @@ MT.wireTiles($('#bmBody'), () => (BM ? BM.tiles : []), bmOpen);
417
495
  $('#bmRange').addEventListener('click', (e) => { const b = e.target.closest('[data-w]'); if (!b || +b.dataset.w === bmWeeks) return; bmWeeks = +b.dataset.w; try { localStorage.setItem(BM_KEY, String(bmWeeks)); } catch { /* not kept */ } bmDraw(); bmLoad(); });
418
496
 
419
497
  /* ── load ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
420
- function draw() { drawHead(); if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; drawDash(); drawReps(); drawDock(); onScroll(); }
498
+ function draw() { drawHead(); if (!dash || !M.dashboards.some((d) => d.id === dash)) dash = M.pinned || 'all'; drawDash(); drawList(); drawDock(); onScroll(); }
421
499
  async function load() {
422
500
  const p = new URLSearchParams(location.search), q = [p.get('ws') ? 'ws=' + encodeURIComponent(p.get('ws')) : '', p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
423
501
  let r = null, status = 0;
424
502
  try { const res = await fetch('/api/insights-premium' + (q ? '?' + q : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
425
503
  if (!r || !r.ok) {
426
504
  $('#snap').textContent = 'The records could not be read';
505
+ $('#insEye').textContent = 'Insight'; $('#insWhy').textContent = '';
427
506
  $('#brief').textContent = 'The KR metric records could not be read, so this page shows nothing rather than guess.' + (r && r.error ? ' The reason: ' + r.error : status ? ' (the server answered ' + status + ')' : ' The server did not answer.');
428
507
  setTimeout(load, 15000);
429
508
  return;
@@ -5,7 +5,7 @@
5
5
  <meta name="pmos-nonce" content="" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
7
7
  <title>PMOS · Insights</title>
8
- <!-- The premium Insights (initiative briefing-premium-insights, slice 9). The fourth place on the rail, in the Briefing's shell. It reads GET /api/insights-premium, built from the KR metric records and the report files the console's Reports tab reads, and GET /api/board-metrics-premium for the Board measures card, whose one press sets a target (POST /api/board-metric-targets/save). -->
8
+ <!-- The premium Insights (initiative briefing-premium-insights, slice 9; insights-one-list puts the insight first, the pinned dashboard on top and one paged list below). The fourth place on the rail, in the Briefing's shell. It reads GET /api/insights-premium, built from the KR metric records and the report files the console's Reports tab reads, and GET /api/board-metrics-premium for the Board measures card, whose one press sets a target (POST /api/board-metric-targets/save). -->
9
9
  <link rel="preload" href="/vendor/geist-var.woff2" as="font" type="font/woff2" crossorigin />
10
10
  <link rel="stylesheet" href="/pm/premium.css" />
11
11
  <link rel="stylesheet" href="/pm/premium-insights.css" />
@@ -36,29 +36,39 @@
36
36
  <h1 class="vh">Insights</h1><div id="crumbHost"></div>
37
37
  <div class="tools tools-top"><span class="vh" id="snap">Reading the records</span></div>
38
38
  </header>
39
- <section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
40
- <section class="card rise" style="--d:4" id="cBm" aria-labelledby="hBm" hidden>
39
+ <section class="hero ins-hero rise" style="--d:2" id="insHero" aria-label="Insight">
40
+ <p class="ieye" id="insEye"></p>
41
+ <p class="brief ihead" id="brief" aria-live="polite"></p>
42
+ <p class="iwhy" id="insWhy"></p>
43
+ <ul class="imore" id="insMore"></ul>
44
+ <div class="iact" id="insAct"></div>
45
+ <p class="note inote" id="insNote"></p>
46
+ </section>
47
+ <section class="card pdcard rise" style="--d:5" id="cDash" aria-labelledby="hDash">
48
+ <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg></span><h2 id="hDash">Dashboard</h2><i class="ptag" id="dashTag"></i><small id="dashCap"></small></div>
49
+ <div class="nact pdbar" id="dashBar" hidden></div>
50
+ <div id="dashBody"></div>
51
+ </section>
52
+ <section class="card nrep rise" style="--d:6" id="cRep" aria-labelledby="hRep">
53
+ <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 6h16M4 12h16M4 18h10"/></svg></span><h2 id="hRep">Dashboards and reports</h2><small id="repCap"></small></div>
54
+ <div class="seg" id="listSeg" role="group" aria-label="Show"><i class="pill"></i></div>
55
+ <div class="lbar">
56
+ <span class="newm"><button class="dmcta" id="listNew" aria-haspopup="menu" aria-expanded="false" aria-controls="listMenu">New ▾</button>
57
+ <span class="lmenu" id="listMenu" role="menu" hidden><button role="menuitem" id="pdNew">Dashboard</button><button role="menuitem" id="repNew">Report</button></span></span>
58
+ <form class="nask" id="repAsk"><input id="repAskIn" maxlength="500" autocomplete="off" placeholder="Ask PMOS to set up a report" aria-label="Ask PMOS to set up a report"><button class="dmcta" id="repAskGo" type="submit">Ask</button></form>
59
+ </div>
60
+ <p class="note nask-n">Ask starts a background run that only proposes a report. Nothing is set up until you press Set it up.</p>
61
+ <p class="mhint">A report is a file in the repository. PMOS drafts it, you read it. <b>Nothing is sent from here.</b> The pin puts one dashboard at the top of this page. It shows nowhere else.</p>
62
+ <div id="repBody"></div>
63
+ <div class="lpager" id="listPager"></div>
64
+ <p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to edit or issue a document.</p>
65
+ </section>
66
+ <section class="card rise" style="--d:7" id="cBm" aria-labelledby="hBm" hidden>
41
67
  <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg></span><h2 id="hBm">Board measures</h2><small id="bmCap"></small><div class="seg mper" id="bmRange" role="group" aria-label="Range"><i class="pill"></i><button data-w="8" aria-pressed="true">8 weeks</button><button data-w="26" aria-pressed="false">26 weeks</button><button data-w="52" aria-pressed="false">52 weeks</button></div></div>
42
68
  <p class="mhint" id="bmHint"></p>
43
69
  <div class="bt2 ibt" id="bmBody"></div>
44
70
  <p class="note" id="bmNote"></p>
45
71
  </section>
46
- <div class="nl">
47
- <div class="nlc">
48
- <section class="card rise" style="--d:5" id="cDash" aria-labelledby="hDash">
49
- <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg></span><h2 id="hDash">Dashboards</h2><small id="dashCap"></small></div>
50
- <div class="seg" id="dashTabs" role="group" aria-label="Dashboard" hidden><i class="pill"></i></div>
51
- <div class="nact pdbar" id="dashBar" hidden></div>
52
- <div id="dashBody"></div>
53
- </section>
54
- </div>
55
- <aside class="nlr" aria-label="Reports">
56
- <section class="card nrep rise" style="--d:6" id="cRep" aria-labelledby="hRep">
57
- <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/></svg></span><h2 id="hRep">Reports</h2><small id="repCap"></small></div>
58
- <div id="repBody"></div>
59
- </section>
60
- </aside>
61
- </div>
62
72
  <p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. A press here records only what it says: a dashboard or a chart in the workspace's state folder, a report setup, request or dismissal in the report ledger, or a report's look in its design folder. The Board measures card counts the Board's four measures from the repository, over 8, 26 or 52 weeks; a target set there is saved in the workspace's state folder and drawn on the Board too. Left out: any measure no record holds. Nothing is sent from this page.</p>
63
73
  </main>
64
74
  <noscript>This page needs JavaScript.</noscript>