diff --git a/src/lib/layout/usageMultiple.svelte b/src/lib/layout/usageMultiple.svelte index 85f5091ca..ff1789c49 100644 --- a/src/lib/layout/usageMultiple.svelte +++ b/src/lib/layout/usageMultiple.svelte @@ -1,19 +1,47 @@
@@ -41,19 +69,12 @@ {#if count} - {@const totalCount = clampMin(total.reduce((a, b) => a + b, 0))} - {formatNumberWithCommas(totalCount)} Total {title.toLocaleLowerCase()}
- ({ - name: legendData[index].name, - data: accumulateFromEndingTotal(c, total[index]) - }))} /> + {#if legendData} + import { base } from '$app/paths'; + import { page } from '$app/state'; + import { clampMin } from '$lib/helpers/numbers'; + import { formatNum } from '$lib/helpers/string'; import { Container, UsageMultiple } from '$lib/layout'; + import type { PageProps } from './$types'; - export let data; + let { data }: PageProps = $props(); - $: reads = data.databaseReads; - $: readsTotal = data.databaseReadsTotal; + const reads = $derived(data.databaseReads ?? []); + const readsTotal = $derived(clampMin(reads.reduce((sum, item) => sum + item.value, 0))); - $: writes = data.databaseWrites; - $: writesTotal = data.databaseWritesTotal; + const writes = $derived(data.databaseWrites ?? []); + const writesTotal = $derived(clampMin(writes.reduce((sum, item) => sum + item.value, 0))); + + const usagePath = $derived( + `${base}/project-${page.params.region}-${page.params.project}/databases/database-${page.params.database}/usage` + ); + import { goto } from '$app/navigation'; + import { base } from '$app/paths'; + import { page } from '$app/state'; import { Container, UsageMultiple } from '$lib/layout'; + import { InputSelect } from '$lib/elements/forms'; + import { clampMin } from '$lib/helpers/numbers'; + import { formatNum } from '$lib/helpers/string'; import { Layout } from '@appwrite.io/pink-svelte'; - import type { PageData } from './$types'; + import type { PageProps } from './$types'; - export let data: PageData; + let { data }: PageProps = $props(); - $: reads = data.databasesReads; - $: readsTotal = data.databasesReadsTotal; + const reads = $derived(data.databasesReads ?? []); + const readsTotal = $derived(clampMin(reads.reduce((sum, item) => sum + item.value, 0))); - $: writes = data.databasesWrites; - $: writesTotal = data.databasesWritesTotal; + const writes = $derived(data.databasesWrites ?? []); + const writesTotal = $derived(clampMin(writes.reduce((sum, item) => sum + item.value, 0))); + + const usagePath = $derived( + `${base}/project-${page.params.region}-${page.params.project}/databases/usage` + ); +
+ goto(`${usagePath}/${e.detail}`)} + id="period" + options={[ + { + label: '24 hours', + value: '24h' + }, + { + label: '30 days', + value: '30d' + }, + { + label: '90 days', + value: '90d' + } + ]} + value={page.params.period ?? '30d'} /> +
+