From 19e3c63fa7f5ff87f6cd95723bf9dfddc6d43b98 Mon Sep 17 00:00:00 2001 From: seriousm4x Date: Sat, 5 Aug 2023 14:08:51 +0200 Subject: [PATCH] various small changes --- frontend/src/lib/components/DeviceCard.svelte | 14 ++++++++++++-- frontend/src/lib/components/DeviceForm.svelte | 2 +- .../src/lib/components/DeviceFormPort.svelte | 16 +++++++--------- frontend/src/routes/device/[id]/+page.svelte | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib/components/DeviceCard.svelte b/frontend/src/lib/components/DeviceCard.svelte index c7ac49e0..464a78ce 100644 --- a/frontend/src/lib/components/DeviceCard.svelte +++ b/frontend/src/lib/components/DeviceCard.svelte @@ -1,10 +1,20 @@
@@ -22,7 +32,7 @@
- {formatDistanceToNow(parseISO(device.updated), { + {formatDistance(parseISO(device.updated), now, { includeSeconds: true, addSuffix: true })} diff --git a/frontend/src/lib/components/DeviceForm.svelte b/frontend/src/lib/components/DeviceForm.svelte index 1186df8c..3c7cf245 100644 --- a/frontend/src/lib/components/DeviceForm.svelte +++ b/frontend/src/lib/components/DeviceForm.svelte @@ -207,7 +207,7 @@
{#each device.expand.ports as _, index} - + {/each}
{#if portErrMsg !== ''} diff --git a/frontend/src/lib/components/DeviceFormPort.svelte b/frontend/src/lib/components/DeviceFormPort.svelte index 86b70497..50125e2e 100644 --- a/frontend/src/lib/components/DeviceFormPort.svelte +++ b/frontend/src/lib/components/DeviceFormPort.svelte @@ -6,7 +6,7 @@ import type { Device, Port } from '$lib/types/device'; import type { Record } from 'pocketbase'; - export let deviceClone: Device; + export let device: Device; export let index: number; export let portErrMsg: string; export let portErrTimeout: number; @@ -17,7 +17,7 @@ .collection('ports') .delete(port.id) .then(() => { - deviceClone.ports = deviceClone.ports.filter((id) => id !== deviceClone.ports[index]); + device.ports = device.ports.filter((id) => id !== device.ports[index]); }) .catch((err) => { clearTimeout(portErrTimeout); @@ -27,13 +27,11 @@ portErrMsg = err; }); } - deviceClone.expand.ports = deviceClone.expand.ports.filter( - (p) => p !== deviceClone.expand.ports[index] - ); + device.expand.ports = device.expand.ports.filter((p) => p !== device.expand.ports[index]); } -{#if deviceClone.expand.ports[index]} +{#if device.expand.ports[index]}
@@ -46,7 +44,7 @@ type="text" placeholder="ssh" class="input input-sm input-bordered w-full" - bind:value={deviceClone.expand.ports[index].name} + bind:value={device.expand.ports[index].name} />
@@ -60,14 +58,14 @@ min="1" max="65535" class="input input-sm input-bordered w-full" - bind:value={deviceClone.expand.ports[index].number} + bind:value={device.expand.ports[index].number} />
diff --git a/frontend/src/routes/device/[id]/+page.svelte b/frontend/src/routes/device/[id]/+page.svelte index fa50f756..6e5a1ecc 100644 --- a/frontend/src/routes/device/[id]/+page.svelte +++ b/frontend/src/routes/device/[id]/+page.svelte @@ -6,7 +6,7 @@ import DeviceForm from '$lib/components/DeviceForm.svelte'; import type { Device, Port } from '$lib/types/device'; - async function getDevice() { + async function getDevice(): Promise { const resp = await $pocketbase .collection('devices') .getOne($page.params.id, { expand: 'ports,groups' });