mirror of
https://github.com/LukeHagar/ui-development-kit.git
synced 2025-12-06 12:57:44 +00:00
added proper search backend and loading bar
This commit is contained in:
@@ -4,23 +4,15 @@ import { getToken, type IdnSession } from "$lib/utils/oauth";
|
|||||||
import { SearchApi, type Search, Paginator } from "sailpoint-api-client";
|
import { SearchApi, type Search, Paginator } from "sailpoint-api-client";
|
||||||
|
|
||||||
/** @type {import('./$types').RequestHandler} */
|
/** @type {import('./$types').RequestHandler} */
|
||||||
export async function GET({ url, cookies }) {
|
export async function POST({ request, cookies }) {
|
||||||
try {
|
try {
|
||||||
const session = JSON.parse(cookies.get('session')!)
|
const session = JSON.parse(cookies.get('session')!)
|
||||||
//const idnSession = <IdnSession>JSON.parse(cookies.get('idnSession')!)
|
|
||||||
const idnSession = await getToken(cookies)
|
const idnSession = await getToken(cookies)
|
||||||
|
const searchJson = await request.json()
|
||||||
|
|
||||||
const config = createConfiguration(session.baseUrl, idnSession.access_token)
|
const config = createConfiguration(session.baseUrl, idnSession.access_token)
|
||||||
let api = new SearchApi(config)
|
let api = new SearchApi(config)
|
||||||
let search: Search = {
|
let search: Search = searchJson
|
||||||
indices: [
|
|
||||||
"events"
|
|
||||||
],
|
|
||||||
query: {
|
|
||||||
query: `name: "Create Account Failed" AND created: [now-90d TO now]`
|
|
||||||
},
|
|
||||||
sort: ["created"]
|
|
||||||
}
|
|
||||||
const val = (await Paginator.paginateSearchApi(api, search, 100, 1000)).data
|
const val = (await Paginator.paginateSearchApi(api, search, 100, 1000)).data
|
||||||
//console.log(val)
|
//console.log(val)
|
||||||
return json(val)
|
return json(val)
|
||||||
@@ -23,14 +23,6 @@ export const load: PageServerLoad = async ({ params, url, cookies }) => {
|
|||||||
console.log(err.response.data);
|
console.log(err.response.data);
|
||||||
console.log(err.response.status);
|
console.log(err.response.status);
|
||||||
console.log(err.response.headers);
|
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));
|
throw redirect(302, generateAuthLink(session.tenantUrl));
|
||||||
} else if (err.request) {
|
} else if (err.request) {
|
||||||
// The request was made but no response was received
|
// The request was made but no response was received
|
||||||
|
|||||||
@@ -1,10 +1,23 @@
|
|||||||
<script lang="ts">
|
<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;
|
//export let data;
|
||||||
let tableSimple: TableSource | undefined = undefined;
|
let tableSimple: TableSource | undefined = undefined;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const response = await fetch('/api/sailpoint', {
|
const search: Search = {
|
||||||
method: 'GET',
|
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: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'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>
|
</script>
|
||||||
|
|
||||||
<div class="p-4">
|
<main>
|
||||||
<img src="/SailPoint-Developer-Community-Lockup.png" alt="sailPoint Logo" />
|
<div class="p-4">
|
||||||
<a href="/home" class="btn variant-filled-primary w-full mt-2 text-slate-50 text-lg">
|
<img src="/SailPoint-Developer-Community-Lockup.png" alt="sailPoint Logo" />
|
||||||
Go back report screen
|
<a href="/home" class="btn variant-filled-primary w-full mt-2 text-slate-50 text-lg">
|
||||||
</a>
|
Go back report screen
|
||||||
<div class="flex justify-center mt-4 flex-col">
|
</a>
|
||||||
<div class="text-2xl text-slate-500 divide-dashed divide-y-2 mt-4 mb-2">
|
<div class="flex justify-center mt-4 flex-col align-middle">
|
||||||
Listing of Source Account Create Errors
|
<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>
|
</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>
|
||||||
</div>
|
</main>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.progress-bar {
|
||||||
|
padding-top: calc(50vh - 4.5rem - 200px);
|
||||||
|
padding-left: calc(50% - 4.5rem);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user