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.
- package/LICENSE +21 -21
- package/README.md +914 -917
- package/SECURITY.md +56 -56
- package/dist/node/cli.js +26 -26
- package/dist/node/monthly.js +17 -17
- package/package.json +2 -2
- package/reports/access-profile-members.yaml +29 -29
- package/reports/access-profile-membership-counts.yaml +17 -17
- package/reports/access-profiles-without-owner.yaml +16 -16
- package/reports/access-request-audit-trail.yaml +36 -36
- package/reports/accounts-by-source.yaml +19 -19
- package/reports/active-identities-without-manager.yaml +22 -22
- package/reports/aggregation-failures.yaml +29 -29
- package/reports/aggregation-history.yaml +27 -27
- package/reports/all-sources.yaml +16 -16
- package/reports/application-accounts.yaml +32 -32
- package/reports/application-entitlements.yaml +31 -31
- package/reports/campaign-progress.yaml +23 -23
- package/reports/certification-decisions.yaml +31 -31
- package/reports/direct-reports-per-manager.yaml +20 -20
- package/reports/disabled-accounts-of-active-people.yaml +33 -33
- package/reports/duplicate-emails.yaml +16 -16
- package/reports/entitlement-holders.yaml +35 -35
- package/reports/entitlements-held-by-inactive-identities.yaml +31 -31
- package/reports/entitlements-without-owner.yaml +28 -28
- package/reports/identities-by-lifecycle-state.yaml +15 -15
- package/reports/identities-missing-key-attributes.yaml +27 -27
- package/reports/identities-with-processing-errors.yaml +19 -19
- package/reports/identity-attribute-mappings.yaml +27 -27
- package/reports/machine-accounts.yaml +28 -28
- package/reports/managers-and-direct-reports.yaml +23 -23
- package/reports/most-access.yaml +18 -18
- package/reports/new-identities.yaml +24 -24
- package/reports/old-passwords.yaml +35 -35
- package/reports/pending-reviews-by-reviewer.yaml +20 -20
- package/reports/person-access.yaml +31 -31
- package/reports/privileged-access.yaml +29 -29
- package/reports/provisioning-error-causes.yaml +27 -27
- package/reports/provisioning-errors.yaml +32 -32
- package/reports/provisioning-failures.yaml +28 -28
- package/reports/recent-access-requests.yaml +22 -22
- package/reports/recent-activity.yaml +32 -32
- package/reports/recent-leavers.yaml +34 -34
- package/reports/role-members.yaml +29 -29
- package/reports/role-membership-counts.yaml +18 -18
- package/reports/roles-without-owner.yaml +17 -17
- package/reports/sources-needing-attention.yaml +23 -23
- package/reports/stuck-access-requests.yaml +29 -29
- package/reports/team-access.yaml +30 -30
- package/reports/terminated-users-with-active-accounts.yaml +46 -46
- package/reports/uncorrelated-accounts.yaml +38 -38
- package/ui/js/00-setup.js +6 -6
- package/ui/js/01-small-helpers.js +143 -143
- package/ui/js/02-connection.js +150 -150
- package/ui/js/03-health-check.js +17 -17
- package/ui/js/04-library.js +135 -135
- package/ui/js/05-pickers.js +163 -163
- package/ui/js/06-report-view.js +157 -157
- package/ui/js/07-fields.js +85 -85
- package/ui/js/08-designer.js +360 -360
- package/ui/js/09-yaml.js +22 -22
- package/ui/js/10-instant-check.js +171 -171
- package/ui/js/11-lookup.js +161 -161
- package/ui/js/12-tenant.js +115 -115
- package/ui/js/13-source-configuration-and-diagnostics.js +64 -64
- package/ui/js/14-certifications.js +68 -68
- package/ui/js/15-monthly-report.js +24 -24
- package/ui/js/16-ownership.js +39 -39
- package/ui/js/17-compare-tenants.js +102 -102
- package/ui/js/18-audit.js +181 -181
- package/ui/js/19-insights.js +108 -108
- package/ui/js/20-role-mining.js +35 -35
- package/ui/js/21-share-reports.js +45 -45
- package/ui/js/22-partner-overview-all-customer-tenants.js +228 -228
- package/ui/js/23-in-app-guidance.js +217 -217
- package/ui/js/24-role-tools.js +220 -220
- package/ui/js/25-schedules.js +264 -264
- package/ui/js/26-start.js +7 -7
- package/ui/js/27-warnings.js +224 -224
- package/ui/js/28-audit-readiness.js +99 -99
- package/ui/js/29-lifecycle.js +182 -182
- package/ui/js/30-labs.js +265 -265
- package/ui/js/31-build.js +203 -203
- package/ui/js/32-lab-examples.js +148 -148
- package/ui/js/33-finder.js +89 -89
- package/ui/js/34-governance.js +129 -129
- package/ui/js/35-watch.js +266 -266
- package/ui/js/36-model.js +247 -247
- package/ui/js/37-logs-and-watch.js +224 -224
- package/ui/shell.html +112 -112
- package/ui/style.css +350 -350
package/ui/js/24-role-tools.js
CHANGED
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
// ---------- role tools ----------
|
|
2
|
-
function pollJob(id, onProgress, onDone, onError, misses) {
|
|
3
|
-
state.activeJob = id;
|
|
4
|
-
api('/api/jobs/' + id).then(function (s) {
|
|
5
|
-
if (s.state === 'running') { onProgress(s.progress + ' · ' + s.seconds + 's'); setTimeout(function () { pollJob(id, onProgress, onDone, onError); }, 800); }
|
|
6
|
-
else if (s.state === 'error') onError(s.error);
|
|
7
|
-
else onDone(s);
|
|
8
|
-
}).catch(function (e) {
|
|
9
|
-
// The local program may be busy for a moment: try again for about a minute before giving up.
|
|
10
|
-
var n = (misses || 0) + 1;
|
|
11
|
-
if (e && e.name === 'TypeError' && n <= 20) { onProgress('Waiting for IdentityScope to answer...'); setTimeout(function () { pollJob(id, onProgress, onDone, onError, n); }, 3000); }
|
|
12
|
-
else onError(errorText(e));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function downloads(job) {
|
|
16
|
-
var dl = function (f, label, primary) { return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label); };
|
|
17
|
-
return el('div', { className: 'bar' }, dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML'));
|
|
18
|
-
}
|
|
19
|
-
state.roleTab = state.roleTab || 'compare';
|
|
20
|
-
state.cmp = { roles: [] };
|
|
21
|
-
state.imp = { roleId: '', criteria: null, loaded: null };
|
|
22
|
-
|
|
23
|
-
function renderRoles() {
|
|
24
|
-
// The role change preview also lives on the Build & test page: redraw that page when it is open.
|
|
25
|
-
if (state.page === 'build') { renderBuild(); return; }
|
|
26
|
-
var outer = $('roles');
|
|
27
|
-
outer.textContent = '';
|
|
28
|
-
var w = el('div', { className: 'wrap', style: 'max-width:1180px' });
|
|
29
|
-
outer.appendChild(w);
|
|
30
|
-
w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, catIcon('Access model'),
|
|
31
|
-
el('div', {}, el('h2', { text: 'Role tools' }), el('p', { className: 'desc', text: 'Understand roles before you change them. Read-only: nothing is changed in ISC.' }))));
|
|
32
|
-
var tabs = el('div', { className: 'tabs' });
|
|
33
|
-
[['compare', 'Compare roles', 'cols'], ['impact', 'Preview a role change', 'eye'], ['mining', 'Find candidate roles', 'search']].forEach(function (t) {
|
|
34
|
-
tabs.appendChild(el('button', { className: 'tab' + (state.roleTab === t[0] ? ' active' : ''), onclick: function () { state.roleTab = t[0]; renderRoles(); } }, icon(t[2]), t[1]));
|
|
35
|
-
});
|
|
36
|
-
w.appendChild(tabs);
|
|
37
|
-
if (state.roleTab === 'compare') renderCompare(w); else if (state.roleTab === 'mining') renderMining(w); else renderImpact(w);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function renderCompare(w) {
|
|
41
|
-
var c = state.cmp;
|
|
42
|
-
var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Pick two to six roles' })));
|
|
43
|
-
card.appendChild(el('div', { className: 'runbar', style: 'margin-top:0;padding-top:0;border-top:none' },
|
|
44
|
-
el('label', { className: 'field', style: 'flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'Roles' }), picker({ options: loadPick('roles'), multiple: true, value: c.roles, placeholder: 'Pick roles', onChange: function (v) { c.roles = v; } })),
|
|
45
|
-
el('button', { className: 'btn primary', onclick: function () {
|
|
46
|
-
c.error = null; c.data = null; c.busy = 'Starting...'; renderRoles();
|
|
47
|
-
api('/api/roles/compare', 'POST', { roles: c.roles }).then(function (r) {
|
|
48
|
-
c.job = r.job;
|
|
49
|
-
pollJob(r.job, function (m) { c.busy = m; var p = $('cmp-progress'); if (p) p.textContent = m; }, function (s) { c.busy = null; c.data = s.extra; renderRoles(); }, function (e) { c.busy = null; c.error = e; renderRoles(); });
|
|
50
|
-
}).catch(function (e) { c.busy = null; c.error = errorText(e); renderRoles(); });
|
|
51
|
-
} }, icon('cols'), 'Compare')));
|
|
52
|
-
w.appendChild(card);
|
|
53
|
-
if (c.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'cmp-progress', text: c.busy, style: 'flex:1' }), stopButton()))); return; }
|
|
54
|
-
if (c.error) { w.appendChild(el('div', { className: 'error', text: c.error })); return; }
|
|
55
|
-
var d = c.data;
|
|
56
|
-
if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Which roles overlap?' }), 'Compare roles to find duplicates to merge, or to explain how two job roles differ.')); return; }
|
|
57
|
-
w.appendChild(el('div', { className: 'rolecards' }, d.roles.map(function (r) {
|
|
58
|
-
return el('div', { className: 'rolecard' }, el('h4', { text: r.name }),
|
|
59
|
-
el('div', { className: 'kv' }, el('span', {}, el('b', { text: fmtNum(r.members) }), ' members'), el('span', {}, el('b', { text: String(r.accessProfiles.length) }), ' access profiles'), el('span', {}, el('b', { text: String(r.effectiveEntitlements) }), ' entitlements')),
|
|
60
|
-
el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: 'Owner: ' + (r.owner || 'none') }), el('span', { text: r.enabled === false ? 'Disabled' : 'Enabled' }), el('span', { text: r.requestable ? 'Requestable' : 'Not requestable' })),
|
|
61
|
-
el('div', { className: 'crit', text: r.criteriaText }));
|
|
62
|
-
})));
|
|
63
|
-
var stats = el('section', { className: 'card' });
|
|
64
|
-
if (d.similarity !== undefined && d.similarity !== null) {
|
|
65
|
-
var pct = Math.round(d.similarity * 100);
|
|
66
|
-
stats.appendChild(el('div', { className: 'bar', style: 'justify-content:space-between' }, el('b', { text: 'Entitlement overlap of the first two roles: ' + pct + '%' }),
|
|
67
|
-
el('span', { className: 'muted small', text: pct >= 80 ? 'Very similar: candidates to merge.' : pct >= 40 ? 'Partly overlapping.' : 'Mostly different.' })));
|
|
68
|
-
stats.appendChild(el('div', { className: 'meter' }, el('span', { style: 'width:' + pct + '%' })));
|
|
69
|
-
}
|
|
70
|
-
stats.appendChild(el('div', { className: 'kv', style: 'margin-top:6px' },
|
|
71
|
-
el('span', {}, el('b', { text: fmtNum(d.members.inAll) }), ' people hold all of them'),
|
|
72
|
-
d.roles.map(function (r, i) { return el('span', {}, el('b', { text: fmtNum(d.members.only[i]) }), ' only ' + r.name); })));
|
|
73
|
-
w.appendChild(stats);
|
|
74
|
-
var filter = c.filter || 'all';
|
|
75
|
-
var chips = el('div', { className: 'chips' }, [['all', 'All access'], ['shared', 'In every role'], ['diff', 'Differences']].map(function (f) {
|
|
76
|
-
return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { c.filter = f[0]; renderRoles(); } });
|
|
77
|
-
}));
|
|
78
|
-
var rows = d.items.filter(function (x) { var all = x.inRole.every(Boolean); return filter === 'all' || (filter === 'shared' ? all : !all); });
|
|
79
|
-
var tcard = el('section', { className: 'card', style: 'padding:16px' }, el('div', { className: 'bar', style: 'justify-content:space-between;margin-bottom:12px' }, chips, downloads(c.job)));
|
|
80
|
-
tcard.appendChild(el('div', { className: 'table-wrap' }, el('table', {},
|
|
81
|
-
el('thead', {}, el('tr', {}, ['Type', 'Access', 'Source'].concat(d.roles.map(function (r) { return r.name; }), ['Granted through']).map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
82
|
-
el('tbody', {}, rows.map(function (x) {
|
|
83
|
-
return el('tr', {}, el('td', { text: x.type }), el('td', { text: x.name }), el('td', { className: x.source ? '' : 'empty-cell', text: x.source || '—' }),
|
|
84
|
-
x.inRole.map(function (v) { return el('td', {}, el('span', { className: v ? 'tick' : 'dash', text: v ? '✓' : '—' })); }),
|
|
85
|
-
el('td', { className: 'muted', text: x.via.join(', ') }));
|
|
86
|
-
})))));
|
|
87
|
-
if (!rows.length) tcard.appendChild(el('div', { className: 'empty', text: 'Nothing in this view.' }));
|
|
88
|
-
w.appendChild(tcard);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var CRIT_OPS = [['EQUALS', 'is'], ['NOT_EQUALS', 'is not'], ['CONTAINS', 'contains'], ['DOES_NOT_CONTAIN', 'does not contain'], ['STARTS_WITH', 'starts with'], ['ENDS_WITH', 'ends with'], ['GREATER_THAN', '>'], ['LESS_THAN', '<'], ['GREATER_THAN_EQUALS', '≥'], ['LESS_THAN_EQUALS', '≤']];
|
|
92
|
-
function newLeaf() { return { operation: 'EQUALS', key: { type: 'IDENTITY', property: 'attribute.department', sourceId: null }, stringValue: '' }; }
|
|
93
|
-
function normalizeCriteria(c) {
|
|
94
|
-
if (!c) return { operation: 'AND', children: [newLeaf()] };
|
|
95
|
-
c = clone(c);
|
|
96
|
-
if (c.operation !== 'AND' && c.operation !== 'OR') return { operation: 'AND', children: [c] };
|
|
97
|
-
return c;
|
|
98
|
-
}
|
|
99
|
-
function identityAttrs() {
|
|
100
|
-
var disc = state.disc.identities;
|
|
101
|
-
if (!disc) { ensureDisc('identities'); return []; }
|
|
102
|
-
return (disc.fields || []).filter(function (f) { return f.path.indexOf('attributes.') === 0; }).map(function (f) { return { name: f.path.slice(11), values: f.values }; });
|
|
103
|
-
}
|
|
104
|
-
function critRow(leaf, onRemove) {
|
|
105
|
-
leaf.key = leaf.key || { type: 'IDENTITY', property: '', sourceId: null };
|
|
106
|
-
var attrs = identityAttrs();
|
|
107
|
-
var type = el('select', { className: 'input', 'aria-label': 'Condition on' }, el('option', { value: 'IDENTITY', text: 'Identity attribute' }), el('option', { value: 'ACCOUNT', text: 'Account attribute' }), el('option', { value: 'ENTITLEMENT', text: 'Entitlement' }));
|
|
108
|
-
type.value = leaf.key.type;
|
|
109
|
-
type.addEventListener('change', function () {
|
|
110
|
-
leaf.key.type = type.value;
|
|
111
|
-
leaf.key.sourceId = type.value === 'IDENTITY' ? null : leaf.key.sourceId;
|
|
112
|
-
if (type.value === 'ENTITLEMENT') leaf.key.property = 'attribute.memberOf';
|
|
113
|
-
renderRoles();
|
|
114
|
-
});
|
|
115
|
-
var src = leaf.key.type === 'IDENTITY' ? el('div', { className: 'muted small', style: 'padding:9px 4px', text: 'any source' })
|
|
116
|
-
: picker({ options: loadPick('sources'), value: leaf.key.sourceId || '', placeholder: 'Pick a source', onChange: function (v) { leaf.key.sourceId = v || null; } });
|
|
117
|
-
var dl1 = 'ca' + Math.random().toString(36).slice(2), dl2 = 'cv' + Math.random().toString(36).slice(2);
|
|
118
|
-
var name = (leaf.key.property || '').replace(/^attribute\./, '');
|
|
119
|
-
var prop = el('input', { className: 'input', value: name, placeholder: leaf.key.type === 'ENTITLEMENT' ? 'memberOf' : 'attribute name', list: leaf.key.type === 'IDENTITY' ? dl1 : null });
|
|
120
|
-
prop.addEventListener('input', function () { leaf.key.property = 'attribute.' + prop.value.trim(); });
|
|
121
|
-
prop.addEventListener('change', function () { renderRoles(); });
|
|
122
|
-
var op = el('select', { className: 'input', 'aria-label': 'Comparison' }, CRIT_OPS.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));
|
|
123
|
-
op.value = leaf.operation;
|
|
124
|
-
op.addEventListener('change', function () { leaf.operation = op.value; });
|
|
125
|
-
var a = attrs.filter(function (x) { return x.name === name; })[0];
|
|
126
|
-
var val = el('input', { className: 'input', value: leaf.stringValue || '', placeholder: leaf.key.type === 'ENTITLEMENT' ? 'entitlement value, e.g. CN=VPN Users,...' : 'value', list: a && a.values.length ? dl2 : null });
|
|
127
|
-
val.addEventListener('input', function () { leaf.stringValue = val.value; });
|
|
128
|
-
return el('div', { className: 'crit-row' }, type, src, el('div', {}, prop, leaf.key.type === 'IDENTITY' ? el('datalist', { id: dl1 }, attrs.map(function (x) { return el('option', { value: x.name }); })) : null),
|
|
129
|
-
op, el('div', {}, val, a && a.values.length ? el('datalist', { id: dl2 }, a.values.map(function (v) { return el('option', { value: v }); })) : null),
|
|
130
|
-
el('button', { className: 'btn icon ghost', title: 'Remove', onclick: onRemove }, icon('x')));
|
|
131
|
-
}
|
|
132
|
-
function opSelect(node) {
|
|
133
|
-
var s = el('select', { className: 'input', style: 'width:auto;display:inline-block', 'aria-label': 'All or any' }, el('option', { value: 'AND', text: 'all' }), el('option', { value: 'OR', text: 'any' }));
|
|
134
|
-
s.value = node.operation;
|
|
135
|
-
s.addEventListener('change', function () { node.operation = s.value; });
|
|
136
|
-
return s;
|
|
137
|
-
}
|
|
138
|
-
function renderImpact(w) {
|
|
139
|
-
var im = state.imp;
|
|
140
|
-
if (!im.criteria) im.criteria = normalizeCriteria(null);
|
|
141
|
-
var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Which role?' })));
|
|
142
|
-
card.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:minmax(280px,1fr) 2fr' },
|
|
143
|
-
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Role (leave empty to try criteria for a new role)' }),
|
|
144
|
-
picker({ options: loadPick('roles'), value: im.roleId, placeholder: 'New role', onChange: function (v) {
|
|
145
|
-
im.roleId = v; im.loaded = null; im.data = null; im.error = null;
|
|
146
|
-
if (!v) { im.criteria = normalizeCriteria(null); renderRoles(); return; }
|
|
147
|
-
api('/api/roles/' + v).then(function (r) { im.loaded = r; im.criteria = normalizeCriteria(r.criteria); renderRoles(); }).catch(function (e) { im.error = errorText(e); renderRoles(); });
|
|
148
|
-
} })),
|
|
149
|
-
im.loaded ? el('div', { className: 'field' }, el('span', { className: 'lbl', text: 'Current criteria' }), el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px', text: im.loaded.criteriaText })) : el('div')));
|
|
150
|
-
if (im.loaded && im.loaded.membershipType === 'IDENTITY_LIST') card.appendChild(el('div', { className: 'note', text: 'This role is given to a fixed list of identities today. You can still try criteria to see who they would cover.' }));
|
|
151
|
-
w.appendChild(card);
|
|
152
|
-
|
|
153
|
-
var ed = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'New criteria' }), el('span', { className: 'muted small', text: 'compared without case, like ISC' })));
|
|
154
|
-
var root = im.criteria;
|
|
155
|
-
ed.appendChild(el('div', { className: 'joiner' }, 'Give the role to people who match', opSelect(root), 'of:'));
|
|
156
|
-
(root.children || []).forEach(function (ch, i) {
|
|
157
|
-
var removeMe = function () { root.children.splice(i, 1); renderRoles(); };
|
|
158
|
-
if (ch.operation === 'AND' || ch.operation === 'OR') {
|
|
159
|
-
var g = el('div', { className: 'crit-group' }, el('div', { className: 'joiner', style: 'justify-content:space-between' }, el('span', {}, 'A group matching ', opSelect(ch), ' of:'), el('button', { className: 'btn icon ghost', title: 'Remove group', onclick: removeMe }, icon('x'))));
|
|
160
|
-
(ch.children || []).forEach(function (leaf, j) { g.appendChild(critRow(leaf, function () { ch.children.splice(j, 1); if (!ch.children.length) root.children.splice(i, 1); renderRoles(); })); });
|
|
161
|
-
g.appendChild(el('button', { className: 'btn sm', onclick: function () { ch.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Condition in this group'));
|
|
162
|
-
ed.appendChild(g);
|
|
163
|
-
} else ed.appendChild(critRow(ch, removeMe));
|
|
164
|
-
});
|
|
165
|
-
ed.appendChild(el('div', { className: 'bar', style: 'margin-top:6px' },
|
|
166
|
-
el('button', { className: 'btn', onclick: function () { root.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Add condition'),
|
|
167
|
-
el('button', { className: 'btn', onclick: function () { root.children.push({ operation: root.operation === 'AND' ? 'OR' : 'AND', children: [newLeaf()] }); renderRoles(); } }, icon('plus'), 'Add group'),
|
|
168
|
-
el('span', { style: 'flex:1' }),
|
|
169
|
-
el('button', { className: 'btn ghost', onclick: function () { modal('Criteria as JSON (for the ISC role API, membership.criteria)', JSON.stringify(im.criteria, null, 2)); } }, icon('code'), 'Show JSON'),
|
|
170
|
-
el('button', { className: 'btn primary', onclick: function () {
|
|
171
|
-
im.error = null; im.data = null; im.busy = 'Starting...'; renderRoles();
|
|
172
|
-
api('/api/roles/impact', 'POST', { roleId: im.roleId || undefined, criteria: im.criteria }).then(function (r) {
|
|
173
|
-
im.job = r.job;
|
|
174
|
-
pollJob(r.job, function (m) { im.busy = m; var p = $('imp-progress'); if (p) p.textContent = m; }, function (s) { im.busy = null; im.data = s.extra; renderRoles(); }, function (e) { im.busy = null; im.error = e; renderRoles(); });
|
|
175
|
-
}).catch(function (e) { im.busy = null; im.error = errorText(e); renderRoles(); });
|
|
176
|
-
} }, icon('eye'), 'Preview who is affected')));
|
|
177
|
-
w.appendChild(ed);
|
|
178
|
-
if (im.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'imp-progress', text: im.busy, style: 'flex:1' }), stopButton()))); return; }
|
|
179
|
-
if (im.error) { w.appendChild(el('div', { className: 'error', text: im.error })); return; }
|
|
180
|
-
var d = im.data;
|
|
181
|
-
if (!d) return;
|
|
182
|
-
var res = el('section', { className: 'card' });
|
|
183
|
-
res.appendChild(el('div', { className: 'card-h' }, el('h3', { text: 'What would change' }), downloads(im.job)));
|
|
184
|
-
res.appendChild(el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px;margin-bottom:12px', text: 'New: ' + d.newCriteria }));
|
|
185
|
-
res.appendChild(el('div', { className: 'bigstats' },
|
|
186
|
-
el('div', { className: 'bigstat gain' }, el('b', { text: '+' + fmtNum(d.gain) }), el('span', { text: 'would gain the role' })),
|
|
187
|
-
el('div', { className: 'bigstat lose' }, el('b', { text: '−' + fmtNum(d.lose) }), el('span', { text: 'would lose it' })),
|
|
188
|
-
d.role ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.holdersNow) }), el('span', { text: 'hold it now' })) : null,
|
|
189
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.matchNew) }), el('span', { text: 'match the new criteria' })),
|
|
190
|
-
d.keepOther ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.keepOther) }), el('span', { text: 'keep it (given another way)' })) : null,
|
|
191
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.identitiesChecked) }), el('span', { text: 'identities checked' }))));
|
|
192
|
-
d.warnings.forEach(function (x) { res.appendChild(el('div', { className: 'note', text: x })); });
|
|
193
|
-
if (d.conditions && d.conditions.length) {
|
|
194
|
-
res.appendChild(el('div', { className: 'muted small', style: 'margin:14px 0 6px;font-weight:600', text: 'Each condition on its own (of ' + fmtNum(d.identitiesChecked) + ' identities)' }));
|
|
195
|
-
res.appendChild(el('div', { className: 'table-wrap', style: 'margin-bottom:14px' }, el('table', {},
|
|
196
|
-
el('thead', {}, el('tr', {}, ['Condition', 'People matching', 'People with any value', 'Most common values'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
197
|
-
el('tbody', {}, d.conditions.map(function (c) {
|
|
198
|
-
return el('tr', {}, el('td', { style: 'font-family:ui-monospace,Consolas,monospace;font-size:12.5px', text: c.text }),
|
|
199
|
-
el('td', { className: 'num' }, el('span', { className: c.matches ? '' : 'chg lose', text: fmtNum(c.matches) })),
|
|
200
|
-
el('td', { className: 'num', text: c.withValue === null ? '\u2014' : fmtNum(c.withValue) }),
|
|
201
|
-
el('td', { className: 'muted', text: c.topValues.map(function (v) { return v.value + ' (' + fmtNum(v.count) + ')'; }).join(', ') || '\u2014' }));
|
|
202
|
-
})))));
|
|
203
|
-
}
|
|
204
|
-
var filter = im.filter || 'all';
|
|
205
|
-
res.appendChild(el('div', { className: 'chips' }, [['all', 'Everyone affected'], ['gain', 'Gain'], ['lose', 'Lose'], ['keep-other', 'Keep (other way)']].map(function (f) {
|
|
206
|
-
return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { im.filter = f[0]; renderRoles(); } });
|
|
207
|
-
})));
|
|
208
|
-
var people = d.people.filter(function (p) { return filter === 'all' || p.change === filter; });
|
|
209
|
-
var label = { gain: 'Gains', lose: 'Loses', 'keep-other': 'Keeps' };
|
|
210
|
-
if (people.length) {
|
|
211
|
-
res.appendChild(el('div', { className: 'table-wrap' }, el('table', {},
|
|
212
|
-
el('thead', {}, el('tr', {}, ['Change', 'Person', 'Email', 'Department', 'Lifecycle state', 'Manager'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
213
|
-
el('tbody', {}, people.slice(0, 1000).map(function (p) {
|
|
214
|
-
return el('tr', {}, el('td', {}, el('span', { className: 'chg ' + p.change, text: label[p.change] })), el('td', { text: p.name }), el('td', { text: p.email || '—' }), el('td', { text: p.department || '—' }), el('td', { text: p.lifecycleState || '—' }), el('td', { text: p.manager || '—' }));
|
|
215
|
-
})))));
|
|
216
|
-
if (people.length > 1000) res.appendChild(el('div', { className: 'note', text: 'Showing 1,000 of ' + fmtNum(people.length) + '. Downloads contain everyone.' }));
|
|
217
|
-
} else res.appendChild(el('div', { className: 'empty', text: d.gain + d.lose === 0 ? 'Nobody would gain or lose the role.' : 'Nobody in this view.' }));
|
|
218
|
-
w.appendChild(res);
|
|
219
|
-
}
|
|
220
|
-
|
|
1
|
+
// ---------- role tools ----------
|
|
2
|
+
function pollJob(id, onProgress, onDone, onError, misses) {
|
|
3
|
+
state.activeJob = id;
|
|
4
|
+
api('/api/jobs/' + id).then(function (s) {
|
|
5
|
+
if (s.state === 'running') { onProgress(s.progress + ' · ' + s.seconds + 's'); setTimeout(function () { pollJob(id, onProgress, onDone, onError); }, 800); }
|
|
6
|
+
else if (s.state === 'error') onError(s.error);
|
|
7
|
+
else onDone(s);
|
|
8
|
+
}).catch(function (e) {
|
|
9
|
+
// The local program may be busy for a moment: try again for about a minute before giving up.
|
|
10
|
+
var n = (misses || 0) + 1;
|
|
11
|
+
if (e && e.name === 'TypeError' && n <= 20) { onProgress('Waiting for IdentityScope to answer...'); setTimeout(function () { pollJob(id, onProgress, onDone, onError, n); }, 3000); }
|
|
12
|
+
else onError(errorText(e));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function downloads(job) {
|
|
16
|
+
var dl = function (f, label, primary) { return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label); };
|
|
17
|
+
return el('div', { className: 'bar' }, dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML'));
|
|
18
|
+
}
|
|
19
|
+
state.roleTab = state.roleTab || 'compare';
|
|
20
|
+
state.cmp = { roles: [] };
|
|
21
|
+
state.imp = { roleId: '', criteria: null, loaded: null };
|
|
22
|
+
|
|
23
|
+
function renderRoles() {
|
|
24
|
+
// The role change preview also lives on the Build & test page: redraw that page when it is open.
|
|
25
|
+
if (state.page === 'build') { renderBuild(); return; }
|
|
26
|
+
var outer = $('roles');
|
|
27
|
+
outer.textContent = '';
|
|
28
|
+
var w = el('div', { className: 'wrap', style: 'max-width:1180px' });
|
|
29
|
+
outer.appendChild(w);
|
|
30
|
+
w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, catIcon('Access model'),
|
|
31
|
+
el('div', {}, el('h2', { text: 'Role tools' }), el('p', { className: 'desc', text: 'Understand roles before you change them. Read-only: nothing is changed in ISC.' }))));
|
|
32
|
+
var tabs = el('div', { className: 'tabs' });
|
|
33
|
+
[['compare', 'Compare roles', 'cols'], ['impact', 'Preview a role change', 'eye'], ['mining', 'Find candidate roles', 'search']].forEach(function (t) {
|
|
34
|
+
tabs.appendChild(el('button', { className: 'tab' + (state.roleTab === t[0] ? ' active' : ''), onclick: function () { state.roleTab = t[0]; renderRoles(); } }, icon(t[2]), t[1]));
|
|
35
|
+
});
|
|
36
|
+
w.appendChild(tabs);
|
|
37
|
+
if (state.roleTab === 'compare') renderCompare(w); else if (state.roleTab === 'mining') renderMining(w); else renderImpact(w);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function renderCompare(w) {
|
|
41
|
+
var c = state.cmp;
|
|
42
|
+
var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Pick two to six roles' })));
|
|
43
|
+
card.appendChild(el('div', { className: 'runbar', style: 'margin-top:0;padding-top:0;border-top:none' },
|
|
44
|
+
el('label', { className: 'field', style: 'flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'Roles' }), picker({ options: loadPick('roles'), multiple: true, value: c.roles, placeholder: 'Pick roles', onChange: function (v) { c.roles = v; } })),
|
|
45
|
+
el('button', { className: 'btn primary', onclick: function () {
|
|
46
|
+
c.error = null; c.data = null; c.busy = 'Starting...'; renderRoles();
|
|
47
|
+
api('/api/roles/compare', 'POST', { roles: c.roles }).then(function (r) {
|
|
48
|
+
c.job = r.job;
|
|
49
|
+
pollJob(r.job, function (m) { c.busy = m; var p = $('cmp-progress'); if (p) p.textContent = m; }, function (s) { c.busy = null; c.data = s.extra; renderRoles(); }, function (e) { c.busy = null; c.error = e; renderRoles(); });
|
|
50
|
+
}).catch(function (e) { c.busy = null; c.error = errorText(e); renderRoles(); });
|
|
51
|
+
} }, icon('cols'), 'Compare')));
|
|
52
|
+
w.appendChild(card);
|
|
53
|
+
if (c.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'cmp-progress', text: c.busy, style: 'flex:1' }), stopButton()))); return; }
|
|
54
|
+
if (c.error) { w.appendChild(el('div', { className: 'error', text: c.error })); return; }
|
|
55
|
+
var d = c.data;
|
|
56
|
+
if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Which roles overlap?' }), 'Compare roles to find duplicates to merge, or to explain how two job roles differ.')); return; }
|
|
57
|
+
w.appendChild(el('div', { className: 'rolecards' }, d.roles.map(function (r) {
|
|
58
|
+
return el('div', { className: 'rolecard' }, el('h4', { text: r.name }),
|
|
59
|
+
el('div', { className: 'kv' }, el('span', {}, el('b', { text: fmtNum(r.members) }), ' members'), el('span', {}, el('b', { text: String(r.accessProfiles.length) }), ' access profiles'), el('span', {}, el('b', { text: String(r.effectiveEntitlements) }), ' entitlements')),
|
|
60
|
+
el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: 'Owner: ' + (r.owner || 'none') }), el('span', { text: r.enabled === false ? 'Disabled' : 'Enabled' }), el('span', { text: r.requestable ? 'Requestable' : 'Not requestable' })),
|
|
61
|
+
el('div', { className: 'crit', text: r.criteriaText }));
|
|
62
|
+
})));
|
|
63
|
+
var stats = el('section', { className: 'card' });
|
|
64
|
+
if (d.similarity !== undefined && d.similarity !== null) {
|
|
65
|
+
var pct = Math.round(d.similarity * 100);
|
|
66
|
+
stats.appendChild(el('div', { className: 'bar', style: 'justify-content:space-between' }, el('b', { text: 'Entitlement overlap of the first two roles: ' + pct + '%' }),
|
|
67
|
+
el('span', { className: 'muted small', text: pct >= 80 ? 'Very similar: candidates to merge.' : pct >= 40 ? 'Partly overlapping.' : 'Mostly different.' })));
|
|
68
|
+
stats.appendChild(el('div', { className: 'meter' }, el('span', { style: 'width:' + pct + '%' })));
|
|
69
|
+
}
|
|
70
|
+
stats.appendChild(el('div', { className: 'kv', style: 'margin-top:6px' },
|
|
71
|
+
el('span', {}, el('b', { text: fmtNum(d.members.inAll) }), ' people hold all of them'),
|
|
72
|
+
d.roles.map(function (r, i) { return el('span', {}, el('b', { text: fmtNum(d.members.only[i]) }), ' only ' + r.name); })));
|
|
73
|
+
w.appendChild(stats);
|
|
74
|
+
var filter = c.filter || 'all';
|
|
75
|
+
var chips = el('div', { className: 'chips' }, [['all', 'All access'], ['shared', 'In every role'], ['diff', 'Differences']].map(function (f) {
|
|
76
|
+
return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { c.filter = f[0]; renderRoles(); } });
|
|
77
|
+
}));
|
|
78
|
+
var rows = d.items.filter(function (x) { var all = x.inRole.every(Boolean); return filter === 'all' || (filter === 'shared' ? all : !all); });
|
|
79
|
+
var tcard = el('section', { className: 'card', style: 'padding:16px' }, el('div', { className: 'bar', style: 'justify-content:space-between;margin-bottom:12px' }, chips, downloads(c.job)));
|
|
80
|
+
tcard.appendChild(el('div', { className: 'table-wrap' }, el('table', {},
|
|
81
|
+
el('thead', {}, el('tr', {}, ['Type', 'Access', 'Source'].concat(d.roles.map(function (r) { return r.name; }), ['Granted through']).map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
82
|
+
el('tbody', {}, rows.map(function (x) {
|
|
83
|
+
return el('tr', {}, el('td', { text: x.type }), el('td', { text: x.name }), el('td', { className: x.source ? '' : 'empty-cell', text: x.source || '—' }),
|
|
84
|
+
x.inRole.map(function (v) { return el('td', {}, el('span', { className: v ? 'tick' : 'dash', text: v ? '✓' : '—' })); }),
|
|
85
|
+
el('td', { className: 'muted', text: x.via.join(', ') }));
|
|
86
|
+
})))));
|
|
87
|
+
if (!rows.length) tcard.appendChild(el('div', { className: 'empty', text: 'Nothing in this view.' }));
|
|
88
|
+
w.appendChild(tcard);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var CRIT_OPS = [['EQUALS', 'is'], ['NOT_EQUALS', 'is not'], ['CONTAINS', 'contains'], ['DOES_NOT_CONTAIN', 'does not contain'], ['STARTS_WITH', 'starts with'], ['ENDS_WITH', 'ends with'], ['GREATER_THAN', '>'], ['LESS_THAN', '<'], ['GREATER_THAN_EQUALS', '≥'], ['LESS_THAN_EQUALS', '≤']];
|
|
92
|
+
function newLeaf() { return { operation: 'EQUALS', key: { type: 'IDENTITY', property: 'attribute.department', sourceId: null }, stringValue: '' }; }
|
|
93
|
+
function normalizeCriteria(c) {
|
|
94
|
+
if (!c) return { operation: 'AND', children: [newLeaf()] };
|
|
95
|
+
c = clone(c);
|
|
96
|
+
if (c.operation !== 'AND' && c.operation !== 'OR') return { operation: 'AND', children: [c] };
|
|
97
|
+
return c;
|
|
98
|
+
}
|
|
99
|
+
function identityAttrs() {
|
|
100
|
+
var disc = state.disc.identities;
|
|
101
|
+
if (!disc) { ensureDisc('identities'); return []; }
|
|
102
|
+
return (disc.fields || []).filter(function (f) { return f.path.indexOf('attributes.') === 0; }).map(function (f) { return { name: f.path.slice(11), values: f.values }; });
|
|
103
|
+
}
|
|
104
|
+
function critRow(leaf, onRemove) {
|
|
105
|
+
leaf.key = leaf.key || { type: 'IDENTITY', property: '', sourceId: null };
|
|
106
|
+
var attrs = identityAttrs();
|
|
107
|
+
var type = el('select', { className: 'input', 'aria-label': 'Condition on' }, el('option', { value: 'IDENTITY', text: 'Identity attribute' }), el('option', { value: 'ACCOUNT', text: 'Account attribute' }), el('option', { value: 'ENTITLEMENT', text: 'Entitlement' }));
|
|
108
|
+
type.value = leaf.key.type;
|
|
109
|
+
type.addEventListener('change', function () {
|
|
110
|
+
leaf.key.type = type.value;
|
|
111
|
+
leaf.key.sourceId = type.value === 'IDENTITY' ? null : leaf.key.sourceId;
|
|
112
|
+
if (type.value === 'ENTITLEMENT') leaf.key.property = 'attribute.memberOf';
|
|
113
|
+
renderRoles();
|
|
114
|
+
});
|
|
115
|
+
var src = leaf.key.type === 'IDENTITY' ? el('div', { className: 'muted small', style: 'padding:9px 4px', text: 'any source' })
|
|
116
|
+
: picker({ options: loadPick('sources'), value: leaf.key.sourceId || '', placeholder: 'Pick a source', onChange: function (v) { leaf.key.sourceId = v || null; } });
|
|
117
|
+
var dl1 = 'ca' + Math.random().toString(36).slice(2), dl2 = 'cv' + Math.random().toString(36).slice(2);
|
|
118
|
+
var name = (leaf.key.property || '').replace(/^attribute\./, '');
|
|
119
|
+
var prop = el('input', { className: 'input', value: name, placeholder: leaf.key.type === 'ENTITLEMENT' ? 'memberOf' : 'attribute name', list: leaf.key.type === 'IDENTITY' ? dl1 : null });
|
|
120
|
+
prop.addEventListener('input', function () { leaf.key.property = 'attribute.' + prop.value.trim(); });
|
|
121
|
+
prop.addEventListener('change', function () { renderRoles(); });
|
|
122
|
+
var op = el('select', { className: 'input', 'aria-label': 'Comparison' }, CRIT_OPS.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));
|
|
123
|
+
op.value = leaf.operation;
|
|
124
|
+
op.addEventListener('change', function () { leaf.operation = op.value; });
|
|
125
|
+
var a = attrs.filter(function (x) { return x.name === name; })[0];
|
|
126
|
+
var val = el('input', { className: 'input', value: leaf.stringValue || '', placeholder: leaf.key.type === 'ENTITLEMENT' ? 'entitlement value, e.g. CN=VPN Users,...' : 'value', list: a && a.values.length ? dl2 : null });
|
|
127
|
+
val.addEventListener('input', function () { leaf.stringValue = val.value; });
|
|
128
|
+
return el('div', { className: 'crit-row' }, type, src, el('div', {}, prop, leaf.key.type === 'IDENTITY' ? el('datalist', { id: dl1 }, attrs.map(function (x) { return el('option', { value: x.name }); })) : null),
|
|
129
|
+
op, el('div', {}, val, a && a.values.length ? el('datalist', { id: dl2 }, a.values.map(function (v) { return el('option', { value: v }); })) : null),
|
|
130
|
+
el('button', { className: 'btn icon ghost', title: 'Remove', onclick: onRemove }, icon('x')));
|
|
131
|
+
}
|
|
132
|
+
function opSelect(node) {
|
|
133
|
+
var s = el('select', { className: 'input', style: 'width:auto;display:inline-block', 'aria-label': 'All or any' }, el('option', { value: 'AND', text: 'all' }), el('option', { value: 'OR', text: 'any' }));
|
|
134
|
+
s.value = node.operation;
|
|
135
|
+
s.addEventListener('change', function () { node.operation = s.value; });
|
|
136
|
+
return s;
|
|
137
|
+
}
|
|
138
|
+
function renderImpact(w) {
|
|
139
|
+
var im = state.imp;
|
|
140
|
+
if (!im.criteria) im.criteria = normalizeCriteria(null);
|
|
141
|
+
var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Which role?' })));
|
|
142
|
+
card.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:minmax(280px,1fr) 2fr' },
|
|
143
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Role (leave empty to try criteria for a new role)' }),
|
|
144
|
+
picker({ options: loadPick('roles'), value: im.roleId, placeholder: 'New role', onChange: function (v) {
|
|
145
|
+
im.roleId = v; im.loaded = null; im.data = null; im.error = null;
|
|
146
|
+
if (!v) { im.criteria = normalizeCriteria(null); renderRoles(); return; }
|
|
147
|
+
api('/api/roles/' + v).then(function (r) { im.loaded = r; im.criteria = normalizeCriteria(r.criteria); renderRoles(); }).catch(function (e) { im.error = errorText(e); renderRoles(); });
|
|
148
|
+
} })),
|
|
149
|
+
im.loaded ? el('div', { className: 'field' }, el('span', { className: 'lbl', text: 'Current criteria' }), el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px', text: im.loaded.criteriaText })) : el('div')));
|
|
150
|
+
if (im.loaded && im.loaded.membershipType === 'IDENTITY_LIST') card.appendChild(el('div', { className: 'note', text: 'This role is given to a fixed list of identities today. You can still try criteria to see who they would cover.' }));
|
|
151
|
+
w.appendChild(card);
|
|
152
|
+
|
|
153
|
+
var ed = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'New criteria' }), el('span', { className: 'muted small', text: 'compared without case, like ISC' })));
|
|
154
|
+
var root = im.criteria;
|
|
155
|
+
ed.appendChild(el('div', { className: 'joiner' }, 'Give the role to people who match', opSelect(root), 'of:'));
|
|
156
|
+
(root.children || []).forEach(function (ch, i) {
|
|
157
|
+
var removeMe = function () { root.children.splice(i, 1); renderRoles(); };
|
|
158
|
+
if (ch.operation === 'AND' || ch.operation === 'OR') {
|
|
159
|
+
var g = el('div', { className: 'crit-group' }, el('div', { className: 'joiner', style: 'justify-content:space-between' }, el('span', {}, 'A group matching ', opSelect(ch), ' of:'), el('button', { className: 'btn icon ghost', title: 'Remove group', onclick: removeMe }, icon('x'))));
|
|
160
|
+
(ch.children || []).forEach(function (leaf, j) { g.appendChild(critRow(leaf, function () { ch.children.splice(j, 1); if (!ch.children.length) root.children.splice(i, 1); renderRoles(); })); });
|
|
161
|
+
g.appendChild(el('button', { className: 'btn sm', onclick: function () { ch.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Condition in this group'));
|
|
162
|
+
ed.appendChild(g);
|
|
163
|
+
} else ed.appendChild(critRow(ch, removeMe));
|
|
164
|
+
});
|
|
165
|
+
ed.appendChild(el('div', { className: 'bar', style: 'margin-top:6px' },
|
|
166
|
+
el('button', { className: 'btn', onclick: function () { root.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Add condition'),
|
|
167
|
+
el('button', { className: 'btn', onclick: function () { root.children.push({ operation: root.operation === 'AND' ? 'OR' : 'AND', children: [newLeaf()] }); renderRoles(); } }, icon('plus'), 'Add group'),
|
|
168
|
+
el('span', { style: 'flex:1' }),
|
|
169
|
+
el('button', { className: 'btn ghost', onclick: function () { modal('Criteria as JSON (for the ISC role API, membership.criteria)', JSON.stringify(im.criteria, null, 2)); } }, icon('code'), 'Show JSON'),
|
|
170
|
+
el('button', { className: 'btn primary', onclick: function () {
|
|
171
|
+
im.error = null; im.data = null; im.busy = 'Starting...'; renderRoles();
|
|
172
|
+
api('/api/roles/impact', 'POST', { roleId: im.roleId || undefined, criteria: im.criteria }).then(function (r) {
|
|
173
|
+
im.job = r.job;
|
|
174
|
+
pollJob(r.job, function (m) { im.busy = m; var p = $('imp-progress'); if (p) p.textContent = m; }, function (s) { im.busy = null; im.data = s.extra; renderRoles(); }, function (e) { im.busy = null; im.error = e; renderRoles(); });
|
|
175
|
+
}).catch(function (e) { im.busy = null; im.error = errorText(e); renderRoles(); });
|
|
176
|
+
} }, icon('eye'), 'Preview who is affected')));
|
|
177
|
+
w.appendChild(ed);
|
|
178
|
+
if (im.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'imp-progress', text: im.busy, style: 'flex:1' }), stopButton()))); return; }
|
|
179
|
+
if (im.error) { w.appendChild(el('div', { className: 'error', text: im.error })); return; }
|
|
180
|
+
var d = im.data;
|
|
181
|
+
if (!d) return;
|
|
182
|
+
var res = el('section', { className: 'card' });
|
|
183
|
+
res.appendChild(el('div', { className: 'card-h' }, el('h3', { text: 'What would change' }), downloads(im.job)));
|
|
184
|
+
res.appendChild(el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px;margin-bottom:12px', text: 'New: ' + d.newCriteria }));
|
|
185
|
+
res.appendChild(el('div', { className: 'bigstats' },
|
|
186
|
+
el('div', { className: 'bigstat gain' }, el('b', { text: '+' + fmtNum(d.gain) }), el('span', { text: 'would gain the role' })),
|
|
187
|
+
el('div', { className: 'bigstat lose' }, el('b', { text: '−' + fmtNum(d.lose) }), el('span', { text: 'would lose it' })),
|
|
188
|
+
d.role ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.holdersNow) }), el('span', { text: 'hold it now' })) : null,
|
|
189
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.matchNew) }), el('span', { text: 'match the new criteria' })),
|
|
190
|
+
d.keepOther ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.keepOther) }), el('span', { text: 'keep it (given another way)' })) : null,
|
|
191
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.identitiesChecked) }), el('span', { text: 'identities checked' }))));
|
|
192
|
+
d.warnings.forEach(function (x) { res.appendChild(el('div', { className: 'note', text: x })); });
|
|
193
|
+
if (d.conditions && d.conditions.length) {
|
|
194
|
+
res.appendChild(el('div', { className: 'muted small', style: 'margin:14px 0 6px;font-weight:600', text: 'Each condition on its own (of ' + fmtNum(d.identitiesChecked) + ' identities)' }));
|
|
195
|
+
res.appendChild(el('div', { className: 'table-wrap', style: 'margin-bottom:14px' }, el('table', {},
|
|
196
|
+
el('thead', {}, el('tr', {}, ['Condition', 'People matching', 'People with any value', 'Most common values'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
197
|
+
el('tbody', {}, d.conditions.map(function (c) {
|
|
198
|
+
return el('tr', {}, el('td', { style: 'font-family:ui-monospace,Consolas,monospace;font-size:12.5px', text: c.text }),
|
|
199
|
+
el('td', { className: 'num' }, el('span', { className: c.matches ? '' : 'chg lose', text: fmtNum(c.matches) })),
|
|
200
|
+
el('td', { className: 'num', text: c.withValue === null ? '\u2014' : fmtNum(c.withValue) }),
|
|
201
|
+
el('td', { className: 'muted', text: c.topValues.map(function (v) { return v.value + ' (' + fmtNum(v.count) + ')'; }).join(', ') || '\u2014' }));
|
|
202
|
+
})))));
|
|
203
|
+
}
|
|
204
|
+
var filter = im.filter || 'all';
|
|
205
|
+
res.appendChild(el('div', { className: 'chips' }, [['all', 'Everyone affected'], ['gain', 'Gain'], ['lose', 'Lose'], ['keep-other', 'Keep (other way)']].map(function (f) {
|
|
206
|
+
return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { im.filter = f[0]; renderRoles(); } });
|
|
207
|
+
})));
|
|
208
|
+
var people = d.people.filter(function (p) { return filter === 'all' || p.change === filter; });
|
|
209
|
+
var label = { gain: 'Gains', lose: 'Loses', 'keep-other': 'Keeps' };
|
|
210
|
+
if (people.length) {
|
|
211
|
+
res.appendChild(el('div', { className: 'table-wrap' }, el('table', {},
|
|
212
|
+
el('thead', {}, el('tr', {}, ['Change', 'Person', 'Email', 'Department', 'Lifecycle state', 'Manager'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),
|
|
213
|
+
el('tbody', {}, people.slice(0, 1000).map(function (p) {
|
|
214
|
+
return el('tr', {}, el('td', {}, el('span', { className: 'chg ' + p.change, text: label[p.change] })), el('td', { text: p.name }), el('td', { text: p.email || '—' }), el('td', { text: p.department || '—' }), el('td', { text: p.lifecycleState || '—' }), el('td', { text: p.manager || '—' }));
|
|
215
|
+
})))));
|
|
216
|
+
if (people.length > 1000) res.appendChild(el('div', { className: 'note', text: 'Showing 1,000 of ' + fmtNum(people.length) + '. Downloads contain everyone.' }));
|
|
217
|
+
} else res.appendChild(el('div', { className: 'empty', text: d.gain + d.lose === 0 ? 'Nobody would gain or lose the role.' : 'Nobody in this view.' }));
|
|
218
|
+
w.appendChild(res);
|
|
219
|
+
}
|
|
220
|
+
|