mirror of
https://github.com/LukeHagar/ui-development-kit.git
synced 2025-12-09 12:57:44 +00:00
Add list-of-identities report and corresponding page to nav
This example report showcases pagination with a default value of 5 records
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { getLimit, getPage, getSorters } from '$lib/Utils.js';
|
||||
import { createConfiguration } from '$lib/sailpoint/sdk.js';
|
||||
import type { IdentityDocument, Search, SearchApiSearchPostRequest } from 'sailpoint-api-client';
|
||||
import { SearchApi } from 'sailpoint-api-client';
|
||||
|
||||
export const load = async ({ url, locals }) => {
|
||||
const config = createConfiguration(locals.session!.baseUrl, locals.idnSession!.access_token);
|
||||
const api = new SearchApi(config);
|
||||
|
||||
const page = getPage(url);
|
||||
const limit = getLimit(url);
|
||||
const sorters = getSorters(url);
|
||||
|
||||
const search: Search = {
|
||||
indices: ['identities'],
|
||||
query: {
|
||||
query: `*`
|
||||
},
|
||||
sort: sorters !== '' ? [sorters] : ['name']
|
||||
};
|
||||
|
||||
const requestParams: SearchApiSearchPostRequest = {
|
||||
search,
|
||||
offset: Number(page) * Number(limit),
|
||||
limit: Number(limit),
|
||||
count: true
|
||||
};
|
||||
|
||||
const reportResp = api.searchPost(requestParams);
|
||||
|
||||
const totalCount = new Promise<number>((resolve) => {
|
||||
reportResp.then((response) => {
|
||||
resolve(response.headers['x-total-count']);
|
||||
});
|
||||
});
|
||||
|
||||
const reportData = new Promise<IdentityDocument[]>((resolve) => {
|
||||
reportResp.then((response) => {
|
||||
resolve(response.data);
|
||||
});
|
||||
});
|
||||
|
||||
return { reportData, totalCount, params: { page, limit, sorters } };
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
<script lang="ts">
|
||||
import Paginator from '$lib/Components/Paginator.svelte';
|
||||
import Progress from '$lib/Components/Progress.svelte';
|
||||
import {
|
||||
TriggerCodeModal,
|
||||
createOnAmountChange,
|
||||
createOnGo,
|
||||
createOnPageChange,
|
||||
formatDate
|
||||
} from '$lib/Utils.js';
|
||||
import { getModalStore } from '@skeletonlabs/skeleton';
|
||||
|
||||
export let data;
|
||||
|
||||
const modalStore = getModalStore();
|
||||
|
||||
$: onPageChange = createOnPageChange(
|
||||
{ ...data.params, filters: '', sorters },
|
||||
'/home/reports/list-of-identities'
|
||||
);
|
||||
$: onAmountChange = createOnAmountChange(
|
||||
{ ...data.params, filters: '', sorters },
|
||||
'/home/reports/list-of-identities'
|
||||
);
|
||||
$: onGo = createOnGo(
|
||||
{ ...data.params, filters: '', sorters },
|
||||
'/home/reports/list-of-identities'
|
||||
);
|
||||
|
||||
let sorters = data.params.sorters || '';
|
||||
</script>
|
||||
|
||||
<div class="flex justify-center flex-col align-middle gap-2">
|
||||
<div class="card p-4">
|
||||
<p class="text-2xl text-center">List of all identities</p>
|
||||
</div>
|
||||
{#await data.reportData}
|
||||
<div class="grid h-full place-content-center p-8">
|
||||
<Progress width="w-[100px]" />
|
||||
</div>
|
||||
{:then reportData}
|
||||
{#await data.totalCount then totalCount}
|
||||
{#if totalCount > 250 || Number(data.params.limit) < totalCount}
|
||||
<div class="card p-4">
|
||||
<Paginator
|
||||
{onAmountChange}
|
||||
{onGo}
|
||||
{onPageChange}
|
||||
settings={{
|
||||
page: Number(data.params.page),
|
||||
limit: Number(data.params.limit),
|
||||
size: totalCount,
|
||||
amounts: [5, 10, 50, 100, 250]
|
||||
}}
|
||||
bind:sorters
|
||||
{totalCount}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
{#if reportData.length === 0}
|
||||
<div class="card p-4">
|
||||
<p class=" text-center text-success-500">No inactive identities with access found</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="table-container">
|
||||
<table class="table">
|
||||
<thead class="table-head">
|
||||
<th> Name </th>
|
||||
<th> DisplayName </th>
|
||||
<th> Sources </th>
|
||||
<th> Created </th>
|
||||
<th> Modified </th>
|
||||
<th> Access Count </th>
|
||||
<th> Entitlement Count </th>
|
||||
<th> Role Count </th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody class="table-body">
|
||||
{#each reportData as identity}
|
||||
<tr>
|
||||
<td>
|
||||
{identity.name}
|
||||
</td>
|
||||
<td>
|
||||
{identity.displayName}
|
||||
</td>
|
||||
<td>
|
||||
{identity.accounts?.map((account) => account.source?.name).join(', ')}
|
||||
</td>
|
||||
<td>
|
||||
{formatDate(identity.created)}
|
||||
</td>
|
||||
<td>
|
||||
{formatDate(identity.modified)}
|
||||
</td>
|
||||
<td>
|
||||
{identity.accessCount}
|
||||
</td>
|
||||
<td>
|
||||
{identity.entitlementCount}
|
||||
</td>
|
||||
<td>
|
||||
{identity.roleCount}
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-col justify-center gap-1">
|
||||
<a
|
||||
href={`/home/identities/${identity.id}`}
|
||||
class="btn btn-sm variant-filled-primary text-sm !text-white"
|
||||
data-sveltekit-preload-data="hover"
|
||||
>
|
||||
Open
|
||||
</a>
|
||||
<button
|
||||
on:click={() => TriggerCodeModal(identity, modalStore)}
|
||||
class="btn btn-sm variant-filled-primary text-sm !text-white"
|
||||
>
|
||||
View
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
</div>
|
||||
@@ -1,4 +1,9 @@
|
||||
export const reports = [
|
||||
{
|
||||
url: '/home/reports/list-of-identities',
|
||||
name: 'List of Identities',
|
||||
description: 'This report will show all identities in the system'
|
||||
},
|
||||
{
|
||||
url: '/home/reports/inactive-identities-with-access',
|
||||
name: 'Inactive Identities With Access',
|
||||
|
||||
Reference in New Issue
Block a user