create-pmos 0.660.0 → 0.662.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 +15 -9
- 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/briefing-premium-insights-test.js +9 -9
- package/workspace/changelog.json +14 -8
- package/workspace/goals-clear-ui-test.js +12 -12
- package/workspace/guide/intelligence-okr-goals.md +12 -1
- package/workspace/guide/routine.md +4 -5
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +1 -1
- package/workspace/okr-goals-ui-test.js +3 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +2 -2
- package/workspace/public/pm/cozy-insights.css +78 -65
- package/workspace/public/pm/cozy-routine-detail.js +99 -0
- package/workspace/public/pm/cozy-routine-model.js +2 -2
- package/workspace/public/pm/cozy-routine.css +64 -66
- package/workspace/public/pm/cozy-routine.js +127 -38
- package/workspace/public/pm/premium-insights.js +183 -73
- package/workspace/public/premium-intelligence.html +38 -24
- package/workspace/public/premium-routine.html +16 -10
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
/* pm/cozy-routine.js — Routine, the place (initiative routine-place, slice 8 of the six-place navigation;
|
|
2
|
-
*
|
|
1
|
+
/* pm/cozy-routine.js — Routine, the place (initiative routine-place, slice 8 of the six-place navigation; rebuilt from the design system's
|
|
2
|
+
* blocks by initiative routine-ds-page, board RoutineDS on Exploring 3 page "pages"; done tests planning/done-tests/routine-place.md and
|
|
3
|
+
* planning/done-tests/routine-ds-page.md).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Main + open item (Komorebi MainItem). The top line is the path, the product chip (the shared scope chip of Events), then + as an icon
|
|
6
|
+
* button: it asks PMOS for a new routine. "PMOS did" is one line on top (a pm-block flat); a press opens the full log in the popup, each line
|
|
7
|
+
* with its Undo. Then one Table block: the kinds as Tabs in its head (All, Reports, Reads, Jobs, Your tasks with counts; PMOS remembers the
|
|
8
|
+
* choice on this computer), and one pm-table of everything that repeats: Routine, Product (two products or more), What it does, When, Next,
|
|
9
|
+
* and the same switch on every row. Group rows (pm-group) say the type, so there is no Type column: Waits for you, Reports, PMOS reads,
|
|
10
|
+
* PMOS jobs, Your tasks (pm/cozy-routine-model.js). A proposed routine waits in Waits for you with its switch off.
|
|
11
|
+
* On a desk a row opens the Detail at the right (pm/cozy-routine-detail.js); a second press, Enter on the open row, or Open in full opens the
|
|
12
|
+
* one popup (pm/cozy-routine-pop.js for a report, pm/cozy-routine-job.js for the rest), where every value edits. Esc closes the Detail; j and
|
|
13
|
+
* k move to the next and the previous routine. A phone opens the popup at once. It replaces the Scheduled work list of Settings › Connectors.
|
|
8
14
|
*
|
|
9
15
|
* READS GET /api/workspaces, then per product GET /api/report-setups/routine?ws and GET /api/autonomy?ws; once GET /api/refresh and
|
|
10
16
|
* GET /api/schedules?all=1. Every product is read: Routine has no product choice (slice 1).
|
|
11
17
|
* 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 switch of a proposed report (Waits for you)
|
|
13
|
-
*
|
|
18
|
+
* your task → POST /api/schedules/update { id, enabled }; the switch of a proposed report (Waits for you), or Yes on its Suggestion →
|
|
19
|
+
* /api/report-setups/confirm | move; No on it → /api/report-setups/drop after its Undo; Yes on "run it again" → /api/refresh/run,
|
|
20
|
+
* /api/scan/now or /api/schedules/run; Undo in the log → POST /api/autonomy/undo. Nothing here sends anything outside. */
|
|
14
21
|
import { pmGet, pmPost } from './http.js';
|
|
15
22
|
import { mountNav } from './cozy-nav.js';
|
|
16
23
|
import { mountLivePill } from './cozy-live-pill.js';
|
|
@@ -22,6 +29,7 @@ import { scopeChipHtml, openScope, scopeWords, whenNames, displayName, productNa
|
|
|
22
29
|
import { atOf } from './cozy-evmodel.js';
|
|
23
30
|
import { openReport } from './cozy-routine-pop.js';
|
|
24
31
|
import { openJob, openNew } from './cozy-routine-job.js'; // reads, jobs, services and your tasks: manage them in the popup (round 3 item 3)
|
|
32
|
+
import { detailHtml } from './cozy-routine-detail.js'; // the Detail at the right (routine-ds-page)
|
|
25
33
|
|
|
26
34
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
27
35
|
const svg = (d, n = 18) => `<svg class="pm-ic" viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
@@ -32,7 +40,8 @@ const I = {
|
|
|
32
40
|
};
|
|
33
41
|
const KIND_KEY = 'pmos.routine.kind';
|
|
34
42
|
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
|
|
35
|
-
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(), gone: new Set(), read: false, err: '', pick: null, all: false, openG: new Set() };
|
|
43
|
+
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(), gone: new Set(), read: false, err: '', pick: null, all: false, openG: new Set(), open: null, msg: '' };
|
|
44
|
+
const NOFAIL = 'pmos.routine.nofail.'; // No on "run it again": hidden for those runs on this computer
|
|
36
45
|
const $ = (id) => document.getElementById(id);
|
|
37
46
|
/** A short line at the bottom. With `undo`, it carries an Undo button and stays 10 s, the time the undo has. */
|
|
38
47
|
const toast = (t, undo) => {
|
|
@@ -92,8 +101,8 @@ async function load() {
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
function kindsHtml(n) {
|
|
95
|
-
// each kind says how many it holds (round 2);
|
|
96
|
-
return KINDS.map(([k, l]) => `<button type="button" class="pm-tab" data-kind="${k}" aria-
|
|
104
|
+
// the Tabs part: each kind says how many it holds (round 2); a kind with none says none (zero is silence)
|
|
105
|
+
return `<div class="pm-tabs" role="tablist" aria-label="Show">${KINDS.map(([k, l]) => `<button type="button" class="pm-tab" role="tab" data-kind="${k}" aria-selected="${S.kind === k}"${n ? ` aria-label="${esc(l + ', ' + (n[k] || 0))}"` : ''}>${esc(l)}${n && n[k] ? ` <span class="rt-n">${n[k]}</span>` : ''}</button>`).join('')}</div>`;
|
|
97
106
|
}
|
|
98
107
|
/* ── the chip (round 2, PR 3): the shared scope chip of Events (pm/scope-chip.js). Products is the saved pick of Work; Programs and Projects
|
|
99
108
|
* are this page's own (kept on this computer). A report is under a program or a project when its setup says so (lib/routine-reports.js
|
|
@@ -155,21 +164,24 @@ function drawPick(groups) {
|
|
|
155
164
|
whenNames().then(() => draw()); // product display names (IDPF, not a folder name) arrive after the first draw
|
|
156
165
|
addEventListener('pp:changed', (e) => { if (e.detail && e.detail.ok) { S.pick = e.detail; S.all = false; draw(); } });
|
|
157
166
|
/** The fold line at the end of Reports: one-time reports and loose drafts, opened as plain rows. */
|
|
158
|
-
const foldHtml = (f) => `<
|
|
167
|
+
const foldHtml = (f, cols) => `<tr class="rt-fold"><td colspan="${cols}"><button type="button" class="pm-fold" data-once aria-expanded="${!!S.once}">${svg(I.chev, 14)}<span>${esc(f.words)}</span></button></td></tr>`;
|
|
159
168
|
/** The Product cell: the product, or the first and +N when one report is in several. Empty for what serves every product. */
|
|
160
169
|
const prodWords = (r) => (r.wss && r.wss.length ? r.wss[0] + (r.wss.length > 1 ? ' +' + (r.wss.length - 1) : '') : '');
|
|
161
170
|
function rowHtml(r, multi) {
|
|
162
171
|
const busy = S.busy.has(r.key);
|
|
163
172
|
// round 3 item 1: the same switch on every row. A proposed routine's switch is off, and turning it on is the yes.
|
|
164
173
|
const label = r.proposed ? r.name + ': proposed by PMOS. Press to start it' : r.name + (r.on ? ': on. Press to pause it' : ': paused. Press to start it again');
|
|
165
|
-
const end = r.on === null ? '
|
|
166
|
-
: `<button type="button" class="
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
const end = r.on === null ? ''
|
|
175
|
+
: `<button type="button" class="pm-switch" role="switch" aria-checked="${r.on}" data-sw="${esc(r.key)}" aria-label="${esc(label)}" title="${r.proposed ? 'Proposed. Turn on to start it' : r.on ? 'On' : 'Paused'}"${busy ? ' disabled' : ''}></button>`;
|
|
176
|
+
// ✕ on a proposed report: PMOS stops proposing it, with Undo (shown on hover, beside the switch)
|
|
177
|
+
const drop = r.proposed && r.kind === 'reports' ? `<button type="button" class="pm-btn rt-drop" data-drop="${esc(r.key)}" aria-label="${esc('Drop ' + r.name + '. PMOS stops proposing it')}" title="Drop this proposal">${svg(I.x, 14)}</button>` : '';
|
|
178
|
+
// a proposal has no Next (its group says it waits); a stuck or missed one, or a draft that waits, is the alert Badge
|
|
179
|
+
const next = r.proposed ? '' : r.late || (r.group === 'once' && r.draft) ? `<span class="pm-badge alert">${esc(r.next)}</span>` : `<span class="pm-meta rt-next">${esc(r.next)}</span>`;
|
|
180
|
+
const star = r.proposed ? `<b class="pm-star" aria-hidden="true">✦</b> ` : '';
|
|
181
|
+
return `<tr class="rt-row${r.off && !r.proposed ? ' off' : ''}${S.open === r.key ? ' sel' : ''}" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc('Open ' + r.name)}"${S.open === r.key ? ' aria-current="true"' : ''}>`
|
|
182
|
+
+ `<td class="rt-name">${star}<b title="${esc(r.name)}">${esc(r.name)}</b></td>${multi ? `<td class="rt-prod" title="${esc((r.wss || []).join(', '))}">${esc(prodWords(r))}</td>` : ''}`
|
|
183
|
+
+ `<td class="rt-does" title="${esc(r.does)}">${esc(r.does)}</td><td class="rt-when"><span class="pm-meta">${esc(r.when)}</span></td>`
|
|
184
|
+
+ `<td class="rt-nx">${next}</td><td class="rt-on"><span class="pm-row">${drop}${end}</span></td></tr>`;
|
|
173
185
|
}
|
|
174
186
|
function draw() {
|
|
175
187
|
const on = onSet();
|
|
@@ -180,10 +192,11 @@ function draw() {
|
|
|
180
192
|
const known = new Set([...groups.programs, ...groups.projects].map((g) => g.id));
|
|
181
193
|
if (S.read) S.sel = { programs: S.sel.programs.filter((t) => known.has(t)), projects: S.sel.projects.filter((t) => known.has(t)) };
|
|
182
194
|
const mine = S.read ? tag(routineRows({ reports: S.reports.filter(inPick(on)), refresh: S.refresh, jobs: S.jobs, tasks: S.tasks.filter(inPick(on)), spaces: S.ws.flatMap((x) => [x.id, x.name]) })).filter(inScope) : [];
|
|
183
|
-
|
|
195
|
+
const counts = S.read ? kindCounts(mine.filter((r) => r.group !== 'once' && (!r.unclear || S.unclear))) : null; // the routines, not the one-time reports
|
|
184
196
|
drawPick(groups);
|
|
185
197
|
const D = didLine(S.done);
|
|
186
|
-
|
|
198
|
+
// PMOS did: one flat block, PMOS speaking; the chevron opens the full log with Undo on each line
|
|
199
|
+
$('rtDid').innerHTML = D ? `<section class="pm-block flat rt-did" aria-label="PMOS did" data-did><b class="pm-star" aria-hidden="true">✦</b><span class="rt-say">${esc(D.text)} <span class="pm-meta">${esc(D.sub)}</span></span><button type="button" class="pm-btn" data-did aria-label="${esc('See what PMOS did. ' + D.text)}" title="See what PMOS did">${svg(I.chev, 16)}</button></section>` : '';
|
|
187
200
|
if (!S.read) return;
|
|
188
201
|
S.rows = mine.filter((r) => !S.gone.has(r.key)); // a deleted task leaves at once; its delete is sent when the Undo has passed
|
|
189
202
|
// rows a PM cannot read are held back, counted in one grey line (round 3 item 2); one-time reports fold under Reports (item 1)
|
|
@@ -204,20 +217,25 @@ function draw() {
|
|
|
204
217
|
// with a program or project picked, PMOS reads and PMOS jobs fold to their heading: they serve every product, so the picked
|
|
205
218
|
// work's own reports come first (design note on #1384). Pressing the heading opens the rows.
|
|
206
219
|
const shut = (g) => extraOn() && (g.id === 'reads' || g.id === 'jobs') && !S.openG.has(g.id) && g.rows.length > 0;
|
|
220
|
+
const cols = multi ? 6 : 5;
|
|
221
|
+
const gwords = { wait: 'PMOS proposes it; turn it on to start' };
|
|
222
|
+
const gline = (g) => `<b>${esc(g.title)}</b> <span class="pm-meta">${g.rows.filter((r) => !r.fold).length}${gwords[g.id] ? ' · ' + gwords[g.id] : ''}</span>`;
|
|
207
223
|
const head = (g) => shut(g) || (extraOn() && S.openG.has(g.id))
|
|
208
|
-
? `<
|
|
209
|
-
: `<
|
|
210
|
-
const unLine = unclear.length ? `<p class="rt-hid">${unclear.length === 1 ? 'One row is' : unclear.length + ' rows are'} hidden because their source is unclear. <button type="button" data-unclear>Show</button></p>` : '';
|
|
224
|
+
? `<tr class="rt-g"><th colspan="${cols}" scope="rowgroup" class="pm-group"><button type="button" class="rt-gf" data-gfold="${esc(g.id)}" aria-expanded="${!shut(g)}" aria-label="${esc((shut(g) ? 'Show ' : 'Fold ') + g.title)}">${svg(I.chev, 14)}${gline(g)}</button></th></tr>`
|
|
225
|
+
: `<tr class="rt-g"><th colspan="${cols}" scope="rowgroup" class="pm-group">${gline(g)}</th></tr>`;
|
|
226
|
+
const unLine = unclear.length ? `<p class="rt-hid pm-meta">${unclear.length === 1 ? 'One row is' : unclear.length + ' rows are'} hidden because their source is unclear. <button type="button" class="pm-chip" data-unclear>Show</button></p>` : '';
|
|
211
227
|
const only = extraOn() ? scopeWords(on ? S.pick : null, S.sel, groups) : '';
|
|
212
|
-
const hidLine = unLine + (hid ? `<p class="rt-hid">${only ? esc('Showing ' + only + ' only. ') + (hid === 1 ? 'One routine is' : hid + ' routines are') : hid === 1 ? 'One routine of another product is' : hid + ' routines of other products are'} not shown. <button type="button" data-showall>Show all</button></p>` : '');
|
|
213
|
-
const f = document.activeElement && document.activeElement.closest && document.activeElement.closest('[data-key],[data-sw],[data-yes]');
|
|
214
|
-
const fk = f ? (f.dataset.key || f.dataset.sw || f.dataset.yes) + (f.dataset.sw ? ':sw' : f.dataset.yes ? ':yes' : '') : '';
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
const hidLine = unLine + (hid ? `<p class="rt-hid pm-meta">${only ? esc('Showing ' + only + ' only. ') + (hid === 1 ? 'One routine is' : hid + ' routines are') : hid === 1 ? 'One routine of another product is' : hid + ' routines of other products are'} not shown. <button type="button" class="pm-chip" data-showall>Show all</button></p>` : '');
|
|
229
|
+
const f = document.activeElement && document.activeElement.closest && document.activeElement.closest('[data-key],[data-sw],[data-yes],[data-kind]');
|
|
230
|
+
const fk = f ? (f.dataset.kind ? 'kind:' + f.dataset.kind + ':kind' : (f.dataset.key || f.dataset.sw || f.dataset.yes) + (f.dataset.sw ? ':sw' : f.dataset.yes ? ':yes' : '')) : '';
|
|
231
|
+
const tabs = kindsHtml(counts);
|
|
232
|
+
// the Table block: the Tabs in its head, then one pm-table; the group rows say the type
|
|
233
|
+
$('rtTable').innerHTML = `<section class="pm-block rt-tbl" aria-label="Everything that repeats"><div class="head">${tabs}</div>` + hidLine + (S.err ? `<p class="rt-quiet pm-meta">${esc(S.err)}</p>`
|
|
234
|
+
: !G.length ? `<p class="rt-quiet pm-meta">${S.kind === 'all' ? 'Nothing repeats yet. Tell PMOS what to do on a schedule with +.' : 'Nothing of this kind repeats.'}</p>`
|
|
235
|
+
: `<table class="pm-table" aria-label="Routine"><thead><tr><th scope="col">Routine</th>${multi ? '<th scope="col" class="rt-prod">Product</th>' : ''}<th scope="col" class="rt-does">What it does</th><th scope="col" class="rt-when">When</th><th scope="col">Next</th><th scope="col" class="rt-on">On</th></tr></thead>`
|
|
236
|
+
+ G.map((g) => `<tbody>${head(g)}${shut(g) ? '' : g.rows.map((r) => (r.fold ? foldHtml(r, cols) : rowHtml(r, multi))).join('')}</tbody>`).join('') + '</table>') + '</section>';
|
|
237
|
+
drawDetail();
|
|
238
|
+
if (fk) { const [k, x] = [fk.replace(/:(sw|yes|kind)$/, ''), (/:(sw|yes|kind)$/.exec(fk) || [])[1]]; const el = $('rtTable').querySelector(x === 'kind' ? `[data-kind="${CSS.escape(k.slice(5))}"]` : x === 'sw' ? `[data-sw="${CSS.escape(k)}"]` : x === 'yes' ? `[data-yes="${CSS.escape(k)}"]` : `[data-key="${CSS.escape(k)}"]`); if (el) el.focus(); }
|
|
221
239
|
}
|
|
222
240
|
|
|
223
241
|
const rowOf = (k) => S.rows.find((r) => r.key === k);
|
|
@@ -226,7 +244,7 @@ const said = (x, ok) => (x && x.ok !== false && !(x && x.error) ? ok : 'Nothing
|
|
|
226
244
|
async function press(key, fn) {
|
|
227
245
|
if (S.busy.has(key)) return;
|
|
228
246
|
S.busy.add(key); draw();
|
|
229
|
-
try {
|
|
247
|
+
try { const m = await fn(); say(m); if (S.open === key) S.msg = m; } finally { S.busy.delete(key); }
|
|
230
248
|
await load();
|
|
231
249
|
}
|
|
232
250
|
function flip(r) {
|
|
@@ -294,6 +312,70 @@ function open(r) {
|
|
|
294
312
|
openJob(r, H);
|
|
295
313
|
}
|
|
296
314
|
|
|
315
|
+
/* ── the Detail at the right (Main + open item; pm/cozy-routine-detail.js draws it) ── */
|
|
316
|
+
const desk = () => typeof innerWidth !== 'number' || innerWidth > 760;
|
|
317
|
+
const hidden = () => { const h = new Set(); try { for (let i = 0; i < localStorage.length; i++) { const k = localStorage.key(i); if (k && k.startsWith(NOFAIL)) h.add(k.slice(NOFAIL.length)); } } catch { /* a private window */ } return h; };
|
|
318
|
+
function detailOf(r) {
|
|
319
|
+
if (r.kind === 'reports') return { row: r, rep: reportOf(r) || null, hide: hidden(), busy: S.busy.has(r.key), msg: S.msg };
|
|
320
|
+
const g = rawOf(r);
|
|
321
|
+
return { row: r, job: { raw: g.raw || {}, tools: g.tools || null, own: g.own || null, svc: r.svc || null, extra: g.extra || null }, hide: hidden(), busy: S.busy.has(r.key), msg: S.msg };
|
|
322
|
+
}
|
|
323
|
+
function drawDetail() {
|
|
324
|
+
const host = $('rtDetail'), page = $('stage'); if (!host) return;
|
|
325
|
+
const r = S.open && desk() ? rowOf(S.open) : null;
|
|
326
|
+
if (S.open && !r && S.read) S.open = null; // the open routine left the table (a filter, a drop): the Detail closes
|
|
327
|
+
const had = host.querySelector('.rt-detail'), keep = had && had.dataset.key === (r && r.key);
|
|
328
|
+
host.innerHTML = r ? detailHtml(detailOf(r)) : '';
|
|
329
|
+
const sec = host.querySelector('.rt-detail'); if (sec) { sec.dataset.key = r.key; if (keep) sec.classList.remove('pm-motion-enter'); }
|
|
330
|
+
if (page) page.classList.toggle('rt-open', !!r);
|
|
331
|
+
}
|
|
332
|
+
/** Show a routine in the Detail (a desk), or open it in full (a phone, or a second press on the open one). */
|
|
333
|
+
function show(r) {
|
|
334
|
+
if (!desk() || S.open === r.key) { open(r); return; }
|
|
335
|
+
S.open = r.key; S.msg = ''; draw();
|
|
336
|
+
const d = $('rtDetail').querySelector('.rt-detail h2'); if (d) d.setAttribute('tabindex', '-1');
|
|
337
|
+
}
|
|
338
|
+
function closeDetail() {
|
|
339
|
+
const k = S.open; if (!k) return;
|
|
340
|
+
S.open = null; S.msg = ''; draw();
|
|
341
|
+
const row = $('rtTable').querySelector(`[data-key="${CSS.escape(k)}"]`); if (row) row.focus(); // back to the list, the row still there
|
|
342
|
+
}
|
|
343
|
+
/** j and k: the next and the previous routine in the table, as it shows. */
|
|
344
|
+
function step(n) {
|
|
345
|
+
const keys = [...$('rtTable').querySelectorAll('tr[data-key]')].map((x) => x.dataset.key), i = keys.indexOf(S.open);
|
|
346
|
+
const k = keys[i < 0 ? 0 : Math.max(0, Math.min(keys.length - 1, i + n))]; if (!k || k === S.open) return;
|
|
347
|
+
S.open = k; S.msg = ''; draw();
|
|
348
|
+
const row = $('rtTable').querySelector(`[data-key="${CSS.escape(k)}"]`); if (row) row.focus();
|
|
349
|
+
}
|
|
350
|
+
/** Yes on "run it again": the same routes as ▶ in the popup (pm/cozy-routine-job.js run). */
|
|
351
|
+
function runNow(r) {
|
|
352
|
+
return press(r.key, async () => {
|
|
353
|
+
const ws = S.home || undefined;
|
|
354
|
+
if (r.kind === 'tasks') return said(await pmPost('/api/schedules/run', { id: r.id }), 'Started. ' + r.name + ' runs now.');
|
|
355
|
+
if (r.id === 'scan') return said(await pmPost('/api/scan/now', { ws }), 'Started. PMOS scans now.');
|
|
356
|
+
if (r.svc) return said(await pmPost('/api/refresh/run', { id: r.parent, svcs: [r.svc], ws }), 'Started. PMOS reads ' + r.name + ' now.');
|
|
357
|
+
return said(await pmPost('/api/refresh/run', { id: r.id, ws }), 'Started. ' + r.name + ' runs now.');
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
async function detailPress(t) {
|
|
361
|
+
const r = rowOf(S.open); if (!r) return;
|
|
362
|
+
const k = t.dataset.rd;
|
|
363
|
+
if (k === 'close') { closeDetail(); return; }
|
|
364
|
+
if (k === 'full') { open(r); return; }
|
|
365
|
+
if (k === 'chat') { const PC = await import('./page-chat.js'); PC.openChat({ id: 'routine-' + r.key, kind: 'routine', title: r.name }, { ws: r.ws || S.home }); return; }
|
|
366
|
+
if (k === 'issue' && t.dataset.path) { const M = await import('./premium-report-read.js'); VW.drill(); M.openReportView(t.dataset.path, { ws: r.ws || undefined, name: r.name }); }
|
|
367
|
+
}
|
|
368
|
+
function sugPress(t) {
|
|
369
|
+
const r = rowOf(t.dataset.key); if (!r) return;
|
|
370
|
+
const a = t.dataset.rsug, pat = t.dataset.pat;
|
|
371
|
+
if (a === 'edit') { open(r); return; } // Change it first: the full popup, where every value edits and the chat is about it
|
|
372
|
+
if (pat === 'wait') { if (a === 'yes') yes(r); else drop(r); return; }
|
|
373
|
+
if (pat === 'fail') {
|
|
374
|
+
if (a === 'yes') { runNow(r); return; }
|
|
375
|
+
store.set(NOFAIL + t.dataset.sig, '1'); draw();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
297
379
|
/* PMOS did, the full log: newest first, each with what it did, why, when, and Undo (POST /api/autonomy/undo) */
|
|
298
380
|
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>`
|
|
299
381
|
+ `<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>`;
|
|
@@ -315,6 +397,8 @@ document.addEventListener('click', (e) => {
|
|
|
315
397
|
const k = e.target.closest('[data-kind]');
|
|
316
398
|
if (k) { S.kind = k.dataset.kind; store.set(KIND_KEY, S.kind); draw(); return; }
|
|
317
399
|
if (e.target.closest('[data-did]')) { openLog(); return; }
|
|
400
|
+
const rd = e.target.closest('[data-rd]'); if (rd) { detailPress(rd); return; }
|
|
401
|
+
const rs = e.target.closest('[data-rsug]'); if (rs) { if (!rs.disabled) sugPress(rs); return; }
|
|
318
402
|
if (e.target.closest('[data-showall]')) { S.all = true; draw(); return; }
|
|
319
403
|
if (e.target.closest('[data-unclear]')) { S.unclear = true; draw(); return; }
|
|
320
404
|
if (e.target.closest('[data-once]')) { S.once = !S.once; draw(); return; }
|
|
@@ -325,13 +409,18 @@ document.addEventListener('click', (e) => {
|
|
|
325
409
|
const d = e.target.closest('[data-drop]'); if (d) { const r = rowOf(d.dataset.drop); if (r) drop(r); return; }
|
|
326
410
|
const s = e.target.closest('[data-sw]'); if (s) { const r = rowOf(s.dataset.sw); if (r && !s.disabled) flip(r); return; }
|
|
327
411
|
const y = e.target.closest('[data-yes]'); if (y) { const r = rowOf(y.dataset.yes); if (r && !y.disabled) yes(r); return; }
|
|
328
|
-
const row = e.target.closest('[data-key]'); if (row && $('rtTable').contains(row)) { const r = rowOf(row.dataset.key); if (r)
|
|
412
|
+
const row = e.target.closest('tr[data-key]'); if (row && $('rtTable').contains(row)) { const r = rowOf(row.dataset.key); if (r) show(r); }
|
|
329
413
|
});
|
|
330
414
|
document.addEventListener('keydown', (e) => {
|
|
415
|
+
const typing = e.target && e.target.closest && e.target.closest('input, textarea, select, [contenteditable="true"]');
|
|
416
|
+
if (S.open && !POP.isOpen() && !typing && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
417
|
+
if (e.key === 'Escape') { e.preventDefault(); closeDetail(); return; }
|
|
418
|
+
if (e.key === 'j' || e.key === 'k') { e.preventDefault(); step(e.key === 'j' ? 1 : -1); return; }
|
|
419
|
+
}
|
|
331
420
|
if (e.key !== 'Enter' && e.key !== ' ') return;
|
|
332
|
-
const row = e.target.closest && e.target.closest('[data-key]');
|
|
421
|
+
const row = e.target.closest && e.target.closest('tr[data-key]');
|
|
333
422
|
if (!row || e.target !== row) return;
|
|
334
|
-
e.preventDefault(); const r = rowOf(row.dataset.key); if (r)
|
|
423
|
+
e.preventDefault(); const r = rowOf(row.dataset.key); if (r) show(r);
|
|
335
424
|
});
|
|
336
425
|
document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); });
|
|
337
426
|
document.addEventListener('cz:chat-turn', () => load()); // PMOS changed something from the chat: the table shows it
|