added proper search backend and loading bar

This commit is contained in:
Philip Ellis
2023-09-21 14:54:02 -05:00
parent 83c80201f0
commit b003959c01
3 changed files with 49 additions and 45 deletions

View File

@@ -4,23 +4,15 @@ import { getToken, type IdnSession } from "$lib/utils/oauth";
import { SearchApi, type Search, Paginator } from "sailpoint-api-client";
/** @type {import('./$types').RequestHandler} */
export async function GET({ url, cookies }) {
export async function POST({ request, cookies }) {
try {
const session = JSON.parse(cookies.get('session')!)
//const idnSession = <IdnSession>JSON.parse(cookies.get('idnSession')!)
const idnSession = await getToken(cookies)
const searchJson = await request.json()
const config = createConfiguration(session.baseUrl, idnSession.access_token)
let api = new SearchApi(config)
let search: Search = {
indices: [
"events"
],
query: {
query: `name: "Create Account Failed" AND created: [now-90d TO now]`
},
sort: ["created"]
}
let search: Search = searchJson
const val = (await Paginator.paginateSearchApi(api, search, 100, 1000)).data
//console.log(val)
return json(val)

View File

@@ -23,14 +23,6 @@ export const load: PageServerLoad = async ({ params, url, cookies }) => {
console.log(err.response.data);
console.log(err.response.status);
console.log(err.response.headers);
// throw error(err.response.status, {
// message: 'IDN Responded with an Error',
// code: JSON.stringify(
// { data: err.response.data, headers: err.response.headers },
// null,
// ' '
// )
// });
throw redirect(302, generateAuthLink(session.tenantUrl));
} else if (err.request) {
// The request was made but no response was received

View File

@@ -1,10 +1,23 @@
<script lang="ts">
import type { TableSource } from '@skeletonlabs/skeleton';
import { ProgressRadial, Table, tableMapperValues } from '@skeletonlabs/skeleton';
import type { Search } from 'sailpoint-api-client';
import { onMount } from 'svelte';
//export let data;
let tableSimple: TableSource | undefined = undefined;
onMount(async () => {
const response = await fetch('/api/sailpoint', {
method: 'GET',
const search: Search = {
indices: ['events'],
query: {
query: `name: "Create Account Failed" AND created: [now-90d TO now]`,
},
sort: ['created'],
};
const response = await fetch('/api/sailpoint/search', {
method: 'POST',
body: JSON.stringify(search),
headers: {
'content-type': 'application/json',
},
@@ -34,30 +47,37 @@
};
}
});
import type { TableSource } from '@skeletonlabs/skeleton';
import { ProgressRadial, Table, tableMapperValues } from '@skeletonlabs/skeleton';
import { onMount } from 'svelte';
</script>
<div class="p-4">
<img src="/SailPoint-Developer-Community-Lockup.png" alt="sailPoint Logo" />
<a href="/home" class="btn variant-filled-primary w-full mt-2 text-slate-50 text-lg">
Go back report screen
</a>
<div class="flex justify-center mt-4 flex-col">
<div class="text-2xl text-slate-500 divide-dashed divide-y-2 mt-4 mb-2">
Listing of Source Account Create Errors
<main>
<div class="p-4">
<img src="/SailPoint-Developer-Community-Lockup.png" alt="sailPoint Logo" />
<a href="/home" class="btn variant-filled-primary w-full mt-2 text-slate-50 text-lg">
Go back report screen
</a>
<div class="flex justify-center mt-4 flex-col align-middle">
<div class="text-2xl text-slate-500 divide-dashed divide-y-2 mt-4 mb-2">
Listing of Source Account Create Errors
</div>
{#if tableSimple}
<Table class="w-full" source={tableSimple} />
{:else}
<div class="progress-bar">
<ProgressRadial
stroke={100}
meter="stroke-primary-500"
track="stroke-primary-500/30"
class="progress-bar"
/>
</div>
{/if}
</div>
{#if tableSimple}
<Table class="w-full" source={tableSimple} />
{:else}
<ProgressRadial
...
stroke={100}
meter="stroke-primary-500"
track="stroke-primary-500/30"
/>
{/if}
</div>
</div>
</main>
<style>
.progress-bar {
padding-top: calc(50vh - 4.5rem - 200px);
padding-left: calc(50% - 4.5rem);
}
</style>