create-pmos 0.397.0 → 0.399.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 +25 -25
- 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 +105 -52
- package/workspace/briefing-premium-board-test.js +284 -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 +85 -196
- package/workspace/briefing-premium-doc-edit-test.js +99 -83
- package/workspace/briefing-premium-initiative-test.js +175 -290
- package/workspace/briefing-premium-insights-test.js +414 -219
- package/workspace/briefing-premium-metrics-test.js +55 -97
- package/workspace/briefing-premium-products-test.js +44 -28
- package/workspace/briefing-premium-sources-test.js +70 -49
- package/workspace/briefing-premium-test.js +155 -648
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +24 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +68 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +121 -24
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +64 -15
- package/workspace/lib/insights-records.js +115 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/meeting-points.js +52 -0
- package/workspace/lib/news-for-you.js +88 -0
- package/workspace/lib/notes-series.js +29 -6
- package/workspace/lib/report-confirm.js +48 -0
- package/workspace/lib/route-modules.js +12 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-home-review.js +108 -0
- package/workspace/lib/routes-initiative-layout.js +57 -0
- package/workspace/lib/routes-insights-premium.js +16 -4
- package/workspace/lib/routes-insights-records.js +133 -0
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +3 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/search-index.js +176 -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 +128 -82
- package/workspace/premium-briefing-depth-test.js +104 -90
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +37 -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 +46 -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 +52 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +10 -3
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +152 -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 +97 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +17 -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 +115 -187
- package/workspace/premium-vw-notes-test.js +88 -109
- package/workspace/premium-vw-rec-test.js +71 -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 +383 -0
- package/workspace/public/pm/bd-asks.js +261 -0
- package/workspace/public/pm/bd-pop.js +59 -0
- package/workspace/public/pm/bd-span.js +222 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/bd-views.js +169 -0
- 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 +798 -230
- package/workspace/public/pm/cozy-ev.css +228 -0
- package/workspace/public/pm/cozy-evmodel.js +106 -0
- package/workspace/public/pm/cozy-evui.js +47 -0
- 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 +437 -170
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +104 -29
- package/workspace/public/pm/cozy-news.js +140 -0
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-search.js +203 -0
- package/workspace/public/pm/cozy-settings.js +198 -0
- package/workspace/public/pm/cozy-sources.js +89 -0
- package/workspace/public/pm/cozy-today.css +217 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +145 -0
- package/workspace/public/pm/cozy-vw-mtg.css +350 -0
- package/workspace/public/pm/cozy-vw-rp.css +152 -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 +1179 -0
- package/workspace/public/pm/home-around.js +413 -0
- package/workspace/public/pm/home-chat.js +512 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-ini-model.js +190 -0
- package/workspace/public/pm/home-ini.css +171 -0
- package/workspace/public/pm/home-ini.js +456 -0
- package/workspace/public/pm/home-list.js +276 -0
- package/workspace/public/pm/home-more.js +132 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-review.js +104 -0
- package/workspace/public/pm/home-task.js +67 -0
- package/workspace/public/pm/home-today.js +144 -0
- package/workspace/public/pm/home-work.js +547 -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 +548 -395
- package/workspace/public/pm/premium-chart-tab.js +109 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +23 -21
- package/workspace/public/pm/premium-insights.js +1102 -581
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-mtg-present.js +138 -0
- package/workspace/public/pm/premium-mtg-replay.js +142 -0
- 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 +669 -476
- package/workspace/public/pm/premium-report-tab.js +116 -67
- package/workspace/public/pm/premium-shell.js +76 -123
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +277 -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 +958 -0
- package/workspace/public/pm/premium-vw-notes.js +116 -68
- 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/rp-parts.js +269 -0
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +29 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +26 -64
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +18 -107
- package/workspace/r/m1.png +0 -0
- package/workspace/r/m2.png +0 -0
- package/workspace/r/m3.png +0 -0
- package/workspace/r/nl.png +0 -0
- 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/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/test-lists/uf-everywhere.json +15 -0
- package/workspace/test-lists/uf-home.json +9 -0
- package/workspace/test-lists/uncovered-board.json +9 -0
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/* pm/home-around.js — the views Around you held on Home (initiative premium-briefing-depth; moved onto Home by premium-agreed-design).
|
|
2
|
+
* premium-uncovered-features (canvas HmAround): Around you is gone, and what it showed lives in one place each. New for you (cozy-news.js)
|
|
3
|
+
* holds the mentions, the finished results and today's digests, and its "Where the rest went" rows open these views, which keep every press
|
|
4
|
+
* of the old card: agent proposals · mentions · portfolio pulse · horizon scan · report found. Data freshness is Sources (cozy-sources.js).
|
|
5
|
+
* Each view opens in the Viewer with Back to New for you; Escape closes the Viewer.
|
|
6
|
+
* Every read is a route the console already uses and every write is a press that says what it does first (pmPost carries the launch nonce).
|
|
7
|
+
* A source that cannot be read is named in its view, never shown as empty. Which products: ?ws=<id> that one, otherwise every product Home reads.
|
|
8
|
+
* Nothing here posts to Slack, Jira, Confluence or mail.
|
|
9
|
+
* openAround(key?) → the body element; key opens one view (prop | men | pulse | scan | rep); no key opens New for you, src opens Sources
|
|
10
|
+
* prepHtmlOf(brief) → the prep line (the meetings left today and how many are prepped), from one GET /api/brief-page answer; New for you shows it */
|
|
11
|
+
import { pmGet, pmPost } from './http.js';
|
|
12
|
+
import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
|
|
13
|
+
|
|
14
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
15
|
+
const STAMP = (n) => String(n).padStart(2, '0');
|
|
16
|
+
const toast = (t) => { const el = document.getElementById('toast'); if (!el) return; el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
|
|
17
|
+
const CHECK = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12l4.5 4.5L19 7"/></svg>';
|
|
18
|
+
const SRCN = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail' };
|
|
19
|
+
const srcName = (s) => SRCN[s] || String(s || 'a source');
|
|
20
|
+
const first = (s) => String(s || '').trim().split(/\s+/)[0];
|
|
21
|
+
const pl = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
22
|
+
const BDI = {
|
|
23
|
+
at: '<circle cx="12" cy="12" r="4"/><path d="M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1"/>',
|
|
24
|
+
prop: '<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"/>',
|
|
25
|
+
pulse: '<path d="M3 12h4l3-7 4 14 3-7h4"/>',
|
|
26
|
+
scan: '<circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/>',
|
|
27
|
+
rep: '<path d="M7 3h8l4 4v14H7z"/><path d="M14 3v5h5M10 13h6M10 17h6"/>',
|
|
28
|
+
src: '<path d="M20 11a8 8 0 0 0-14.6-4.5M4 13a8 8 0 0 0 14.6 4.5"/><path d="M5 3v4h4M19 21v-4h-4"/>',
|
|
29
|
+
x: '<path d="M6 6l12 12M18 6 6 18"/>',
|
|
30
|
+
};
|
|
31
|
+
const bdIco = (d) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${d}</svg>`;
|
|
32
|
+
const H2 = (t) => `<h4>${esc(t)}</h4>`;
|
|
33
|
+
const kv = (rows) => `<dl class="hv-facts">${rows.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>`;
|
|
34
|
+
|
|
35
|
+
const A = { prop: null, men: null, pulse: null, scan: null, rep: null }; // the last answer of each read
|
|
36
|
+
const DEC = new Map(); // proposals decided on this visit: id → { item, st: 'kept' | 'back' | 'dropped', note, wrote, warnings }
|
|
37
|
+
const PNOTE = {}, PERR = {}, PBACK = new Set();
|
|
38
|
+
const MREAD = new Map(), MADD = new Set();
|
|
39
|
+
const SDEC = new Map();
|
|
40
|
+
const SERR = {}, SWHY = {}, SOPEN = new Set();
|
|
41
|
+
const REC = new Map(), RERR = {};
|
|
42
|
+
const PMORE = new Set();
|
|
43
|
+
let MTAB = 'all', BUSY = '', PSEL = '', PINFO = false, VIEW = '', PRODS = null;
|
|
44
|
+
const getj = async (p) => { const r = await pmGet(p); return r && r.ok !== false ? r : { ok: false, error: (r && r.error) || 'the server did not answer' }; };
|
|
45
|
+
const wq = (ws) => (ws ? 'ws=' + encodeURIComponent(ws) : '');
|
|
46
|
+
const wsParam = () => new URLSearchParams(location.search).get('ws') || '';
|
|
47
|
+
const said = (r) => 'could not be read: ' + (r && r.error ? r.error : 'the server did not answer');
|
|
48
|
+
async function prods() {
|
|
49
|
+
const one = wsParam(); if (one) return [{ ws: one, name: one }];
|
|
50
|
+
if (!PRODS) { const r = await getj('/api/briefing-premium'); PRODS = r.ok && r.model && r.model.products ? r.model.products.available.filter((x) => x.on).map((x) => ({ ws: x.ws, name: x.name })) : []; if (!PRODS.length) PRODS = [{ ws: '', name: '' }]; }
|
|
51
|
+
return PRODS;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ── reads ── */
|
|
55
|
+
async function readProps(P) {
|
|
56
|
+
const items = [], errs = [];
|
|
57
|
+
await Promise.all(P.flatMap((p) => ['initiative', 'work'].map(async (kind) => {
|
|
58
|
+
const r = await getj('/api/driver/open?target_kind=' + kind + (p.ws ? '&' + wq(p.ws) : ''));
|
|
59
|
+
if (!r.ok) { errs.push(r.error); return; }
|
|
60
|
+
if (r.mode !== 'approve') return; // Off and Shadow raise nothing here (the console draws the same)
|
|
61
|
+
for (const [tid, list] of Object.entries(r.targets || {})) for (const pr of list) items.push({ id: pr.id, ws: r.ws, pname: P.length > 1 ? p.name : '', kind, tid, p: pr, title: '' });
|
|
62
|
+
})));
|
|
63
|
+
items.sort((a, b) => String(a.p.at).localeCompare(String(b.p.at)) || a.id.localeCompare(b.id));
|
|
64
|
+
if (items.some((x) => x.kind === 'work')) {
|
|
65
|
+
const w = await getj('/api/pm-items'), by = new Map(((w.ok && w.items) || []).map((i) => [i.id, i.title]));
|
|
66
|
+
items.forEach((x) => { if (x.kind === 'work') x.title = by.get(x.tid) || ''; });
|
|
67
|
+
}
|
|
68
|
+
if (!items.length && errs.length) return { ok: false, error: errs[0] };
|
|
69
|
+
return { ok: true, items, errs };
|
|
70
|
+
}
|
|
71
|
+
let BP = null;
|
|
72
|
+
const briefPage = (force) => (BP && !force && Date.now() - BP.at < 30000 ? BP.p : (BP = { at: Date.now(), p: getj('/api/brief-page' + (wsParam() ? '?' + wq(wsParam()) : '')) }).p);
|
|
73
|
+
async function readMen() { const r = await briefPage(); return r.ok ? { ok: true, list: Array.isArray(r.mentions) ? r.mentions : null } : r; }
|
|
74
|
+
const PST = { 'on time': ['ok', 'On time'], 'at risk': ['warn', 'At risk'], delayed: ['bad', 'Delayed'], overdue: ['bad', 'Overdue'], 'no plan': ['', 'No plan'] };
|
|
75
|
+
/** One Calendar row as the pulse draws it. cls: bad (late) · warn (at risk) · ok (on plan) · '' (no plan date). The Calendar's own status. */
|
|
76
|
+
export function pulseRow(g) {
|
|
77
|
+
const j = g.jira && Number.isInteger(g.jira.total) && g.jira.total > 0 && Number.isInteger(g.jira.done) ? g.jira : null;
|
|
78
|
+
const f = (g.forecast && (g.forecast.end || g.forecast.start)) || null;
|
|
79
|
+
if (j && (!PST[g.status] || g.status === 'no plan')) {
|
|
80
|
+
const all = j.done >= j.total;
|
|
81
|
+
return { id: g.id, title: g.title || g.id, cls: j.blocked > 0 ? 'warn' : all ? 'ok' : '', word: j.blocked > 0 ? 'Blocked' : all ? 'Done in Jira' : 'In progress',
|
|
82
|
+
why: j.done + ' of ' + j.total + ' done in Jira' + (j.blocked > 0 ? ', ' + j.blocked + ' blocked' : '') + '; no promised date' };
|
|
83
|
+
}
|
|
84
|
+
const k = PST[g.status] ? g.status : 'no plan', p = g.promised || null;
|
|
85
|
+
return { id: g.id, title: g.title || g.id, cls: PST[k][0], word: PST[k][1] + (g.slip_days > 0 ? ' +' + g.slip_days + ' d' : ''),
|
|
86
|
+
why: (p ? 'Forecast ' + (f || 'not set') + ' vs promised ' + p : 'No promised date' + (f ? '; forecast ' + f : '')) + (j ? '. ' + j.done + ' of ' + j.total + ' done in Jira' : '') };
|
|
87
|
+
}
|
|
88
|
+
async function readPulse(P) {
|
|
89
|
+
const d = new Date(), day = d.getFullYear() + '-' + STAMP(d.getMonth() + 1) + '-' + STAMP(d.getDate()), rows = [], errs = [];
|
|
90
|
+
let none = 0;
|
|
91
|
+
await Promise.all(P.map(async (p, i) => {
|
|
92
|
+
const r = await getj('/api/calendar-views?view=quarter&only=gantt&date=' + day + (p.ws ? '&' + wq(p.ws) : ''));
|
|
93
|
+
if (!r.ok) { errs.push(r.error); return; }
|
|
94
|
+
none += Number(r.no_plan) || 0;
|
|
95
|
+
for (const g of r.gantt || []) rows.push({ ...pulseRow(g), ws: p.ws, pname: P.length > 1 ? p.name : '', at: i });
|
|
96
|
+
}));
|
|
97
|
+
rows.sort((a, b) => a.at - b.at);
|
|
98
|
+
if (!rows.length && !none && errs.length) return { ok: false, error: errs[0] };
|
|
99
|
+
return { ok: true, rows, none, errs };
|
|
100
|
+
}
|
|
101
|
+
async function readScan(P) {
|
|
102
|
+
const got = [], errs = [];
|
|
103
|
+
await Promise.all(P.map(async (p, i) => { const r = await getj('/api/scan/portfolio' + (p.ws ? '?' + wq(p.ws) : '')); if (!r.ok) errs.push(r.error); else got.push({ ...r, pname: P.length > 1 ? p.name : '', at: i }); }));
|
|
104
|
+
got.sort((a, b) => a.at - b.at);
|
|
105
|
+
if (!got.length && errs.length) return { ok: false, error: errs[0] };
|
|
106
|
+
return { ok: true, scans: got, errs };
|
|
107
|
+
}
|
|
108
|
+
async function readReps(P) {
|
|
109
|
+
const got = [], errs = [];
|
|
110
|
+
await Promise.all(P.map(async (p, i) => {
|
|
111
|
+
const r = await getj('/api/report-setups' + (p.ws ? '?' + wq(p.ws) : ''));
|
|
112
|
+
if (!r.ok) errs.push((P.length > 1 && p.name ? p.name + ': ' : '') + r.error);
|
|
113
|
+
else got.push({ ws: r.ws || p.ws, pname: P.length > 1 ? p.name : '', at: i, finder: r.finder || null, findings: Array.isArray(r.findings) ? r.findings : [] });
|
|
114
|
+
}));
|
|
115
|
+
got.sort((a, b) => a.at - b.at);
|
|
116
|
+
if (!got.length && errs.length) return { ok: false, error: errs[0] };
|
|
117
|
+
return { ok: true, prods: got, errs };
|
|
118
|
+
}
|
|
119
|
+
async function readAll(which) {
|
|
120
|
+
const P = await prods(), all = !which;
|
|
121
|
+
const job = { prop: () => readProps(P), men: () => readMen(), pulse: () => readPulse(P), scan: () => readScan(P), rep: () => readReps(P) };
|
|
122
|
+
await Promise.all(Object.keys(job).filter((k) => all || which.includes(k)).map(async (k) => { try { A[k] = await job[k](); } catch (e) { A[k] = { ok: false, error: String((e && e.message) || e) }; } }));
|
|
123
|
+
redraw();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* ── words ── */
|
|
127
|
+
const PWHAT = { problem: 'Problem statement', evidence: 'Evidence', sizing: 'Opportunity sizing', assumption: 'Riskiest assumption and spike brief', stakeholders: 'Stakeholders', move: 'Move', note: 'Note', 'next-step': 'Next step', 'follow-up': 'Follow-up' };
|
|
128
|
+
const pWhat = (p) => (p.what === 'move' && p.data && p.data.to ? 'Move to ' + p.data.to : PWHAT[p.what] || p.what);
|
|
129
|
+
const pKeep = (p) => ({ problem: 'Keep writes the problem statement into the stage record.', move: 'Keep moves the initiative on its board.', 'next-step': 'Keep adds the next step to your Work item.', 'follow-up': 'Keep copies the follow-up text. Nothing is sent to anyone.', doc: 'Keep issues the draft document.' }[p.what] || 'Keep records that you accept it. Nothing else changes.');
|
|
130
|
+
const pWrote = (w) => ({ problem: 'The problem statement is in the stage record.', move: 'The initiative moved.', doc: 'The document was issued.', 'next-step': 'The next step is in your Work item.' }[w] || 'It is recorded. Nothing else changed.');
|
|
131
|
+
const pText = (p) => {
|
|
132
|
+
const t = p.data && typeof p.data.text === 'string' ? p.data.text : '';
|
|
133
|
+
if (p.what === 'move') return 'Move this initiative to ' + ((p.data && p.data.to) || 'the next stage') + '.';
|
|
134
|
+
if (t) return t;
|
|
135
|
+
if (p.data && Array.isArray(p.data.items)) return pl(p.data.items.length, 'item', 'items') + ' with a pointer each.';
|
|
136
|
+
return '';
|
|
137
|
+
};
|
|
138
|
+
const iniTitle = (x) => { const r = A.pulse && A.pulse.ok && A.pulse.rows.find((y) => y.id === x.tid && y.ws === x.ws); return r ? r.title : ''; };
|
|
139
|
+
const targetOf = (x) => (x.kind === 'work' ? 'Work · ' : 'Initiative · ') + (x.title || (x.kind === 'initiative' ? iniTitle(x) : '') || x.tid);
|
|
140
|
+
const openProps = () => (A.prop && A.prop.ok ? A.prop.items : []);
|
|
141
|
+
const shownMen = () => {
|
|
142
|
+
const l = A.men && A.men.ok && A.men.list ? A.men.list : [];
|
|
143
|
+
return l.filter((m) => !m.in_needs && (MREAD.has(m.id) || !m.read)).map((m) => (MREAD.has(m.id) ? { ...m, read: MREAD.get(m.id) } : m));
|
|
144
|
+
};
|
|
145
|
+
const waitM = (l) => l.filter((m) => m.reply && !m.read);
|
|
146
|
+
function menLine(l) {
|
|
147
|
+
const w = waitM(l), rest = l.filter((m) => !m.read).length - w.length;
|
|
148
|
+
if (!w.length) return rest ? 'No one is waiting on a reply. ' + pl(rest, 'mention is', 'mentions are') + ' for your information.' : 'No mentions are left unread.';
|
|
149
|
+
const names = w.map((m) => (m.who ? first(m.who) : 'Someone') + ' in ' + srcName(m.source)), s = names.length < 2 ? names[0] : names.slice(0, -1).join(', ') + ' and ' + names[names.length - 1];
|
|
150
|
+
return s + (w.length === 1 ? ' is' : ' are') + ' waiting on your reply.' + (rest ? ' ' + rest + (rest === 1 ? ' more is' : ' more are') + ' for your information.' : '');
|
|
151
|
+
}
|
|
152
|
+
const mWhen = (iso) => {
|
|
153
|
+
if (!iso) return '';
|
|
154
|
+
const d = new Date(iso), n = new Date(), hm = STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()), k = (x) => x.getFullYear() * 400 + x.getMonth() * 32 + x.getDate(), y = new Date(n); y.setDate(y.getDate() - 1);
|
|
155
|
+
return k(d) === k(n) ? hm : k(d) === k(y) ? 'yesterday ' + hm : d.getDate() + '/' + (d.getMonth() + 1) + ' ' + hm;
|
|
156
|
+
};
|
|
157
|
+
const groups = (rows) => ({ bad: rows.filter((r) => r.cls === 'bad'), warn: rows.filter((r) => r.cls === 'warn'), ok: rows.filter((r) => r.cls === 'ok'), none: rows.filter((r) => !r.cls) });
|
|
158
|
+
const PGW = { bad: 'Late', warn: 'At risk', ok: 'On plan', none: 'No plan date' };
|
|
159
|
+
const bar = (g, n, extra) => `<span class="bd-bar" aria-hidden="true">${['bad', 'warn', 'ok', 'none'].map((k) => { const c = k === 'none' ? g.none.length + extra : g[k].length; return c ? `<i class="${k}" data-w="${c / n * 100}"></i>` : ''; }).join('')}</span>`;
|
|
160
|
+
const dayWord = (iso) => {
|
|
161
|
+
const d = new Date(iso); if (!Number.isFinite(d.getTime())) return '';
|
|
162
|
+
const n = new Date(), y = new Date(n), hm = STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()); y.setDate(y.getDate() - 1);
|
|
163
|
+
return d.toDateString() === n.toDateString() ? 'today, ' + hm : d.toDateString() === y.toDateString() ? 'yesterday, ' + hm : d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()] + ', ' + hm;
|
|
164
|
+
};
|
|
165
|
+
const scanOpen = () => (A.scan && A.scan.ok ? A.scan.scans.reduce((n, s) => n + (s.proposals_waiting || 0), 0) : 0);
|
|
166
|
+
const repFound = () => (A.rep && A.rep.ok ? A.rep.prods.flatMap((q) => q.findings.map((f) => ({ ...f, ws: q.ws, pname: q.pname }))) : []);
|
|
167
|
+
const pHm = (iso) => { const d = new Date(iso); return STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()); };
|
|
168
|
+
/** The prep line: of the meetings still ahead today, how many have nothing left to do before them (/api/brief-page, `before` is the open items linked to a meeting). */
|
|
169
|
+
export function prepHtmlOf(p) {
|
|
170
|
+
const t = p && p.ok !== false ? p.today || [] : [], left = t.filter((m) => m.state !== 'past'), ok = left.filter((m) => !(m.before || []).length).length;
|
|
171
|
+
if (!left.length) return '<div id="prep" class="ar-prep" hidden></div>';
|
|
172
|
+
const cur = t.find((m) => m.state === 'now'), nxt = cur || t.find((m) => m.state === 'next'), R = 17, C = 2 * Math.PI * R;
|
|
173
|
+
return `<div id="prep" class="ar-prep"><svg width="44" height="44" viewBox="0 0 44 44" role="img" aria-label="${ok} of ${left.length} prepped"><circle class="rb" cx="22" cy="22" r="${R}" fill="none" stroke-width="6"/><circle class="rg" cx="22" cy="22" r="${R}" fill="none" stroke-width="6" stroke-linecap="round" stroke-dasharray="${(C * ok / left.length).toFixed(2)} ${C.toFixed(2)}" transform="rotate(-90 22 22)"/><text class="rt" x="22" y="26" text-anchor="middle">${ok}/${left.length}</text></svg><div>${nxt ? `<b>${esc(nxt.title)}${cur ? ' is on now' : ' at ' + pHm(nxt.start) + ' is next'}</b>` : ''}<span>${pl(left.length, 'meeting', 'meetings')} left today. ${ok} of ${left.length} prepped.</span></div></div>`;
|
|
174
|
+
}
|
|
175
|
+
const bdLink = (href) => (/^https:\/\/\S+$/i.test(String(href || '')) ? href : '');
|
|
176
|
+
|
|
177
|
+
/* ── the pieces of a view ── */
|
|
178
|
+
const bdActs = (...b) => `<div class="bd-acts">${b.join('')}</div>`;
|
|
179
|
+
const bdBtn = (label, act, id, alt, attrs) => `<button type="button" class="hx-b cta${alt ? ' alt' : ' pri'}" data-bda="${act}"${id != null ? ` data-id="${esc(id)}"` : ''}${attrs || ''}>${esc(label)}</button>`;
|
|
180
|
+
const bdDone = (ok, text) => `<p class="bd-done" role="status">${ok ? CHECK : bdIco(BDI.x)}<span>${esc(text)}</span></p>`;
|
|
181
|
+
const bdChip = (t, c) => `<span class="bd-chip${c ? ' ' + c : ''}">${esc(t)}</span>`;
|
|
182
|
+
const bdFail = (id, e) => (e[id] ? `<p class="nodef err" role="alert">${esc(e[id])}</p>` : '');
|
|
183
|
+
|
|
184
|
+
/* ── agent proposals ── */
|
|
185
|
+
function propItem(it, sel) {
|
|
186
|
+
const p = it.p, d = DEC.get(it.id), id = it.id, text = pText(p), more = PMORE.has(id), on = !d && id === sel;
|
|
187
|
+
const src = (p.sources || []).filter((s) => s && s.ref).map((s) => (bdLink(s.ref) ? `<a href="${esc(bdLink(s.ref))}" target="_blank" rel="noopener noreferrer">${esc(s.label || s.ref)}</a>` : esc((s.label ? s.label + ': ' : '') + s.ref))).join(' · ');
|
|
188
|
+
const line = text || (p.why ? 'Why: ' + p.why : ''), extra = (text && p.why) || src;
|
|
189
|
+
let act = '';
|
|
190
|
+
if (d) act = d.st === 'kept' ? bdDone(true, 'Kept. ' + pWrote(d.wrote) + (d.warnings.length ? ' ' + d.warnings.join(' ') : '')) : d.st === 'back' ? bdDone(true, 'Sent back with your note: “' + d.note + '”. The note starts a new run.') : bdDone(false, 'Dropped. It counts as a correction.');
|
|
191
|
+
else if (on && !PBACK.has(id)) act = bdFail(id, PERR);
|
|
192
|
+
const pick = d ? `<span class="bd-t">${esc(targetOf(it))}</span>` : `<button type="button" class="bd-t pc-pick" data-bda="psel" data-id="${esc(id)}" aria-pressed="${on}">${esc(targetOf(it))}</button>`;
|
|
193
|
+
return `<div class="bd-it pcard${d ? ' decided' : ''}${on ? ' on' : ''}" data-id="${esc(id)}"${d ? '' : ' data-bda="psel"'}><small class="pc-k">${esc(pWhat(p))}${it.pname ? ' · ' + esc(it.pname) : ''}</small>${pick}`
|
|
194
|
+
+ (line ? `<p class="pc-line${more ? ' open' : ''}"><span>${esc(line)}</span>${extra ? `<button type="button" class="pc-more" data-bda="pmore" data-id="${esc(id)}" aria-expanded="${more}">${more ? 'Less' : 'Read more'}</button>` : ''}</p>` : '')
|
|
195
|
+
+ (extra ? `<div class="pc-x"${more ? '' : ' hidden'}>${text && p.why ? `<p class="bd-why">Why: ${esc(p.why)}</p>` : ''}${src ? `<p class="bd-why">Sources: ${src}</p>` : ''}</div>` : '') + act + '</div>';
|
|
196
|
+
}
|
|
197
|
+
const propSel = (L) => { const w = L.filter((it) => !DEC.has(it.id)); return (w.find((it) => it.id === PSEL) || w[0] || {}).id || ''; };
|
|
198
|
+
function propsHtml() {
|
|
199
|
+
const a = A.prop; if (!a || !a.ok) return `<p class="nodef err" role="alert">Agent proposals ${esc(said(a))}</p>`;
|
|
200
|
+
const L = a.items.concat([...DEC.values()].map((d) => d.item).filter((it) => !a.items.some((o) => o.id === it.id))), sel = propSel(L), it = L.find((x) => x.id === sel);
|
|
201
|
+
const notes = [it ? pKeep(it.p) + ' Drop counts as a correction. Send back starts a new run with your note. None of the three can be undone.' : '', 'The agent mode (Off, Shadow, Approve) stays in Settings. This list shows a kind only when its mode is Approve.', a.errs.length ? 'Not read: ' + a.errs[0] : ''].filter(Boolean);
|
|
202
|
+
const info = `<div class="pc-info"><button type="button" class="hx-b alt" data-bda="pinfo" aria-expanded="${PINFO}" aria-controls="pcNotes"><i class="pc-i" aria-hidden="true">i</i>Nothing changes a record until you keep it</button><div id="pcNotes"${PINFO ? '' : ' hidden'}>${notes.map((t) => `<p class="bd-why">${esc(t)}</p>`).join('')}</div></div>`;
|
|
203
|
+
const back = it && PBACK.has(it.id), id = it ? esc(it.id) : '';
|
|
204
|
+
const note = back ? `<label class="bd-l" for="bdn-${id}">What should the agent change?</label><textarea id="bdn-${id}" data-bdn="${id}" maxlength="500" rows="2">${esc(PNOTE[it.id] || '')}</textarea>${bdFail(it.id, PERR)}` : '';
|
|
205
|
+
const pbar = !it ? '' : `<div class="pc-bar">${note}<div class="pc-row">${back
|
|
206
|
+
? `<button type="button" class="hx-b pc-q" data-bda="pcancel" data-id="${id}">Cancel</button><button type="button" class="hx-b pri pc-p" data-bda="pback" data-id="${id}"${(PNOTE[it.id] || '').trim() ? '' : ' disabled'}>Send back</button>`
|
|
207
|
+
: `<button type="button" class="hx-b pc-q" data-bda="pnote" data-id="${id}">Send back</button><button type="button" class="hx-b pc-q" data-bda="pdrop" data-id="${id}">Drop</button><button type="button" class="hx-b pri pc-p" data-bda="pkeep" data-id="${id}">Keep</button>`}</div><p class="pc-fine">${L.filter((x) => !DEC.has(x.id)).length > 1 ? 'For the chosen card · ' : ''}Can’t be undone</p></div>`;
|
|
208
|
+
return (L.length ? `<div class="bd-list pc-list">${L.map((x) => propItem(x, sel)).join('')}</div>` : `<p class="empty3">${CHECK}No agent proposals wait.</p>`) + info + pbar;
|
|
209
|
+
}
|
|
210
|
+
const propTitle = () => { const a = A.prop; if (!a || !a.ok) return 'Agent proposals'; const n = a.items.length; return n ? n + (n === 1 ? ' waits' : ' wait') + ' for you' : 'All decided'; };
|
|
211
|
+
async function propPress(b) {
|
|
212
|
+
if (b.dataset.bda === 'pinfo') { PINFO = !PINFO; draw('[data-bda="pinfo"]'); return; }
|
|
213
|
+
const act = b.dataset.bda, id = b.dataset.id;
|
|
214
|
+
if (act === 'pmore') { if (PMORE.has(id)) PMORE.delete(id); else PMORE.add(id); draw(`[data-bda="pmore"][data-id="${CSS.escape(id)}"]`); return; }
|
|
215
|
+
const it = openProps().find((x) => x.id === id); if (!it) return;
|
|
216
|
+
if (act === 'psel') { PSEL = id; draw(`[data-bda="psel"][data-id="${CSS.escape(id)}"]`); return; }
|
|
217
|
+
if (act === 'pnote') { PBACK.add(id); draw(`[data-bdn="${CSS.escape(id)}"]`); return; }
|
|
218
|
+
if (act === 'pcancel') { PBACK.delete(id); delete PERR[id]; draw(`[data-bda="pnote"][data-id="${CSS.escape(id)}"]`); return; }
|
|
219
|
+
const note = (PNOTE[id] || '').trim();
|
|
220
|
+
if (act === 'pback' && !note) { PERR[id] = 'Write one line for the agent. A note starts its next run.'; draw(`[data-bdn="${CSS.escape(id)}"]`); return; }
|
|
221
|
+
if (!['pkeep', 'pback', 'pdrop'].includes(act)) return;
|
|
222
|
+
BUSY = id; b.disabled = true;
|
|
223
|
+
const r = await pmPost('/api/driver/' + (act === 'pkeep' ? 'keep' : act === 'pback' ? 'return' : 'drop'), { ws: it.ws, proposal: id, ...(act === 'pback' ? { note } : {}) });
|
|
224
|
+
BUSY = '';
|
|
225
|
+
if (!r || r.ok !== true) { PERR[id] = (r && r.error) || 'It was not recorded.'; draw(); return; }
|
|
226
|
+
delete PERR[id]; PBACK.delete(id);
|
|
227
|
+
DEC.set(id, { item: it, st: act === 'pkeep' ? 'kept' : act === 'pback' ? 'back' : 'dropped', note, wrote: r.wrote, warnings: r.warnings || [] });
|
|
228
|
+
toast(act === 'pkeep' ? 'Kept.' : act === 'pback' ? 'Sent back with your note.' : 'Dropped. It counts as a correction.');
|
|
229
|
+
await readAll(['prop']); draw('.pc-bar .pc-p:not([disabled])');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* ── mentions ── */
|
|
233
|
+
const taskLine = (m) => (m.reply ? 'Reply to ' + (m.who ? first(m.who) : 'the sender') + ' (' + srcName(m.source) + ') by today' : 'Read ' + (m.who ? first(m.who) : 'the sender') + '\'s note (' + srcName(m.source) + ')');
|
|
234
|
+
function menHtml() {
|
|
235
|
+
const a = A.men; if (!a || !a.ok) return `<p class="nodef err" role="alert">Mentions ${esc(said(a))}</p>`;
|
|
236
|
+
if (a.list === null) return '<p class="empty3">No brief for today, so no mentions were read.</p><p class="hx-n">Mentions come from today\'s brief. Nothing here replies, reacts or posts in Slack, Jira, Confluence or mail.</p>';
|
|
237
|
+
const l = shownMen(), ORD = ['slack', 'jira', 'confluence', 'mail'], srcs = ORD.filter((k) => l.some((m) => m.source === k)).concat([...new Set(l.map((m) => m.source))].filter((k) => !ORD.includes(k)));
|
|
238
|
+
if (MTAB !== 'all' && !srcs.includes(MTAB)) MTAB = 'all';
|
|
239
|
+
const rows = l.filter((m) => MTAB === 'all' || m.source === MTAB).sort((x, y) => (y.reply - x.reply) || ((y.at ? Date.parse(y.at) : 0) - (x.at ? Date.parse(x.at) : 0)));
|
|
240
|
+
const tabs = `<div class="hx-tabs" role="group" aria-label="Source">${['all', ...srcs].map((k) => `<button type="button" data-bda="mtab" data-k="${esc(k)}" aria-pressed="${MTAB === k}">${k === 'all' ? 'All ' + l.length : esc(srcName(k)) + ' ' + l.filter((m) => m.source === k).length}</button>`).join('')}</div>`;
|
|
241
|
+
const item = (m) => {
|
|
242
|
+
const link = bdLink(m.link), when = mWhen(m.at);
|
|
243
|
+
const acts = m.read ? bdActs(bdBtn('Mark unread', 'munread', m.id, true))
|
|
244
|
+
: bdActs(MADD.has(m.id) ? bdDone(true, 'In your Work list.') : bdBtn('Make it a task', 'madd', m.id), bdBtn('Mark read', 'mread', m.id, true), link ? `<a class="hx-b cta alt" href="${esc(link)}" target="_blank" rel="noopener noreferrer" data-bdlink="${esc(m.id)}">Open in ${esc(srcName(m.source))}</a>` : '')
|
|
245
|
+
+ (MADD.has(m.id) ? '' : `<p class="bd-why">Make it a task adds “${esc(taskLine(m))}” to your Work list. Mark read hides it from today's list.</p>`) + bdFail(m.id, SERR);
|
|
246
|
+
return `<div class="bd-it${m.read ? ' decided' : ''}" data-id="${esc(m.id)}"><div class="bd-h">${bdChip(srcName(m.source) + (m.where ? ' · ' + m.where : ''))}${when ? bdChip(when) : ''}${m.reply ? bdChip('Needs your reply', 'warn') : bdChip('For your information')}</div><span class="bd-t">${esc(m.who || srcName(m.source))}</span><p class="bd-q">${esc(m.text)}</p>${m.initiative ? `<p class="bd-why">${esc(m.initiative)}</p>` : ''}${acts}</div>`;
|
|
247
|
+
};
|
|
248
|
+
return (l.length ? `<div class="bd-top">${tabs}</div><div class="bd-list">${rows.map(item).join('')}</div>` : '<p class="empty3">' + CHECK + 'No one has mentioned you today.</p>')
|
|
249
|
+
+ '<p class="hx-n">Mentions come from today\'s brief. A mention that is already a Needs-you row is not listed here. Nothing here replies, reacts or posts in Slack, Jira, Confluence or mail.</p>';
|
|
250
|
+
}
|
|
251
|
+
async function menPress(b) {
|
|
252
|
+
const act = b.dataset.bda, id = b.dataset.id;
|
|
253
|
+
if (act === 'mtab') { MTAB = b.dataset.k; draw(`[data-bda="mtab"][data-k="${CSS.escape(MTAB)}"]`); return; }
|
|
254
|
+
const m = shownMen().find((x) => x.id === id); if (!m || !['madd', 'mread', 'munread'].includes(act)) return;
|
|
255
|
+
BUSY = id; b.disabled = true; delete SERR[id];
|
|
256
|
+
const r = act === 'madd' ? await pmPost('/api/pm-items/add', { line: taskLine(m) }) : await pmPost('/api/mentions/read', { id, read: act === 'mread' });
|
|
257
|
+
BUSY = '';
|
|
258
|
+
if (!r || r.ok === false) { SERR[id] = 'That did not go through' + (r && r.error ? ': ' + r.error : '.'); draw(); return; }
|
|
259
|
+
if (act === 'madd') { MADD.add(id); toast('Added to Work: ' + taskLine(m).replace(/ by today$/, '')); draw(`.bd-it[data-id="${CSS.escape(id)}"] [data-bda="mread"]`); }
|
|
260
|
+
else { MREAD.set(id, act === 'mread'); toast(act === 'mread' ? 'Marked read.' : 'Marked unread.'); draw(`.bd-it[data-id="${CSS.escape(id)}"] button`); }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* ── portfolio pulse ── */
|
|
264
|
+
function pulseHtml() {
|
|
265
|
+
const a = A.pulse; if (!a || !a.ok) return `<p class="nodef err" role="alert">Portfolio pulse ${esc(said(a))}</p>`;
|
|
266
|
+
const g = groups(a.rows), n = a.rows.length + a.none, item = (r) => `<div class="bd-it"><div class="bd-h">${bdChip(r.word, r.cls === 'bad' ? 'hot' : r.cls === 'warn' ? 'warn' : '')}${r.pname ? bdChip(r.pname) : ''}</div><span class="bd-t">${esc(r.title)}</span><p class="bd-why">${esc(r.why)}</p>${bdActs(`<a class="hx-b cta alt" href="/premium.html?ini=${encodeURIComponent(r.id)}${r.ws ? '&ws=' + encodeURIComponent(r.ws) : ''}">Open the initiative</a>`)}</div>`;
|
|
267
|
+
const hot = g.bad.concat(g.warn);
|
|
268
|
+
return `<div class="bd-leg">${['bad', 'warn', 'ok', 'none'].map((k) => `<span><i class="${k}"></i>${PGW[k]} ${k === 'none' ? g.none.length + a.none : g[k].length}</span>`).join('')}</div>${n ? bar(g, n, a.none) : ''}`
|
|
269
|
+
+ H2('Needs a look') + (hot.length ? `<div class="bd-list">${hot.map(item).join('')}</div>` : '<p class="hx-n">Nothing is late or at risk.</p>')
|
|
270
|
+
+ `<details class="bd-more"><summary>${g.ok.length} on plan</summary><div class="bd-list">${g.ok.map(item).join('')}</div></details>`
|
|
271
|
+
+ `<details class="bd-more"><summary>${g.none.length + a.none} with no plan date</summary><div class="bd-list">${g.none.map(item).join('')}</div>${a.none ? `<p class="hx-n">${pl(a.none, 'more initiative has', 'more initiatives have')} no promised date and no Jira read, so they are not listed.</p>` : ''}</details>`
|
|
272
|
+
+ (a.errs.length ? `<p class="hx-n">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="hx-n">The status is the Calendar\'s: the promised date against the forecast, or the Jira read. It is not a forecast of its own, and nothing here changes a record.</p>';
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* ── horizon scan ── */
|
|
276
|
+
const SKIND = { create: ['New initiative', 'Approve', 'The initiative was created in the first stage of the board.'], research: ['Research', 'Start the research', 'A research scan was started.'], attach: ['Evidence', 'Approve', 'An evidence line was written.'] };
|
|
277
|
+
const sDoes = (p) => { const f = p.fields || {}; return p.kind === 'create' ? 'Approve creates the initiative in the first stage of the ' + (f.board || 'board') + ' workflow.' : p.kind === 'research' ? 'Start the research starts a research scan' + (f.question ? ' for “' + f.question + '”' : '') + '.' : 'Approve writes an evidence line on ' + (f.initiative || 'the initiative') + '.'; };
|
|
278
|
+
function scanProp(p, ws) {
|
|
279
|
+
const d = SDEC.get(p.id), k = SKIND[p.kind] || [p.kind, 'Approve', 'It is recorded.'], f = p.fields || {};
|
|
280
|
+
const act = d ? bdDone(d.st === 'ok', d.st === 'ok' ? 'Approved. ' + k[2] : 'Dismissed. It counts as a correction.') + (d.st === 'no' ? bdActs(bdBtn('Undo', 'sundo', p.id, true, ` data-ws="${esc(ws)}"`)) : '')
|
|
281
|
+
: SOPEN.has(p.id) ? `<label class="bd-l" for="bds-${esc(p.id)}">Why dismiss it? A reason is required.</label><input type="text" id="bds-${esc(p.id)}" data-bds="${esc(p.id)}" maxlength="500" value="${esc(SWHY[p.id] || '')}" placeholder="For example: we already decided this">${bdFail(p.id, SERR)}`
|
|
282
|
+
+ bdActs(bdBtn('Dismiss', 'sdis', p.id, false, ` data-ws="${esc(ws)}"${(SWHY[p.id] || '').trim() ? '' : ' disabled'}`), bdBtn('Cancel', 'sdiscancel', p.id, true)) + '<p class="bd-why">A dismissal counts as a correction. The scan will not raise the same thing again.</p>'
|
|
283
|
+
: bdActs(bdBtn(k[1], 'sapp', p.id, false, ` data-ws="${esc(ws)}"`), bdBtn('Dismiss', 'sdisopen', p.id, true)) + `<p class="bd-why">${esc(sDoes(p))} Dismiss asks for a reason and counts as a correction.</p>` + bdFail(p.id, SERR);
|
|
284
|
+
return `<div class="bd-it${d ? ' decided' : ''}" data-id="${esc(p.id)}"><div class="bd-h">${bdChip(k[0])}${f.board ? bdChip(f.board) : ''}</div><span class="bd-t">${esc(p.title)}</span>${p.why ? `<p class="bd-why">${esc(p.why)}</p>` : ''}${p.finding ? `<p class="bd-q">${esc(p.finding)}</p>` : ''}${act}</div>`;
|
|
285
|
+
}
|
|
286
|
+
function scanPart(s) {
|
|
287
|
+
const lastWord = s.last ? dayWord(s.last.at) + (s.last.ok === false ? ' (did not finish' + (s.last.reason ? ': ' + s.last.reason : '') + ')' : '') : 'No scan has run yet';
|
|
288
|
+
const nextWord = s.switched_off ? 'Scans are switched off on this machine' : s.next ? dayWord(s.next) + (s.schedule ? ' · ' + s.schedule : '') : (s.schedule || 'Not scheduled');
|
|
289
|
+
let ctl;
|
|
290
|
+
if (s.open) ctl = `<div class="bd-it"><span class="bd-t">Scanning now</span><div class="bd-steps">${(s.open.steps || []).map((x) => `<div class="${esc(x.state)}"><i></i>${esc(x.label || x.id)}${x.state === 'work' ? ' …' : ''}</div>`).join('')}</div>${bdActs(bdBtn(s.open.stopping ? 'Stopping…' : 'Stop', 'sstop', s.ws, true, s.open.stopping ? ' disabled' : ''))}<p class="bd-why">Stop ends the scan. Nothing it has not filed is written.</p></div>`;
|
|
291
|
+
else {
|
|
292
|
+
const m = s.manual || {}, no = s.switched_off ? 'Scans are switched off on this machine.' : m.ok === false ? (m.error || 'A manual scan cannot start now.') : '';
|
|
293
|
+
ctl = bdActs(bdBtn('Scan now', 'snow', s.ws, false, no ? ' disabled' : '')) + `<p class="bd-why">${no ? esc(no) + ' ' : ''}Scan now starts an agent that reads the public web for your watch list and this repository, then writes reports with proposals. Nothing acts until you approve it.${m.limit ? ' ' + m.left + ' of ' + m.limit + ' manual scans left today.' : ''}</p>`;
|
|
294
|
+
}
|
|
295
|
+
const top = s.reports.filter((r) => !r.parent && r.written), scan = s.last && s.last.scan, show = top.filter((r) => r.scan === scan || (r.proposals && r.proposals.open > 0) || [...SDEC.values()].some((d) => d.p.report === r.id));
|
|
296
|
+
const reps = show.map((r) => {
|
|
297
|
+
const ps = s.proposals.filter((p) => p.report === r.id), dec = [...SDEC.entries()].filter(([, d]) => d.p.report === r.id && !ps.some((p) => p.id === d.p.id)).map(([, d]) => d.p), all = ps.concat(dec);
|
|
298
|
+
return H2(r.label || r.type + ' report') + `<p class="bd-q">${esc(r.title)}</p><p class="bd-why">From: ${esc(r.origin || 'the repository')} · ${ps.length} of ${(r.proposals && r.proposals.total) || all.length} proposals wait</p><div class="bd-list">${all.map((p) => scanProp(p, s.ws)).join('')}</div>`;
|
|
299
|
+
}).join('');
|
|
300
|
+
return (s.pname ? H2(s.pname) : '') + kv([['Last scan', lastWord], ['Next', nextWord]]) + ctl + (reps || (s.last ? '<p class="hx-n">The last scan wrote no report.</p>' : ''));
|
|
301
|
+
}
|
|
302
|
+
function scanHtml() {
|
|
303
|
+
const a = A.scan; if (!a || !a.ok) return `<p class="nodef err" role="alert">Horizon scan ${esc(said(a))}</p>`;
|
|
304
|
+
return a.scans.map(scanPart).join('') + (a.errs.length ? `<p class="hx-n">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="hx-n">One scan covers the whole product. The watch list, the scan setting, the report documents and Change on a proposal stay in Settings.</p>';
|
|
305
|
+
}
|
|
306
|
+
let SPOLL = null;
|
|
307
|
+
function scanPoll() {
|
|
308
|
+
clearTimeout(SPOLL);
|
|
309
|
+
if (!A.scan || !A.scan.ok || !A.scan.scans.some((s) => s.open)) return;
|
|
310
|
+
SPOLL = setTimeout(async () => { if (VIEW !== 'scan') return; await readAll(['scan']); scanPoll(); }, 4000);
|
|
311
|
+
}
|
|
312
|
+
async function scanPress(b) {
|
|
313
|
+
const act = b.dataset.bda, id = b.dataset.id, ws = b.dataset.ws || '';
|
|
314
|
+
if (act === 'sdisopen') { SOPEN.add(id); draw(`[data-bds="${CSS.escape(id)}"]`); return; }
|
|
315
|
+
if (act === 'sdiscancel') { SOPEN.delete(id); delete SERR[id]; draw(`[data-bda="sdisopen"][data-id="${CSS.escape(id)}"]`); return; }
|
|
316
|
+
if (!['snow', 'sstop', 'sapp', 'sdis', 'sundo'].includes(act)) return;
|
|
317
|
+
const why = (SWHY[id] || '').trim();
|
|
318
|
+
if (act === 'sdis' && !why) return;
|
|
319
|
+
BUSY = id; b.disabled = true;
|
|
320
|
+
let r;
|
|
321
|
+
if (act === 'snow') r = await pmPost('/api/scan/now', { ws: id });
|
|
322
|
+
else if (act === 'sstop') r = await pmPost('/api/scan/stop', { ws: id });
|
|
323
|
+
else r = await pmPost('/api/scan/proposal', { ws, id, action: act === 'sapp' ? 'approve' : act === 'sdis' ? 'dismiss' : 'undo', ...(act === 'sdis' ? { why } : {}) });
|
|
324
|
+
BUSY = '';
|
|
325
|
+
if (!r || r.ok !== true) { SERR[id] = (r && r.error) || 'It did not go through.'; draw(); toast(SERR[id]); return; }
|
|
326
|
+
delete SERR[id];
|
|
327
|
+
if (act === 'sapp' || act === 'sdis') { const p = A.scan.scans.flatMap((s) => s.proposals).find((x) => x.id === id); if (p) SDEC.set(id, { st: act === 'sapp' ? 'ok' : 'no', p }); SOPEN.delete(id); toast(act === 'sapp' ? 'Approved.' : 'Dismissed. It counts as a correction.'); }
|
|
328
|
+
else if (act === 'sundo') { SDEC.delete(id); toast('The dismissal was taken back.'); }
|
|
329
|
+
else toast(act === 'snow' ? 'Scan started. It runs in the background.' : 'Stopping the scan.');
|
|
330
|
+
await readAll(['scan']); draw(act === 'snow' ? '[data-bda="sstop"]' : act === 'sstop' ? '[data-bda="snow"]' : `.bd-it[data-id="${CSS.escape(id)}"] .bd-done`); scanPoll();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* ── report found ── */
|
|
334
|
+
const EVK = { mail: 'Mail', calendar: 'Calendar', slack: 'Slack', drive: 'Drive', confluence: 'Confluence' };
|
|
335
|
+
const CONF = { likely: 'Likely', 'not-sure': 'Not sure' };
|
|
336
|
+
function repItem(f) {
|
|
337
|
+
const d = REC.get(f.id), id = f.id;
|
|
338
|
+
const ev = (f.evidence || []).filter((e) => e && e.text).map((e) => bdChip((EVK[e.kind] || String(e.kind || 'Source')) + ': ' + e.text)).join('');
|
|
339
|
+
const act = d ? (d.st === 'set' ? bdDone(true, 'Set up' + (d.setup ? ' as ' + d.setup : '') + '. Its first cycle is drafted on this machine. Nothing was sent.') : bdDone(true, 'Marked not a report. The finder will not raise it again.'))
|
|
340
|
+
: bdActs(bdBtn('Set up', 'rset', id, false, ` data-ws="${esc(f.ws)}"`), bdBtn('Not a report', 'rno', id, true, ` data-ws="${esc(f.ws)}"`)) + '<p class="bd-why">Set up creates the recurring report and drafts its first cycle on this machine. PMOS drafts only. Nothing is sent. Not a report: the finder will not raise it again.</p>' + bdFail(id, RERR);
|
|
341
|
+
return `<div class="bd-it${d ? ' decided' : ''}" data-id="${esc(id)}"><div class="bd-h">${f.confidence && CONF[f.confidence] ? bdChip(CONF[f.confidence]) : ''}${f.pname ? bdChip(f.pname) : ''}</div><span class="bd-t">${esc(f.name)}</span>${f.why ? `<p class="bd-q">${esc(f.why)}</p>` : ''}${ev ? `<p class="bd-h">${ev}</p>` : ''}${act}</div>`;
|
|
342
|
+
}
|
|
343
|
+
function repHtml() {
|
|
344
|
+
const a = A.rep; if (!a || !a.ok) return `<p class="nodef err" role="alert">Report finder ${esc(said(a))}</p>`;
|
|
345
|
+
const L = repFound().concat([...REC.values()].map((d) => d.f).filter((f) => !repFound().some((o) => o.id === f.id && o.ws === f.ws)));
|
|
346
|
+
return (L.length ? `<p class="bd-top">${repFound().length ? pl(repFound().length, 'report was', 'reports were') + ' found in your work.' : 'All decided.'} PMOS drafts only. Nothing is sent.</p><div class="bd-list">${L.map(repItem).join('')}</div>` : `<p class="empty3">${CHECK}No report found.</p>`)
|
|
347
|
+
+ (a.errs.length ? `<p class="hx-n">Not read: ${esc(a.errs[0])}</p>` : '') + '<p class="hx-n">The finder reads your calendar, Slack and the subjects of mail you sent, never message bodies. Change first, the report finder settings and every other report press stay in Insights.</p>';
|
|
348
|
+
}
|
|
349
|
+
async function repPress(b) {
|
|
350
|
+
const act = b.dataset.bda, id = b.dataset.id, ws = b.dataset.ws || '', f = repFound().find((x) => x.id === id && x.ws === ws);
|
|
351
|
+
if (!f || !['rset', 'rno'].includes(act)) return;
|
|
352
|
+
BUSY = id; b.disabled = true;
|
|
353
|
+
const r = act === 'rset' ? await pmPost('/api/report-setups/setup', { ws, finding: id }) : await pmPost('/api/report-setups/dismiss', { ws, finding: id, name: f.name });
|
|
354
|
+
BUSY = '';
|
|
355
|
+
if (!r || r.ok !== true) { RERR[id] = (r && r.error) || 'It did not go through.'; draw(); toast(RERR[id]); return; }
|
|
356
|
+
delete RERR[id];
|
|
357
|
+
REC.set(id, { st: act === 'rset' ? 'set' : 'no', f, setup: act === 'rset' && r.setup ? r.setup.name || '' : '' });
|
|
358
|
+
toast(act === 'rset' ? 'Set up. Nothing is sent.' : 'Marked not a report.');
|
|
359
|
+
await readAll(['rep']); draw(`.bd-it[data-id="${CSS.escape(id)}"] .bd-done`);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/* ── the card ── */
|
|
363
|
+
const VIEWS = {
|
|
364
|
+
prop: { kind: 'Agent proposals', title: propTitle, html: propsHtml, press: propPress, say: () => (A.prop && A.prop.ok ? (A.prop.items.length ? pl(A.prop.items.length, 'proposal waits', 'proposals wait') + ' for you. Keep one to record it, send it back with a note, or drop it.' : 'No proposal waits for you.') : 'The proposals could not be read.') },
|
|
365
|
+
men: { kind: 'Mentions', title: () => 'Mentions', html: menHtml, press: menPress, say: () => (A.men && A.men.ok && A.men.list ? menLine(shownMen()) + ' Make one a task, mark it read, or open it where it was said.' : 'Mentions could not be read from today\'s brief.') },
|
|
366
|
+
pulse: { kind: 'Portfolio pulse', title: () => 'Portfolio pulse', html: pulseHtml, press: async () => {}, say: () => { const a = A.pulse, g = a && a.ok ? groups(a.rows) : null; return g ? `${g.bad.length} late and ${g.warn.length} at risk, of ${a.rows.length + a.none}. The late and at-risk ones are listed first.` : 'The initiatives could not be read.'; } },
|
|
367
|
+
scan: { kind: 'Horizon scan', title: () => 'Horizon scan', html: scanHtml, press: scanPress, say: () => (A.scan && A.scan.ok ? (scanOpen() ? pl(scanOpen(), 'proposal waits', 'proposals wait') + ' for you. Nothing acts until you approve it.' : 'No proposal waits for you. Nothing acts until you approve it.') : 'The scan could not be read.') },
|
|
368
|
+
rep: { kind: 'Report finder', title: () => 'Report found', html: repHtml, press: repPress, say: () => (A.rep && A.rep.ok ? (repFound().length ? pl(repFound().length, 'report was', 'reports were') + ' found in your work. Set it up, or say it is not a report. PMOS drafts only.' : 'No report waits for you.') : 'The findings could not be read.') },
|
|
369
|
+
};
|
|
370
|
+
let BODY = null;
|
|
371
|
+
/** Draw the card: the rows, or the open view. focus: a selector to focus after the draw. */
|
|
372
|
+
function draw(focus) {
|
|
373
|
+
if (!BODY || !BODY.isConnected) return;
|
|
374
|
+
{ const c = vwCurrent(); if (!c || !/^more:around/.test(c.id || '')) return; } // the Viewer moved on to another item: a late read draws nothing
|
|
375
|
+
const V = VIEWS[VIEW];
|
|
376
|
+
if (V) {
|
|
377
|
+
const t = document.getElementById('czVwTitle'); if (t) t.textContent = V.title();
|
|
378
|
+
BODY.innerHTML = `<div class="ar"><div class="ar-hd"><button type="button" class="hx-b alt" data-bda="back">Back to New for you</button></div>${A[VIEW] === null ? '<p class="hx-n ar-say" role="status">Reading</p>' // the view opens before its first read ends
|
|
379
|
+
: `<p class="hx-n ar-say">${esc(V.say())}</p><div class="bd-a" data-bd-view="${VIEW}">${V.html()}</div>`}</div>`;
|
|
380
|
+
}
|
|
381
|
+
BODY.querySelectorAll('.bd-bar i[data-w]').forEach((i) => i.style.setProperty('--bd-w', i.dataset.w + '%')); // each part of the pulse bar is as wide as its share
|
|
382
|
+
if (focus) { const f = BODY.querySelector(focus) || BODY.querySelector('.bd-a button:not([disabled]), .bd-a a'); if (f) f.focus(); }
|
|
383
|
+
}
|
|
384
|
+
const redraw = () => draw();
|
|
385
|
+
function show(k) {
|
|
386
|
+
VIEW = VIEWS[k] ? k : '';
|
|
387
|
+
PSEL = ''; PINFO = false;
|
|
388
|
+
BODY = vwOpen({ id: 'more:around' + (VIEW ? ':' + VIEW : ''), kind: VIEW ? VIEWS[VIEW].kind : 'Around you', title: VIEW ? VIEWS[VIEW].title() : 'What the agents and others left for you', icon: 'info',
|
|
389
|
+
render: (b) => { b.classList.add('hx'); BODY = b; draw(); wire(b); }, onClose: () => { clearTimeout(SPOLL); } });
|
|
390
|
+
if (VIEW === 'scan') scanPoll();
|
|
391
|
+
return BODY;
|
|
392
|
+
}
|
|
393
|
+
function wire(b) {
|
|
394
|
+
b.onclick = async (e) => {
|
|
395
|
+
const r = e.target.closest('[data-bd]'); if (r && !VIEW) { show(r.dataset.bd); return; }
|
|
396
|
+
const t = e.target.closest('[data-bda]'); if (!t || BUSY) return;
|
|
397
|
+
if (t.dataset.bda === 'back') { import('./cozy-news.js').then((M) => M.openNews({})); return; } // Around you is gone: its views come from New for you
|
|
398
|
+
if (t.disabled) return;
|
|
399
|
+
if (VIEWS[VIEW]) await VIEWS[VIEW].press(t);
|
|
400
|
+
};
|
|
401
|
+
b.oninput = (e) => {
|
|
402
|
+
const n = e.target.closest('[data-bdn]'); if (n) { PNOTE[n.dataset.bdn] = n.value; const k = b.querySelector(`[data-bda="pback"][data-id="${CSS.escape(n.dataset.bdn)}"]`); if (k) k.disabled = !n.value.trim(); return; }
|
|
403
|
+
const s = e.target.closest('[data-bds]'); if (s) { SWHY[s.dataset.bds] = s.value; const k = b.querySelector(`[data-bda="sdis"][data-id="${CSS.escape(s.dataset.bds)}"]`); if (k) k.disabled = !s.value.trim(); }
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/** premium-uncovered-features (HmAround): Around you is gone. No key opens New for you, src opens Sources; the other keys open their view. */
|
|
407
|
+
export function openAround(key) {
|
|
408
|
+
if (key === 'src') return import('./cozy-sources.js').then((M) => M.openSources());
|
|
409
|
+
if (!key || !VIEWS[key]) return import('./cozy-news.js').then((M) => M.openNews({}));
|
|
410
|
+
const body = show(key);
|
|
411
|
+
readAll();
|
|
412
|
+
return body;
|
|
413
|
+
}
|