From 8e305069fc502d896a42998e29ece40a3b508a04 Mon Sep 17 00:00:00 2001 From: lucarickli Date: Sat, 23 Nov 2024 21:57:32 +0100 Subject: [PATCH] fix dialog overflow & user badges --- .../data/machine/MachineInfo.svelte | 11 ++++++++-- .../ui/dialog/dialog-content.svelte | 20 +++++++++---------- src/lib/mock/handlers.ts | 2 +- src/lib/utils/misc.ts | 4 ++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/lib/components/data/machine/MachineInfo.svelte b/src/lib/components/data/machine/MachineInfo.svelte index 7d1d124..5445d26 100644 --- a/src/lib/components/data/machine/MachineInfo.svelte +++ b/src/lib/components/data/machine/MachineInfo.svelte @@ -29,6 +29,7 @@ import MachineActions from './MachineActions.svelte'; import MachineStatus from './MachineStatus.svelte'; + import { invertHex } from '$lib/utils/misc'; // import DeleteMachine from './DeleteMachine.svelte'; // import EditMachine from './EditMachine.svelte'; @@ -136,14 +137,20 @@
+ + User: {machine.user?.name} + + {#if machine.expiry} {#if isExpired(machine.expiry)} - Session expired {new Date(machine.expiry).toDateString()} + Session expired: {new Date(machine.expiry).toDateString()} {:else} - Session expires {neverExpires(machine.expiry) + Session expires: {neverExpires(machine.expiry) ? 'never' : formatDuration(Date.now() - new Date(machine.expiry).getTime())} diff --git a/src/lib/components/ui/dialog/dialog-content.svelte b/src/lib/components/ui/dialog/dialog-content.svelte index 183e798..cf1d03c 100644 --- a/src/lib/components/ui/dialog/dialog-content.svelte +++ b/src/lib/components/ui/dialog/dialog-content.svelte @@ -1,15 +1,15 @@ @@ -20,14 +20,14 @@ {transition} {transitionConfig} class={cn( - "bg-background fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg md:w-full", + 'fixed left-[50%] top-[50%] z-50 grid max-h-[80svh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-scroll border bg-background p-6 shadow-lg sm:rounded-lg md:w-full', className )} {...$$restProps} > Close diff --git a/src/lib/mock/handlers.ts b/src/lib/mock/handlers.ts index 519f42a..1a6914d 100644 --- a/src/lib/mock/handlers.ts +++ b/src/lib/mock/handlers.ts @@ -168,7 +168,7 @@ export const handlers = [ name: usernames[userId] }, ipAddresses: [ - `100.64.${Math.trunc((id + 1) / 255)}.${(id + 1) % 255}`, + `100.64.${((id + 1) / 255).toFixed(0)}.${(id + 1) % 255}`, 'fd7a:115c:a1e0::' + (id + 1).toString(16) ] }; diff --git a/src/lib/utils/misc.ts b/src/lib/utils/misc.ts index ce356b2..8903c6a 100644 --- a/src/lib/utils/misc.ts +++ b/src/lib/utils/misc.ts @@ -7,3 +7,7 @@ export function debounce>(callback: (...args: T) => void, w }, wait); }; } + +export function invertHex(hex: string) { + return (Number(`0x1${hex}`) ^ 0xffffff).toString(16).substr(1).toUpperCase(); +}