Update package version, updated Logout function to delete cookies, Cleaned Logs, Added Breadcrumbs, Added Pagination to sources, Cleaned Styles, and improve code structure

This commit is contained in:
luke-hagar-sp
2024-01-22 11:20:59 -06:00
parent a9a4950c1b
commit 13bc01dffb
10 changed files with 291 additions and 179 deletions

View File

@@ -6,7 +6,7 @@ export function formatDate(date: string | null | undefined) {
} }
export function getLimit(url: URL) { export function getLimit(url: URL) {
return url.searchParams.get('limit') || '10'; return url.searchParams.get('limit') || '250';
} }
export function getFilters(url: URL) { export function getFilters(url: URL) {

View File

@@ -17,14 +17,14 @@ export const actions = {
const sessionString = cookies.get('idnSession'); const sessionString = cookies.get('idnSession');
if (sessionString) { if (sessionString) {
console.log('sessionString', sessionString); // console.log('sessionString', sessionString);
const session = JSON.parse(sessionString); const session = JSON.parse(sessionString);
if (session.org == tenant) { if (session.org == tenant) {
console.debug('Credential Cache Hit'); // console.debug('Credential Cache Hit');
throw redirect(302, '/home'); throw redirect(302, '/home');
} else { } else {
console.debug('Credential Cache Miss'); // console.debug('Credential Cache Miss');
} }
} }

View File

@@ -41,7 +41,7 @@ export const load: PageServerLoad = async ({ url, cookies }) => {
}); });
const idnSession: IdnSession = response.data as IdnSession; const idnSession: IdnSession = response.data as IdnSession;
console.log(idnSession); // console.log(idnSession);
cookies.set('idnSession', JSON.stringify(idnSession)); cookies.set('idnSession', JSON.stringify(idnSession));
return { idnSession, counterList }; return { idnSession, counterList };

View File

