identityscope 0.0.0-stage → 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 -0
- package/README.md +916 -2
- package/SECURITY.md +56 -0
- package/dist/core/audit-readiness.d.ts +158 -0
- package/dist/core/audit-readiness.js +357 -0
- package/dist/core/audit-readiness.js.map +1 -0
- package/dist/core/certs.d.ts +68 -0
- package/dist/core/certs.js +132 -0
- package/dist/core/certs.js.map +1 -0
- package/dist/core/checks.d.ts +133 -0
- package/dist/core/checks.js +512 -0
- package/dist/core/checks.js.map +1 -0
- package/dist/core/cloud-rules.d.ts +20 -0
- package/dist/core/cloud-rules.js +44 -0
- package/dist/core/cloud-rules.js.map +1 -0
- package/dist/core/compare.d.ts +45 -0
- package/dist/core/compare.js +372 -0
- package/dist/core/compare.js.map +1 -0
- package/dist/core/conditions.d.ts +10 -0
- package/dist/core/conditions.js +201 -0
- package/dist/core/conditions.js.map +1 -0
- package/dist/core/credentials.d.ts +71 -0
- package/dist/core/credentials.js +211 -0
- package/dist/core/credentials.js.map +1 -0
- package/dist/core/datasets.d.ts +53 -0
- package/dist/core/datasets.js +596 -0
- package/dist/core/datasets.js.map +1 -0
- package/dist/core/definition.d.ts +32 -0
- package/dist/core/definition.js +301 -0
- package/dist/core/definition.js.map +1 -0
- package/dist/core/discover.d.ts +32 -0
- package/dist/core/discover.js +105 -0
- package/dist/core/discover.js.map +1 -0
- package/dist/core/engine.d.ts +18 -0
- package/dist/core/engine.js +290 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/fields.d.ts +16 -0
- package/dist/core/fields.js +132 -0
- package/dist/core/fields.js.map +1 -0
- package/dist/core/governance-trail.d.ts +211 -0
- package/dist/core/governance-trail.js +557 -0
- package/dist/core/governance-trail.js.map +1 -0
- package/dist/core/http-transport.d.ts +66 -0
- package/dist/core/http-transport.js +247 -0
- package/dist/core/http-transport.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/insights.d.ts +176 -0
- package/dist/core/insights.js +417 -0
- package/dist/core/insights.js.map +1 -0
- package/dist/core/joiner-evidence.d.ts +98 -0
- package/dist/core/joiner-evidence.js +254 -0
- package/dist/core/joiner-evidence.js.map +1 -0
- package/dist/core/lab/credential-map.d.ts +50 -0
- package/dist/core/lab/credential-map.js +163 -0
- package/dist/core/lab/credential-map.js.map +1 -0
- package/dist/core/lab/javadate.d.ts +7 -0
- package/dist/core/lab/javadate.js +307 -0
- package/dist/core/lab/javadate.js.map +1 -0
- package/dist/core/lab/jsonpath.d.ts +11 -0
- package/dist/core/lab/jsonpath.js +273 -0
- package/dist/core/lab/jsonpath.js.map +1 -0
- package/dist/core/lab/policy-preview.d.ts +43 -0
- package/dist/core/lab/policy-preview.js +78 -0
- package/dist/core/lab/policy-preview.js.map +1 -0
- package/dist/core/lab/rfc5646.d.ts +2 -0
- package/dist/core/lab/rfc5646.js +421 -0
- package/dist/core/lab/rfc5646.js.map +1 -0
- package/dist/core/lab/transform-impact.d.ts +63 -0
- package/dist/core/lab/transform-impact.js +138 -0
- package/dist/core/lab/transform-impact.js.map +1 -0
- package/dist/core/lab/transform-people.d.ts +61 -0
- package/dist/core/lab/transform-people.js +132 -0
- package/dist/core/lab/transform-people.js.map +1 -0
- package/dist/core/lab/transforms.d.ts +79 -0
- package/dist/core/lab/transforms.js +738 -0
- package/dist/core/lab/transforms.js.map +1 -0
- package/dist/core/lab/velocity.d.ts +33 -0
- package/dist/core/lab/velocity.js +874 -0
- package/dist/core/lab/velocity.js.map +1 -0
- package/dist/core/lab/workflow-health.d.ts +80 -0
- package/dist/core/lab/workflow-health.js +234 -0
- package/dist/core/lab/workflow-health.js.map +1 -0
- package/dist/core/lab/workflows.d.ts +87 -0
- package/dist/core/lab/workflows.js +568 -0
- package/dist/core/lab/workflows.js.map +1 -0
- package/dist/core/lifecycle-gaps.d.ts +192 -0
- package/dist/core/lifecycle-gaps.js +389 -0
- package/dist/core/lifecycle-gaps.js.map +1 -0
- package/dist/core/logs.d.ts +145 -0
- package/dist/core/logs.js +342 -0
- package/dist/core/logs.js.map +1 -0
- package/dist/core/lookup.d.ts +129 -0
- package/dist/core/lookup.js +289 -0
- package/dist/core/lookup.js.map +1 -0
- package/dist/core/model-insights.d.ts +247 -0
- package/dist/core/model-insights.js +474 -0
- package/dist/core/model-insights.js.map +1 -0
- package/dist/core/narrow.d.ts +23 -0
- package/dist/core/narrow.js +137 -0
- package/dist/core/narrow.js.map +1 -0
- package/dist/core/nerm.d.ts +154 -0
- package/dist/core/nerm.js +397 -0
- package/dist/core/nerm.js.map +1 -0
- package/dist/core/operations-watch.d.ts +232 -0
- package/dist/core/operations-watch.js +491 -0
- package/dist/core/operations-watch.js.map +1 -0
- package/dist/core/output/csv.d.ts +6 -0
- package/dist/core/output/csv.js +22 -0
- package/dist/core/output/csv.js.map +1 -0
- package/dist/core/output/html.d.ts +11 -0
- package/dist/core/output/html.js +66 -0
- package/dist/core/output/html.js.map +1 -0
- package/dist/core/output/xlsx.d.ts +3 -0
- package/dist/core/output/xlsx.js +130 -0
- package/dist/core/output/xlsx.js.map +1 -0
- package/dist/core/output/zip.d.ts +16 -0
- package/dist/core/output/zip.js +106 -0
- package/dist/core/output/zip.js.map +1 -0
- package/dist/core/ownership.d.ts +39 -0
- package/dist/core/ownership.js +100 -0
- package/dist/core/ownership.js.map +1 -0
- package/dist/core/patterns.d.ts +11 -0
- package/dist/core/patterns.js +31 -0
- package/dist/core/patterns.js.map +1 -0
- package/dist/core/preview.d.ts +96 -0
- package/dist/core/preview.js +173 -0
- package/dist/core/preview.js.map +1 -0
- package/dist/core/roles.d.ts +125 -0
- package/dist/core/roles.js +420 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/tenant.d.ts +67 -0
- package/dist/core/tenant.js +194 -0
- package/dist/core/tenant.js.map +1 -0
- package/dist/core/threat-signals.d.ts +112 -0
- package/dist/core/threat-signals.js +250 -0
- package/dist/core/threat-signals.js.map +1 -0
- package/dist/core/threat-watch.d.ts +144 -0
- package/dist/core/threat-watch.js +282 -0
- package/dist/core/threat-watch.js.map +1 -0
- package/dist/core/transport.d.ts +82 -0
- package/dist/core/transport.js +312 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/core/types.d.ts +137 -0
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/warnings.d.ts +236 -0
- package/dist/core/warnings.js +504 -0
- package/dist/core/warnings.js.map +1 -0
- package/dist/demo/tenant.d.ts +1572 -0
- package/dist/demo/tenant.js +1023 -0
- package/dist/demo/tenant.js.map +1 -0
- package/dist/node/attribute-history.d.ts +22 -0
- package/dist/node/attribute-history.js +86 -0
- package/dist/node/attribute-history.js.map +1 -0
- package/dist/node/changes.d.ts +20 -0
- package/dist/node/changes.js +78 -0
- package/dist/node/changes.js.map +1 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.js +291 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/config.d.ts +72 -0
- package/dist/node/config.js +203 -0
- package/dist/node/config.js.map +1 -0
- package/dist/node/credentials.d.ts +13 -0
- package/dist/node/credentials.js +24 -0
- package/dist/node/credentials.js.map +1 -0
- package/dist/node/delivery.d.ts +10 -0
- package/dist/node/delivery.js +105 -0
- package/dist/node/delivery.js.map +1 -0
- package/dist/node/doctor.d.ts +2 -0
- package/dist/node/doctor.js +151 -0
- package/dist/node/doctor.js.map +1 -0
- package/dist/node/drift.d.ts +31 -0
- package/dist/node/drift.js +56 -0
- package/dist/node/drift.js.map +1 -0
- package/dist/node/evidence.d.ts +42 -0
- package/dist/node/evidence.js +129 -0
- package/dist/node/evidence.js.map +1 -0
- package/dist/node/exceptions.d.ts +30 -0
- package/dist/node/exceptions.js +83 -0
- package/dist/node/exceptions.js.map +1 -0
- package/dist/node/history.d.ts +35 -0
- package/dist/node/history.js +74 -0
- package/dist/node/history.js.map +1 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.js +8 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/keep.d.ts +9 -0
- package/dist/node/keep.js +39 -0
- package/dist/node/keep.js.map +1 -0
- package/dist/node/loader.d.ts +7 -0
- package/dist/node/loader.js +35 -0
- package/dist/node/loader.js.map +1 -0
- package/dist/node/log-files.d.ts +16 -0
- package/dist/node/log-files.js +93 -0
- package/dist/node/log-files.js.map +1 -0
- package/dist/node/monthly.d.ts +41 -0
- package/dist/node/monthly.js +108 -0
- package/dist/node/monthly.js.map +1 -0
- package/dist/node/oauth-login.d.ts +45 -0
- package/dist/node/oauth-login.js +121 -0
- package/dist/node/oauth-login.js.map +1 -0
- package/dist/node/packs.d.ts +32 -0
- package/dist/node/packs.js +43 -0
- package/dist/node/packs.js.map +1 -0
- package/dist/node/privileged-seen.d.ts +11 -0
- package/dist/node/privileged-seen.js +41 -0
- package/dist/node/privileged-seen.js.map +1 -0
- package/dist/node/recipients.d.ts +17 -0
- package/dist/node/recipients.js +51 -0
- package/dist/node/recipients.js.map +1 -0
- package/dist/node/runner.d.ts +51 -0
- package/dist/node/runner.js +298 -0
- package/dist/node/runner.js.map +1 -0
- package/dist/node/runtime.d.ts +12 -0
- package/dist/node/runtime.js +13 -0
- package/dist/node/runtime.js.map +1 -0
- package/dist/node/schedules.d.ts +87 -0
- package/dist/node/schedules.js +141 -0
- package/dist/node/schedules.js.map +1 -0
- package/dist/node/secrets.d.ts +37 -0
- package/dist/node/secrets.js +219 -0
- package/dist/node/secrets.js.map +1 -0
- package/dist/node/support.d.ts +14 -0
- package/dist/node/support.js +133 -0
- package/dist/node/support.js.map +1 -0
- package/dist/node/tenants.d.ts +93 -0
- package/dist/node/tenants.js +255 -0
- package/dist/node/tenants.js.map +1 -0
- package/dist/node/ui-page.d.ts +1 -0
- package/dist/node/ui-page.js +3 -0
- package/dist/node/ui-page.js.map +1 -0
- package/dist/node/ui-server.d.ts +48 -0
- package/dist/node/ui-server.js +2665 -0
- package/dist/node/ui-server.js.map +1 -0
- package/dist/node/write.d.ts +9 -0
- package/dist/node/write.js +53 -0
- package/dist/node/write.js.map +1 -0
- package/dist/reports/builtin.generated.d.ts +1 -0
- package/dist/reports/builtin.generated.js +49 -0
- package/dist/reports/builtin.generated.js.map +1 -0
- package/dist/reports/library.d.ts +6 -0
- package/dist/reports/library.js +18 -0
- package/dist/reports/library.js.map +1 -0
- package/launcher/IdentityScope.cmd +11 -0
- package/package.json +69 -4
- package/reports/access-profile-members.yaml +29 -0
- package/reports/access-profile-membership-counts.yaml +17 -0
- package/reports/access-profiles-without-owner.yaml +16 -0
- package/reports/access-request-audit-trail.yaml +36 -0
- package/reports/accounts-by-source.yaml +19 -0
- package/reports/active-identities-without-manager.yaml +22 -0
- package/reports/aggregation-failures.yaml +29 -0
- package/reports/aggregation-history.yaml +27 -0
- package/reports/all-sources.yaml +16 -0
- package/reports/application-accounts.yaml +32 -0
- package/reports/application-entitlements.yaml +31 -0
- package/reports/campaign-progress.yaml +23 -0
- package/reports/certification-decisions.yaml +31 -0
- package/reports/direct-reports-per-manager.yaml +20 -0
- package/reports/disabled-accounts-of-active-people.yaml +33 -0
- package/reports/duplicate-emails.yaml +16 -0
- package/reports/entitlement-holders.yaml +35 -0
- package/reports/entitlements-held-by-inactive-identities.yaml +31 -0
- package/reports/entitlements-without-owner.yaml +28 -0
- package/reports/identities-by-lifecycle-state.yaml +15 -0
- package/reports/identities-missing-key-attributes.yaml +27 -0
- package/reports/identities-with-processing-errors.yaml +19 -0
- package/reports/identity-attribute-mappings.yaml +27 -0
- package/reports/machine-accounts.yaml +28 -0
- package/reports/managers-and-direct-reports.yaml +23 -0
- package/reports/most-access.yaml +18 -0
- package/reports/new-identities.yaml +24 -0
- package/reports/old-passwords.yaml +35 -0
- package/reports/pending-reviews-by-reviewer.yaml +20 -0
- package/reports/person-access.yaml +31 -0
- package/reports/privileged-access.yaml +29 -0
- package/reports/provisioning-error-causes.yaml +27 -0
- package/reports/provisioning-errors.yaml +32 -0
- package/reports/provisioning-failures.yaml +28 -0
- package/reports/recent-access-requests.yaml +22 -0
- package/reports/recent-activity.yaml +32 -0
- package/reports/recent-leavers.yaml +34 -0
- package/reports/role-members.yaml +29 -0
- package/reports/role-membership-counts.yaml +18 -0
- package/reports/roles-without-owner.yaml +17 -0
- package/reports/sources-needing-attention.yaml +23 -0
- package/reports/stuck-access-requests.yaml +29 -0
- package/reports/team-access.yaml +30 -0
- package/reports/terminated-users-with-active-accounts.yaml +46 -0
- package/reports/uncorrelated-accounts.yaml +38 -0
- package/ui/js/00-setup.js +6 -0
- package/ui/js/01-small-helpers.js +143 -0
- package/ui/js/02-connection.js +150 -0
- package/ui/js/03-health-check.js +17 -0
- package/ui/js/04-library.js +135 -0
- package/ui/js/05-pickers.js +163 -0
- package/ui/js/06-report-view.js +157 -0
- package/ui/js/07-fields.js +85 -0
- package/ui/js/08-designer.js +360 -0
- package/ui/js/09-yaml.js +22 -0
- package/ui/js/10-instant-check.js +171 -0
- package/ui/js/11-lookup.js +161 -0
- package/ui/js/12-tenant.js +115 -0
- package/ui/js/13-source-configuration-and-diagnostics.js +64 -0
- package/ui/js/14-certifications.js +68 -0
- package/ui/js/15-monthly-report.js +24 -0
- package/ui/js/16-ownership.js +39 -0
- package/ui/js/17-compare-tenants.js +102 -0
- package/ui/js/18-audit.js +181 -0
- package/ui/js/19-insights.js +108 -0
- package/ui/js/20-role-mining.js +35 -0
- package/ui/js/21-share-reports.js +45 -0
- package/ui/js/22-partner-overview-all-customer-tenants.js +228 -0
- package/ui/js/23-in-app-guidance.js +217 -0
- package/ui/js/24-role-tools.js +220 -0
- package/ui/js/25-schedules.js +264 -0
- package/ui/js/26-start.js +7 -0
- package/ui/js/27-warnings.js +224 -0
- package/ui/js/28-audit-readiness.js +99 -0
- package/ui/js/29-lifecycle.js +182 -0
- package/ui/js/30-labs.js +265 -0
- package/ui/js/31-build.js +203 -0
- package/ui/js/32-lab-examples.js +148 -0
- package/ui/js/33-finder.js +89 -0
- package/ui/js/34-governance.js +129 -0
- package/ui/js/35-watch.js +266 -0
- package/ui/js/36-model.js +247 -0
- package/ui/js/37-logs-and-watch.js +224 -0
- package/ui/shell.html +112 -0
- package/ui/style.css +350 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// ---------- designer ----------
|
|
2
|
+
var TEMPLATES = [
|
|
3
|
+
{ key: 'people', label: 'People', desc: 'One row per identity', icon: 'people', dataset: 'identities', cols: ['identity.displayName', 'identity.email', 'identity.attributes.department', 'identity.attributes.cloudLifecycleState', 'identity.manager.displayName'] },
|
|
4
|
+
{ key: 'people-accounts', label: 'People and their accounts', desc: 'One row per account of each person', icon: 'apps', dataset: 'identities', expand: 'identity.accounts', cols: ['identity.displayName', 'identity.attributes.cloudLifecycleState', 'account.source.name', 'account.name', 'account.disabled'] },
|
|
5
|
+
{ key: 'people-access', label: 'People and their access', desc: 'One row per role, access profile or entitlement held', icon: 'layers', dataset: 'identities', expand: 'identity.access', cols: ['identity.displayName', 'identity.email', 'access.type', 'access.displayName', 'access.source.name', 'access.privileged'] },
|
|
6
|
+
{ key: 'accounts', label: 'Accounts', desc: 'All accounts, linked or not', icon: 'apps', dataset: 'accounts', cols: ['account.sourceName', 'account.name', 'account.nativeIdentity', 'account.uncorrelated', 'account.disabled'] },
|
|
7
|
+
{ key: 'entitlements', label: 'Entitlements', desc: 'Groups, profiles, permissions', icon: 'layers', dataset: 'entitlements', cols: ['entitlement.source.name', 'entitlement.name', 'entitlement.owner.name', 'entitlement.privileged', 'entitlement.requestable'] },
|
|
8
|
+
{ key: 'roles', label: 'Roles', desc: 'Role catalog', icon: 'layers', dataset: 'roles', cols: ['role.name', 'role.owner.name', 'role.enabled', 'role.requestable', 'role.accessProfileCount'] },
|
|
9
|
+
{ key: 'accessProfiles', label: 'Access profiles', desc: 'Access profile catalog', icon: 'layers', dataset: 'accessProfiles', cols: ['accessProfile.source.name', 'accessProfile.name', 'accessProfile.owner.name', 'accessProfile.enabled', 'accessProfile.requestable'] },
|
|
10
|
+
{ key: 'sources', label: 'Sources', desc: 'Connected applications', icon: 'db', dataset: 'sources', cols: ['source.name', 'source.type', 'source.status', 'source.owner.name', 'source.authoritative'] },
|
|
11
|
+
{ key: 'events', label: 'Audit events', desc: 'What happened, when, by whom', icon: 'pulse', dataset: 'events', cols: ['event.created', 'event.name', 'event.type', 'event.status', 'event.target.name', 'event.actor.name'] },
|
|
12
|
+
{ key: 'accessRequests', label: 'Access requests', desc: 'Requests and where they stand', icon: 'inbox', dataset: 'accessRequests', cols: ['request.created', 'request.requestedFor.name', 'request.name', 'request.type', 'request.state'] },
|
|
13
|
+
{ key: 'certificationItems', label: 'Review decisions', desc: 'Certification items and decisions', icon: 'cert', dataset: 'certificationItems', cols: ['item.campaign.name', 'item.certification.reviewer.name', 'item.identitySummary.name', 'item.accessSummary.access.name', 'item.decision'] },
|
|
14
|
+
{ key: 'activities', label: 'Account activities', desc: 'Provisioning: creates, changes, errors', icon: 'pulse', dataset: 'accountActivities', cols: ['activity.created', 'activity.action', 'activity.recipient.name', 'activity.sources', 'activity.status', 'activity.errors'] },
|
|
15
|
+
{ key: 'mappings', label: 'Identity mappings', desc: 'Where each identity attribute comes from', icon: 'db', dataset: 'identityProfiles', expand: 'profile.mappings', cols: ['profile.name', 'mapping.attribute', 'mapping.kind', 'mapping.source', 'mapping.sourceAttribute', 'mapping.transform'] },
|
|
16
|
+
{ key: 'campaigns', label: 'Campaigns', desc: 'Certification campaigns', icon: 'cert', dataset: 'campaigns', cols: ['campaign.name', 'campaign.status', 'campaign.deadline', 'campaign.totalCertifications', 'campaign.completedCertifications'] }
|
|
17
|
+
];
|
|
18
|
+
function templateFor(d) {
|
|
19
|
+
return TEMPLATES.filter(function (t) { return t.dataset === d.from.dataset && (t.expand || '') === (d.expand ? d.expand.path : ''); })[0];
|
|
20
|
+
}
|
|
21
|
+
function applyTemplate(d, t) {
|
|
22
|
+
d.from = { dataset: t.dataset };
|
|
23
|
+
if (t.expand) d.expand = { path: t.expand, as: t.expand === 'identity.access' ? 'access' : t.expand === 'profile.mappings' ? 'mapping' : 'account' }; else delete d.expand;
|
|
24
|
+
delete d.where; delete d.joins; delete d.filter; delete d.sort; delete d.group; delete d.limit;
|
|
25
|
+
Object.keys(d.params || {}).forEach(function (k) { delete d.params[k]; });
|
|
26
|
+
delete d.params;
|
|
27
|
+
var ds = datasetOf(t.dataset);
|
|
28
|
+
d.columns = t.cols.map(function (p) {
|
|
29
|
+
var root = p.split('.')[0], rest = p.split('.').slice(1).join('.');
|
|
30
|
+
var list = root === (ds.alias) ? ds.fields : (ds.itemFields && ds.itemFields[(t.expand || '').split('.').slice(1).join('.')]) || [];
|
|
31
|
+
var f = list.filter(function (x) { return x.path === rest; })[0];
|
|
32
|
+
return { field: p, label: f ? f.label : undefined, format: f ? formatFor(f.type) : undefined };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function newReport() {
|
|
36
|
+
var def = { id: 'my-report-' + Date.now().toString(36), name: 'New report', category: 'My reports', from: { dataset: 'identities' } };
|
|
37
|
+
applyTemplate(def, TEMPLATES[0]);
|
|
38
|
+
state.current = { source: null, def: def, custom: true, isNew: true };
|
|
39
|
+
state.tab = 'design';
|
|
40
|
+
state.result = null;
|
|
41
|
+
state.groupBy = '';
|
|
42
|
+
state.runError = null;
|
|
43
|
+
state.paramValues = {};
|
|
44
|
+
state.dirty = true;
|
|
45
|
+
renderLibrary();
|
|
46
|
+
renderMain();
|
|
47
|
+
}
|
|
48
|
+
$('btn-new').addEventListener('click', newReport);
|
|
49
|
+
|
|
50
|
+
function changed() { state.dirty = true; state.current.yaml = null; }
|
|
51
|
+
function card(stepNo, iconName, title, hint) {
|
|
52
|
+
return el('section', { className: 'card' }, el('div', { className: 'card-h' },
|
|
53
|
+
el('h3', {}, stepNo ? el('span', { className: 'step', text: String(stepNo) }) : icon(iconName), title),
|
|
54
|
+
hint ? el('span', { className: 'muted small', text: hint }) : null));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function renderDesign(w) {
|
|
58
|
+
var c = state.current, d = c.def, ds = datasetOf(d.from.dataset);
|
|
59
|
+
ensureDisc(d.from.dataset);
|
|
60
|
+
var disc = state.disc[d.from.dataset] || {};
|
|
61
|
+
|
|
62
|
+
// about
|
|
63
|
+
var nameIn = el('input', { className: 'input', value: d.name });
|
|
64
|
+
nameIn.addEventListener('input', function () { d.name = nameIn.value; changed(); });
|
|
65
|
+
var descIn = el('input', { className: 'input', value: d.description || '', placeholder: 'What this report shows and who it is for' });
|
|
66
|
+
descIn.addEventListener('input', function () { d.description = descIn.value || undefined; changed(); });
|
|
67
|
+
var about = card(0, 'file', 'About this report');
|
|
68
|
+
about.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:1fr 2fr' },
|
|
69
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Name' }), nameIn),
|
|
70
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Description' }), descIn)));
|
|
71
|
+
if (!c.custom) about.appendChild(el('div', { className: 'note', text: 'This is a ready-made report. Your changes are saved as your own copy under "My reports".' }));
|
|
72
|
+
w.appendChild(about);
|
|
73
|
+
|
|
74
|
+
// 1. data
|
|
75
|
+
var tpl = templateFor(d);
|
|
76
|
+
var data = card(1, null, 'What do you want a row to be?', disc.loading ? 'reading a sample of your tenant...' : disc.sampled !== undefined ? 'fields checked against ' + disc.sampled + ' records of your tenant' : '');
|
|
77
|
+
data.appendChild(el('div', { className: 'tiles' }, TEMPLATES.map(function (t) {
|
|
78
|
+
return el('button', { className: 'tile' + (tpl === t ? ' active' : ''), onclick: function () {
|
|
79
|
+
if (tpl === t) return;
|
|
80
|
+
if ((d.filter || d.where || d.group) && !confirm('Start over with "' + t.label + '"? Filters and columns are reset.')) return;
|
|
81
|
+
applyTemplate(d, t); changed(); renderMain();
|
|
82
|
+
} }, catIcon({ people: 'People', apps: 'Application owners', layers: 'Access model', db: 'Hygiene', pulse: 'Operations', inbox: 'Requests', cert: 'Certifications' }[t.icon]), el('div', {}, el('b', { text: t.label }), el('span', { text: t.desc })));
|
|
83
|
+
})));
|
|
84
|
+
if (!tpl) data.appendChild(el('div', { className: 'note', text: 'This report reads ' + ds.label.toLowerCase() + (d.expand ? ', one row per item of ' + d.expand.path : '') + '. Pick a tile to start over with another kind of row.' }));
|
|
85
|
+
if (disc.error) data.appendChild(el('div', { className: 'note', text: 'Could not read a sample from your tenant, so only the standard fields are offered. ' + disc.error }));
|
|
86
|
+
if (d.where || (d.expand && d.expand.where) || (d.joins && d.joins.length)) {
|
|
87
|
+
data.appendChild(el('div', { className: 'note', text: 'This report also has built-in rules and lookups. They are kept as they are; see the YAML tab.' }));
|
|
88
|
+
}
|
|
89
|
+
w.appendChild(data);
|
|
90
|
+
|
|
91
|
+
// 2. filters
|
|
92
|
+
w.appendChild(filtersCard(d));
|
|
93
|
+
|
|
94
|
+
// 3. columns or counts
|
|
95
|
+
w.appendChild(columnsCard(d));
|
|
96
|
+
|
|
97
|
+
// 4. sort and limit
|
|
98
|
+
var sortCard = card(4, null, 'Order and size');
|
|
99
|
+
var s0 = (d.sort && d.sort[0]) || '';
|
|
100
|
+
var dir = el('select', { className: 'input' }, el('option', { value: '', text: 'A → Z, smallest, oldest first' }), el('option', { value: '-', text: 'Z → A, largest, newest first' }));
|
|
101
|
+
dir.value = s0.charAt(0) === '-' ? '-' : '';
|
|
102
|
+
var sortField = s0.replace(/^[-+]/, '');
|
|
103
|
+
var writeSort = function () { if (sortField) d.sort = [dir.value + sortField]; else delete d.sort; changed(); };
|
|
104
|
+
dir.addEventListener('change', writeSort);
|
|
105
|
+
var lim = el('input', { className: 'input', type: 'number', min: '1', placeholder: 'all rows', value: d.limit || '' });
|
|
106
|
+
lim.addEventListener('input', function () { var n = Number(lim.value); if (lim.value && n > 0) d.limit = Math.floor(n); else delete d.limit; changed(); });
|
|
107
|
+
sortCard.appendChild(el('div', { className: 'grid' },
|
|
108
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Sort by' }), fieldSelect(d, sortField, function (v) { sortField = v; writeSort(); }, { empty: 'Report order' })),
|
|
109
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Direction' }), dir),
|
|
110
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Only the first' }), lim)));
|
|
111
|
+
w.appendChild(sortCard);
|
|
112
|
+
|
|
113
|
+
// advanced
|
|
114
|
+
var search = ds.kind === 'search';
|
|
115
|
+
var qv = search ? d.from.query : d.from.filter;
|
|
116
|
+
var qIn = el('input', { className: 'input', value: Array.isArray(qv) ? qv.join(search ? ' AND ' : ' and ') : (qv || ''), placeholder: ds.hint || '' });
|
|
117
|
+
qIn.addEventListener('input', function () {
|
|
118
|
+
var key = search ? 'query' : 'filter';
|
|
119
|
+
if (qIn.value.trim()) d.from[key] = qIn.value; else delete d.from[key];
|
|
120
|
+
changed();
|
|
121
|
+
});
|
|
122
|
+
w.appendChild(el('section', { className: 'card' }, el('details', { className: 'adv' }, el('summary', { text: 'Advanced: make big reports faster' }),
|
|
123
|
+
el('p', { className: 'muted small', text: search ? 'An ISC search query narrows what is read from the tenant before your filters run. Your filters above still decide the result.' : 'An ISC API filter narrows what is read from the tenant before your filters run.' }),
|
|
124
|
+
el('label', { className: 'field' }, el('span', { className: 'lbl', text: search ? 'Search query' : 'API filter' }), qIn))));
|
|
125
|
+
|
|
126
|
+
// values to try the asked filters with
|
|
127
|
+
if (d.params && Object.keys(d.params).length) {
|
|
128
|
+
state.paramValues = state.paramValues || {};
|
|
129
|
+
var tc = card(0, 'sliders', 'Try it with', 'these are asked each time the report runs');
|
|
130
|
+
tc.appendChild(paramsGrid(d.params, state.paramValues, null, d));
|
|
131
|
+
w.appendChild(tc);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// actions
|
|
135
|
+
var msg = el('span', { className: 'muted small' });
|
|
136
|
+
w.appendChild(el('div', { className: 'actionbar' },
|
|
137
|
+
el('button', { className: 'btn', onclick: function () { run(500); setTimeout(function () { var o = $('run-out'); if (o) o.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 50); } }, icon('eye'), 'Preview'),
|
|
138
|
+
el('button', { className: 'btn primary', onclick: function () { save(msg); } }, icon('save'), c.custom ? 'Save' : 'Save as my report'),
|
|
139
|
+
c.custom && !c.isNew ? el('button', { className: 'btn ghost danger', onclick: function () {
|
|
140
|
+
if (!confirm('Delete "' + c.def.name + '"?')) return;
|
|
141
|
+
api('/api/reports/' + c.def.id, 'DELETE').then(function () { state.current = null; toast('Report deleted'); loadLibrary(); }).catch(function (e) { msg.textContent = errorText(e); });
|
|
142
|
+
} }, icon('trash'), 'Delete') : null,
|
|
143
|
+
msg));
|
|
144
|
+
w.appendChild(el('div', { id: 'run-out' }));
|
|
145
|
+
renderResult();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function filtersCard(d) {
|
|
149
|
+
var fc = card(2, null, 'Which rows?', 'leave empty for all');
|
|
150
|
+
var f = d.filter;
|
|
151
|
+
var list = !f ? [] : f.all ? f.all : f.any ? f.any : f.not ? null : [f];
|
|
152
|
+
var flat = list && list.every(function (x) { return typeof x.field === 'string'; });
|
|
153
|
+
if (!flat) { fc.appendChild(el('div', { className: 'muted', text: 'These filters are nested; edit them in the YAML tab.' })); return fc; }
|
|
154
|
+
var mode = f && f.any ? 'any' : 'all';
|
|
155
|
+
var write = function () {
|
|
156
|
+
list.forEach(function (x) { if (!needsValue(x.op)) delete x.value; });
|
|
157
|
+
var valid = list.filter(function (x) { return x.field; });
|
|
158
|
+
if (!valid.length) delete d.filter; else if (valid.length === 1) d.filter = valid[0]; else d.filter = mode === 'any' ? { any: valid } : { all: valid };
|
|
159
|
+
changed();
|
|
160
|
+
};
|
|
161
|
+
if (list.length > 1) {
|
|
162
|
+
var modeSel = el('select', { className: 'input', style: 'width:auto' }, el('option', { value: 'all', text: 'all' }), el('option', { value: 'any', text: 'any' }));
|
|
163
|
+
modeSel.value = mode;
|
|
164
|
+
modeSel.addEventListener('change', function () { mode = modeSel.value; write(); });
|
|
165
|
+
fc.appendChild(el('div', { className: 'joiner' }, 'Keep rows that match', modeSel, 'of these:'));
|
|
166
|
+
}
|
|
167
|
+
list.forEach(function (x, i) { fc.appendChild(conditionRow(d, x, function () { write(); }, function () { removeAsk(d, x); list.splice(i, 1); write(); renderMain(); })); });
|
|
168
|
+
fc.appendChild(el('button', { className: 'btn', onclick: function () {
|
|
169
|
+
var first = flatFields(d)[0];
|
|
170
|
+
list.push({ field: first ? first.value : '', op: opsFor(first ? first.type : 'string')[0][0], value: '' });
|
|
171
|
+
if (!needsValue(list[list.length - 1].op)) delete list[list.length - 1].value;
|
|
172
|
+
write(); renderMain();
|
|
173
|
+
} }, icon('plus'), 'Add a filter'));
|
|
174
|
+
return fc;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function paramNameFor(d, label) {
|
|
178
|
+
var base = label.replace(/[^A-Za-z0-9 ]/g, ' ').trim().split(/\s+/).map(function (w, i) { w = w.toLowerCase(); return i ? w.charAt(0).toUpperCase() + w.slice(1) : w; }).join('') || 'value';
|
|
179
|
+
if (/^[0-9]/.test(base)) base = 'p' + base;
|
|
180
|
+
var n = base, k = 2;
|
|
181
|
+
while (d.params && d.params[n]) n = base + k++;
|
|
182
|
+
return n;
|
|
183
|
+
}
|
|
184
|
+
function removeAsk(d, x) {
|
|
185
|
+
var m = typeof x.value === 'string' && ASK.exec(x.value);
|
|
186
|
+
if (m && d.params) { delete d.params[m[1]]; if (!Object.keys(d.params).length) delete d.params; }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function conditionRow(d, x, write, remove) {
|
|
190
|
+
var info = fieldInfo(d, x.field);
|
|
191
|
+
var ops = opsFor(info.type);
|
|
192
|
+
if (!ops.some(function (o) { return o[0] === x.op; })) ops = ops.concat([[x.op, (state.catalog.operators.filter(function (o) { return o.op === x.op; })[0] || { label: x.op }).label]]);
|
|
193
|
+
var askM = typeof x.value === 'string' && ASK.exec(x.value);
|
|
194
|
+
var fieldSel = fieldSelect(d, x.field, function (v) {
|
|
195
|
+
removeAsk(d, x);
|
|
196
|
+
x.field = v;
|
|
197
|
+
var t = fieldInfo(d, v).type;
|
|
198
|
+
x.op = opsFor(t)[0][0];
|
|
199
|
+
if (needsValue(x.op)) x.value = ''; else delete x.value;
|
|
200
|
+
write(); renderMain();
|
|
201
|
+
});
|
|
202
|
+
var opSel = el('select', { className: 'input' }, ops.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));
|
|
203
|
+
opSel.value = x.op;
|
|
204
|
+
opSel.addEventListener('change', function () {
|
|
205
|
+
var wasList = x.op === 'in' || x.op === 'notIn';
|
|
206
|
+
x.op = opSel.value;
|
|
207
|
+
var isList = x.op === 'in' || x.op === 'notIn';
|
|
208
|
+
if (!needsValue(x.op)) { removeAsk(d, x); delete x.value; }
|
|
209
|
+
else if (!askM && wasList !== isList) x.value = isList ? (x.value ? [String(x.value)] : []) : (Array.isArray(x.value) ? (x.value[0] || '') : x.value || '');
|
|
210
|
+
else if (askM) { var p = d.params[askM[1]]; p.type = isList ? 'list' : (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') ? 'number' : 'string'; }
|
|
211
|
+
write(); renderMain();
|
|
212
|
+
});
|
|
213
|
+
var valueBox = el('div');
|
|
214
|
+
if (askM) {
|
|
215
|
+
var p = (d.params || {})[askM[1]] || {};
|
|
216
|
+
var q = el('input', { className: 'input', value: p.description || '', placeholder: 'Question shown when running' });
|
|
217
|
+
q.addEventListener('input', function () { p.description = q.value || undefined; changed(); });
|
|
218
|
+
valueBox.appendChild(q);
|
|
219
|
+
} else if (needsValue(x.op)) {
|
|
220
|
+
valueBox.appendChild(valueEditor(d, x, info, write));
|
|
221
|
+
}
|
|
222
|
+
var askBox = el('input', { type: 'checkbox', checked: !!askM });
|
|
223
|
+
askBox.addEventListener('change', function () {
|
|
224
|
+
if (askBox.checked) {
|
|
225
|
+
// Source names become a source drop-down: ask for the source, filter on its ID.
|
|
226
|
+
var idField = isSourceName(x.field) ? x.field.replace(/source\.name$|source\.displayableName$/, 'source.id').replace(/sourceName$/, 'sourceId') : null;
|
|
227
|
+
if (idField && flatFields(d).some(function (f) { return f.value === idField; })) { x.field = idField; x.value = Array.isArray(x.value) ? [] : ''; }
|
|
228
|
+
var listOp = x.op === 'in' || x.op === 'notIn';
|
|
229
|
+
var numeric = x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number';
|
|
230
|
+
var name = paramNameFor(d, fieldInfo(d, x.field).label);
|
|
231
|
+
d.params = d.params || {};
|
|
232
|
+
var spec = { type: listOp ? 'list' : numeric ? 'number' : 'string', description: fieldInfo(d, x.field).label + (numeric && x.op !== 'eq' ? ' (days)' : '') };
|
|
233
|
+
if (isSourceId(x.field)) spec.pick = 'sources';
|
|
234
|
+
var cur = x.value;
|
|
235
|
+
if (cur !== '' && cur !== undefined && !(Array.isArray(cur) && !cur.length) && !isSourceId(x.field)) spec['default'] = cur;
|
|
236
|
+
d.params[name] = spec;
|
|
237
|
+
x.value = '${' + name + '}';
|
|
238
|
+
state.paramValues = state.paramValues || {};
|
|
239
|
+
state.paramValues[name] = spec['default'] !== undefined ? spec['default'] : spec.type === 'list' ? [] : '';
|
|
240
|
+
} else {
|
|
241
|
+
var m = ASK.exec(x.value);
|
|
242
|
+
var prev = m && d.params && d.params[m[1]];
|
|
243
|
+
removeAsk(d, x);
|
|
244
|
+
x.value = prev && prev['default'] !== undefined ? prev['default'] : (x.op === 'in' || x.op === 'notIn') ? [] : '';
|
|
245
|
+
}
|
|
246
|
+
write(); renderMain();
|
|
247
|
+
});
|
|
248
|
+
var ask = needsValue(x.op) ? el('label', { className: 'ask' }, askBox, el('span', { text: askM ? 'Asked when the report runs (and in schedules).' : 'Ask for this value each time the report runs' })) : null;
|
|
249
|
+
return el('div', { className: 'cond' }, fieldSel, opSel, valueBox,
|
|
250
|
+
el('button', { className: 'btn icon ghost', title: 'Remove this filter', onclick: remove }, icon('x')), ask);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function valueEditor(d, x, info, write) {
|
|
254
|
+
var listOp = x.op === 'in' || x.op === 'notIn';
|
|
255
|
+
var path = info.path || x.field;
|
|
256
|
+
if (isSourceId(path) || isSourceName(path)) {
|
|
257
|
+
return picker({ options: loadPick('sources'), multiple: listOp, value: x.value, valueKey: isSourceId(path) ? 'value' : 'label', onChange: function (v) { x.value = v; write(); }, placeholder: listOp ? 'Pick sources' : 'Pick a source' });
|
|
258
|
+
}
|
|
259
|
+
if (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') {
|
|
260
|
+
var n = el('input', { className: 'input', type: 'number', value: x.value === undefined ? '' : String(x.value), placeholder: x.op === 'newerThanDays' || x.op === 'olderThanDays' ? 'days, e.g. 30' : 'number' });
|
|
261
|
+
n.addEventListener('input', function () { x.value = n.value === '' ? '' : Number(n.value); write(); });
|
|
262
|
+
return n;
|
|
263
|
+
}
|
|
264
|
+
if (listOp) {
|
|
265
|
+
if (info.values && info.values.length && info.values.length <= 50) {
|
|
266
|
+
return picker({ options: info.values.map(function (v) { return { value: v, label: v }; }), multiple: true, value: x.value, onChange: function (v) { x.value = v; write(); }, placeholder: 'Pick or type values' });
|
|
267
|
+
}
|
|
268
|
+
return tokenInput({ value: x.value, suggestions: info.values, onChange: function (v) { x.value = v; write(); } });
|
|
269
|
+
}
|
|
270
|
+
var id = 'sv' + Math.random().toString(36).slice(2);
|
|
271
|
+
var t = el('input', { className: 'input', value: x.value === undefined ? '' : String(x.value), list: info.values && info.values.length ? id : null, placeholder: info.values && info.values.length ? 'e.g. ' + info.values.slice(0, 2).join(', ') : 'value' });
|
|
272
|
+
t.addEventListener('input', function () { x.value = t.value; write(); });
|
|
273
|
+
return el('div', {}, t, info.values && info.values.length ? el('datalist', { id: id }, info.values.map(function (v) { return el('option', { value: v }); })) : null);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function columnsCard(d) {
|
|
277
|
+
var counting = !!(d.group && d.group.by && d.group.by.length);
|
|
278
|
+
var cc = card(3, null, 'What to show', null);
|
|
279
|
+
var modeSel = el('div', { className: 'chips', style: 'margin-bottom:14px' },
|
|
280
|
+
el('button', { className: 'chip' + (!counting ? ' active' : ''), onclick: function () {
|
|
281
|
+
if (!counting) return;
|
|
282
|
+
d.columns = state.current.stash || d.columns; delete d.group; changed(); renderMain();
|
|
283
|
+
} }, icon('cols'), 'A list of rows'),
|
|
284
|
+
el('button', { className: 'chip' + (counting ? ' active' : ''), onclick: function () {
|
|
285
|
+
if (counting) return;
|
|
286
|
+
state.current.stash = clone(d.columns || []);
|
|
287
|
+
var first = (d.columns && d.columns[0] && d.columns[0].field) || (flatFields(d)[0] || {}).value;
|
|
288
|
+
d.group = { by: [first], countLabel: 'Count' };
|
|
289
|
+
syncGroupColumns(d); changed(); renderMain();
|
|
290
|
+
} }, icon('sigma'), 'Counts (summary)'));
|
|
291
|
+
cc.appendChild(modeSel);
|
|
292
|
+
if (counting) {
|
|
293
|
+
cc.appendChild(el('p', { className: 'muted small', style: 'margin-top:0', text: 'One row per combination of these fields, with how many rows have it. Largest first.' }));
|
|
294
|
+
d.group.by.forEach(function (b, i) {
|
|
295
|
+
cc.appendChild(el('div', { className: 'colrow', style: 'grid-template-columns:28px 1fr auto' }, el('span', { className: 'n', text: String(i + 1) }),
|
|
296
|
+
fieldSelect(d, b, function (v) { d.group.by[i] = v; syncGroupColumns(d); changed(); }, { counting: true }),
|
|
297
|
+
el('button', { className: 'btn icon ghost', title: 'Remove', disabled: d.group.by.length === 1, onclick: function () { d.group.by.splice(i, 1); syncGroupColumns(d); changed(); renderMain(); } }, icon('x'))));
|
|
298
|
+
});
|
|
299
|
+
if (d.group.by.length < 4) cc.appendChild(fieldSelect(d, '', function (v) { if (!v) return; d.group.by.push(v); syncGroupColumns(d); changed(); renderMain(); }, { empty: '+ Also count by...', counting: true }));
|
|
300
|
+
var cl = el('input', { className: 'input', value: d.group.countLabel || 'Count', style: 'max-width:260px' });
|
|
301
|
+
cl.addEventListener('input', function () { d.group.countLabel = cl.value || undefined; changed(); });
|
|
302
|
+
cc.appendChild(el('label', { className: 'field', style: 'margin:14px 0 0' }, el('span', { className: 'lbl', text: 'Heading of the count column' }), cl));
|
|
303
|
+
return cc;
|
|
304
|
+
}
|
|
305
|
+
var formats = [['', 'Automatic'], ['text', 'Text'], ['date', 'Date'], ['datetime', 'Date and time'], ['number', 'Number'], ['boolean', 'Yes / No'], ['list', 'List'], ['count', 'How many'], ['json', 'Raw']];
|
|
306
|
+
d.columns = d.columns || [];
|
|
307
|
+
d.columns.forEach(function (col, i) {
|
|
308
|
+
var li = el('input', { className: 'input', value: col.label || '', placeholder: fieldInfo(d, col.field).label });
|
|
309
|
+
li.addEventListener('input', function () { col.label = li.value || undefined; changed(); });
|
|
310
|
+
var fs = el('select', { className: 'input' }, formats.map(function (x) { return el('option', { value: x[0], text: x[1] }); }));
|
|
311
|
+
fs.value = col.format || '';
|
|
312
|
+
fs.addEventListener('change', function () { col.format = fs.value || undefined; changed(); });
|
|
313
|
+
var move = function (delta) {
|
|
314
|
+
var j = i + delta;
|
|
315
|
+
if (j < 0 || j >= d.columns.length) return;
|
|
316
|
+
var t = d.columns[i]; d.columns[i] = d.columns[j]; d.columns[j] = t;
|
|
317
|
+
changed(); renderMain();
|
|
318
|
+
};
|
|
319
|
+
cc.appendChild(el('div', { className: 'colrow' }, el('span', { className: 'n', text: String(i + 1) }),
|
|
320
|
+
fieldSelect(d, col.field, function (v) { col.field = v; var inf = fieldInfo(d, v); col.label = inf.label; col.format = formatFor(inf.type); changed(); renderMain(); }),
|
|
321
|
+
li, fs,
|
|
322
|
+
el('div', { className: 'bar', style: 'gap:2px' },
|
|
323
|
+
el('button', { className: 'btn icon ghost', title: 'Move up', disabled: i === 0, onclick: function () { move(-1); } }, icon('up')),
|
|
324
|
+
el('button', { className: 'btn icon ghost', title: 'Move down', disabled: i === d.columns.length - 1, onclick: function () { move(1); } }, icon('down')),
|
|
325
|
+
el('button', { className: 'btn icon ghost', title: 'Remove', onclick: function () { d.columns.splice(i, 1); changed(); renderMain(); } }, icon('x')))));
|
|
326
|
+
});
|
|
327
|
+
if (!d.columns.length) cc.appendChild(el('div', { className: 'note', text: 'Add at least one column.' }));
|
|
328
|
+
var addSel = fieldSelect(d, '', function (v) {
|
|
329
|
+
if (!v) return;
|
|
330
|
+
var inf = fieldInfo(d, v);
|
|
331
|
+
d.columns.push({ field: v, label: inf.label, format: formatFor(inf.type) });
|
|
332
|
+
changed(); renderMain();
|
|
333
|
+
}, { empty: '+ Add a column...' });
|
|
334
|
+
addSel.style.maxWidth = '420px';
|
|
335
|
+
cc.appendChild(el('div', { style: 'margin-top:10px' }, addSel));
|
|
336
|
+
return cc;
|
|
337
|
+
}
|
|
338
|
+
function syncGroupColumns(d) {
|
|
339
|
+
d.columns = d.group.by.filter(Boolean).map(function (b) { var inf = fieldInfo(d, b); return { field: b, label: inf.label, format: inf.type === 'date' ? 'date' : undefined }; });
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function save(msg) {
|
|
343
|
+
var c = state.current;
|
|
344
|
+
var def = clone(c.def);
|
|
345
|
+
if (!c.custom) {
|
|
346
|
+
def.id = def.id + '-copy';
|
|
347
|
+
def.name = def.name + ' (my copy)';
|
|
348
|
+
var n = 2;
|
|
349
|
+
while (state.reports.some(function (r) { return r.definition.id === def.id; })) def.id = c.def.id + '-copy-' + n++;
|
|
350
|
+
}
|
|
351
|
+
def.category = c.custom ? (def.category || 'My reports') : 'My reports';
|
|
352
|
+
msg.textContent = '';
|
|
353
|
+
api('/api/reports', 'POST', { definition: def }).then(function (r) {
|
|
354
|
+
toast('Saved "' + def.name + '" to My reports');
|
|
355
|
+
state.dirty = false;
|
|
356
|
+
state.current = null;
|
|
357
|
+
return loadLibrary(r.saved);
|
|
358
|
+
}).catch(function (e) { msg.textContent = ''; msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });
|
|
359
|
+
}
|
|
360
|
+
|
package/ui/js/09-yaml.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ---------- yaml ----------
|
|
2
|
+
function renderYaml(w) {
|
|
3
|
+
var c = state.current;
|
|
4
|
+
var ta = el('textarea', { className: 'yaml', spellcheck: 'false' });
|
|
5
|
+
var problems = el('div');
|
|
6
|
+
w.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'The full report definition. Copy it to share the report, or edit it directly and press Apply.' }));
|
|
7
|
+
w.appendChild(ta);
|
|
8
|
+
w.appendChild(problems);
|
|
9
|
+
w.appendChild(el('div', { className: 'bar', style: 'margin-top:12px' },
|
|
10
|
+
el('button', { className: 'btn primary', onclick: function () {
|
|
11
|
+
problems.textContent = '';
|
|
12
|
+
api('/api/parse', 'POST', { yaml: ta.value }).then(function (r) { c.def = r.definition; changed(); c.yaml = ta.value; state.tab = 'design'; toast('Applied'); renderMain(); })
|
|
13
|
+
.catch(function (e) { problems.appendChild(el('div', { className: 'error', text: errorText(e) })); });
|
|
14
|
+
} }, 'Apply'),
|
|
15
|
+
el('button', { className: 'btn', onclick: function () { navigator.clipboard.writeText(ta.value).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')));
|
|
16
|
+
if (c.yaml && !state.dirty) ta.value = c.yaml;
|
|
17
|
+
else api('/api/yaml', 'POST', { definition: c.def }).then(function (r) {
|
|
18
|
+
ta.value = r.yaml;
|
|
19
|
+
if (r.problems.length) problems.appendChild(el('div', { className: 'error', text: 'Fix before running:\n- ' + r.problems.join('\n- ') }));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// ---------- instant check ----------
|
|
2
|
+
state.chk = { results: null, meta: null, selected: null, auto: 0, timer: null, busy: null };
|
|
3
|
+
var STATUS = { ok: ['OK', 'ok'], warn: ['Attention', 'warn'], bad: ['Problem', 'bad'], error: ['Could not check', 'err'], off: ['Off', 'off'] };
|
|
4
|
+
function ago(iso) {
|
|
5
|
+
if (!iso) return '';
|
|
6
|
+
var s = Math.round((Date.now() - Date.parse(iso)) / 1000);
|
|
7
|
+
if (s < 60) return 'just now';
|
|
8
|
+
if (s < 3600) return Math.round(s / 60) + ' min ago';
|
|
9
|
+
if (s < 86400) return Math.round(s / 3600) + ' h ago';
|
|
10
|
+
return Math.round(s / 86400) + ' days ago';
|
|
11
|
+
}
|
|
12
|
+
function when(iso) { return iso ? iso.replace('T', ' ').slice(0, 16) : '—'; }
|
|
13
|
+
function sparkline(points, w, h) {
|
|
14
|
+
var NS = 'http://www.w3.org/2000/svg';
|
|
15
|
+
var svg = document.createElementNS(NS, 'svg');
|
|
16
|
+
svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);
|
|
17
|
+
svg.setAttribute('width', w); svg.setAttribute('height', h);
|
|
18
|
+
svg.setAttribute('class', 'spark');
|
|
19
|
+
var vals = (points || []).filter(function (p) { return p.value !== null && p.value !== undefined; }).slice(-30);
|
|
20
|
+
if (vals.length < 2) return svg;
|
|
21
|
+
var max = Math.max.apply(null, vals.map(function (p) { return p.value; })), min = Math.min.apply(null, vals.map(function (p) { return p.value; }));
|
|
22
|
+
var span = max - min || 1;
|
|
23
|
+
var pts = vals.map(function (p, i) { return (i * (w - 4) / (vals.length - 1) + 2).toFixed(1) + ',' + (h - 3 - ((p.value - min) / span) * (h - 6)).toFixed(1); });
|
|
24
|
+
var line = document.createElementNS(NS, 'polyline');
|
|
25
|
+
line.setAttribute('points', pts.join(' '));
|
|
26
|
+
line.setAttribute('fill', 'none'); line.setAttribute('stroke', 'currentColor'); line.setAttribute('stroke-width', '1.8'); line.setAttribute('stroke-linejoin', 'round');
|
|
27
|
+
svg.appendChild(line);
|
|
28
|
+
var last = pts[pts.length - 1].split(',');
|
|
29
|
+
var dot = document.createElementNS(NS, 'circle');
|
|
30
|
+
dot.setAttribute('cx', last[0]); dot.setAttribute('cy', last[1]); dot.setAttribute('r', '2.6'); dot.setAttribute('fill', 'currentColor');
|
|
31
|
+
svg.appendChild(dot);
|
|
32
|
+
var t = document.createElementNS(NS, 'title');
|
|
33
|
+
t.textContent = vals.length + ' checks, from ' + fmtNum(min) + ' to ' + fmtNum(max);
|
|
34
|
+
svg.appendChild(t);
|
|
35
|
+
return svg;
|
|
36
|
+
}
|
|
37
|
+
function loadCheckMeta() { return api('/api/checks').then(function (m) { state.chk.meta = m; return m; }); }
|
|
38
|
+
function runAllChecks() {
|
|
39
|
+
var c = state.chk;
|
|
40
|
+
if (c.busy) return;
|
|
41
|
+
c.busy = 'Starting the checks...'; c.error = null; renderChecks();
|
|
42
|
+
api('/api/checks/run', 'POST', {}).then(function (r) {
|
|
43
|
+
c.job = r.job;
|
|
44
|
+
pollJob(r.job, function (m) { c.busy = m; var p = $('chk-progress'); if (p) p.textContent = m; },
|
|
45
|
+
function (s) { c.busy = null; c.results = s.extra.results; c.headline = s.extra.headline; c.at = new Date().toISOString(); loadCheckMeta().then(renderChecks, renderChecks); },
|
|
46
|
+
function (e) { c.busy = null; c.error = e; renderChecks(); });
|
|
47
|
+
}).catch(function (e) { c.busy = null; c.error = errorText(e); renderChecks(); });
|
|
48
|
+
}
|
|
49
|
+
function setAuto(min) {
|
|
50
|
+
var c = state.chk;
|
|
51
|
+
c.auto = min;
|
|
52
|
+
if (c.timer) clearInterval(c.timer);
|
|
53
|
+
c.timer = min ? setInterval(function () { if (!$('checks').classList.contains('hidden')) runAllChecks(); }, min * 60000) : null;
|
|
54
|
+
}
|
|
55
|
+
function renderChecks() {
|
|
56
|
+
var c = state.chk;
|
|
57
|
+
var outer = $('checks');
|
|
58
|
+
outer.textContent = '';
|
|
59
|
+
var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
|
|
60
|
+
outer.appendChild(w);
|
|
61
|
+
if (!c.meta) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadCheckMeta().then(renderChecks, function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }
|
|
62
|
+
var autoSel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Refresh the instant check automatically' }, [[0, 'Refresh: off'], [5, 'Every 5 min'], [15, 'Every 15 min'], [30, 'Every 30 min'], [60, 'Every hour']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
|
|
63
|
+
autoSel.value = String(c.auto || 0);
|
|
64
|
+
autoSel.addEventListener('change', function () { setAuto(Number(autoSel.value)); });
|
|
65
|
+
w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:#b91c1c;background:#fdeaea' }, icon('pulse')),
|
|
66
|
+
el('div', { style: 'flex:1' }, el('h2', { text: 'Instant check' }), el('p', { className: 'desc', text: 'Every daily check in one click: provisioning, aggregations, sources, identities, requests, leavers, campaigns. Read-only.' })),
|
|
67
|
+
autoSel,
|
|
68
|
+
el('button', { className: 'btn', onclick: function () { c.showLimits = !c.showLimits; renderChecks(); } }, icon('sliders'), 'Limits'),
|
|
69
|
+
el('button', { className: 'btn primary', disabled: !!c.busy, onclick: runAllChecks }, icon('play'), c.results ? 'Check again' : 'Run all checks')));
|
|
70
|
+
if (c.showLimits) w.appendChild(limitsCard());
|
|
71
|
+
if (c.error) w.appendChild(el('div', { className: 'error', text: c.error }));
|
|
72
|
+
var trends = c.meta.trends || {};
|
|
73
|
+
var results = c.results;
|
|
74
|
+
var bad = 0, warn = 0, err = 0;
|
|
75
|
+
(results || []).forEach(function (r) { if (r.status === 'bad') bad++; else if (r.status === 'warn') warn++; else if (r.status === 'error') err++; });
|
|
76
|
+
if (c.busy) w.appendChild(el('div', { className: 'banner run' }, el('span', { className: 'spinner' }), el('span', { id: 'chk-progress', text: c.busy, style: 'flex:1' }), stopButton()));
|
|
77
|
+
else if (results) {
|
|
78
|
+
var level = bad ? 'bad' : warn || err ? 'warn' : 'ok';
|
|
79
|
+
w.appendChild(el('div', { className: 'banner ' + level },
|
|
80
|
+
el('b', { text: level === 'ok' ? 'All checks OK' : c.headline.charAt(0).toUpperCase() + c.headline.slice(1) }),
|
|
81
|
+
el('span', { text: 'Checked ' + ago(c.at) + (c.auto ? ' · refreshes every ' + c.auto + ' min' : '') }),
|
|
82
|
+
el('span', { style: 'flex:1' }),
|
|
83
|
+
c.job ? el('a', { className: 'btn sm', href: '/api/jobs/' + c.job + '/download?format=xlsx&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Summary in Excel') : null));
|
|
84
|
+
} else {
|
|
85
|
+
var lastAt = null;
|
|
86
|
+
Object.keys(trends).forEach(function (k) { var p = trends[k].points; if (p && p.length && (!lastAt || p[p.length - 1].at > lastAt)) lastAt = p[p.length - 1].at; });
|
|
87
|
+
w.appendChild(el('div', { className: 'banner idle' }, el('b', { text: lastAt ? 'Last checked ' + ago(lastAt) : 'Not checked yet' }), el('span', { text: 'Press "Run all checks". A full check takes from a few seconds to a few minutes on large tenants.' })));
|
|
88
|
+
}
|
|
89
|
+
var grid = el('div', { className: 'tiles-chk' });
|
|
90
|
+
var byId = {};
|
|
91
|
+
(results || []).forEach(function (r) { byId[r.id] = r; });
|
|
92
|
+
c.meta.checks.forEach(function (m) {
|
|
93
|
+
var r = byId[m.id];
|
|
94
|
+
var tr = trends[m.id] || {};
|
|
95
|
+
var off = m.optIn ? !(m.settings && m.settings.enabled === true) : (m.settings && m.settings.enabled === false);
|
|
96
|
+
var st = off ? 'off' : r ? r.status : (tr.status || null);
|
|
97
|
+
var stale = !r && st;
|
|
98
|
+
var tile = el('button', { className: 'chk ' + (st ? STATUS[st][1] : 'none') + (c.selected === m.id ? ' sel' : '') + (stale ? ' stale' : ''), onclick: function () { c.selected = c.selected === m.id ? null : m.id; renderChecks(); } });
|
|
99
|
+
tile.appendChild(el('div', { className: 'chk-top' }, el('span', { className: 'chk-dot' }), el('span', { className: 'chk-label', text: m.label }), st ? el('span', { className: 'chk-st', text: STATUS[st][0] + (stale && !off ? ' (last time)' : '') }) : null));
|
|
100
|
+
var value = r ? r.value : (tr.points && tr.points.length ? tr.points[tr.points.length - 1].value : null);
|
|
101
|
+
tile.appendChild(el('div', { className: 'chk-mid' }, el('b', { text: value === null || value === undefined ? '—' : fmtNum(value) }), el('span', { className: 'muted', text: value === 1 ? (m.unit === 'people' ? 'person' : m.unit.replace(/ies$/, 'y').replace(/s$/, '')) : m.unit }),
|
|
102
|
+
el('span', { style: 'flex:1' }), sparkline(tr.points, 92, 30)));
|
|
103
|
+
tile.appendChild(el('div', { className: 'chk-sum', text: off ? (m.optIn && !(m.settings && m.settings.enabled === false) ? 'Needs setting up: save the end-date attribute on Warnings > End dates.' : 'Switched off in Limits.') : r ? r.summary : (tr.summary || m.description) }));
|
|
104
|
+
if (r && r.newCount && !m.growth) tile.appendChild(el('span', { className: 'pill blue', text: r.newCount + ' new' }));
|
|
105
|
+
if (r && r.top && r.top.length) tile.appendChild(el('div', { className: 'chk-top3' }, r.top.map(function (x) { return el('div', {}, el('span', { text: x.label }), el('b', { text: fmtNum(x.count) })); })));
|
|
106
|
+
grid.appendChild(tile);
|
|
107
|
+
});
|
|
108
|
+
w.appendChild(grid);
|
|
109
|
+
if (c.selected) w.appendChild(checkDetail(c.meta.checks.filter(function (m) { return m.id === c.selected; })[0], byId[c.selected], trends[c.selected]));
|
|
110
|
+
}
|
|
111
|
+
function checkDetail(m, r, tr) {
|
|
112
|
+
var card = el('section', { className: 'card', style: 'margin-top:16px' });
|
|
113
|
+
card.appendChild(el('div', { className: 'card-h' }, el('h3', { text: m.label }),
|
|
114
|
+
m.report ? el('button', { className: 'btn sm', onclick: function () {
|
|
115
|
+
var rep = state.reports.filter(function (x) { return x.definition.id === m.report; })[0];
|
|
116
|
+
if (!rep) return;
|
|
117
|
+
showPage('reports'); select(rep);
|
|
118
|
+
if (r && r.params) Object.keys(r.params).forEach(function (k) { state.paramValues[k] = r.params[k]; });
|
|
119
|
+
renderMain();
|
|
120
|
+
} }, icon('file'), 'Open the full report') : null));
|
|
121
|
+
card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: m.description + ' Amber from ' + fmtNum((m.settings.warn || m.defaults.warn)) + ', red from ' + fmtNum((m.settings.bad || m.defaults.bad)) + (m.growth ? ' more than the previous check.' : '.') }));
|
|
122
|
+
var pts = (tr && tr.points) || [];
|
|
123
|
+
if (pts.length >= 2) {
|
|
124
|
+
card.appendChild(el('div', { className: 'trend' }, el('div', { className: 'muted small', text: 'Trend (' + pts.length + ' checks since ' + when(pts[0].at).slice(0, 10) + ')' }), sparkline(pts, 640, 90)));
|
|
125
|
+
}
|
|
126
|
+
var fx = fixCard(m.id);
|
|
127
|
+
if (fx && (!r || r.status !== 'ok')) card.appendChild(fx);
|
|
128
|
+
if (!r) { card.appendChild(el('div', { className: 'muted', text: 'Run the checks to see the details.' })); return card; }
|
|
129
|
+
if (r.newItems && r.newItems.length) card.appendChild(el('div', { className: 'note', text: 'New since the previous check: ' + r.newItems.join('; ') + (r.newCount > r.newItems.length ? ' and ' + (r.newCount - r.newItems.length) + ' more' : '') }));
|
|
130
|
+
if (r.status === 'error') { card.appendChild(el('div', { className: 'error', text: r.error })); return card; }
|
|
131
|
+
if (!r.rows.length) { card.appendChild(el('div', { className: 'empty', text: 'Nothing found. Good.' })); return card; }
|
|
132
|
+
card.appendChild(el('div', { className: 'table-wrap', style: 'max-height:50vh' }, el('table', {},
|
|
133
|
+
el('thead', {}, el('tr', {}, r.columns.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }), m.growth ? null : el('th', { style: 'cursor:default' }, el('span', { className: 'sr-only', text: 'Exception' })))),
|
|
134
|
+
el('tbody', {}, r.rows.map(function (row, i) {
|
|
135
|
+
var key = r.rowKeys && r.rowKeys[i];
|
|
136
|
+
return el('tr', {}, row.map(function (v) { return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) }); }),
|
|
137
|
+
m.growth ? null : el('td', { style: 'width:1%;white-space:nowrap' }, key ? el('button', { className: 'btn sm', title: 'Accept this item as an exception, with a reason and an end date', 'aria-label': 'Accept ' + key + ' as an exception', onclick: function () { acceptDialog(m, key, runAllChecks); } }, 'Accept…') : null));
|
|
138
|
+
})))));
|
|
139
|
+
if (r.value > r.rows.length) card.appendChild(el('div', { className: 'note', text: 'Showing ' + r.rows.length + ' of ' + fmtNum(r.value) + '. Open the full report for everything.' }));
|
|
140
|
+
if (r.accepted) card.appendChild(el('p', { className: 'muted small' }, fmtNum(r.accepted) + ' accepted as exception' + (r.accepted === 1 ? '' : 's') + ' and left out. ', el('button', { className: 'btn link', style: 'padding:0', text: 'See exceptions', onclick: function () { state.au.tab = 'exceptions'; showPage('certs'); } })));
|
|
141
|
+
return card;
|
|
142
|
+
}
|
|
143
|
+
function limitsCard() {
|
|
144
|
+
var c = state.chk;
|
|
145
|
+
var edits = {};
|
|
146
|
+
var rows = c.meta.checks.map(function (m) {
|
|
147
|
+
var s = m.settings || {};
|
|
148
|
+
var e = edits[m.id] = { enabled: m.optIn ? s.enabled === true : s.enabled !== false, optIn: !!m.optIn, warn: s.warn, bad: s.bad, days: s.days };
|
|
149
|
+
var on = el('input', { type: 'checkbox', checked: e.enabled });
|
|
150
|
+
on.addEventListener('change', function () { e.enabled = on.checked; });
|
|
151
|
+
var num = function (key, ph) {
|
|
152
|
+
var i = el('input', { className: 'input', type: 'number', min: '1', value: e[key] === undefined ? '' : String(e[key]), placeholder: String(ph), style: 'width:110px;padding:5px 8px' });
|
|
153
|
+
i.addEventListener('input', function () { e[key] = i.value === '' ? undefined : Number(i.value); });
|
|
154
|
+
return i;
|
|
155
|
+
};
|
|
156
|
+
return el('tr', {}, el('td', {}, el('label', { className: 'check' }, on, m.label)),
|
|
157
|
+
el('td', {}, num('warn', m.defaults.warn)), el('td', {}, num('bad', m.defaults.bad)),
|
|
158
|
+
el('td', {}, m.defaults.days !== undefined ? num('days', m.defaults.days) : el('span', { className: 'muted', text: '—' })),
|
|
159
|
+
el('td', { className: 'muted small', text: m.growth ? 'limits apply to the increase' : '' }));
|
|
160
|
+
});
|
|
161
|
+
var msg = el('span');
|
|
162
|
+
return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Limits' }), el('span', { className: 'muted small', text: 'empty = default (shown in grey). Also used by scheduled instant checks.' })),
|
|
163
|
+
el('div', { className: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ['Check', 'Amber from', 'Red from', 'Days', ''].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))), el('tbody', {}, rows))),
|
|
164
|
+
el('div', { className: 'bar', style: 'margin-top:12px' }, el('button', { className: 'btn primary', onclick: function () {
|
|
165
|
+
var out = {};
|
|
166
|
+
Object.keys(edits).forEach(function (k) { var e = edits[k]; var o = {}; if (!e.enabled) o.enabled = false; else if (e.optIn) o.enabled = true; ['warn', 'bad', 'days'].forEach(function (x) { if (e[x] !== undefined && !isNaN(e[x])) o[x] = e[x]; }); out[k] = o; });
|
|
167
|
+
msg.textContent = '';
|
|
168
|
+
api('/api/checks/settings', 'PUT', { checks: out }).then(function () { toast('Limits saved'); c.showLimits = false; return loadCheckMeta(); }).then(renderChecks).catch(function (e) { msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });
|
|
169
|
+
} }, icon('save'), 'Save limits'), msg));
|
|
170
|
+
}
|
|
171
|
+
|