identityscope 0.28.3 → 0.28.4
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 +917 -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/19-insights.js
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
// ---------- Insights (Monthly report, License reclaim, Access requests) ----------
|
|
2
|
-
state.inz = { tab: 'monthly' };
|
|
3
|
-
function renderInsights() {
|
|
4
|
-
var outer = $('monthly');
|
|
5
|
-
outer.textContent = '';
|
|
6
|
-
var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
|
|
7
|
-
outer.appendChild(w);
|
|
8
|
-
w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0e7c66;background:#e3f5f0' }, icon('sigma')),
|
|
9
|
-
el('div', {}, el('h2', { text: 'Insights' }), el('p', { className: 'desc', text: 'The monthly report for management, licenses you could reclaim, and how access requests flow. Read-only.' }))));
|
|
10
|
-
var tabs = el('div', { className: 'tabs' });
|
|
11
|
-
[['monthly', 'Monthly report', 'file'], ['reclaim', 'License reclaim', 'down'], ['requests', 'Access requests', 'inbox']].forEach(function (t) {
|
|
12
|
-
tabs.appendChild(el('button', { className: 'tab' + (state.inz.tab === t[0] ? ' active' : ''), onclick: function () { state.inz.tab = t[0]; if (t[0] === 'monthly') state.mr.data = null; renderInsights(); } }, icon(t[2]), t[1]));
|
|
13
|
-
});
|
|
14
|
-
w.appendChild(tabs);
|
|
15
|
-
if (state.inz.tab === 'reclaim') renderReclaim(w);
|
|
16
|
-
else if (state.inz.tab === 'requests') renderRequests(w);
|
|
17
|
-
else monthlyTab(w);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// license reclaim
|
|
21
|
-
state.rc = {};
|
|
22
|
-
function renderReclaim(w) {
|
|
23
|
-
var R = state.rc;
|
|
24
|
-
if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderInsights); return; }
|
|
25
|
-
var cfg = state.ins.reclaim || {};
|
|
26
|
-
if (!R.form) R.form = { dormantDays: cfg.dormantDays || 90, currency: cfg.currency || '', leaverStates: (cfg.leaverStates || ['inactive', 'terminated']).slice(), sources: clone(cfg.sources || {}) };
|
|
27
|
-
var F = R.form;
|
|
28
|
-
var sources = R.sources;
|
|
29
|
-
if (!sources) loadPick('sources').then(function (list) { R.sources = list; if (state.page === 'monthly' && state.inz.tab === 'reclaim') renderInsights(); }).catch(function (e) { toast(errorText(e)); });
|
|
30
|
-
var msg = el('div');
|
|
31
|
-
var days = el('input', { className: 'input', type: 'number', min: '7', value: String(F.dormantDays), style: 'width:100px', 'aria-label': 'Dormant after (days)' });
|
|
32
|
-
days.addEventListener('input', function () { F.dormantDays = Number(days.value); });
|
|
33
|
-
var cur = el('input', { className: 'input', value: F.currency, placeholder: 'USD', style: 'width:90px', 'aria-label': 'Currency' });
|
|
34
|
-
cur.addEventListener('input', function () { F.currency = cur.value; });
|
|
35
|
-
var rows = (sources || []).map(function (s) {
|
|
36
|
-
var one = F.sources[s.label] || {};
|
|
37
|
-
var cost = el('input', { className: 'input', type: 'number', min: '0', step: '0.01', 'aria-label': 'Cost per account per month for ' + s.label, value: one.cost === undefined ? '' : String(one.cost), placeholder: 'e.g. 12.50', style: 'width:120px' });
|
|
38
|
-
cost.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].cost = cost.value === '' ? undefined : Number(cost.value); });
|
|
39
|
-
var ll = el('input', { className: 'input', 'aria-label': 'Last login attribute for ' + s.label, value: one.lastLogin || '', placeholder: s.hint && /active directory/i.test(s.hint) ? 'lastLogonTimestamp' : 'attribute name', style: 'width:220px' });
|
|
40
|
-
ll.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].lastLogin = ll.value; });
|
|
41
|
-
return [s.label, s.hint, cost, ll];
|
|
42
|
-
});
|
|
43
|
-
w.appendChild(el('details', { className: 'card adv', open: !Object.keys(cfg.sources || {}).length || null }, el('summary', { style: 'font-weight:600', text: 'Settings: cost per account and sign-in dates' }),
|
|
44
|
-
el('p', { className: 'muted small', text: 'Cost: what one account on the application costs per month (license or subscription), to estimate savings. Sign-in attribute: the account attribute that holds the last sign-in date, for example lastLogonTimestamp for Active Directory. It must be in the source’s account schema in ISC. Leave both empty for sources you do not pay for.' }),
|
|
45
|
-
el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('span', { text: 'Dormant after' }), days, el('span', { text: 'days without sign-in. Currency' }), cur,
|
|
46
|
-
el('span', { text: 'People have left when lifecycle state is' }), tokenInput({ value: F.leaverStates, onChange: function (v) { F.leaverStates = v; } })),
|
|
47
|
-
sources ? simpleTable(['Source', 'Type', 'Monthly cost per account', 'Sign-in date attribute'], rows) : el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading sources...'),
|
|
48
|
-
el('div', { className: 'bar', style: 'margin-top:10px' }, el('button', { className: 'btn', onclick: function () {
|
|
49
|
-
msg.textContent = '';
|
|
50
|
-
api('/api/reclaim/settings', 'PUT', F).then(function () { return loadInsightSettings(function () { R.form = null; toast('Settings saved'); renderInsights(); }); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
51
|
-
} }, icon('save'), 'Save settings')), msg));
|
|
52
|
-
w.appendChild(el('div', { className: 'bar', style: 'margin:14px 0' }, el('span', { className: 'muted', style: 'flex:1', text: 'Finds enabled accounts of people who left and accounts nobody signed in with for a long time, so licenses can be taken back. Disabling them is up to you in ISC.' }),
|
|
53
|
-
el('button', { className: 'btn primary', disabled: !!R.busy, onclick: function () { runJobInto(R, '/api/reclaim/run', {}, renderInsights); } }, icon('play'), R.data ? 'Look again' : 'Find licenses to reclaim')));
|
|
54
|
-
if (R.busy) { w.appendChild(busyBox(R.busy)); return; }
|
|
55
|
-
if (R.error) { w.appendChild(el('div', { className: 'error', text: R.error })); return; }
|
|
56
|
-
var d = R.data;
|
|
57
|
-
if (!d) return;
|
|
58
|
-
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
59
|
-
var T = d.totals;
|
|
60
|
-
w.appendChild(el('div', { className: 'bigstats' },
|
|
61
|
-
el('div', { className: 'bigstat' + (T.accounts ? ' lose' : '') }, el('b', { text: fmtNum(T.accounts) }), el('span', { text: 'accounts to reclaim' })),
|
|
62
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.leaver) }), el('span', { text: 'held by people who left' })),
|
|
63
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.dormant) }), el('span', { text: 'no sign-in for ' + d.dormantDays + '+ days' })),
|
|
64
|
-
el('div', { className: 'bigstat' + (T.monthly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.monthly, d.currency) : '—' }), el('span', { text: 'possible saving per month' })),
|
|
65
|
-
el('div', { className: 'bigstat' + (T.yearly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.yearly, d.currency) : '—' }), el('span', { text: 'per year' }))));
|
|
66
|
-
w.appendChild(section('By application', d.sources.length, simpleTable(['Source', 'People who left', 'Dormant', 'Cost per account', 'Per month', 'Per year'], d.sources.map(function (s) {
|
|
67
|
-
return [el('button', { className: 'btn link', style: 'padding:0', text: s.source, onclick: function () { R.only = R.only === s.source ? null : s.source; renderInsights(); } }), s.leaver, s.dormant, moneyText(s.costPerAccount, d.currency), moneyText(s.monthly, d.currency), moneyText(s.yearly, d.currency)];
|
|
68
|
-
}))));
|
|
69
|
-
var list = d.rows.filter(function (r) { return !R.only || r.source === R.only; });
|
|
70
|
-
w.appendChild(section(R.only ? 'Accounts on ' + R.only : 'Accounts', list.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, R.only ? el('button', { className: 'btn ghost sm', onclick: function () { R.only = null; renderInsights(); } }, 'Show all') : null, downloads(R.job)),
|
|
71
|
-
simpleTable(['Source', 'Account', 'Person', 'Why', 'Last sign-in', 'Privileged'], list.slice(0, 2000).map(function (r) {
|
|
72
|
-
return [r.source, r.account, r.person, el('span', { className: 'chg ' + (r.reason === 'Person has left' ? 'lose' : 'off'), text: r.reason + (r.lifecycleState && r.reason === 'Person has left' ? ' (' + r.lifecycleState + ')' : '') }), r.lastLogin ? r.lastLogin.slice(0, 10) + ' (' + r.daysSince + ' days)' : null, yesNo(r.privileged, true)];
|
|
73
|
-
})))));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// access requests
|
|
77
|
-
state.rq = { days: 90 };
|
|
78
|
-
function renderRequests(w) {
|
|
79
|
-
var Q = state.rq;
|
|
80
|
-
var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[30, 'Last 30 days'], [90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
|
|
81
|
-
period.value = String(Q.days);
|
|
82
|
-
period.addEventListener('change', function () { Q.days = Number(period.value); });
|
|
83
|
-
w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'How long requests wait for approval, which approvers are slow or have requests waiting, and which access is requested and rejected most. An admin sign-in sees everyone’s requests.' }), period,
|
|
84
|
-
el('button', { className: 'btn primary', disabled: !!Q.busy, onclick: function () { runJobInto(Q, '/api/requests/run', { days: Q.days }, renderInsights); } }, icon('play'), Q.data ? 'Read again' : 'Read requests')));
|
|
85
|
-
if (Q.busy) { w.appendChild(busyBox(Q.busy)); return; }
|
|
86
|
-
if (Q.error) { w.appendChild(el('div', { className: 'error', text: Q.error })); return; }
|
|
87
|
-
var d = Q.data;
|
|
88
|
-
if (!d) return;
|
|
89
|
-
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
90
|
-
var T = d.totals;
|
|
91
|
-
var hrs = function (h) { return h === null ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; };
|
|
92
|
-
w.appendChild(el('div', { className: 'bigstats' },
|
|
93
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.requests) }), el('span', { text: 'requests in ' + d.days + ' days' })),
|
|
94
|
-
el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToApprove) }), el('span', { text: 'typical wait for an approval' })),
|
|
95
|
-
el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToComplete) }), el('span', { text: 'typical time to get the access' })),
|
|
96
|
-
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.rejected) }), el('span', { text: 'rejected' })),
|
|
97
|
-
el('div', { className: 'bigstat' + (T.open ? ' lose' : '') }, el('b', { text: fmtNum(T.open) }), el('span', { text: 'still open' })),
|
|
98
|
-
el('div', { className: 'bigstat' + (T.failed ? ' lose' : '') }, el('b', { text: fmtNum(T.failed) }), el('span', { text: 'failed' }))));
|
|
99
|
-
if (d.weekly.length > 1) w.appendChild(section('Requests per week', null, el('div', { style: 'color:var(--accent)' }, sparkline(d.weekly.map(function (x) { return { value: x.requests }; }), 900, 60), el('div', { className: 'muted small', text: d.weekly[0].week + ' to ' + d.weekly[d.weekly.length - 1].week }))));
|
|
100
|
-
w.appendChild(section('Approvers', d.approvers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(Q.job)),
|
|
101
|
-
simpleTable(['Approver', 'Decisions', 'Approved', 'Rejected', 'Typical time to decide', 'Waiting now', 'Oldest waiting'], d.approvers.map(function (a) {
|
|
102
|
-
return [a.name, a.decisions, a.approved, a.rejected, hrs(a.medianHours), a.pending ? el('span', { className: 'chg lose', text: String(a.pending) }) : 0, a.oldestPendingDays === null ? null : a.oldestPendingDays + ' days'];
|
|
103
|
-
})))));
|
|
104
|
-
w.appendChild(section('Most requested access', d.items.length, simpleTable(['Access', 'Type', 'Requests', 'Completed', 'Rejected', 'Reject rate'], d.items.slice(0, 100).map(function (i) {
|
|
105
|
-
return [i.name, i.type, i.requests, i.completed, i.rejected, i.rejectRate === null ? null : (i.rejectRate >= 50 && i.rejected > 1 ? el('span', { className: 'chg lose', text: i.rejectRate + '%' }) : i.rejectRate + '%')];
|
|
106
|
-
}))));
|
|
107
|
-
}
|
|
108
|
-
|
|
1
|
+
// ---------- Insights (Monthly report, License reclaim, Access requests) ----------
|
|
2
|
+
state.inz = { tab: 'monthly' };
|
|
3
|
+
function renderInsights() {
|
|
4
|
+
var outer = $('monthly');
|
|
5
|
+
outer.textContent = '';
|
|
6
|
+
var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
|
|
7
|
+
outer.appendChild(w);
|
|
8
|
+
w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0e7c66;background:#e3f5f0' }, icon('sigma')),
|
|
9
|
+
el('div', {}, el('h2', { text: 'Insights' }), el('p', { className: 'desc', text: 'The monthly report for management, licenses you could reclaim, and how access requests flow. Read-only.' }))));
|
|
10
|
+
var tabs = el('div', { className: 'tabs' });
|
|
11
|
+
[['monthly', 'Monthly report', 'file'], ['reclaim', 'License reclaim', 'down'], ['requests', 'Access requests', 'inbox']].forEach(function (t) {
|
|
12
|
+
tabs.appendChild(el('button', { className: 'tab' + (state.inz.tab === t[0] ? ' active' : ''), onclick: function () { state.inz.tab = t[0]; if (t[0] === 'monthly') state.mr.data = null; renderInsights(); } }, icon(t[2]), t[1]));
|
|
13
|
+
});
|
|
14
|
+
w.appendChild(tabs);
|
|
15
|
+
if (state.inz.tab === 'reclaim') renderReclaim(w);
|
|
16
|
+
else if (state.inz.tab === 'requests') renderRequests(w);
|
|
17
|
+
else monthlyTab(w);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// license reclaim
|
|
21
|
+
state.rc = {};
|
|
22
|
+
function renderReclaim(w) {
|
|
23
|
+
var R = state.rc;
|
|
24
|
+
if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderInsights); return; }
|
|
25
|
+
var cfg = state.ins.reclaim || {};
|
|
26
|
+
if (!R.form) R.form = { dormantDays: cfg.dormantDays || 90, currency: cfg.currency || '', leaverStates: (cfg.leaverStates || ['inactive', 'terminated']).slice(), sources: clone(cfg.sources || {}) };
|
|
27
|
+
var F = R.form;
|
|
28
|
+
var sources = R.sources;
|
|
29
|
+
if (!sources) loadPick('sources').then(function (list) { R.sources = list; if (state.page === 'monthly' && state.inz.tab === 'reclaim') renderInsights(); }).catch(function (e) { toast(errorText(e)); });
|
|
30
|
+
var msg = el('div');
|
|
31
|
+
var days = el('input', { className: 'input', type: 'number', min: '7', value: String(F.dormantDays), style: 'width:100px', 'aria-label': 'Dormant after (days)' });
|
|
32
|
+
days.addEventListener('input', function () { F.dormantDays = Number(days.value); });
|
|
33
|
+
var cur = el('input', { className: 'input', value: F.currency, placeholder: 'USD', style: 'width:90px', 'aria-label': 'Currency' });
|
|
34
|
+
cur.addEventListener('input', function () { F.currency = cur.value; });
|
|
35
|
+
var rows = (sources || []).map(function (s) {
|
|
36
|
+
var one = F.sources[s.label] || {};
|
|
37
|
+
var cost = el('input', { className: 'input', type: 'number', min: '0', step: '0.01', 'aria-label': 'Cost per account per month for ' + s.label, value: one.cost === undefined ? '' : String(one.cost), placeholder: 'e.g. 12.50', style: 'width:120px' });
|
|
38
|
+
cost.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].cost = cost.value === '' ? undefined : Number(cost.value); });
|
|
39
|
+
var ll = el('input', { className: 'input', 'aria-label': 'Last login attribute for ' + s.label, value: one.lastLogin || '', placeholder: s.hint && /active directory/i.test(s.hint) ? 'lastLogonTimestamp' : 'attribute name', style: 'width:220px' });
|
|
40
|
+
ll.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].lastLogin = ll.value; });
|
|
41
|
+
return [s.label, s.hint, cost, ll];
|
|
42
|
+
});
|
|
43
|
+
w.appendChild(el('details', { className: 'card adv', open: !Object.keys(cfg.sources || {}).length || null }, el('summary', { style: 'font-weight:600', text: 'Settings: cost per account and sign-in dates' }),
|
|
44
|
+
el('p', { className: 'muted small', text: 'Cost: what one account on the application costs per month (license or subscription), to estimate savings. Sign-in attribute: the account attribute that holds the last sign-in date, for example lastLogonTimestamp for Active Directory. It must be in the source’s account schema in ISC. Leave both empty for sources you do not pay for.' }),
|
|
45
|
+
el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('span', { text: 'Dormant after' }), days, el('span', { text: 'days without sign-in. Currency' }), cur,
|
|
46
|
+
el('span', { text: 'People have left when lifecycle state is' }), tokenInput({ value: F.leaverStates, onChange: function (v) { F.leaverStates = v; } })),
|
|
47
|
+
sources ? simpleTable(['Source', 'Type', 'Monthly cost per account', 'Sign-in date attribute'], rows) : el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading sources...'),
|
|
48
|
+
el('div', { className: 'bar', style: 'margin-top:10px' }, el('button', { className: 'btn', onclick: function () {
|
|
49
|
+
msg.textContent = '';
|
|
50
|
+
api('/api/reclaim/settings', 'PUT', F).then(function () { return loadInsightSettings(function () { R.form = null; toast('Settings saved'); renderInsights(); }); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
51
|
+
} }, icon('save'), 'Save settings')), msg));
|
|
52
|
+
w.appendChild(el('div', { className: 'bar', style: 'margin:14px 0' }, el('span', { className: 'muted', style: 'flex:1', text: 'Finds enabled accounts of people who left and accounts nobody signed in with for a long time, so licenses can be taken back. Disabling them is up to you in ISC.' }),
|
|
53
|
+
el('button', { className: 'btn primary', disabled: !!R.busy, onclick: function () { runJobInto(R, '/api/reclaim/run', {}, renderInsights); } }, icon('play'), R.data ? 'Look again' : 'Find licenses to reclaim')));
|
|
54
|
+
if (R.busy) { w.appendChild(busyBox(R.busy)); return; }
|
|
55
|
+
if (R.error) { w.appendChild(el('div', { className: 'error', text: R.error })); return; }
|
|
56
|
+
var d = R.data;
|
|
57
|
+
if (!d) return;
|
|
58
|
+
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
59
|
+
var T = d.totals;
|
|
60
|
+
w.appendChild(el('div', { className: 'bigstats' },
|
|
61
|
+
el('div', { className: 'bigstat' + (T.accounts ? ' lose' : '') }, el('b', { text: fmtNum(T.accounts) }), el('span', { text: 'accounts to reclaim' })),
|
|
62
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.leaver) }), el('span', { text: 'held by people who left' })),
|
|
63
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.dormant) }), el('span', { text: 'no sign-in for ' + d.dormantDays + '+ days' })),
|
|
64
|
+
el('div', { className: 'bigstat' + (T.monthly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.monthly, d.currency) : '—' }), el('span', { text: 'possible saving per month' })),
|
|
65
|
+
el('div', { className: 'bigstat' + (T.yearly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.yearly, d.currency) : '—' }), el('span', { text: 'per year' }))));
|
|
66
|
+
w.appendChild(section('By application', d.sources.length, simpleTable(['Source', 'People who left', 'Dormant', 'Cost per account', 'Per month', 'Per year'], d.sources.map(function (s) {
|
|
67
|
+
return [el('button', { className: 'btn link', style: 'padding:0', text: s.source, onclick: function () { R.only = R.only === s.source ? null : s.source; renderInsights(); } }), s.leaver, s.dormant, moneyText(s.costPerAccount, d.currency), moneyText(s.monthly, d.currency), moneyText(s.yearly, d.currency)];
|
|
68
|
+
}))));
|
|
69
|
+
var list = d.rows.filter(function (r) { return !R.only || r.source === R.only; });
|
|
70
|
+
w.appendChild(section(R.only ? 'Accounts on ' + R.only : 'Accounts', list.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, R.only ? el('button', { className: 'btn ghost sm', onclick: function () { R.only = null; renderInsights(); } }, 'Show all') : null, downloads(R.job)),
|
|
71
|
+
simpleTable(['Source', 'Account', 'Person', 'Why', 'Last sign-in', 'Privileged'], list.slice(0, 2000).map(function (r) {
|
|
72
|
+
return [r.source, r.account, r.person, el('span', { className: 'chg ' + (r.reason === 'Person has left' ? 'lose' : 'off'), text: r.reason + (r.lifecycleState && r.reason === 'Person has left' ? ' (' + r.lifecycleState + ')' : '') }), r.lastLogin ? r.lastLogin.slice(0, 10) + ' (' + r.daysSince + ' days)' : null, yesNo(r.privileged, true)];
|
|
73
|
+
})))));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// access requests
|
|
77
|
+
state.rq = { days: 90 };
|
|
78
|
+
function renderRequests(w) {
|
|
79
|
+
var Q = state.rq;
|
|
80
|
+
var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[30, 'Last 30 days'], [90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
|
|
81
|
+
period.value = String(Q.days);
|
|
82
|
+
period.addEventListener('change', function () { Q.days = Number(period.value); });
|
|
83
|
+
w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'How long requests wait for approval, which approvers are slow or have requests waiting, and which access is requested and rejected most. An admin sign-in sees everyone’s requests.' }), period,
|
|
84
|
+
el('button', { className: 'btn primary', disabled: !!Q.busy, onclick: function () { runJobInto(Q, '/api/requests/run', { days: Q.days }, renderInsights); } }, icon('play'), Q.data ? 'Read again' : 'Read requests')));
|
|
85
|
+
if (Q.busy) { w.appendChild(busyBox(Q.busy)); return; }
|
|
86
|
+
if (Q.error) { w.appendChild(el('div', { className: 'error', text: Q.error })); return; }
|
|
87
|
+
var d = Q.data;
|
|
88
|
+
if (!d) return;
|
|
89
|
+
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
90
|
+
var T = d.totals;
|
|
91
|
+
var hrs = function (h) { return h === null ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; };
|
|
92
|
+
w.appendChild(el('div', { className: 'bigstats' },
|
|
93
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.requests) }), el('span', { text: 'requests in ' + d.days + ' days' })),
|
|
94
|
+
el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToApprove) }), el('span', { text: 'typical wait for an approval' })),
|
|
95
|
+
el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToComplete) }), el('span', { text: 'typical time to get the access' })),
|
|
96
|
+
el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.rejected) }), el('span', { text: 'rejected' })),
|
|
97
|
+
el('div', { className: 'bigstat' + (T.open ? ' lose' : '') }, el('b', { text: fmtNum(T.open) }), el('span', { text: 'still open' })),
|
|
98
|
+
el('div', { className: 'bigstat' + (T.failed ? ' lose' : '') }, el('b', { text: fmtNum(T.failed) }), el('span', { text: 'failed' }))));
|
|
99
|
+
if (d.weekly.length > 1) w.appendChild(section('Requests per week', null, el('div', { style: 'color:var(--accent)' }, sparkline(d.weekly.map(function (x) { return { value: x.requests }; }), 900, 60), el('div', { className: 'muted small', text: d.weekly[0].week + ' to ' + d.weekly[d.weekly.length - 1].week }))));
|
|
100
|
+
w.appendChild(section('Approvers', d.approvers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(Q.job)),
|
|
101
|
+
simpleTable(['Approver', 'Decisions', 'Approved', 'Rejected', 'Typical time to decide', 'Waiting now', 'Oldest waiting'], d.approvers.map(function (a) {
|
|
102
|
+
return [a.name, a.decisions, a.approved, a.rejected, hrs(a.medianHours), a.pending ? el('span', { className: 'chg lose', text: String(a.pending) }) : 0, a.oldestPendingDays === null ? null : a.oldestPendingDays + ' days'];
|
|
103
|
+
})))));
|
|
104
|
+
w.appendChild(section('Most requested access', d.items.length, simpleTable(['Access', 'Type', 'Requests', 'Completed', 'Rejected', 'Reject rate'], d.items.slice(0, 100).map(function (i) {
|
|
105
|
+
return [i.name, i.type, i.requests, i.completed, i.rejected, i.rejectRate === null ? null : (i.rejectRate >= 50 && i.rejected > 1 ? el('span', { className: 'chg lose', text: i.rejectRate + '%' }) : i.rejectRate + '%')];
|
|
106
|
+
}))));
|
|
107
|
+
}
|
|
108
|
+
|
package/ui/js/20-role-mining.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
// ---------- role mining (a Role tools tab) ----------
|
|
2
|
-
state.mn = { attribute: 'department', minGroup: 5, minShare: 80 };
|
|
3
|
-
function renderMining(w) {
|
|
4
|
-
var M = state.mn;
|
|
5
|
-
var attrs = identityAttrs();
|
|
6
|
-
var names = attrs.map(function (a) { return a.name; });
|
|
7
|
-
if (names.indexOf(M.attribute) < 0) names.unshift(M.attribute);
|
|
8
|
-
var attr = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Group people by' }, names.map(function (n) { return el('option', { value: n, text: n }); }));
|
|
9
|
-
attr.value = M.attribute;
|
|
10
|
-
attr.addEventListener('change', function () { M.attribute = attr.value; });
|
|
11
|
-
var minG = el('input', { className: 'input', type: 'number', min: '1', value: String(M.minGroup), style: 'width:80px', 'aria-label': 'Smallest group size' });
|
|
12
|
-
minG.addEventListener('input', function () { M.minGroup = Number(minG.value); });
|
|
13
|
-
var share = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Held by at least' }, [60, 70, 80, 90, 100].map(function (n) { return el('option', { value: String(n), text: n + '%' }); }));
|
|
14
|
-
share.value = String(M.minShare);
|
|
15
|
-
share.addEventListener('change', function () { M.minShare = Number(share.value); });
|
|
16
|
-
w.appendChild(el('section', { className: 'card' },
|
|
17
|
-
el('p', { className: 'muted', style: 'margin-top:0', text: 'Groups people by an identity attribute (department, job title, location...) and lists the entitlements most of each group already hold. Those are candidates for a birthright role with that attribute as membership criteria. Items an existing role already gives are marked.' }),
|
|
18
|
-
el('div', { className: 'bar' }, el('span', { text: 'Group people by' }), attr, el('span', { text: 'groups of at least' }), minG, el('span', { text: 'people, access held by at least' }), share,
|
|
19
|
-
el('button', { className: 'btn primary', disabled: !!M.busy, onclick: function () { runJobInto(M, '/api/mining/run', { attribute: M.attribute, minGroup: M.minGroup, minShare: M.minShare }, renderRoles); } }, icon('play'), 'Find candidate roles'))));
|
|
20
|
-
if (M.busy) { w.appendChild(busyBox(M.busy)); return; }
|
|
21
|
-
if (M.error) { w.appendChild(el('div', { className: 'error', text: M.error })); return; }
|
|
22
|
-
var d = M.data;
|
|
23
|
-
if (!d) return;
|
|
24
|
-
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
25
|
-
var fresh = d.candidates.filter(function (c) { return c.newItems > 0; }).length;
|
|
26
|
-
w.appendChild(el('div', { className: 'banner ' + (fresh ? 'warn' : 'ok') }, el('b', { text: fresh ? fresh + ' group' + (fresh > 1 ? 's have' : ' has') + ' common access no role gives yet' : 'No new candidate roles' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' active people in ' + fmtNum(d.groups) + ' groups' }), el('span', { style: 'flex:1' }), downloads(M.job)));
|
|
27
|
-
d.candidates.slice(0, 60).forEach(function (c) {
|
|
28
|
-
w.appendChild(section(d.attribute + ' = ' + c.value, fmtNum(c.members) + (c.members === 1 ? ' person' : ' people'), el('div', {},
|
|
29
|
-
simpleTable(['Entitlement', 'Source', 'Held by', 'Already in a role'], c.items.map(function (i) {
|
|
30
|
-
return [i.name, i.source, i.holders + ' (' + i.share + '%)', i.covered ? el('span', { className: 'chg gain', text: 'Yes' }) : el('span', { className: 'chg lose', text: 'No' })];
|
|
31
|
-
})),
|
|
32
|
-
c.newItems ? el('p', { className: 'muted small', text: 'Candidate role: members where ' + d.attribute + ' is "' + c.value + '", with the ' + c.newItems + ' item' + (c.newItems > 1 ? 's' : '') + ' marked No. Check it first with "Preview a role change".' }) : null)));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
// ---------- role mining (a Role tools tab) ----------
|
|
2
|
+
state.mn = { attribute: 'department', minGroup: 5, minShare: 80 };
|
|
3
|
+
function renderMining(w) {
|
|
4
|
+
var M = state.mn;
|
|
5
|
+
var attrs = identityAttrs();
|
|
6
|
+
var names = attrs.map(function (a) { return a.name; });
|
|
7
|
+
if (names.indexOf(M.attribute) < 0) names.unshift(M.attribute);
|
|
8
|
+
var attr = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Group people by' }, names.map(function (n) { return el('option', { value: n, text: n }); }));
|
|
9
|
+
attr.value = M.attribute;
|
|
10
|
+
attr.addEventListener('change', function () { M.attribute = attr.value; });
|
|
11
|
+
var minG = el('input', { className: 'input', type: 'number', min: '1', value: String(M.minGroup), style: 'width:80px', 'aria-label': 'Smallest group size' });
|
|
12
|
+
minG.addEventListener('input', function () { M.minGroup = Number(minG.value); });
|
|
13
|
+
var share = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Held by at least' }, [60, 70, 80, 90, 100].map(function (n) { return el('option', { value: String(n), text: n + '%' }); }));
|
|
14
|
+
share.value = String(M.minShare);
|
|
15
|
+
share.addEventListener('change', function () { M.minShare = Number(share.value); });
|
|
16
|
+
w.appendChild(el('section', { className: 'card' },
|
|
17
|
+
el('p', { className: 'muted', style: 'margin-top:0', text: 'Groups people by an identity attribute (department, job title, location...) and lists the entitlements most of each group already hold. Those are candidates for a birthright role with that attribute as membership criteria. Items an existing role already gives are marked.' }),
|
|
18
|
+
el('div', { className: 'bar' }, el('span', { text: 'Group people by' }), attr, el('span', { text: 'groups of at least' }), minG, el('span', { text: 'people, access held by at least' }), share,
|
|
19
|
+
el('button', { className: 'btn primary', disabled: !!M.busy, onclick: function () { runJobInto(M, '/api/mining/run', { attribute: M.attribute, minGroup: M.minGroup, minShare: M.minShare }, renderRoles); } }, icon('play'), 'Find candidate roles'))));
|
|
20
|
+
if (M.busy) { w.appendChild(busyBox(M.busy)); return; }
|
|
21
|
+
if (M.error) { w.appendChild(el('div', { className: 'error', text: M.error })); return; }
|
|
22
|
+
var d = M.data;
|
|
23
|
+
if (!d) return;
|
|
24
|
+
d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
|
|
25
|
+
var fresh = d.candidates.filter(function (c) { return c.newItems > 0; }).length;
|
|
26
|
+
w.appendChild(el('div', { className: 'banner ' + (fresh ? 'warn' : 'ok') }, el('b', { text: fresh ? fresh + ' group' + (fresh > 1 ? 's have' : ' has') + ' common access no role gives yet' : 'No new candidate roles' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' active people in ' + fmtNum(d.groups) + ' groups' }), el('span', { style: 'flex:1' }), downloads(M.job)));
|
|
27
|
+
d.candidates.slice(0, 60).forEach(function (c) {
|
|
28
|
+
w.appendChild(section(d.attribute + ' = ' + c.value, fmtNum(c.members) + (c.members === 1 ? ' person' : ' people'), el('div', {},
|
|
29
|
+
simpleTable(['Entitlement', 'Source', 'Held by', 'Already in a role'], c.items.map(function (i) {
|
|
30
|
+
return [i.name, i.source, i.holders + ' (' + i.share + '%)', i.covered ? el('span', { className: 'chg gain', text: 'Yes' }) : el('span', { className: 'chg lose', text: 'No' })];
|
|
31
|
+
})),
|
|
32
|
+
c.newItems ? el('p', { className: 'muted small', text: 'Candidate role: members where ' + d.attribute + ' is "' + c.value + '", with the ' + c.newItems + ' item' + (c.newItems > 1 ? 's' : '') + ' marked No. Check it first with "Preview a role change".' }) : null)));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// ---------- share reports (report packs) ----------
|
|
2
|
-
function sharePanel() {
|
|
3
|
-
var m = $('main');
|
|
4
|
-
m.textContent = '';
|
|
5
|
-
var w = el('div', { className: 'wrap', style: 'max-width:980px' });
|
|
6
|
-
m.appendChild(w);
|
|
7
|
-
pageHead(w, 'copy', '#334155', '#eef1f5', 'Share reports', 'Export reports to one file and import packs from colleagues or other companies. A pack holds report definitions only, never data or credentials.');
|
|
8
|
-
var mine = state.reports.filter(function (r) { return r.custom; });
|
|
9
|
-
var chosen = mine.map(function (r) { return r.definition.id; });
|
|
10
|
-
var exportList = el('div', { className: 'checklist' }, (mine.length ? mine : state.reports.slice(0, 0)).map(function (r) {
|
|
11
|
-
var c = el('input', { type: 'checkbox', checked: true });
|
|
12
|
-
c.addEventListener('change', function () { chosen = chosen.filter(function (x) { return x !== r.definition.id; }); if (c.checked) chosen.push(r.definition.id); });
|
|
13
|
-
return el('label', { className: 'cl-item' }, c, el('span', { text: r.definition.name + ' (' + r.definition.id + ')' }));
|
|
14
|
-
}));
|
|
15
|
-
w.appendChild(section('Export my reports', mine.length, mine.length ? el('div', {}, exportList, el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {
|
|
16
|
-
if (!chosen.length) { toast('Choose at least one report'); return; }
|
|
17
|
-
var a = el('a', { href: '/api/packs/download?ids=' + encodeURIComponent(chosen.join(',')) + '&k=' + encodeURIComponent(KEY), download: '' });
|
|
18
|
-
document.body.appendChild(a); a.click(); a.remove();
|
|
19
|
-
} }, icon('download'), 'Download pack')) : el('div', { className: 'muted', text: 'You have no reports of your own yet. Use New report or Customize on a ready-made report.' })));
|
|
20
|
-
var box = el('div');
|
|
21
|
-
var file = el('input', { type: 'file', accept: '.json,application/json' });
|
|
22
|
-
file.addEventListener('change', function () {
|
|
23
|
-
var f = file.files && file.files[0];
|
|
24
|
-
if (!f) return;
|
|
25
|
-
if (f.size > 1500000) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: 'The file is too large for a report pack.' })); return; }
|
|
26
|
-
f.text().then(function (text) {
|
|
27
|
-
return api('/api/packs/preview', 'POST', { text: text }).then(function (p) {
|
|
28
|
-
box.textContent = '';
|
|
29
|
-
var pick = p.entries.filter(function (e) { return e.status === 'new' || e.status === 'replaces yours'; }).map(function (e) { return e.id; });
|
|
30
|
-
box.appendChild(simpleTable(['', 'Report', 'ID', 'What happens'], p.entries.map(function (e) {
|
|
31
|
-
var ok = e.status === 'new' || e.status === 'replaces yours';
|
|
32
|
-
var c = el('input', { type: 'checkbox', checked: ok, disabled: !ok });
|
|
33
|
-
c.addEventListener('change', function () { pick = pick.filter(function (x) { return x !== e.id; }); if (c.checked) pick.push(e.id); });
|
|
34
|
-
var what = e.status === 'new' ? el('span', { className: 'chg gain', text: 'Added' }) : e.status === 'replaces yours' ? el('span', { className: 'chg lose', text: 'Replaces your report with this ID' }) : e.status === 'built in' ? el('span', { className: 'chg off', text: 'Skipped: same ID as a ready-made report' }) : el('span', { className: 'chg lose', text: 'Skipped: ' + e.problems.join('; ') });
|
|
35
|
-
return [c, e.name, e.id, what];
|
|
36
|
-
})));
|
|
37
|
-
box.appendChild(el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {
|
|
38
|
-
api('/api/packs/import', 'POST', { text: text, ids: pick }).then(function (r) { toast(r.saved.length + ' report' + (r.saved.length === 1 ? '' : 's') + ' added'); loadLibrary(); }).catch(function (e) { box.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
39
|
-
} }, icon('plus'), 'Add the chosen reports'));
|
|
40
|
-
});
|
|
41
|
-
}).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
42
|
-
});
|
|
43
|
-
w.appendChild(section('Import a pack', null, el('div', {}, el('p', { className: 'muted small', style: 'margin-top:0', text: 'Choose a .json pack file. You see every report before anything is added. Ready-made reports are never replaced.' }), file, box)));
|
|
44
|
-
}
|
|
45
|
-
|
|
1
|
+
// ---------- share reports (report packs) ----------
|
|
2
|
+
function sharePanel() {
|
|
3
|
+
var m = $('main');
|
|
4
|
+
m.textContent = '';
|
|
5
|
+
var w = el('div', { className: 'wrap', style: 'max-width:980px' });
|
|
6
|
+
m.appendChild(w);
|
|
7
|
+
pageHead(w, 'copy', '#334155', '#eef1f5', 'Share reports', 'Export reports to one file and import packs from colleagues or other companies. A pack holds report definitions only, never data or credentials.');
|
|
8
|
+
var mine = state.reports.filter(function (r) { return r.custom; });
|
|
9
|
+
var chosen = mine.map(function (r) { return r.definition.id; });
|
|
10
|
+
var exportList = el('div', { className: 'checklist' }, (mine.length ? mine : state.reports.slice(0, 0)).map(function (r) {
|
|
11
|
+
var c = el('input', { type: 'checkbox', checked: true });
|
|
12
|
+
c.addEventListener('change', function () { chosen = chosen.filter(function (x) { return x !== r.definition.id; }); if (c.checked) chosen.push(r.definition.id); });
|
|
13
|
+
return el('label', { className: 'cl-item' }, c, el('span', { text: r.definition.name + ' (' + r.definition.id + ')' }));
|
|
14
|
+
}));
|
|
15
|
+
w.appendChild(section('Export my reports', mine.length, mine.length ? el('div', {}, exportList, el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {
|
|
16
|
+
if (!chosen.length) { toast('Choose at least one report'); return; }
|
|
17
|
+
var a = el('a', { href: '/api/packs/download?ids=' + encodeURIComponent(chosen.join(',')) + '&k=' + encodeURIComponent(KEY), download: '' });
|
|
18
|
+
document.body.appendChild(a); a.click(); a.remove();
|
|
19
|
+
} }, icon('download'), 'Download pack')) : el('div', { className: 'muted', text: 'You have no reports of your own yet. Use New report or Customize on a ready-made report.' })));
|
|
20
|
+
var box = el('div');
|
|
21
|
+
var file = el('input', { type: 'file', accept: '.json,application/json' });
|
|
22
|
+
file.addEventListener('change', function () {
|
|
23
|
+
var f = file.files && file.files[0];
|
|
24
|
+
if (!f) return;
|
|
25
|
+
if (f.size > 1500000) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: 'The file is too large for a report pack.' })); return; }
|
|
26
|
+
f.text().then(function (text) {
|
|
27
|
+
return api('/api/packs/preview', 'POST', { text: text }).then(function (p) {
|
|
28
|
+
box.textContent = '';
|
|
29
|
+
var pick = p.entries.filter(function (e) { return e.status === 'new' || e.status === 'replaces yours'; }).map(function (e) { return e.id; });
|
|
30
|
+
box.appendChild(simpleTable(['', 'Report', 'ID', 'What happens'], p.entries.map(function (e) {
|
|
31
|
+
var ok = e.status === 'new' || e.status === 'replaces yours';
|
|
32
|
+
var c = el('input', { type: 'checkbox', checked: ok, disabled: !ok });
|
|
33
|
+
c.addEventListener('change', function () { pick = pick.filter(function (x) { return x !== e.id; }); if (c.checked) pick.push(e.id); });
|
|
34
|
+
var what = e.status === 'new' ? el('span', { className: 'chg gain', text: 'Added' }) : e.status === 'replaces yours' ? el('span', { className: 'chg lose', text: 'Replaces your report with this ID' }) : e.status === 'built in' ? el('span', { className: 'chg off', text: 'Skipped: same ID as a ready-made report' }) : el('span', { className: 'chg lose', text: 'Skipped: ' + e.problems.join('; ') });
|
|
35
|
+
return [c, e.name, e.id, what];
|
|
36
|
+
})));
|
|
37
|
+
box.appendChild(el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {
|
|
38
|
+
api('/api/packs/import', 'POST', { text: text, ids: pick }).then(function (r) { toast(r.saved.length + ' report' + (r.saved.length === 1 ? '' : 's') + ' added'); loadLibrary(); }).catch(function (e) { box.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
39
|
+
} }, icon('plus'), 'Add the chosen reports'));
|
|
40
|
+
});
|
|
41
|
+
}).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
42
|
+
});
|
|
43
|
+
w.appendChild(section('Import a pack', null, el('div', {}, el('p', { className: 'muted small', style: 'margin-top:0', text: 'Choose a .json pack file. You see every report before anything is added. Ready-made reports are never replaced.' }), file, box)));
|
|
44
|
+
}
|
|
45
|
+
|