@@ -1,6 +1,25 @@
<script> <script lang="ts">
import { page } from '$app/stores';
import LeftSidebar from '$lib/sidebar/LeftSidebar.svelte'; import LeftSidebar from '$lib/sidebar/LeftSidebar.svelte';
import { AppBar, AppShell, LightSwitch } from '@skeletonlabs/skeleton'; import { AppBar, AppShell, Avatar, LightSwitch } from '@skeletonlabs/skeleton';
let crumbs: Array<{ label: string; href: string }> = [];
$: {
// Remove zero-length tokens.
const tokens = $page.url.pathname.split('/').filter((t) => t !== '');
// Create { label, href } pairs for each token.
let tokenPath = '';
crumbs = tokens.map((t) => {
tokenPath += '/' + t;
t = t.charAt(0).toUpperCase() + t.slice(1);
return { label: t, href: tokenPath };
});
// Add a way to get home too.
// crumbs.unshift({ label: 'Home', href: '/' });
}
</script> </script>
<AppShell> <AppShell>
@@ -12,7 +31,8 @@
<p class="text-xl">IdentityNow Admin Console</p> <p class="text-xl">IdentityNow Admin Console</p>
<svelte:fragment slot="trail"> <svelte:fragment slot="trail">
<LightSwitch /> <LightSwitch />
<a href="/logout" class="btn variant-filled-primary !text-white text-lg">Logout</a> <Avatar width="w-10" />
<a href="/logout" class="btn variant-filled-primary !text-white text-xs">Logout</a>
</svelte:fragment> </svelte:fragment>
</AppBar> </AppBar>
</svelte:fragment> </svelte:fragment>
@@ -22,9 +42,24 @@
<!-- <svelte:fragment slot="sidebarRight">Sidebar Right</svelte:fragment> --> <!-- <svelte:fragment slot="sidebarRight">Sidebar Right</svelte:fragment> -->
<!-- <svelte:fragment slot="pageHeader">Page Header</svelte:fragment> --> <!-- <svelte:fragment slot="pageHeader">Page Header</svelte:fragment> -->
<!-- Router Slot --> <!-- Router Slot -->
<div class="h-full"> <div class="max-h-screen">
<div class="pl-2 pt-2 pr-2">
<ol class="breadcrumb card p-2">
{#each crumbs as crumb, i}
<!-- If crumb index is less than the breadcrumb length minus 1 -->
{#if i < crumbs.length - 1}
<li class="crumb"><a class="anchor" href={crumb.href}>{crumb.label}</a></li>
<li class="crumb-separator" aria-hidden>&rsaquo;</li>
{:else}
<li class="crumb">{crumb.label}</li>
{/if}
{/each}
</ol>
</div>
<div class="p-2">
<slot /> <slot />
</div> </div>
</div>
<!-- ---- / ---- --> <!-- ---- / ---- -->
<!-- <svelte:fragment slot="pageFooter">Page Footer</svelte:fragment> --> <!-- <svelte:fragment slot="pageFooter">Page Footer</svelte:fragment> -->
<!-- <svelte:fragment slot="footer">Footer</svelte:fragment> --> <!-- <svelte:fragment slot="footer">Footer</svelte:fragment> -->

View File

@@ -2,7 +2,7 @@
import { reports } from '$lib/sidebar/reports'; import { reports } from '$lib/sidebar/reports';
</script> </script>
<div class="flex flex-row flex-wrap gap-4 p-4 justify-center"> <div class="flex flex-row flex-wrap gap-4 justify-center">
{#each reports as report (report.url)} {#each reports as report (report.url)}
<a <a
class="card card-hover overflow-hidden w-modal-slim" class="card card-hover overflow-hidden w-modal-slim"

View File

@@ -38,7 +38,6 @@
let sorters = ''; let sorters = '';
</script> </script>
<div class="p-4">
<div class="card flex justify-center flex-col align-middle"> <div class="card flex justify-center flex-col align-middle">
<div class=" p-4 flex flex-row justify-between gap-4 flex-wrap"> <div class=" p-4 flex flex-row justify-between gap-4 flex-wrap">
<div class="flex flex-row gap-1"> <div class="flex flex-row gap-1">
@@ -60,6 +59,7 @@
/> />
<button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button> <button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button>
</div> </div>
<p class="my-auto">Total Count: {data.totalCount}</p>
<Paginator <Paginator
bind:settings bind:settings
on:page={onPageChange} on:page={onPageChange}
@@ -140,6 +140,7 @@
/> />
<button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button> <button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button>
</div> </div>
<p class="my-auto">Total Count: {data.totalCount}</p>
<Paginator <Paginator
bind:settings bind:settings
on:page={onPageChange} on:page={onPageChange}
@@ -151,4 +152,3 @@
/> />
</div> </div>
</div> </div>
</div>

View File

@@ -25,8 +25,6 @@ export const load = async ({ cookies, url }) => {
const apiResponse = await api.listSources(requestParams); const apiResponse = await api.listSources(requestParams);
console.log(apiResponse);
return { return {
totalCount: apiResponse.headers['x-total-count'], totalCount: apiResponse.headers['x-total-count'],
sources: apiResponse.data, sources: apiResponse.data,

View File

@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { ModalSettings } from '@skeletonlabs/skeleton'; import { createOnAmountChange, createOnGo, createOnPageChange } from '$lib/Utils.js';
import { getModalStore } from '@skeletonlabs/skeleton'; import type { ModalSettings, PaginationSettings } from '@skeletonlabs/skeleton';
import { Paginator, getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore(); const modalStore = getModalStore();
@@ -18,10 +19,57 @@
modalStore.trigger(modal); modalStore.trigger(modal);
} }
$: onPageChange = createOnPageChange({ ...data.params, filters, sorters }, '/home/identities');
$: onAmountChange = createOnAmountChange(
{ ...data.params, filters, sorters },
'/home/identities'
);
$: onGo = createOnGo({ ...data.params, filters, sorters }, '/home/identities');
let settings = {
page: Number(data.params.page),
limit: Number(data.params.limit),
size: data.totalCount,
amounts: [10, 50, 100, 250]
} satisfies PaginationSettings;
let filters = '';
let sorters = '';
</script> </script>
<div class="p-4"> <div class="card flex justify-center flex-col align-middle">
<div class="flex justify-center flex-col align-middle"> <div class=" p-4 flex flex-row justify-between gap-4 flex-wrap">
<div class="flex flex-row gap-1">
<input
on:keydown={onGo}
bind:value={filters}
class="input"
title="Filter"
type="text"
placeholder="Filter"
/>
<input
on:keydown={onGo}
bind:value={sorters}
class="input"
title="Sorter"
type="text"
placeholder="Sorter"
/>
<button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button>
</div>
<p class="my-auto">Total Count: {data.totalCount}</p>
<Paginator
bind:settings
on:page={onPageChange}
on:amount={onAmountChange}
showNumerals={true}
maxNumerals={1}
showFirstLastButtons={true}
showPreviousNextButtons={true}
/>
</div>
<table class="table"> <table class="table">
<thead> <thead>
<th>ID</th> <th>ID</th>
@@ -74,5 +122,35 @@
{/each} {/each}
</tbody> </tbody>
</table> </table>
<div class=" p-4 flex flex-row justify-between gap-4 flex-wrap">
<div class="flex flex-row gap-1">
<input
on:keydown={onGo}
bind:value={filters}
class="input"
title="Filter"
type="text"
placeholder="Filter"
/>
<input
on:keydown={onGo}
bind:value={sorters}
class="input"
title="Sorter"
type="text"
placeholder="Sorter"
/>
<button on:click={onGo} class="btn variant-filled-primary text-white"> Go </button>
</div>
<p class="my-auto">Total Count: {data.totalCount}</p>
<Paginator
bind:settings
on:page={onPageChange}
on:amount={onAmountChange}
showNumerals={true}
maxNumerals={1}
showFirstLastButtons={true}
showPreviousNextButtons={true}
/>
</div> </div>
</div> </div>

View File

@@ -1,5 +1,6 @@
export const load = async ({ cookies }) => { export const load = async ({ cookies }) => {
cookies.delete('session'); cookies.delete('session');
cookies.delete('idnSession');
return { sessionLoggedOut: true }; return { sessionLoggedOut: true };
}; };

View File

@@ -1,7 +1,7 @@
{ {
"name": "idn-admin-console", "name": "idn-admin-console",
"description": "A troubleshooting and administration app for IdentityNow", "description": "A troubleshooting and administration app for IdentityNow",
"version": "0.0.1", "version": "0.0.2",
"private": true, "private": true,
"author": { "author": {
"name": "Luke Hagar", "name": "Luke Hagar",