create-pmos 0.609.0 → 0.611.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 +69 -27
- package/payload/KIT-VERSION +1 -1
- 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/workspace/board-columns-test.js +2 -1
- package/workspace/board-deliveries-test.js +2 -1
- package/workspace/board-programs-test.js +9 -5
- package/workspace/board-publish-ui-test.js +2 -1
- package/workspace/board-shared-ui-test.js +2 -1
- package/workspace/board-workflows-test.js +2 -1
- package/workspace/briefing-premium-adddoc-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +10 -9
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-initiative-test.js +7 -6
- package/workspace/briefing-premium-insights-test.js +12 -11
- package/workspace/briefing-premium-products-test.js +4 -2
- package/workspace/briefing-premium-sources-test.js +1 -1
- package/workspace/briefing-premium-test.js +6 -5
- package/workspace/briefing-premium-work-test.js +1 -1
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +68 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +11 -10
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +92 -11
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +50 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/home-other-product-test.js +2 -1
- package/workspace/home-railcard-test.js +2 -1
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/beside-page.js +15 -0
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/events-place.js +216 -0
- package/workspace/lib/library-items.js +78 -0
- package/workspace/lib/notes.js +6 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-events-place.js +166 -0
- package/workspace/lib/routes-library.js +89 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +20 -0
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +52 -0
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +11 -9
- package/workspace/metric-drafts-ui-test.js +3 -1
- package/workspace/milestone-pins-test.js +2 -1
- package/workspace/milestone-suggest-test.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +6 -4
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-chat-context-test.js +6 -6
- package/workspace/premium-chat-line-test.js +1 -1
- package/workspace/premium-chat-notes-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +2 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-cal-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +2 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +3 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +5 -3
- package/workspace/public/pm/bd-ini-panel.js +75 -8
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-scroll.js +4 -2
- package/workspace/public/pm/bd-work.css +130 -0
- package/workspace/public/pm/bd-work.js +356 -0
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-ev.css +52 -0
- package/workspace/public/pm/cozy-events-view.js +142 -0
- package/workspace/public/pm/cozy-events.css +107 -0
- package/workspace/public/pm/cozy-events.js +210 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-library.css +36 -0
- package/workspace/public/pm/cozy-live-pill.js +3 -1
- package/workspace/public/pm/cozy-nav.js +70 -7
- package/workspace/public/pm/cozy-panels.js +1 -1
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pick.js +6 -2
- package/workspace/public/pm/cozy-pop-work.css +165 -0
- package/workspace/public/pm/cozy-pop-work.js +427 -0
- package/workspace/public/pm/cozy-popup.css +113 -0
- package/workspace/public/pm/cozy-popup.js +408 -0
- package/workspace/public/pm/cozy-routine-model.js +111 -0
- package/workspace/public/pm/cozy-routine-pop.js +196 -0
- package/workspace/public/pm/cozy-routine.css +102 -0
- package/workspace/public/pm/cozy-routine.js +156 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +10 -1
- package/workspace/public/pm/cozy-today-app.js +236 -0
- package/workspace/public/pm/cozy-today-model.js +176 -0
- package/workspace/public/pm/cozy-today-page.css +100 -0
- package/workspace/public/pm/cozy-today-view.js +76 -0
- package/workspace/public/pm/cozy-viewer.js +66 -18
- package/workspace/public/pm/home-app.js +29 -6
- package/workspace/public/pm/home-ini.js +39 -7
- package/workspace/public/pm/library-model.js +69 -0
- package/workspace/public/pm/library-open.js +34 -0
- package/workspace/public/pm/page-chat.js +16 -4
- package/workspace/public/pm/pop-sessions.js +65 -0
- package/workspace/public/pm/pop-work-model.js +335 -0
- package/workspace/public/pm/premium-board.js +137 -11
- package/workspace/public/pm/premium-insights.js +14 -2
- package/workspace/public/pm/premium-library.js +122 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +42 -0
- package/workspace/public/premium-library.html +31 -0
- package/workspace/public/premium-routine.html +31 -0
- package/workspace/public/today.html +50 -0
- package/workspace/ready-dash-ui-test.js +3 -1
- package/workspace/rename-test.js +2 -1
- package/workspace/run-tests.js +4 -1
- package/workspace/server.js +3 -2
- package/workspace/sort-order-test.js +2 -1
- package/workspace/split-merge-ui-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +5 -3
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-card-test.js +2 -1
- package/workspace/task-delete-test.js +3 -1
- package/workspace/task-links-test.js +4 -2
- package/workspace/task-milestones-test.js +4 -2
- package/workspace/task-plans-test.js +3 -1
- package/workspace/task-press-test.js +3 -1
- package/workspace/task-views-test.js +10 -8
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/library-place.json +9 -0
- package/workspace/test-lists/one-popup.json +9 -0
- package/workspace/test-lists/pop-work.json +9 -0
- package/workspace/test-lists/routine-place.json +9 -0
- package/workspace/test-lists/today-log.json +9 -0
- package/workspace/test-lists/work-view.json +9 -0
- package/workspace/timeline-holds-test.js +3 -1
- package/workspace/tk-tasks-test.js +3 -1
- package/workspace/viewer-trail-test.js +1 -1
- package/workspace/workflows-setup-test.js +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/* pm/cozy-routine-pop.js — a routine in the one popup (initiative routine-place, slice 8 of the six-place navigation; board 10 on Exploring 2;
|
|
2
|
+
* done test planning/done-tests/routine-place.md T3, T4).
|
|
3
|
+
*
|
|
4
|
+
* Press a row of Routine: the popup of slice 2 (cozy-popup.js) opens, the routine on the left and Ask PMOS on the right, already about it.
|
|
5
|
+
* A REPORT the newest issue to read; above it one ✦ line "Issue this draft to <who it tells>?" with ✓ and ✕ while that issue is a draft
|
|
6
|
+
* and the report's one act is Issue (lib/report-acts.js); the issue chooser, Draft or Issued, and the pencil that opens the full
|
|
7
|
+
* report reader (premium-report-read.js: Edit, Present, Share, Download stay there). Beside it ONE grey box, the setup: On,
|
|
8
|
+
* Repeats, Next, Tells, After the run, Built from, then the issues (press one to read it). Press a value to change it, or tell
|
|
9
|
+
* PMOS in the chat ("send it on Thursdays"). A field the record leaves silent is not drawn.
|
|
10
|
+
* A report that waits for your word (its definition, or a move to the product it is about) shows that one ✦ line instead.
|
|
11
|
+
* The chat is the report's own conversation (report-flow.js chatOf), so a change PMOS writes goes to the report's own session.
|
|
12
|
+
* ANY OTHER the setup cozy-schedwork.js draws for it (Active, Next run, Repeats, Working hours only, PMOS's ✦ rhythm, History, ▶).
|
|
13
|
+
*
|
|
14
|
+
* WRITES, each the PM's press on a route that exists: ✓ issue → GET /api/report/draft (the sha as read) then POST /api/report/issue, which
|
|
15
|
+
* freezes the issue; nothing is sent outward, the PM sends it from their own mail, as today. On → /api/report-setups/pause | resume.
|
|
16
|
+
* Repeats → /api/report-setups/edit { schedule }. Tells → /api/report-setups/edit { audience } on Enter or leaving the field. ✓ of a waiting
|
|
17
|
+
* report → /api/report-setups/confirm | move. ✕ hides the ✦ line for that issue on this computer.
|
|
18
|
+
* reportHtml(R, now) — pure, for the tests: R = { row, text, path, hide, msg, busy, editTells } */
|
|
19
|
+
import { mdHtml } from './chat-md.js';
|
|
20
|
+
import { nextOf } from './cozy-evmodel.js';
|
|
21
|
+
import { CADENCES, chatOf } from './report-flow.js';
|
|
22
|
+
|
|
23
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
24
|
+
const svg = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
25
|
+
const I = { check: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', pen: 'M5 19l1-4L16.5 4.5l3 3L9 18z', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z' };
|
|
26
|
+
const MONS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
27
|
+
const DAYS = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
28
|
+
/** "18 Nov", from a YYYY-MM-DD slot. */
|
|
29
|
+
export const dayMon = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(s || '')); return m ? +m[3] + ' ' + MONS[+m[2] - 1] : String(s || ''); };
|
|
30
|
+
/** "Issue 2 · 18 Nov": issues are counted from the first. */
|
|
31
|
+
export function issueName(issues, path) {
|
|
32
|
+
const L = (issues || []).slice().sort((a, b) => (a.slot < b.slot ? -1 : 1)), i = L.findIndex((x) => x.path === path);
|
|
33
|
+
return i < 0 ? '' : 'Issue ' + (i + 1) + ' · ' + dayMon(L[i].slot);
|
|
34
|
+
}
|
|
35
|
+
/** Where a report is built from, in words: "Your work", "Goals", "A dashboard" (lib/report-setups.js sources), with the product. */
|
|
36
|
+
export function builtFrom(row) {
|
|
37
|
+
const s = String((row && row.source) || '');
|
|
38
|
+
const w = s === 'work' ? 'Your work' : /^intelligence:/.test(s) ? 'Goals' : /^dashboard:/.test(s) ? 'A dashboard' : /^ready:/.test(s) ? 'A ready-made report' : s ? s.replace(/^./, (c) => c.toUpperCase()) : '';
|
|
39
|
+
return [row && row.wsName, w].filter(Boolean).join(' · ');
|
|
40
|
+
}
|
|
41
|
+
/** The Repeats choices: the four cadences, the current one selected (a cadence PMOS does not offer stays as it is). */
|
|
42
|
+
export function repeatChoices(sch) {
|
|
43
|
+
const cur = sch && sch.cadence;
|
|
44
|
+
const L = CADENCES.map(([v, l]) => [v, l, v === cur]);
|
|
45
|
+
if (cur && !L.some((x) => x[2])) L.push([cur, cur, true]);
|
|
46
|
+
return L;
|
|
47
|
+
}
|
|
48
|
+
const at = (sch) => (sch && sch.cadence === 'monthly' ? 'day ' + (sch.dayOfMonth || 1) + ', ' : sch && sch.day && sch.cadence !== 'daily' ? (DAYS[sch.day] || sch.day).slice(0, 3) + ' ' : '') + ((sch && sch.time) || '');
|
|
49
|
+
const sw = (on, label) => `<button type="button" class="rt-sw" role="switch" aria-checked="${!!on}" data-rp="on" aria-label="${esc(label)}" title="${esc(label)}"></button>`;
|
|
50
|
+
const kv = (k, v, cls = '') => `<div class="rp-r${cls}"><span>${esc(k)}</span>${v}</div>`;
|
|
51
|
+
const fm = (t) => String(t || '').replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '');
|
|
52
|
+
|
|
53
|
+
/** The report in the popup, as html. Pure. */
|
|
54
|
+
export function reportHtml(R, now = Date.now()) {
|
|
55
|
+
const r = R.row || {}, issues = r.issues || [], cur = issues.find((x) => x.path === R.path) || r.latest || null;
|
|
56
|
+
const a = r.act || null, who = r.audience || '';
|
|
57
|
+
const nope = R.hide && cur && R.hide.has(cur.path);
|
|
58
|
+
// the one ✦ line: a waiting definition or move, else a draft to issue
|
|
59
|
+
let sg = '';
|
|
60
|
+
if (a && (a.act === 'confirm' || a.act === 'move')) {
|
|
61
|
+
const t = a.act === 'confirm' ? 'Its definition waits for your word. Start it as it is?' : 'It is about ' + (a.toName || 'another product') + '. Move it there?';
|
|
62
|
+
sg = `<div class="rp-sg" role="group" aria-label="PMOS suggests"><h5>${svg(I.spark, 13)}PMOS suggests</h5><div><span>${esc(t)}</span>`
|
|
63
|
+
+ `<button type="button" class="rp-y" data-rp="${a.act}" aria-label="${esc(a.act === 'confirm' ? 'Yes, start it' : a.label)}" title="${esc(a.act === 'confirm' ? 'Yes, start it' : a.label)}"${R.busy ? ' disabled' : ''}>${svg(I.check, 14)}</button></div></div>`;
|
|
64
|
+
} else if (a && a.act === 'issue' && cur && cur.state === 'draft' && cur.path === (r.latest && r.latest.path) && !nope) {
|
|
65
|
+
sg = `<div class="rp-sg" role="group" aria-label="PMOS suggests"><h5>${svg(I.spark, 13)}PMOS suggests</h5><div><span>${esc('Issue this draft' + (who ? ' to ' + who : '') + '?')}</span>`
|
|
66
|
+
+ `<button type="button" class="rp-y" data-rp="issue" aria-label="Yes, issue it" title="Yes, issue it"${R.busy ? ' disabled' : ''}>${svg(I.check, 14)}</button>`
|
|
67
|
+
+ `<button type="button" class="rp-n" data-rp="nope" aria-label="Not now" title="Not now">${svg(I.x, 14)}</button></div></div>`;
|
|
68
|
+
}
|
|
69
|
+
const pick = issues.length > 1 ? `<label class="vh" for="rpIss">Issue</label><select id="rpIss" class="rp-ch" data-rp="pick">${issues.map((x) => `<option value="${esc(x.path)}"${cur && x.path === cur.path ? ' selected' : ''}>${esc(issueName(issues, x.path))}</option>`).join('')}</select>`
|
|
70
|
+
: cur ? `<span class="rp-ch">${esc(issueName(issues, cur.path))}</span>` : '';
|
|
71
|
+
const meta = cur ? `<div class="rp-m">${pick}<span>${cur.state === 'issued' ? 'Issued' : 'Draft'}</span><button type="button" class="rp-ed" data-rp="edit" aria-label="Change the text" title="Change the text">${svg(I.pen, 17)}</button></div>` : '';
|
|
72
|
+
const body = !cur ? '<p class="rp-q">No issue is written yet. PMOS drafts the first one on its day.</p>'
|
|
73
|
+
: R.text == null ? '<p class="rp-q">Reading the issue.</p>' : R.err ? `<p class="rp-q">${esc(R.err)}</p>` : `<div class="rp-txt">${mdHtml(fm(R.text))}</div>`;
|
|
74
|
+
// the setup: only what the records say
|
|
75
|
+
const s = r.schedule;
|
|
76
|
+
const rows = [];
|
|
77
|
+
if (r.status) rows.push(kv('On', sw(r.status === 'active', r.status === 'active' ? 'On. Press to pause it' : 'Paused. Press to start it again')));
|
|
78
|
+
if (r.status && s) rows.push(kv('Repeats', `<label class="vh" for="rpRep">Repeats</label><select id="rpRep" class="rp-sel" data-rp="rep"${R.busy ? ' disabled' : ''}>${repeatChoices(s).map(([v, l, on]) => `<option value="${esc(v)}"${on ? ' selected' : ''}>${esc(l + (on && at(s) ? ', ' + at(s) : ''))}</option>`).join('')}</select>`));
|
|
79
|
+
else if (r.when) rows.push(kv('Repeats', `<em>${esc(r.when)}</em>`));
|
|
80
|
+
if (r.status === 'active' && r.next) rows.push(kv('Next', `<em>${esc(nextOf(r.next, now).replace(/^./, (c) => c.toUpperCase()))}</em>`));
|
|
81
|
+
if (r.status) rows.push(kv('Tells', R.editTells ? `<label class="vh" for="rpTells">Tells</label><input id="rpTells" class="rp-in" data-rp="tells" value="${esc(who)}" maxlength="120">`
|
|
82
|
+
: `<button type="button" class="rp-sel" data-rp="tells-ed" aria-label="${esc('Tells: ' + (who || 'nobody named') + '. Press to change it')}">${esc(who || 'Name who reads it')}</button>`));
|
|
83
|
+
else if (who) rows.push(kv('Tells', `<em>${esc(who)}</em>`));
|
|
84
|
+
if (r.status) rows.push(kv('After the run', '<em>You issue it</em>'));
|
|
85
|
+
if (builtFrom(r)) rows.push(kv('Built from', `<em>${esc(builtFrom(r))}</em>`));
|
|
86
|
+
const iss = issues.slice(0, 8).map((x) => `<button type="button" class="rp-r rp-i${cur && x.path === cur.path ? ' cur' : ''}" data-rp="open" data-path="${esc(x.path)}"><span>${esc(issueName(issues, x.path))}</span><em${x.state === 'draft' ? ' class="w"' : ''}>${x.state === 'issued' ? (x.archived ? 'Archived' : 'Issued') : 'Draft'}</em></button>`).join('');
|
|
87
|
+
const box = `<aside class="rp-box" aria-label="Setup"><h6>Setup</h6>${rows.join('')}${iss ? `<h6>Issues</h6>${iss}` : ''}`
|
|
88
|
+
+ (r.status ? '<p>To change the setup, press a value. Or tell PMOS on the right, for example “send it on Thursdays”.</p>' : '') + '</aside>';
|
|
89
|
+
const msg = R.msg ? `<p class="rp-msg" role="status">${esc(R.msg)}</p>` : '<p class="rp-msg" role="status"></p>';
|
|
90
|
+
return `<div class="rp-w"><div class="rp-main">${sg}${meta}${body}${msg}</div>${box}</div>`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ── the popup: open, draw, presses ── */
|
|
94
|
+
const NOPE = 'pmos.routine.nope.';
|
|
95
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
|
|
96
|
+
let P = null; // the report shown: { R, body, h }
|
|
97
|
+
const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
98
|
+
|
|
99
|
+
/** Open a report row of Routine in the popup. h: { VW, http: { pmGet, pmPost }, reload(), toast(text) } */
|
|
100
|
+
export async function openReport(row, h) {
|
|
101
|
+
const hide = new Set(); for (const x of row.issues || []) if (store.get(NOPE + x.path)) hide.add(x.path);
|
|
102
|
+
const R = { row, path: row.latest ? row.latest.path : '', text: null, err: '', hide, msg: '', busy: false, editTells: false };
|
|
103
|
+
const me = P = { R, body: null, h };
|
|
104
|
+
const PC = await import('./page-chat.js');
|
|
105
|
+
const base = PC.targetOf({ id: 'report-' + row.id, kind: 'report', title: row.name }, row.ws);
|
|
106
|
+
const t = { ...base, ...chatOf({ name: row.name, audience: row.audience, output: row.output, latest: row.latest }, row.id), ws: row.ws || undefined, scope: base.scope, role: base.role };
|
|
107
|
+
t.empty = 'Ask about ' + row.name + ', or tell PMOS what to change. Nothing is issued.';
|
|
108
|
+
if (typeof t.intro === 'string') t.intro = { text: t.intro }; // the chat draws an intro as { text }
|
|
109
|
+
h.VW.open({ id: 'routine:' + row.ws + ':' + row.id, kind: 'Report', title: row.name, icon: 'report',
|
|
110
|
+
pop: { id: 'report-' + row.id, kind: 'report', title: row.name, ws: row.ws || undefined, target: t },
|
|
111
|
+
render: (b) => { me.body = b; draw(me); wire(me); },
|
|
112
|
+
onClose: () => { if (P === me) P = null; } });
|
|
113
|
+
read(me);
|
|
114
|
+
return me;
|
|
115
|
+
}
|
|
116
|
+
function draw(me) { if (me.body && me.body.isConnected) me.body.innerHTML = reportHtml(me.R); }
|
|
117
|
+
async function read(me) {
|
|
118
|
+
const R = me.R; if (!R.path) { R.text = ''; draw(me); return; }
|
|
119
|
+
try {
|
|
120
|
+
const r = await fetch('/api/doc?' + q({ ws: R.row.ws, path: R.path }), { credentials: 'same-origin' });
|
|
121
|
+
R.text = r.ok ? await r.text() : ''; R.err = r.ok ? '' : 'The issue could not be read.';
|
|
122
|
+
} catch { R.text = ''; R.err = 'The issue could not be read.'; }
|
|
123
|
+
if (P === me) draw(me);
|
|
124
|
+
}
|
|
125
|
+
const said = (r, ok) => (r && r.ok !== false && !(r && r.error) ? ok : 'Nothing changed: ' + ((r && r.error) || 'the server did not answer') + '.');
|
|
126
|
+
async function refresh(me) {
|
|
127
|
+
const j = await me.h.http.pmGet('/api/report-setups/routine?' + q({ ws: me.R.row.ws })).catch(() => null);
|
|
128
|
+
const row = j && j.ok && (j.reports || []).find((x) => x.id === me.R.row.id);
|
|
129
|
+
if (row) me.R.row = { ...row, ws: me.R.row.ws, wsName: me.R.row.wsName };
|
|
130
|
+
if (me.h.reload) me.h.reload();
|
|
131
|
+
}
|
|
132
|
+
function wire(me) {
|
|
133
|
+
const b = me.body; if (!b || b.__rp) return; b.__rp = true;
|
|
134
|
+
const post = me.h.http.pmPost, R = me.R;
|
|
135
|
+
const act = async (fn) => { if (R.busy) return; R.busy = true; draw(me); try { R.msg = await fn(); } finally { R.busy = false; } await refresh(me); if (P === me) draw(me); };
|
|
136
|
+
b.addEventListener('click', async (e) => {
|
|
137
|
+
const t = e.target.closest('[data-rp]'); if (!t || t.tagName === 'SELECT' || t.tagName === 'INPUT') return;
|
|
138
|
+
const k = t.dataset.rp, row = R.row, ws = row.ws || undefined;
|
|
139
|
+
if (k === 'open') { R.path = t.dataset.path; R.text = null; R.msg = ''; draw(me); read(me); return; }
|
|
140
|
+
if (k === 'nope') { store.set(NOPE + R.path, '1'); R.hide.add(R.path); R.msg = 'PMOS will not ask about this draft again.'; draw(me); return; }
|
|
141
|
+
if (k === 'edit') { const M = await import('./premium-report-read.js'); me.h.VW.drill(); M.openReportView(R.path, { ws: row.ws, name: row.name }); return; }
|
|
142
|
+
if (k === 'tells-ed') { R.editTells = true; draw(me); const i = b.querySelector('#rpTells'); if (i) { i.focus(); i.select(); } return; }
|
|
143
|
+
if (k === 'on') return act(async () => { const on = row.status !== 'active'; return said(await post('/api/report-setups/' + (on ? 'resume' : 'pause'), { ws, id: row.id }), on ? 'On. PMOS drafts it on its day again.' : 'Paused. PMOS does not draft it until you turn it on.'); });
|
|
144
|
+
if (k === 'confirm') return act(async () => said(await post('/api/report-setups/confirm', { ws, id: row.id }), 'Started. Its drafts follow the definition as it is.'));
|
|
145
|
+
if (k === 'move') return act(async () => said(await post('/api/report-setups/move', { ws, id: row.id, to: row.act.to }), 'Moved to ' + row.act.toName + '. It drafts there from now on.'));
|
|
146
|
+
if (k === 'issue') {
|
|
147
|
+
return act(async () => {
|
|
148
|
+
const c = /\/([^/]+)\/(\d{4}-\d{2}-\d{2})\.md$/.exec(R.path) || [];
|
|
149
|
+
const cur = await me.h.http.pmGet('/api/report/draft?' + q({ ws: row.ws, cadence: c[1], slot: c[2] })).catch(() => null);
|
|
150
|
+
if (!cur || !cur.sha) return 'Not issued: the draft could not be read. Open it with the pencil and issue it there.';
|
|
151
|
+
const r = await post('/api/report/issue', { ws, cadence: c[1], slot: c[2], sha: cur.sha });
|
|
152
|
+
if (r && r.ok) { if (me.h.toast) me.h.toast('Issued. Send it from your own mail.'); return 'Issued. It stays as it is now. Send it from your own mail.'; }
|
|
153
|
+
return said(r, '');
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
b.addEventListener('change', (e) => {
|
|
158
|
+
const t = e.target; if (!t.dataset) return;
|
|
159
|
+
if (t.dataset.rp === 'pick') { R.path = t.value; R.text = null; R.msg = ''; draw(me); read(me); return; }
|
|
160
|
+
if (t.dataset.rp === 'rep') {
|
|
161
|
+
const row = R.row, s = row.schedule || {}, v = t.value;
|
|
162
|
+
const sch = { cadence: v, time: s.time || '09:00', ...(v === 'weekly' || v === 'bi-weekly' ? { day: s.day || 'Mon' } : {}), ...(v === 'monthly' ? { dayOfMonth: s.dayOfMonth || 1 } : {}), ...(s.anchor && v === 'bi-weekly' ? { anchor: s.anchor } : {}) };
|
|
163
|
+
act(async () => said(await post('/api/report-setups/edit', { ws: row.ws || undefined, id: row.id, schedule: sch }), 'Saved. ' + (CADENCES.find((x) => x[0] === v) || [0, v])[1] + '.'));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const tells = (i) => {
|
|
167
|
+
if (!R.editTells) return;
|
|
168
|
+
R.editTells = false;
|
|
169
|
+
const v = String(i.value || '').trim(), row = R.row;
|
|
170
|
+
if (!v || v === (row.audience || '')) { draw(me); return; }
|
|
171
|
+
act(async () => said(await post('/api/report-setups/edit', { ws: row.ws || undefined, id: row.id, audience: v }), 'Saved. It tells ' + v + '.'));
|
|
172
|
+
};
|
|
173
|
+
b.addEventListener('keydown', (e) => {
|
|
174
|
+
const t = e.target; if (!t.dataset || t.dataset.rp !== 'tells') return;
|
|
175
|
+
if (e.key === 'Enter') { e.preventDefault(); tells(t); } else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); R.editTells = false; draw(me); }
|
|
176
|
+
});
|
|
177
|
+
b.addEventListener('focusout', (e) => { const t = e.target; if (t.dataset && t.dataset.rp === 'tells') tells(t); });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Open a read, a job or one of your tasks in the popup: the setup cozy-schedwork.js draws. h: { VW, reload() } */
|
|
181
|
+
export async function openJob(row, h) {
|
|
182
|
+
const SW = await import('./cozy-schedwork.js');
|
|
183
|
+
const kind = row.kind === 'tasks' ? 'task' : 'job';
|
|
184
|
+
let sub = 'sw:' + kind + ':' + row.id, msg = '', body = null;
|
|
185
|
+
const draw = () => { if (body && body.isConnected) body.innerHTML = `<div class="cz ev-st rp-job">${SW.swBody(sub)}${msg ? `<p class="ev-small rp-msg" role="status">${esc(msg)}</p>` : ''}</div>`; };
|
|
186
|
+
const fresh = () => { if (h.reload) h.reload(); };
|
|
187
|
+
const H = { go: (k) => { if (!k || k === 'list') { h.VW.closePop(); return; } sub = 'sw:' + k; msg = ''; draw(); }, say: (m) => { msg = m; }, draw, fresh };
|
|
188
|
+
h.VW.open({ id: 'routine:' + row.key, kind: row.kind === 'tasks' ? 'Your task' : row.kind === 'reads' ? 'PMOS reads' : 'PMOS job', title: row.name, icon: row.kind === 'tasks' ? 'task' : row.kind === 'reads' ? 'source' : 'gear',
|
|
189
|
+
pop: { id: 'routine-' + row.id, kind: 'routine', title: row.name },
|
|
190
|
+
render: (b) => {
|
|
191
|
+
body = b; draw();
|
|
192
|
+
b.addEventListener('click', (e) => { const t = e.target.closest('button, a'); if (t && body.contains(t)) SW.swPress(t, H); });
|
|
193
|
+
b.addEventListener('change', (e) => { SW.swChange(e.target, H); });
|
|
194
|
+
} });
|
|
195
|
+
await SW.swLoad(draw);
|
|
196
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* pm/cozy-routine.css — Routine (initiative routine-place, board 11) and a routine in the popup (board 10). One container: the page panel; the
|
|
2
|
+
* table is one card with a thin border; the setup is one grey box. Tokens are cozy.css's. */
|
|
3
|
+
.rt-page { gap: 14px; }
|
|
4
|
+
.rt-bar { display: flex; align-items: center; gap: 12px; }
|
|
5
|
+
.rt-seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--cz-well); flex-wrap: wrap; }
|
|
6
|
+
.rt-seg button { all: unset; cursor: pointer; height: 30px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink2); display: inline-flex; align-items: center; }
|
|
7
|
+
.rt-seg button[aria-pressed="true"] { background: var(--cz-card); color: var(--cz-ink); box-shadow: 0 1px 2px rgba(30, 40, 60, .12); }
|
|
8
|
+
.rt-seg button:focus-visible, .rt-add:focus-visible, .rt-did:focus-visible, .rt-r:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
9
|
+
.rt-add { all: unset; cursor: pointer; margin-left: auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
|
|
10
|
+
.rt-add svg, .rt-did svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
11
|
+
.rt-add:hover { background: var(--cz-well); }
|
|
12
|
+
.rt-did { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px; background: var(--cz-well); font-size: var(--fs-body); color: var(--cz-ink); }
|
|
13
|
+
.rt-did > b { color: var(--cz-c-6b4fa3); }
|
|
14
|
+
.rt-did span { flex: 1; min-width: 0; }
|
|
15
|
+
.rt-did em { font-style: normal; color: var(--cz-ink3); }
|
|
16
|
+
.rt-tbl { border-radius: 16px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; font-size: var(--fs-body); color: var(--cz-ink); }
|
|
17
|
+
.rt-r { display: grid; grid-template-columns: 26px minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr) 44px; align-items: center; column-gap: 12px; min-height: 46px; padding: 0 18px; box-shadow: inset 0 -1px 0 var(--cz-hair); }
|
|
18
|
+
.rt-r:last-child { box-shadow: none; }
|
|
19
|
+
.rt-r.rt-h { min-height: 38px; background: var(--cz-well); font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
20
|
+
.rt-r.rt-g { min-height: 34px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); background: var(--cz-well); }
|
|
21
|
+
.rt-r.rt-g > div { grid-column: 1 / -1; }
|
|
22
|
+
.rt-r.rt-row { cursor: pointer; }
|
|
23
|
+
.rt-r.rt-row:hover { background: var(--cz-well); }
|
|
24
|
+
.rt-r .e { display: flex; justify-content: flex-end; align-items: center; }
|
|
25
|
+
.rt-r .ic { color: var(--cz-ink3); display: grid; place-items: center; }
|
|
26
|
+
.rt-r .ic svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
27
|
+
.rt-r .n { font-weight: var(--fw-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
28
|
+
.rt-r .c { color: var(--cz-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
29
|
+
.rt-r .w { color: var(--cz-risk); font-weight: var(--fw-strong); display: inline-flex; align-items: center; gap: 7px; }
|
|
30
|
+
.rt-r .w::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-dot-risk); flex: none; }
|
|
31
|
+
.rt-r.off .n, .rt-r.off .c { color: var(--cz-ink3); }
|
|
32
|
+
.rt-sw { all: unset; box-sizing: border-box; cursor: pointer; width: 34px; height: 20px; border-radius: 999px; background: var(--cz-well2); position: relative; justify-self: end; flex: none; }
|
|
33
|
+
.rt-sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--cz-card); box-shadow: 0 1px 2px rgba(30, 40, 60, .25); transition: left .15s; }
|
|
34
|
+
.rt-sw[aria-checked="true"] { background: var(--cz-blue); }
|
|
35
|
+
.rt-sw[aria-checked="true"]::after { left: 17px; }
|
|
36
|
+
.rt-sw:focus-visible, .rt-yes:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
37
|
+
.rt-yes { all: unset; cursor: pointer; justify-self: end; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-ink); color: var(--cz-card); }
|
|
38
|
+
.rt-yes svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
|
|
39
|
+
.rt-yes[disabled], .rt-sw[disabled] { opacity: .5; cursor: default; }
|
|
40
|
+
.rt-note, .rt-quiet { margin: 0 6px; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
41
|
+
.rt-msg { margin: 0 6px; font-size: var(--fs-meta); color: var(--cz-ink2); min-height: 1em; }
|
|
42
|
+
.rt-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; padding: 10px 16px; border-radius: 12px; background: var(--cz-ink); color: var(--cz-card); font-size: var(--fs-body); opacity: 0; pointer-events: none; transition: opacity .2s; }
|
|
43
|
+
.rt-toast.on { opacity: 1; }
|
|
44
|
+
@media (max-width: 760px) {
|
|
45
|
+
.rt-r { grid-template-columns: 22px minmax(0, 1fr) minmax(0, .8fr) 44px; padding: 0 12px; min-height: 52px; }
|
|
46
|
+
.rt-r .c.does, .rt-r .c.when, .rt-r.rt-h .does, .rt-r.rt-h .when { display: none; }
|
|
47
|
+
.rt-seg { border-radius: 16px; }
|
|
48
|
+
}
|
|
49
|
+
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
50
|
+
|
|
51
|
+
/* PMOS did, the full log (in the popup) */
|
|
52
|
+
.rt-log { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px 20px; font-size: var(--fs-body); color: var(--cz-ink); }
|
|
53
|
+
.rt-log .l { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; box-shadow: inset 0 -1px 0 var(--cz-hair); }
|
|
54
|
+
.rt-log .l span { flex: 1; min-width: 0; }
|
|
55
|
+
.rt-log .l b { font-weight: var(--fw-strong); display: block; }
|
|
56
|
+
.rt-log .l em { font-style: normal; color: var(--cz-ink3); font-size: var(--fs-meta); }
|
|
57
|
+
.rt-log .l button { all: unset; cursor: pointer; flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
|
|
58
|
+
.rt-log .l button:hover { background: var(--cz-well); }
|
|
59
|
+
.rt-log .l button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
60
|
+
.rt-log .l button[disabled] { opacity: .4; cursor: default; }
|
|
61
|
+
|
|
62
|
+
/* a report in the popup (board 10): the issue on the left, the setup in one grey box */
|
|
63
|
+
.rp-w { display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: 22px; align-items: start; padding: 4px 4px 24px; }
|
|
64
|
+
@media (max-width: 1100px) { .rp-w { grid-template-columns: minmax(0, 1fr); row-gap: 16px; } }
|
|
65
|
+
.rp-main { font-size: var(--fs-body); line-height: 1.55; color: var(--cz-ink); min-width: 0; }
|
|
66
|
+
.rp-sg { margin: 0 0 16px; border-radius: 12px; background: var(--cz-card); box-shadow: inset 0 0 0 1px rgba(107, 91, 210, .28); padding: 8px 12px; }
|
|
67
|
+
.rp-sg h5 { margin: 0 0 2px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-c-6b4fa3); display: flex; align-items: center; gap: 5px; }
|
|
68
|
+
.rp-sg div { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); line-height: 1.4; }
|
|
69
|
+
.rp-sg div span { flex: 1; min-width: 0; }
|
|
70
|
+
.rp-sg button { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink); }
|
|
71
|
+
.rp-sg button.rp-y { background: var(--cz-ink); color: var(--cz-card); box-shadow: none; }
|
|
72
|
+
.rp-sg button[disabled] { opacity: .5; cursor: default; }
|
|
73
|
+
.rp-m { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
74
|
+
.rp-ch { height: 28px; padding: 0 10px; border-radius: 999px; background: var(--cz-well); font: inherit; font-weight: var(--fw-strong); color: var(--cz-ink2); border: 0; display: inline-flex; align-items: center; }
|
|
75
|
+
.rp-ed { all: unset; cursor: pointer; margin-left: auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
|
|
76
|
+
.rp-ed:hover { background: var(--cz-well); }
|
|
77
|
+
.rp-txt h1, .rp-txt h2, .rp-txt h3, .rp-txt h4 { font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink2); margin: 20px 0 4px; }
|
|
78
|
+
.rp-txt p { margin: 0 0 8px; }
|
|
79
|
+
.rp-txt ul, .rp-txt ol { margin: 0 0 8px; padding-left: 20px; }
|
|
80
|
+
.rp-txt table { border-collapse: collapse; font-size: var(--fs-body); margin: 6px 0 10px; }
|
|
81
|
+
.rp-txt th, .rp-txt td { padding: 4px 8px; box-shadow: inset 0 -1px 0 var(--cz-hair); text-align: left; }
|
|
82
|
+
.rp-q { color: var(--cz-ink3); font-size: var(--fs-body); }
|
|
83
|
+
.rp-msg { margin: 10px 0 0; font-size: var(--fs-meta); color: var(--cz-ink2); min-height: 1em; }
|
|
84
|
+
.rp-box { border-radius: 16px; background: var(--cz-well); padding: 12px 14px 14px; font-size: var(--fs-meta); color: var(--cz-ink); }
|
|
85
|
+
.rp-box h6 { margin: 4px 2px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
86
|
+
.rp-box h6 + .rp-r { box-shadow: none; }
|
|
87
|
+
.rp-box h6:not(:first-child) { margin-top: 14px; }
|
|
88
|
+
.rp-box .rp-r { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 2px; box-shadow: inset 0 1px 0 var(--cz-hair); }
|
|
89
|
+
.rp-box .rp-r > span { flex: 1; min-width: 0; color: var(--cz-ink2); }
|
|
90
|
+
.rp-box .rp-r em { font-style: normal; text-align: right; }
|
|
91
|
+
.rp-box .rp-r em.w { color: var(--cz-risk); font-weight: var(--fw-strong); }
|
|
92
|
+
.rp-box .rp-i { cursor: pointer; }
|
|
93
|
+
.rp-box .rp-i.cur > span { font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
94
|
+
.rp-box .rp-sel { all: unset; cursor: pointer; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--cz-card); font-weight: var(--fw-strong); font-size: var(--fs-meta); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
|
|
95
|
+
.rp-box select.rp-sel { appearance: auto; }
|
|
96
|
+
.rp-box .rp-in { height: 28px; border-radius: 10px; border: 0; padding: 0 8px; font: inherit; font-size: var(--fs-meta); background: var(--cz-card); max-width: 170px; }
|
|
97
|
+
.rp-box p { margin: 12px 2px 0; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink3); }
|
|
98
|
+
.rp-box .rt-sw { justify-self: auto; }
|
|
99
|
+
/* a read, a job or your task in the popup: the setup cozy-schedwork.js draws, without the Settings dialog's frame */
|
|
100
|
+
.ev-st.rp-job { position: static; transform: none; z-index: auto; width: auto; height: auto; display: block; overflow: visible; box-shadow: none; border-radius: 0; background: none; max-width: 680px; padding: 4px 4px 24px; }
|
|
101
|
+
.rp-job .ev-dr-hd:has([data-ev-sw=""]) { display: none; }
|
|
102
|
+
.rp-job .ev-dr-hd [data-ev-sw=""] { display: none; }
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* pm/cozy-routine.js — Routine, the place (initiative routine-place, slice 8 of the six-place navigation; board 11 on Exploring 2; build plan
|
|
2
|
+
* /mnt/project-files/nav-structure/build-plan.md; done test planning/done-tests/routine-place.md).
|
|
3
|
+
*
|
|
4
|
+
* One table of everything that repeats: Routine, What it does, When, Next, and a switch that pauses it. Groups: Waits for you (one ✓),
|
|
5
|
+
* Reports, PMOS reads, PMOS jobs, Your tasks (pm/cozy-routine-model.js). The kinds above it filter the table; PMOS remembers the choice on this
|
|
6
|
+
* computer. "PMOS did" is one line on top; a press opens the full log in the popup, each line with its Undo. + opens Ask PMOS about a new
|
|
7
|
+
* routine. A row opens the one popup (pm/cozy-routine-pop.js). It replaces the Scheduled work list of Settings › Connectors, which now goes here.
|
|
8
|
+
*
|
|
9
|
+
* READS GET /api/workspaces, then per product GET /api/report-setups/routine?ws and GET /api/autonomy?ws; once GET /api/refresh and
|
|
10
|
+
* GET /api/schedules?all=1. Every product is read: Routine has no product choice (slice 1).
|
|
11
|
+
* WRITES, each the PM's press: a report's switch → POST /api/report-setups/pause | resume; a read or a job → POST /api/refresh/source { id, on };
|
|
12
|
+
* your task → POST /api/schedules/update { id, enabled }; the ✓ of Waits for you → /api/report-setups/confirm | move; Undo in the log →
|
|
13
|
+
* POST /api/autonomy/undo. Nothing here runs a routine or sends anything. */
|
|
14
|
+
import { pmGet, pmPost } from './http.js';
|
|
15
|
+
import { mountNav } from './cozy-nav.js';
|
|
16
|
+
import { mountLivePill } from './cozy-live-pill.js';
|
|
17
|
+
import * as VW from './cozy-viewer.js';
|
|
18
|
+
import * as POP from './cozy-popup.js';
|
|
19
|
+
import { KINDS, routineRows, routineGroups, didLine } from './cozy-routine-model.js';
|
|
20
|
+
import { atOf } from './cozy-evmodel.js';
|
|
21
|
+
import { openReport, openJob } from './cozy-routine-pop.js';
|
|
22
|
+
|
|
23
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
24
|
+
const svg = (d, n = 18) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
25
|
+
const I = {
|
|
26
|
+
reports: 'M4 20V10M10 20V4M16 20v-8M22 20H2', reads: 'M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6zM12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 1 0 0-5',
|
|
27
|
+
jobs: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', tasks: 'M5 5h14v14H5zM8.5 12.5l2.5 2.5 4.5-5',
|
|
28
|
+
check: 'M5 12.5l4.5 4.5L19 7.5', chev: 'M9 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
|
|
29
|
+
};
|
|
30
|
+
const KIND_KEY = 'pmos.routine.kind';
|
|
31
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
|
|
32
|
+
const S = { ws: [], reports: [], refresh: [], tasks: [], done: [], kind: KINDS.some(([k]) => k === store.get(KIND_KEY)) ? store.get(KIND_KEY) : 'all', rows: [], busy: new Set(), read: false, err: '' };
|
|
33
|
+
const $ = (id) => document.getElementById(id);
|
|
34
|
+
const toast = (t) => { const el = $('toast'); if (!el) return; el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
|
|
35
|
+
const say = (t) => { const el = $('rtMsg'); if (el) el.textContent = t || ''; };
|
|
36
|
+
const enc = encodeURIComponent;
|
|
37
|
+
|
|
38
|
+
mountNav('routine', document, {});
|
|
39
|
+
mountLivePill(document);
|
|
40
|
+
|
|
41
|
+
async function load() {
|
|
42
|
+
const w = await pmGet('/api/workspaces').catch(() => null);
|
|
43
|
+
S.ws = w && Array.isArray(w.workspaces) ? w.workspaces.map((x) => ({ id: x.id, name: x.label || x.name || x.id })) : [];
|
|
44
|
+
const per = await Promise.all(S.ws.map((x) => Promise.all([pmGet('/api/report-setups/routine?ws=' + enc(x.id)).catch(() => null), pmGet('/api/autonomy?ws=' + enc(x.id)).catch(() => null)])));
|
|
45
|
+
const [rf, sc] = await Promise.all([pmGet('/api/refresh').catch(() => null), pmGet('/api/schedules?all=1').catch(() => null)]);
|
|
46
|
+
S.reports = []; S.done = [];
|
|
47
|
+
per.forEach(([r, a], i) => {
|
|
48
|
+
const x = S.ws[i];
|
|
49
|
+
if (r && r.ok) for (const row of r.reports || []) S.reports.push({ ...row, ws: x.id, wsName: x.name });
|
|
50
|
+
if (a && a.ok) for (const d of a.done || []) S.done.push({ ...d, ws: x.id });
|
|
51
|
+
});
|
|
52
|
+
S.done.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
|
|
53
|
+
S.refresh = rf && rf.ok && Array.isArray(rf.rows) ? rf.rows : [];
|
|
54
|
+
S.tasks = sc && Array.isArray(sc.schedules) ? sc.schedules : [];
|
|
55
|
+
S.err = !w ? 'PMOS is not answering. The table shows again when it is back.' : '';
|
|
56
|
+
S.read = true;
|
|
57
|
+
draw();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function kindsHtml() {
|
|
61
|
+
return KINDS.map(([k, l]) => `<button type="button" data-kind="${k}" aria-pressed="${S.kind === k}">${esc(l)}</button>`).join('');
|
|
62
|
+
}
|
|
63
|
+
function rowHtml(r) {
|
|
64
|
+
const busy = S.busy.has(r.key);
|
|
65
|
+
const end = r.wait ? `<button type="button" class="rt-yes" data-yes="${esc(r.key)}" aria-label="${esc(r.wait.label + ': ' + r.name)}" title="${esc(r.wait.label)}"${busy ? ' disabled' : ''}>${svg(I.check, 14)}</button>`
|
|
66
|
+
: r.on === null ? '<span></span>'
|
|
67
|
+
: `<button type="button" class="rt-sw" role="switch" aria-checked="${r.on}" data-sw="${esc(r.key)}" aria-label="${esc(r.name + (r.on ? ': on. Press to pause it' : ': paused. Press to start it again'))}" title="${r.on ? 'On' : 'Paused'}"${busy ? ' disabled' : ''}></button>`;
|
|
68
|
+
const next = r.wait ? `<span class="w">${esc(r.next)}</span>` : r.late ? `<span class="w">${esc(r.next)}</span>` : esc(r.next);
|
|
69
|
+
return `<div class="rt-r rt-row${r.off ? ' off' : ''}" role="row" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc('Open ' + r.name)}">`
|
|
70
|
+
+ `<span class="ic" role="cell">${svg(I[r.kind], 17)}</span><span class="n" role="cell" title="${esc(r.name)}">${esc(r.name)}</span>`
|
|
71
|
+
+ `<span class="c does" role="cell" title="${esc(r.does)}">${esc(r.does)}</span><span class="c when" role="cell" title="${esc(r.when)}">${esc(r.when)}</span>`
|
|
72
|
+
+ `<span class="c" role="cell">${next}</span><span role="cell" class="e">${end}</span></div>`;
|
|
73
|
+
}
|
|
74
|
+
function draw() {
|
|
75
|
+
$('rtKinds').innerHTML = kindsHtml();
|
|
76
|
+
const D = didLine(S.done);
|
|
77
|
+
$('rtDid').innerHTML = D ? `<button type="button" class="rt-did" data-did aria-label="${esc(D.text + ' Open the full log')}"><b aria-hidden="true">✦</b><span>${esc(D.text)} <em>${esc(D.sub)}</em></span>${svg(I.chev, 14)}</button>` : '';
|
|
78
|
+
if (!S.read) return;
|
|
79
|
+
S.rows = routineRows({ reports: S.reports, refresh: S.refresh, tasks: S.tasks, many: new Set(S.reports.map((r) => r.ws)).size > 1 });
|
|
80
|
+
const G = routineGroups(S.rows, S.kind);
|
|
81
|
+
const f = document.activeElement && document.activeElement.closest && document.activeElement.closest('[data-key],[data-sw],[data-yes]');
|
|
82
|
+
const fk = f ? (f.dataset.key || f.dataset.sw || f.dataset.yes) + (f.dataset.sw ? ':sw' : f.dataset.yes ? ':yes' : '') : '';
|
|
83
|
+
$('rtTable').innerHTML = S.err ? `<p class="rt-quiet">${esc(S.err)}</p>`
|
|
84
|
+
: !G.length ? `<p class="rt-quiet">${S.kind === 'all' ? 'Nothing repeats yet. Tell PMOS what to do on a schedule with +.' : 'Nothing of this kind repeats.'}</p>`
|
|
85
|
+
: `<div class="rt-tbl" role="table" aria-label="Routine"><div class="rt-r rt-h" role="row"><span role="columnheader"><span class="vh">Kind</span></span><span role="columnheader">Routine</span><span role="columnheader" class="does">What it does</span><span role="columnheader" class="when">When</span><span role="columnheader">Next</span><span role="columnheader"><span class="vh">On</span></span></div>`
|
|
86
|
+
+ G.map((g) => `<div class="rt-r rt-g" role="row"><div role="rowheader">${esc(g.title)}</div></div>` + g.rows.map(rowHtml).join('')).join('') + '</div>'
|
|
87
|
+
+ '<p class="rt-note">Everything that repeats, in one table. Press a row to open it. The switch pauses it.</p>';
|
|
88
|
+
if (fk) { const [k, x] = [fk.replace(/:(sw|yes)$/, ''), (/:(sw|yes)$/.exec(fk) || [])[1]]; const el = $('rtTable').querySelector(x === 'sw' ? `[data-sw="${CSS.escape(k)}"]` : x === 'yes' ? `[data-yes="${CSS.escape(k)}"]` : `[data-key="${CSS.escape(k)}"]`); if (el) el.focus(); }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const rowOf = (k) => S.rows.find((r) => r.key === k);
|
|
92
|
+
const reportOf = (r) => S.reports.find((x) => x.ws === r.ws && x.id === r.id);
|
|
93
|
+
const said = (x, ok) => (x && x.ok !== false && !(x && x.error) ? ok : 'Nothing changed: ' + ((x && x.error) || 'the server did not answer') + '.');
|
|
94
|
+
async function press(key, fn) {
|
|
95
|
+
if (S.busy.has(key)) return;
|
|
96
|
+
S.busy.add(key); draw();
|
|
97
|
+
try { say(await fn()); } finally { S.busy.delete(key); }
|
|
98
|
+
await load();
|
|
99
|
+
}
|
|
100
|
+
function flip(r) {
|
|
101
|
+
return press(r.key, async () => {
|
|
102
|
+
const on = !r.on;
|
|
103
|
+
if (r.kind === 'reports') return said(await pmPost('/api/report-setups/' + (on ? 'resume' : 'pause'), { ws: r.ws || undefined, id: r.id }), r.name + (on ? ' is on.' : ' is paused. PMOS does not draft it until you turn it on.'));
|
|
104
|
+
if (r.kind === 'tasks') return said(await pmPost('/api/schedules/update', { id: r.id, enabled: on }), r.name + (on ? ' runs on its schedule again.' : ' is paused.'));
|
|
105
|
+
return said(await pmPost('/api/refresh/source', { id: r.id, on }), r.name + (on ? ' is on.' : ' is paused. PMOS does not run it on its own.'));
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function yes(r) {
|
|
109
|
+
const rep = reportOf(r); if (!rep || !rep.act) return;
|
|
110
|
+
return press(r.key, async () => (rep.act.act === 'move'
|
|
111
|
+
? said(await pmPost('/api/report-setups/move', { ws: r.ws || undefined, id: r.id, to: rep.act.to }), 'Moved ' + r.name + ' to ' + rep.act.toName + '. It drafts there from now on.')
|
|
112
|
+
: said(await pmPost('/api/report-setups/confirm', { ws: r.ws || undefined, id: r.id }), 'Started ' + r.name + '. Its drafts follow the definition as it is.')));
|
|
113
|
+
}
|
|
114
|
+
const H = { VW, http: { pmGet, pmPost }, reload: () => load(), toast };
|
|
115
|
+
function open(r) {
|
|
116
|
+
if (r.kind === 'reports') { const rep = reportOf(r); if (rep) openReport(rep, H); return; }
|
|
117
|
+
openJob(r, H);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* PMOS did, the full log: newest first, each with what it did, why, when, and Undo (POST /api/autonomy/undo) */
|
|
121
|
+
const logHtml = () => `<div class="rt-log" role="list">${S.done.map((d) => `<div class="l" role="listitem"><span><b>${esc(d.title || 'Done')}</b><em>${esc([d.reason, atOf(d.at)].filter(Boolean).join(' · '))}</em></span>`
|
|
122
|
+
+ `<button type="button" data-undo="${esc(d.ref)}" data-ws="${esc(d.ws)}" aria-label="${esc('Undo: ' + (d.title || 'this'))}" title="Undo">${svg(I.undo, 16)}</button></div>`).join('') || '<p class="rt-quiet">Nothing in the last 14 days.</p>'}</div>`;
|
|
123
|
+
function openLog() {
|
|
124
|
+
VW.open({ id: 'routine:did', kind: 'PMOS did', title: 'PMOS did', icon: 'spark', pop: { id: 'routine-did', kind: 'routine', title: 'What PMOS did' },
|
|
125
|
+
render: (b) => {
|
|
126
|
+
b.innerHTML = logHtml();
|
|
127
|
+
b.addEventListener('click', async (e) => {
|
|
128
|
+
const u = e.target.closest('[data-undo]'); if (!u || u.disabled) return;
|
|
129
|
+
u.disabled = true;
|
|
130
|
+
const x = await pmPost('/api/autonomy/undo', { ws: u.dataset.ws || undefined, ref: u.dataset.undo }).catch(() => null);
|
|
131
|
+
if (!x || !x.ok) { u.disabled = false; toast((x && x.error) || 'It could not be undone. Nothing changed.'); return; }
|
|
132
|
+
toast('Undone.'); await load(); if (b.isConnected) b.innerHTML = logHtml();
|
|
133
|
+
});
|
|
134
|
+
} });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
document.addEventListener('click', (e) => {
|
|
138
|
+
const k = e.target.closest('[data-kind]');
|
|
139
|
+
if (k) { S.kind = k.dataset.kind; store.set(KIND_KEY, S.kind); draw(); return; }
|
|
140
|
+
if (e.target.closest('[data-did]')) { openLog(); return; }
|
|
141
|
+
if (e.target.closest('#rtAdd')) { import('./page-chat.js').then((M) => (window.innerWidth > 760 ? POP.openCos(M.cosTarget('Routine')) : M.openCos({ here: 'Routine' }))); return; }
|
|
142
|
+
const s = e.target.closest('[data-sw]'); if (s) { const r = rowOf(s.dataset.sw); if (r && !s.disabled) flip(r); return; }
|
|
143
|
+
const y = e.target.closest('[data-yes]'); if (y) { const r = rowOf(y.dataset.yes); if (r && !y.disabled) yes(r); return; }
|
|
144
|
+
const row = e.target.closest('[data-key]'); if (row && $('rtTable').contains(row)) { const r = rowOf(row.dataset.key); if (r) open(r); }
|
|
145
|
+
});
|
|
146
|
+
document.addEventListener('keydown', (e) => {
|
|
147
|
+
if (e.key !== 'Enter' && e.key !== ' ') return;
|
|
148
|
+
const row = e.target.closest && e.target.closest('[data-key]');
|
|
149
|
+
if (!row || e.target !== row) return;
|
|
150
|
+
e.preventDefault(); const r = rowOf(row.dataset.key); if (r) open(r);
|
|
151
|
+
});
|
|
152
|
+
document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); });
|
|
153
|
+
document.addEventListener('cz:chat-turn', () => load()); // PMOS changed something from the chat: the table shows it
|
|
154
|
+
setInterval(() => { if (!document.hidden && !POP.isOpen()) load(); }, 60000);
|
|
155
|
+
draw();
|
|
156
|
+
load();
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* The row line under each source (how often · next, amber with ↻ only when a read was missed) is pm/cozy-evmodel.js scheduleLine. This
|
|
4
4
|
* module draws the two panels the rows open, inside the Connectors section (cozy-settings.js T.sub):
|
|
5
5
|
* list "Scheduled work": every source PMOS reads on a schedule, PMOS's own jobs and your own scheduled tasks, each with how
|
|
6
|
-
* often and when it runs next.
|
|
6
|
+
* often and when it runs next. Since slice 8 of the six-place navigation it is the place Routine (pm/cozy-routine.js); the
|
|
7
|
+
* entry under the sources goes there (swEntry), and an old ?settings=scheduled link still opens this list.
|
|
7
8
|
* job:<id> one source or job (lib/refresh.js id), like the scheduled task page of the Claude app: Active, Next run, Repeats,
|
|
8
9
|
* Working hours only, PMOS's ✦ rhythm proposal (✓ saves it, ✕ hides it for today), History and ▶ Read now.
|
|
9
10
|
* job:tools.<svc> one service of Your tools (batch 31 item 6, agreed design StA): its own rhythm or that of Your tools, Next run,
|
|
@@ -95,11 +96,11 @@ export function svcOf(rows, id) {
|
|
|
95
96
|
what: 'PMOS reads ' + v.label + ' for the Briefing. ' + (v.own ? 'It has a rhythm of its own.' : 'It follows the rhythm of Your tools.') + ' Services due at the same minute share one session.' };
|
|
96
97
|
}
|
|
97
98
|
const rowOf = (id) => (S.rows || []).find((r) => r.id === id) || svcOf(S.rows, id);
|
|
98
|
-
/** The
|
|
99
|
+
/** The one line under the sources that goes to Routine (slice 8 of the six-place navigation): Scheduled work left Settings and is a place now.
|
|
100
|
+
* The rows above it still open their own setup here (job:<id>). */
|
|
99
101
|
export function swEntry() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
+ ib('data-ev-sw="list"', 'Open Scheduled work', CHEV) + '</div>';
|
|
102
|
+
return `<a class="ev-trow ev-fr ev-sw-entry" href="/premium-routine.html"><span class="ev-gut"></span><span class="ev-sw-ic" aria-hidden="true">${svg(CLOCK, 18)}</span><div class="ev-tx ev-grow"><span>Scheduled work is in Routine</span><p class="ev-small ev-mut">Everything PMOS does on a schedule, with your reports and your own tasks</p></div>`
|
|
103
|
+
+ `<span class="ev-ib" aria-hidden="true">${svg(CHEV, 18)}</span></a>`;
|
|
103
104
|
}
|
|
104
105
|
const head = (title, back, backLabel) => `<div class="ev-dr-hd">${ib(`data-ev-sw="${esc(back)}"`, backLabel, BACK)}<h4 class="ev-grow">${esc(title)}</h4></div>`;
|
|
105
106
|
|
|
@@ -108,7 +108,7 @@ function general() {
|
|
|
108
108
|
const upd = ready() ? `<div class="ev-card ev-upd">${adFace('needs-you')}<span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="updates">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
|
|
109
109
|
return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
|
|
110
110
|
+ trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
|
|
111
|
-
+ trow('Product', 'Which products
|
|
111
|
+
+ trow('Product', 'Which products Today, Work and Goals read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
|
|
112
112
|
+ trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
|
|
113
113
|
+ trow('Your impact', 'Adler’s sprout and your impact log. Only you see it. Nothing leaves PMOS.', sw(impactOn(), 'data-ev-impact', 'Your impact'))
|
|
114
114
|
+ trow('Agents write to Jira', 'Only after you press Commit. Never on their own.', (ready() ? '' : adFace('needs-you', 24)) + '<span class="ev-pill ok">Fixed</span>')
|
|
@@ -511,6 +511,7 @@ function draw() {
|
|
|
511
511
|
// the amber box sits on top of the other sections only: on Connectors the trouble row says it (say it once, CnA)
|
|
512
512
|
el.querySelector('.ev-st-main').innerHTML = (T.sec === 'connectors' ? '' : staleHtml()) + `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3>${all}<button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
|
|
513
513
|
+ BODY[T.sec]() + `<p role="status"${T.msg && AD.moodOfText(T.msg) === 'honest' ? ' class="ev-say honest"' : ''}>${T.msg && AD.moodOfText(T.msg) === 'honest' ? AD.adler('honest', 24, { label: false }) : ''}${esc(T.msg)}</p>`;
|
|
514
|
+
cardRows(el.querySelector('.ev-st-main')); el.querySelectorAll('.ev-st-main .sc-w').forEach(cardRows);
|
|
514
515
|
if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
|
|
515
516
|
wfPanel(el);
|
|
516
517
|
const setup = el.querySelector('[data-claude-setup]');
|
|
@@ -518,6 +519,14 @@ function draw() {
|
|
|
518
519
|
const cur = el.querySelector('.ev-st-nav [aria-current="page"]'); if (cur && cur.scrollIntoView) cur.scrollIntoView({ block: 'nearest', inline: 'nearest' }); // on a phone the section row scrolls: keep the open one in view
|
|
519
520
|
if (had && !ae.isConnected) { const f = (key && el.querySelector(`[${key.name}="${CSS.escape(key.value)}"]`)) || el.querySelector('[aria-current="page"]'); if (f) f.focus(); }
|
|
520
521
|
}
|
|
522
|
+
/** One container (slice 1, board StSettings): rows that follow each other sit in one card with a thin border, never a card in a card. */
|
|
523
|
+
function cardRows(root) {
|
|
524
|
+
if (!root) return;
|
|
525
|
+
let run = [];
|
|
526
|
+
const flush = () => { if (run.length) { const c = document.createElement('div'); c.className = 'ev-tcard'; run[0].before(c); run.forEach((r) => c.appendChild(r)); run = []; } };
|
|
527
|
+
[...root.children].forEach((k) => { if (k.classList.contains('ev-trow')) run.push(k); else flush(); });
|
|
528
|
+
flush();
|
|
529
|
+
}
|
|
521
530
|
/** Workspaces › Workflows (UI grill U1): pm/wf-page.js draws into its host, the same node across redraws; leaving it lets it go. */
|
|
522
531
|
let WF = null, wfOpts = {};
|
|
523
532
|
function wfPanel(el) {
|