identityscope 0.28.3 → 0.28.5

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.
Files changed (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +914 -917
  3. package/SECURITY.md +56 -56
  4. package/dist/node/cli.js +26 -26
  5. package/dist/node/monthly.js +17 -17
  6. package/package.json +2 -2
  7. package/reports/access-profile-members.yaml +29 -29
  8. package/reports/access-profile-membership-counts.yaml +17 -17
  9. package/reports/access-profiles-without-owner.yaml +16 -16
  10. package/reports/access-request-audit-trail.yaml +36 -36
  11. package/reports/accounts-by-source.yaml +19 -19
  12. package/reports/active-identities-without-manager.yaml +22 -22
  13. package/reports/aggregation-failures.yaml +29 -29
  14. package/reports/aggregation-history.yaml +27 -27
  15. package/reports/all-sources.yaml +16 -16
  16. package/reports/application-accounts.yaml +32 -32
  17. package/reports/application-entitlements.yaml +31 -31
  18. package/reports/campaign-progress.yaml +23 -23
  19. package/reports/certification-decisions.yaml +31 -31
  20. package/reports/direct-reports-per-manager.yaml +20 -20
  21. package/reports/disabled-accounts-of-active-people.yaml +33 -33
  22. package/reports/duplicate-emails.yaml +16 -16
  23. package/reports/entitlement-holders.yaml +35 -35
  24. package/reports/entitlements-held-by-inactive-identities.yaml +31 -31
  25. package/reports/entitlements-without-owner.yaml +28 -28
  26. package/reports/identities-by-lifecycle-state.yaml +15 -15
  27. package/reports/identities-missing-key-attributes.yaml +27 -27
  28. package/reports/identities-with-processing-errors.yaml +19 -19
  29. package/reports/identity-attribute-mappings.yaml +27 -27
  30. package/reports/machine-accounts.yaml +28 -28
  31. package/reports/managers-and-direct-reports.yaml +23 -23
  32. package/reports/most-access.yaml +18 -18
  33. package/reports/new-identities.yaml +24 -24
  34. package/reports/old-passwords.yaml +35 -35
  35. package/reports/pending-reviews-by-reviewer.yaml +20 -20
  36. package/reports/person-access.yaml +31 -31
  37. package/reports/privileged-access.yaml +29 -29
  38. package/reports/provisioning-error-causes.yaml +27 -27
  39. package/reports/provisioning-errors.yaml +32 -32
  40. package/reports/provisioning-failures.yaml +28 -28
  41. package/reports/recent-access-requests.yaml +22 -22
  42. package/reports/recent-activity.yaml +32 -32
  43. package/reports/recent-leavers.yaml +34 -34
  44. package/reports/role-members.yaml +29 -29
  45. package/reports/role-membership-counts.yaml +18 -18
  46. package/reports/roles-without-owner.yaml +17 -17
  47. package/reports/sources-needing-attention.yaml +23 -23
  48. package/reports/stuck-access-requests.yaml +29 -29
  49. package/reports/team-access.yaml +30 -30
  50. package/reports/terminated-users-with-active-accounts.yaml +46 -46
  51. package/reports/uncorrelated-accounts.yaml +38 -38
  52. package/ui/js/00-setup.js +6 -6
  53. package/ui/js/01-small-helpers.js +143 -143
  54. package/ui/js/02-connection.js +150 -150
  55. package/ui/js/03-health-check.js +17 -17
  56. package/ui/js/04-library.js +135 -135
  57. package/ui/js/05-pickers.js +163 -163
  58. package/ui/js/06-report-view.js +157 -157
  59. package/ui/js/07-fields.js +85 -85
  60. package/ui/js/08-designer.js +360 -360
  61. package/ui/js/09-yaml.js +22 -22
  62. package/ui/js/10-instant-check.js +171 -171
  63. package/ui/js/11-lookup.js +161 -161
  64. package/ui/js/12-tenant.js +115 -115
  65. package/ui/js/13-source-configuration-and-diagnostics.js +64 -64
  66. package/ui/js/14-certifications.js +68 -68
  67. package/ui/js/15-monthly-report.js +24 -24
  68. package/ui/js/16-ownership.js +39 -39
  69. package/ui/js/17-compare-tenants.js +102 -102
  70. package/ui/js/18-audit.js +181 -181
  71. package/ui/js/19-insights.js +108 -108
  72. package/ui/js/20-role-mining.js +35 -35
  73. package/ui/js/21-share-reports.js +45 -45
  74. package/ui/js/22-partner-overview-all-customer-tenants.js +228 -228
  75. package/ui/js/23-in-app-guidance.js +217 -217
  76. package/ui/js/24-role-tools.js +220 -220
  77. package/ui/js/25-schedules.js +264 -264
  78. package/ui/js/26-start.js +7 -7
  79. package/ui/js/27-warnings.js +224 -224
  80. package/ui/js/28-audit-readiness.js +99 -99
  81. package/ui/js/29-lifecycle.js +182 -182
  82. package/ui/js/30-labs.js +265 -265
  83. package/ui/js/31-build.js +203 -203
  84. package/ui/js/32-lab-examples.js +148 -148
  85. package/ui/js/33-finder.js +89 -89
  86. package/ui/js/34-governance.js +129 -129
  87. package/ui/js/35-watch.js +266 -266
  88. package/ui/js/36-model.js +247 -247
  89. package/ui/js/37-logs-and-watch.js +224 -224
  90. package/ui/shell.html +112 -112
  91. package/ui/style.css +350 -350
package/ui/js/09-yaml.js CHANGED
@@ -1,22 +1,22 @@
1
- // ---------- yaml ----------
2
- function renderYaml(w) {
3
- var c = state.current;
4
- var ta = el('textarea', { className: 'yaml', spellcheck: 'false' });
5
- var problems = el('div');
6
- w.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'The full report definition. Copy it to share the report, or edit it directly and press Apply.' }));
7
- w.appendChild(ta);
8
- w.appendChild(problems);
9
- w.appendChild(el('div', { className: 'bar', style: 'margin-top:12px' },
10
- el('button', { className: 'btn primary', onclick: function () {
11
- problems.textContent = '';
12
- api('/api/parse', 'POST', { yaml: ta.value }).then(function (r) { c.def = r.definition; changed(); c.yaml = ta.value; state.tab = 'design'; toast('Applied'); renderMain(); })
13
- .catch(function (e) { problems.appendChild(el('div', { className: 'error', text: errorText(e) })); });
14
- } }, 'Apply'),
15
- el('button', { className: 'btn', onclick: function () { navigator.clipboard.writeText(ta.value).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')));
16
- if (c.yaml && !state.dirty) ta.value = c.yaml;
17
- else api('/api/yaml', 'POST', { definition: c.def }).then(function (r) {
18
- ta.value = r.yaml;
19
- if (r.problems.length) problems.appendChild(el('div', { className: 'error', text: 'Fix before running:\n- ' + r.problems.join('\n- ') }));
20
- });
21
- }
22
-
1
+ // ---------- yaml ----------
2
+ function renderYaml(w) {
3
+ var c = state.current;
4
+ var ta = el('textarea', { className: 'yaml', spellcheck: 'false' });
5
+ var problems = el('div');
6
+ w.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'The full report definition. Copy it to share the report, or edit it directly and press Apply.' }));
7
+ w.appendChild(ta);
8
+ w.appendChild(problems);
9
+ w.appendChild(el('div', { className: 'bar', style: 'margin-top:12px' },
10
+ el('button', { className: 'btn primary', onclick: function () {
11
+ problems.textContent = '';
12
+ api('/api/parse', 'POST', { yaml: ta.value }).then(function (r) { c.def = r.definition; changed(); c.yaml = ta.value; state.tab = 'design'; toast('Applied'); renderMain(); })
13
+ .catch(function (e) { problems.appendChild(el('div', { className: 'error', text: errorText(e) })); });
14
+ } }, 'Apply'),
15
+ el('button', { className: 'btn', onclick: function () { navigator.clipboard.writeText(ta.value).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')));
16
+ if (c.yaml && !state.dirty) ta.value = c.yaml;
17
+ else api('/api/yaml', 'POST', { definition: c.def }).then(function (r) {
18
+ ta.value = r.yaml;
19
+ if (r.problems.length) problems.appendChild(el('div', { className: 'error', text: 'Fix before running:\n- ' + r.problems.join('\n- ') }));
20
+ });
21
+ }
22
+
@@ -1,171 +1,171 @@
1
- // ---------- instant check ----------
2
- state.chk = { results: null, meta: null, selected: null, auto: 0, timer: null, busy: null };
3
- var STATUS = { ok: ['OK', 'ok'], warn: ['Attention', 'warn'], bad: ['Problem', 'bad'], error: ['Could not check', 'err'], off: ['Off', 'off'] };
4
- function ago(iso) {
5
- if (!iso) return '';
6
- var s = Math.round((Date.now() - Date.parse(iso)) / 1000);
7
- if (s < 60) return 'just now';
8
- if (s < 3600) return Math.round(s / 60) + ' min ago';
9
- if (s < 86400) return Math.round(s / 3600) + ' h ago';
10
- return Math.round(s / 86400) + ' days ago';
11
- }
12
- function when(iso) { return iso ? iso.replace('T', ' ').slice(0, 16) : '—'; }
13
- function sparkline(points, w, h) {
14
- var NS = 'http://www.w3.org/2000/svg';
15
- var svg = document.createElementNS(NS, 'svg');
16
- svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);
17
- svg.setAttribute('width', w); svg.setAttribute('height', h);
18
- svg.setAttribute('class', 'spark');
19
- var vals = (points || []).filter(function (p) { return p.value !== null && p.value !== undefined; }).slice(-30);
20
- if (vals.length < 2) return svg;
21
- var max = Math.max.apply(null, vals.map(function (p) { return p.value; })), min = Math.min.apply(null, vals.map(function (p) { return p.value; }));
22
- var span = max - min || 1;
23
- var pts = vals.map(function (p, i) { return (i * (w - 4) / (vals.length - 1) + 2).toFixed(1) + ',' + (h - 3 - ((p.value - min) / span) * (h - 6)).toFixed(1); });
24
- var line = document.createElementNS(NS, 'polyline');
25
- line.setAttribute('points', pts.join(' '));
26
- line.setAttribute('fill', 'none'); line.setAttribute('stroke', 'currentColor'); line.setAttribute('stroke-width', '1.8'); line.setAttribute('stroke-linejoin', 'round');
27
- svg.appendChild(line);
28
- var last = pts[pts.length - 1].split(',');
29
- var dot = document.createElementNS(NS, 'circle');
30
- dot.setAttribute('cx', last[0]); dot.setAttribute('cy', last[1]); dot.setAttribute('r', '2.6'); dot.setAttribute('fill', 'currentColor');
31
- svg.appendChild(dot);
32
- var t = document.createElementNS(NS, 'title');
33
- t.textContent = vals.length + ' checks, from ' + fmtNum(min) + ' to ' + fmtNum(max);
34
- svg.appendChild(t);
35
- return svg;
36
- }
37
- function loadCheckMeta() { return api('/api/checks').then(function (m) { state.chk.meta = m; return m; }); }
38
- function runAllChecks() {
39
- var c = state.chk;
40
- if (c.busy) return;
41
- c.busy = 'Starting the checks...'; c.error = null; renderChecks();
42
- api('/api/checks/run', 'POST', {}).then(function (r) {
43
- c.job = r.job;
44
- pollJob(r.job, function (m) { c.busy = m; var p = $('chk-progress'); if (p) p.textContent = m; },
45
- function (s) { c.busy = null; c.results = s.extra.results; c.headline = s.extra.headline; c.at = new Date().toISOString(); loadCheckMeta().then(renderChecks, renderChecks); },
46
- function (e) { c.busy = null; c.error = e; renderChecks(); });
47
- }).catch(function (e) { c.busy = null; c.error = errorText(e); renderChecks(); });
48
- }
49
- function setAuto(min) {
50
- var c = state.chk;
51
- c.auto = min;
52
- if (c.timer) clearInterval(c.timer);
53
- c.timer = min ? setInterval(function () { if (!$('checks').classList.contains('hidden')) runAllChecks(); }, min * 60000) : null;
54
- }
55
- function renderChecks() {
56
- var c = state.chk;
57
- var outer = $('checks');
58
- outer.textContent = '';
59
- var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
60
- outer.appendChild(w);
61
- if (!c.meta) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadCheckMeta().then(renderChecks, function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }
62
- var autoSel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Refresh the instant check automatically' }, [[0, 'Refresh: off'], [5, 'Every 5 min'], [15, 'Every 15 min'], [30, 'Every 30 min'], [60, 'Every hour']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
63
- autoSel.value = String(c.auto || 0);
64
- autoSel.addEventListener('change', function () { setAuto(Number(autoSel.value)); });
65
- w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:#b91c1c;background:#fdeaea' }, icon('pulse')),
66
- el('div', { style: 'flex:1' }, el('h2', { text: 'Instant check' }), el('p', { className: 'desc', text: 'Every daily check in one click: provisioning, aggregations, sources, identities, requests, leavers, campaigns. Read-only.' })),
67
- autoSel,
68
- el('button', { className: 'btn', onclick: function () { c.showLimits = !c.showLimits; renderChecks(); } }, icon('sliders'), 'Limits'),
69
- el('button', { className: 'btn primary', disabled: !!c.busy, onclick: runAllChecks }, icon('play'), c.results ? 'Check again' : 'Run all checks')));
70
- if (c.showLimits) w.appendChild(limitsCard());
71
- if (c.error) w.appendChild(el('div', { className: 'error', text: c.error }));
72
- var trends = c.meta.trends || {};
73
- var results = c.results;
74
- var bad = 0, warn = 0, err = 0;
75
- (results || []).forEach(function (r) { if (r.status === 'bad') bad++; else if (r.status === 'warn') warn++; else if (r.status === 'error') err++; });
76
- if (c.busy) w.appendChild(el('div', { className: 'banner run' }, el('span', { className: 'spinner' }), el('span', { id: 'chk-progress', text: c.busy, style: 'flex:1' }), stopButton()));
77
- else if (results) {
78
- var level = bad ? 'bad' : warn || err ? 'warn' : 'ok';
79
- w.appendChild(el('div', { className: 'banner ' + level },
80
- el('b', { text: level === 'ok' ? 'All checks OK' : c.headline.charAt(0).toUpperCase() + c.headline.slice(1) }),
81
- el('span', { text: 'Checked ' + ago(c.at) + (c.auto ? ' · refreshes every ' + c.auto + ' min' : '') }),
82
- el('span', { style: 'flex:1' }),
83
- c.job ? el('a', { className: 'btn sm', href: '/api/jobs/' + c.job + '/download?format=xlsx&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Summary in Excel') : null));
84
- } else {
85
- var lastAt = null;
86
- Object.keys(trends).forEach(function (k) { var p = trends[k].points; if (p && p.length && (!lastAt || p[p.length - 1].at > lastAt)) lastAt = p[p.length - 1].at; });
87
- w.appendChild(el('div', { className: 'banner idle' }, el('b', { text: lastAt ? 'Last checked ' + ago(lastAt) : 'Not checked yet' }), el('span', { text: 'Press "Run all checks". A full check takes from a few seconds to a few minutes on large tenants.' })));
88
- }
89
- var grid = el('div', { className: 'tiles-chk' });
90
- var byId = {};
91
- (results || []).forEach(function (r) { byId[r.id] = r; });
92
- c.meta.checks.forEach(function (m) {
93
- var r = byId[m.id];
94
- var tr = trends[m.id] || {};
95
- var off = m.optIn ? !(m.settings && m.settings.enabled === true) : (m.settings && m.settings.enabled === false);
96
- var st = off ? 'off' : r ? r.status : (tr.status || null);
97
- var stale = !r && st;
98
- var tile = el('button', { className: 'chk ' + (st ? STATUS[st][1] : 'none') + (c.selected === m.id ? ' sel' : '') + (stale ? ' stale' : ''), onclick: function () { c.selected = c.selected === m.id ? null : m.id; renderChecks(); } });
99
- tile.appendChild(el('div', { className: 'chk-top' }, el('span', { className: 'chk-dot' }), el('span', { className: 'chk-label', text: m.label }), st ? el('span', { className: 'chk-st', text: STATUS[st][0] + (stale && !off ? ' (last time)' : '') }) : null));
100
- var value = r ? r.value : (tr.points && tr.points.length ? tr.points[tr.points.length - 1].value : null);
101
- tile.appendChild(el('div', { className: 'chk-mid' }, el('b', { text: value === null || value === undefined ? '—' : fmtNum(value) }), el('span', { className: 'muted', text: value === 1 ? (m.unit === 'people' ? 'person' : m.unit.replace(/ies$/, 'y').replace(/s$/, '')) : m.unit }),
102
- el('span', { style: 'flex:1' }), sparkline(tr.points, 92, 30)));
103
- tile.appendChild(el('div', { className: 'chk-sum', text: off ? (m.optIn && !(m.settings && m.settings.enabled === false) ? 'Needs setting up: save the end-date attribute on Warnings > End dates.' : 'Switched off in Limits.') : r ? r.summary : (tr.summary || m.description) }));
104
- if (r && r.newCount && !m.growth) tile.appendChild(el('span', { className: 'pill blue', text: r.newCount + ' new' }));
105
- if (r && r.top && r.top.length) tile.appendChild(el('div', { className: 'chk-top3' }, r.top.map(function (x) { return el('div', {}, el('span', { text: x.label }), el('b', { text: fmtNum(x.count) })); })));
106
- grid.appendChild(tile);
107
- });
108
- w.appendChild(grid);
109
- if (c.selected) w.appendChild(checkDetail(c.meta.checks.filter(function (m) { return m.id === c.selected; })[0], byId[c.selected], trends[c.selected]));
110
- }
111
- function checkDetail(m, r, tr) {
112
- var card = el('section', { className: 'card', style: 'margin-top:16px' });
113
- card.appendChild(el('div', { className: 'card-h' }, el('h3', { text: m.label }),
114
- m.report ? el('button', { className: 'btn sm', onclick: function () {
115
- var rep = state.reports.filter(function (x) { return x.definition.id === m.report; })[0];
116
- if (!rep) return;
117
- showPage('reports'); select(rep);
118
- if (r && r.params) Object.keys(r.params).forEach(function (k) { state.paramValues[k] = r.params[k]; });
119
- renderMain();
120
- } }, icon('file'), 'Open the full report') : null));
121
- card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: m.description + ' Amber from ' + fmtNum((m.settings.warn || m.defaults.warn)) + ', red from ' + fmtNum((m.settings.bad || m.defaults.bad)) + (m.growth ? ' more than the previous check.' : '.') }));
122
- var pts = (tr && tr.points) || [];
123
- if (pts.length >= 2) {
124
- card.appendChild(el('div', { className: 'trend' }, el('div', { className: 'muted small', text: 'Trend (' + pts.length + ' checks since ' + when(pts[0].at).slice(0, 10) + ')' }), sparkline(pts, 640, 90)));
125
- }
126
- var fx = fixCard(m.id);
127
- if (fx && (!r || r.status !== 'ok')) card.appendChild(fx);
128
- if (!r) { card.appendChild(el('div', { className: 'muted', text: 'Run the checks to see the details.' })); return card; }
129
- if (r.newItems && r.newItems.length) card.appendChild(el('div', { className: 'note', text: 'New since the previous check: ' + r.newItems.join('; ') + (r.newCount > r.newItems.length ? ' and ' + (r.newCount - r.newItems.length) + ' more' : '') }));
130
- if (r.status === 'error') { card.appendChild(el('div', { className: 'error', text: r.error })); return card; }
131
- if (!r.rows.length) { card.appendChild(el('div', { className: 'empty', text: 'Nothing found. Good.' })); return card; }
132
- card.appendChild(el('div', { className: 'table-wrap', style: 'max-height:50vh' }, el('table', {},
133
- el('thead', {}, el('tr', {}, r.columns.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }), m.growth ? null : el('th', { style: 'cursor:default' }, el('span', { className: 'sr-only', text: 'Exception' })))),
134
- el('tbody', {}, r.rows.map(function (row, i) {
135
- var key = r.rowKeys && r.rowKeys[i];
136
- return el('tr', {}, row.map(function (v) { return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) }); }),
137
- m.growth ? null : el('td', { style: 'width:1%;white-space:nowrap' }, key ? el('button', { className: 'btn sm', title: 'Accept this item as an exception, with a reason and an end date', 'aria-label': 'Accept ' + key + ' as an exception', onclick: function () { acceptDialog(m, key, runAllChecks); } }, 'Accept…') : null));
138
- })))));
139
- if (r.value > r.rows.length) card.appendChild(el('div', { className: 'note', text: 'Showing ' + r.rows.length + ' of ' + fmtNum(r.value) + '. Open the full report for everything.' }));
140
- if (r.accepted) card.appendChild(el('p', { className: 'muted small' }, fmtNum(r.accepted) + ' accepted as exception' + (r.accepted === 1 ? '' : 's') + ' and left out. ', el('button', { className: 'btn link', style: 'padding:0', text: 'See exceptions', onclick: function () { state.au.tab = 'exceptions'; showPage('certs'); } })));
141
- return card;
142
- }
143
- function limitsCard() {
144
- var c = state.chk;
145
- var edits = {};
146
- var rows = c.meta.checks.map(function (m) {
147
- var s = m.settings || {};
148
- var e = edits[m.id] = { enabled: m.optIn ? s.enabled === true : s.enabled !== false, optIn: !!m.optIn, warn: s.warn, bad: s.bad, days: s.days };
149
- var on = el('input', { type: 'checkbox', checked: e.enabled });
150
- on.addEventListener('change', function () { e.enabled = on.checked; });
151
- var num = function (key, ph) {
152
- var i = el('input', { className: 'input', type: 'number', min: '1', value: e[key] === undefined ? '' : String(e[key]), placeholder: String(ph), style: 'width:110px;padding:5px 8px' });
153
- i.addEventListener('input', function () { e[key] = i.value === '' ? undefined : Number(i.value); });
154
- return i;
155
- };
156
- return el('tr', {}, el('td', {}, el('label', { className: 'check' }, on, m.label)),
157
- el('td', {}, num('warn', m.defaults.warn)), el('td', {}, num('bad', m.defaults.bad)),
158
- el('td', {}, m.defaults.days !== undefined ? num('days', m.defaults.days) : el('span', { className: 'muted', text: '—' })),
159
- el('td', { className: 'muted small', text: m.growth ? 'limits apply to the increase' : '' }));
160
- });
161
- var msg = el('span');
162
- return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Limits' }), el('span', { className: 'muted small', text: 'empty = default (shown in grey). Also used by scheduled instant checks.' })),
163
- el('div', { className: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ['Check', 'Amber from', 'Red from', 'Days', ''].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))), el('tbody', {}, rows))),
164
- el('div', { className: 'bar', style: 'margin-top:12px' }, el('button', { className: 'btn primary', onclick: function () {
165
- var out = {};
166
- Object.keys(edits).forEach(function (k) { var e = edits[k]; var o = {}; if (!e.enabled) o.enabled = false; else if (e.optIn) o.enabled = true; ['warn', 'bad', 'days'].forEach(function (x) { if (e[x] !== undefined && !isNaN(e[x])) o[x] = e[x]; }); out[k] = o; });
167
- msg.textContent = '';
168
- api('/api/checks/settings', 'PUT', { checks: out }).then(function () { toast('Limits saved'); c.showLimits = false; return loadCheckMeta(); }).then(renderChecks).catch(function (e) { msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });
169
- } }, icon('save'), 'Save limits'), msg));
170
- }
171
-
1
+ // ---------- instant check ----------
2
+ state.chk = { results: null, meta: null, selected: null, auto: 0, timer: null, busy: null };
3
+ var STATUS = { ok: ['OK', 'ok'], warn: ['Attention', 'warn'], bad: ['Problem', 'bad'], error: ['Could not check', 'err'], off: ['Off', 'off'] };
4
+ function ago(iso) {
5
+ if (!iso) return '';
6
+ var s = Math.round((Date.now() - Date.parse(iso)) / 1000);
7
+ if (s < 60) return 'just now';
8
+ if (s < 3600) return Math.round(s / 60) + ' min ago';
9
+ if (s < 86400) return Math.round(s / 3600) + ' h ago';
10
+ return Math.round(s / 86400) + ' days ago';
11
+ }
12
+ function when(iso) { return iso ? iso.replace('T', ' ').slice(0, 16) : '—'; }
13
+ function sparkline(points, w, h) {
14
+ var NS = 'http://www.w3.org/2000/svg';
15
+ var svg = document.createElementNS(NS, 'svg');
16
+ svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);
17
+ svg.setAttribute('width', w); svg.setAttribute('height', h);
18
+ svg.setAttribute('class', 'spark');
19
+ var vals = (points || []).filter(function (p) { return p.value !== null && p.value !== undefined; }).slice(-30);
20
+ if (vals.length < 2) return svg;
21
+ var max = Math.max.apply(null, vals.map(function (p) { return p.value; })), min = Math.min.apply(null, vals.map(function (p) { return p.value; }));
22
+ var span = max - min || 1;
23
+ var pts = vals.map(function (p, i) { return (i * (w - 4) / (vals.length - 1) + 2).toFixed(1) + ',' + (h - 3 - ((p.value - min) / span) * (h - 6)).toFixed(1); });
24
+ var line = document.createElementNS(NS, 'polyline');
25
+ line.setAttribute('points', pts.join(' '));
26
+ line.setAttribute('fill', 'none'); line.setAttribute('stroke', 'currentColor'); line.setAttribute('stroke-width', '1.8'); line.setAttribute('stroke-linejoin', 'round');
27
+ svg.appendChild(line);
28
+ var last = pts[pts.length - 1].split(',');
29
+ var dot = document.createElementNS(NS, 'circle');
30
+ dot.setAttribute('cx', last[0]); dot.setAttribute('cy', last[1]); dot.setAttribute('r', '2.6'); dot.setAttribute('fill', 'currentColor');
31
+ svg.appendChild(dot);
32
+ var t = document.createElementNS(NS, 'title');
33
+ t.textContent = vals.length + ' checks, from ' + fmtNum(min) + ' to ' + fmtNum(max);
34
+ svg.appendChild(t);
35
+ return svg;
36
+ }
37
+ function loadCheckMeta() { return api('/api/checks').then(function (m) { state.chk.meta = m; return m; }); }
38
+ function runAllChecks() {
39
+ var c = state.chk;
40
+ if (c.busy) return;
41
+ c.busy = 'Starting the checks...'; c.error = null; renderChecks();
42
+ api('/api/checks/run', 'POST', {}).then(function (r) {
43
+ c.job = r.job;
44
+ pollJob(r.job, function (m) { c.busy = m; var p = $('chk-progress'); if (p) p.textContent = m; },
45
+ function (s) { c.busy = null; c.results = s.extra.results; c.headline = s.extra.headline; c.at = new Date().toISOString(); loadCheckMeta().then(renderChecks, renderChecks); },
46
+ function (e) { c.busy = null; c.error = e; renderChecks(); });
47
+ }).catch(function (e) { c.busy = null; c.error = errorText(e); renderChecks(); });
48
+ }
49
+ function setAuto(min) {
50
+ var c = state.chk;
51
+ c.auto = min;
52
+ if (c.timer) clearInterval(c.timer);
53
+ c.timer = min ? setInterval(function () { if (!$('checks').classList.contains('hidden')) runAllChecks(); }, min * 60000) : null;
54
+ }
55
+ function renderChecks() {
56
+ var c = state.chk;
57
+ var outer = $('checks');
58
+ outer.textContent = '';
59
+ var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
60
+ outer.appendChild(w);
61
+ if (!c.meta) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadCheckMeta().then(renderChecks, function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }
62
+ var autoSel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Refresh the instant check automatically' }, [[0, 'Refresh: off'], [5, 'Every 5 min'], [15, 'Every 15 min'], [30, 'Every 30 min'], [60, 'Every hour']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
63
+ autoSel.value = String(c.auto || 0);
64
+ autoSel.addEventListener('change', function () { setAuto(Number(autoSel.value)); });
65
+ w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:#b91c1c;background:#fdeaea' }, icon('pulse')),
66
+ el('div', { style: 'flex:1' }, el('h2', { text: 'Instant check' }), el('p', { className: 'desc', text: 'Every daily check in one click: provisioning, aggregations, sources, identities, requests, leavers, campaigns. Read-only.' })),
67
+ autoSel,
68
+ el('button', { className: 'btn', onclick: function () { c.showLimits = !c.showLimits; renderChecks(); } }, icon('sliders'), 'Limits'),
69
+ el('button', { className: 'btn primary', disabled: !!c.busy, onclick: runAllChecks }, icon('play'), c.results ? 'Check again' : 'Run all checks')));
70
+ if (c.showLimits) w.appendChild(limitsCard());
71
+ if (c.error) w.appendChild(el('div', { className: 'error', text: c.error }));
72
+ var trends = c.meta.trends || {};
73
+ var results = c.results;
74
+ var bad = 0, warn = 0, err = 0;
75
+ (results || []).forEach(function (r) { if (r.status === 'bad') bad++; else if (r.status === 'warn') warn++; else if (r.status === 'error') err++; });
76
+ if (c.busy) w.appendChild(el('div', { className: 'banner run' }, el('span', { className: 'spinner' }), el('span', { id: 'chk-progress', text: c.busy, style: 'flex:1' }), stopButton()));
77
+ else if (results) {
78
+ var level = bad ? 'bad' : warn || err ? 'warn' : 'ok';
79
+ w.appendChild(el('div', { className: 'banner ' + level },
80
+ el('b', { text: level === 'ok' ? 'All checks OK' : c.headline.charAt(0).toUpperCase() + c.headline.slice(1) }),
81
+ el('span', { text: 'Checked ' + ago(c.at) + (c.auto ? ' · refreshes every ' + c.auto + ' min' : '') }),
82
+ el('span', { style: 'flex:1' }),
83
+ c.job ? el('a', { className: 'btn sm', href: '/api/jobs/' + c.job + '/download?format=xlsx&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Summary in Excel') : null));
84
+ } else {
85
+ var lastAt = null;
86
+ Object.keys(trends).forEach(function (k) { var p = trends[k].points; if (p && p.length && (!lastAt || p[p.length - 1].at > lastAt)) lastAt = p[p.length - 1].at; });
87
+ w.appendChild(el('div', { className: 'banner idle' }, el('b', { text: lastAt ? 'Last checked ' + ago(lastAt) : 'Not checked yet' }), el('span', { text: 'Press "Run all checks". A full check takes from a few seconds to a few minutes on large tenants.' })));
88
+ }
89
+ var grid = el('div', { className: 'tiles-chk' });
90
+ var byId = {};
91
+ (results || []).forEach(function (r) { byId[r.id] = r; });
92
+ c.meta.checks.forEach(function (m) {
93
+ var r = byId[m.id];
94
+ var tr = trends[m.id] || {};
95
+ var off = m.optIn ? !(m.settings && m.settings.enabled === true) : (m.settings && m.settings.enabled === false);
96
+ var st = off ? 'off' : r ? r.status : (tr.status || null);
97
+ var stale = !r && st;
98
+ var tile = el('button', { className: 'chk ' + (st ? STATUS[st][1] : 'none') + (c.selected === m.id ? ' sel' : '') + (stale ? ' stale' : ''), onclick: function () { c.selected = c.selected === m.id ? null : m.id; renderChecks(); } });
99
+ tile.appendChild(el('div', { className: 'chk-top' }, el('span', { className: 'chk-dot' }), el('span', { className: 'chk-label', text: m.label }), st ? el('span', { className: 'chk-st', text: STATUS[st][0] + (stale && !off ? ' (last time)' : '') }) : null));
100
+ var value = r ? r.value : (tr.points && tr.points.length ? tr.points[tr.points.length - 1].value : null);
101
+ tile.appendChild(el('div', { className: 'chk-mid' }, el('b', { text: value === null || value === undefined ? '—' : fmtNum(value) }), el('span', { className: 'muted', text: value === 1 ? (m.unit === 'people' ? 'person' : m.unit.replace(/ies$/, 'y').replace(/s$/, '')) : m.unit }),
102
+ el('span', { style: 'flex:1' }), sparkline(tr.points, 92, 30)));
103
+ tile.appendChild(el('div', { className: 'chk-sum', text: off ? (m.optIn && !(m.settings && m.settings.enabled === false) ? 'Needs setting up: save the end-date attribute on Warnings > End dates.' : 'Switched off in Limits.') : r ? r.summary : (tr.summary || m.description) }));
104
+ if (r && r.newCount && !m.growth) tile.appendChild(el('span', { className: 'pill blue', text: r.newCount + ' new' }));
105
+ if (r && r.top && r.top.length) tile.appendChild(el('div', { className: 'chk-top3' }, r.top.map(function (x) { return el('div', {}, el('span', { text: x.label }), el('b', { text: fmtNum(x.count) })); })));
106
+ grid.appendChild(tile);
107
+ });
108
+ w.appendChild(grid);
109
+ if (c.selected) w.appendChild(checkDetail(c.meta.checks.filter(function (m) { return m.id === c.selected; })[0], byId[c.selected], trends[c.selected]));
110
+ }
111
+ function checkDetail(m, r, tr) {
112
+ var card = el('section', { className: 'card', style: 'margin-top:16px' });
113
+ card.appendChild(el('div', { className: 'card-h' }, el('h3', { text: m.label }),
114
+ m.report ? el('button', { className: 'btn sm', onclick: function () {
115
+ var rep = state.reports.filter(function (x) { return x.definition.id === m.report; })[0];
116
+ if (!rep) return;
117
+ showPage('reports'); select(rep);
118
+ if (r && r.params) Object.keys(r.params).forEach(function (k) { state.paramValues[k] = r.params[k]; });
119
+ renderMain();
120
+ } }, icon('file'), 'Open the full report') : null));
121
+ card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: m.description + ' Amber from ' + fmtNum((m.settings.warn || m.defaults.warn)) + ', red from ' + fmtNum((m.settings.bad || m.defaults.bad)) + (m.growth ? ' more than the previous check.' : '.') }));
122
+ var pts = (tr && tr.points) || [];
123
+ if (pts.length >= 2) {
124
+ card.appendChild(el('div', { className: 'trend' }, el('div', { className: 'muted small', text: 'Trend (' + pts.length + ' checks since ' + when(pts[0].at).slice(0, 10) + ')' }), sparkline(pts, 640, 90)));
125
+ }
126
+ var fx = fixCard(m.id);
127
+ if (fx && (!r || r.status !== 'ok')) card.appendChild(fx);
128
+ if (!r) { card.appendChild(el('div', { className: 'muted', text: 'Run the checks to see the details.' })); return card; }
129
+ if (r.newItems && r.newItems.length) card.appendChild(el('div', { className: 'note', text: 'New since the previous check: ' + r.newItems.join('; ') + (r.newCount > r.newItems.length ? ' and ' + (r.newCount - r.newItems.length) + ' more' : '') }));
130
+ if (r.status === 'error') { card.appendChild(el('div', { className: 'error', text: r.error })); return card; }
131
+ if (!r.rows.length) { card.appendChild(el('div', { className: 'empty', text: 'Nothing found. Good.' })); return card; }
132
+ card.appendChild(el('div', { className: 'table-wrap', style: 'max-height:50vh' }, el('table', {},
133
+ el('thead', {}, el('tr', {}, r.columns.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }), m.growth ? null : el('th', { style: 'cursor:default' }, el('span', { className: 'sr-only', text: 'Exception' })))),
134
+ el('tbody', {}, r.rows.map(function (row, i) {
135
+ var key = r.rowKeys && r.rowKeys[i];
136
+ return el('tr', {}, row.map(function (v) { return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) }); }),
137
+ m.growth ? null : el('td', { style: 'width:1%;white-space:nowrap' }, key ? el('button', { className: 'btn sm', title: 'Accept this item as an exception, with a reason and an end date', 'aria-label': 'Accept ' + key + ' as an exception', onclick: function () { acceptDialog(m, key, runAllChecks); } }, 'Accept…') : null));
138
+ })))));
139
+ if (r.value > r.rows.length) card.appendChild(el('div', { className: 'note', text: 'Showing ' + r.rows.length + ' of ' + fmtNum(r.value) + '. Open the full report for everything.' }));
140
+ if (r.accepted) card.appendChild(el('p', { className: 'muted small' }, fmtNum(r.accepted) + ' accepted as exception' + (r.accepted === 1 ? '' : 's') + ' and left out. ', el('button', { className: 'btn link', style: 'padding:0', text: 'See exceptions', onclick: function () { state.au.tab = 'exceptions'; showPage('certs'); } })));
141
+ return card;
142
+ }
143
+ function limitsCard() {
144
+ var c = state.chk;
145
+ var edits = {};
146
+ var rows = c.meta.checks.map(function (m) {
147
+ var s = m.settings || {};
148
+ var e = edits[m.id] = { enabled: m.optIn ? s.enabled === true : s.enabled !== false, optIn: !!m.optIn, warn: s.warn, bad: s.bad, days: s.days };
149
+ var on = el('input', { type: 'checkbox', checked: e.enabled });
150
+ on.addEventListener('change', function () { e.enabled = on.checked; });
151
+ var num = function (key, ph) {
152
+ var i = el('input', { className: 'input', type: 'number', min: '1', value: e[key] === undefined ? '' : String(e[key]), placeholder: String(ph), style: 'width:110px;padding:5px 8px' });
153
+ i.addEventListener('input', function () { e[key] = i.value === '' ? undefined : Number(i.value); });
154
+ return i;
155
+ };
156
+ return el('tr', {}, el('td', {}, el('label', { className: 'check' }, on, m.label)),
157
+ el('td', {}, num('warn', m.defaults.warn)), el('td', {}, num('bad', m.defaults.bad)),
158
+ el('td', {}, m.defaults.days !== undefined ? num('days', m.defaults.days) : el('span', { className: 'muted', text: '—' })),
159
+ el('td', { className: 'muted small', text: m.growth ? 'limits apply to the increase' : '' }));
160
+ });
161
+ var msg = el('span');
162
+ return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Limits' }), el('span', { className: 'muted small', text: 'empty = default (shown in grey). Also used by scheduled instant checks.' })),
163
+ el('div', { className: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ['Check', 'Amber from', 'Red from', 'Days', ''].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))), el('tbody', {}, rows))),
164
+ el('div', { className: 'bar', style: 'margin-top:12px' }, el('button', { className: 'btn primary', onclick: function () {
165
+ var out = {};
166
+ Object.keys(edits).forEach(function (k) { var e = edits[k]; var o = {}; if (!e.enabled) o.enabled = false; else if (e.optIn) o.enabled = true; ['warn', 'bad', 'days'].forEach(function (x) { if (e[x] !== undefined && !isNaN(e[x])) o[x] = e[x]; }); out[k] = o; });
167
+ msg.textContent = '';
168
+ api('/api/checks/settings', 'PUT', { checks: out }).then(function () { toast('Limits saved'); c.showLimits = false; return loadCheckMeta(); }).then(renderChecks).catch(function (e) { msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });
169
+ } }, icon('save'), 'Save limits'), msg));
170
+ }
171
+