diff --git a/prisma/schema.prisma b/prisma/schema.prisma index cf904f5..15edaf2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -8,23 +8,24 @@ generator client { } model User { - id Int @id @default(autoincrement()) - username String @unique - email String @unique - password String - createdAt DateTime @default(now()) - lastSeen DateTime @default(now()) - settings UserSettings? + id Int @id @default(autoincrement()) + username String @unique + email String @unique + password String + createdAt DateTime @default(now()) + lastSeen DateTime @default(now()) + settings UserSettings? // STORED AS MEGABYTES !! - maxUpload Int @default(100) - uploads Upload[] - sessions Session[] + maxUploadMB Int @default(100) + uploads Upload[] + sessions Session[] } model Session { - id String @id @unique - user User @relation(fields: [userId], references: [id]) - userId Int + id String @id @unique + user User @relation(fields: [userId], references: [id]) + userId Int + authorized Boolean createdAt DateTime @default(now()) expiresAt DateTime @@ -45,9 +46,8 @@ model UserSettings { } model Upload { - id String @id - - uploader User @relation(fields: [uploaderId], references: [id]) + id String @id + uploader User @relation(fields: [uploaderId], references: [id]) uploaderId Int fileName String @unique diff --git a/src/routes/(app)/dashboard/+page.js b/src/routes/(app)/dashboard/+page.js index 5b9fd0b..e14f25b 100644 --- a/src/routes/(app)/dashboard/+page.js +++ b/src/routes/(app)/dashboard/+page.js @@ -1,7 +1,10 @@ /** @type {import("@sveltejs/kit").Load } */ -export async function load({ fetch }) { - const response = await fetch('/api/statistics'); - const statistics = await response.json(); +export function load({ fetch }) { + const statistics = fetch('/api/statistics').then((response) => response.json()); - return { statistics }; + return { + streamed: { + statistics + } + }; } diff --git a/src/routes/(app)/dashboard/+page.svelte b/src/routes/(app)/dashboard/+page.svelte index db76235..bf4b672 100644 --- a/src/routes/(app)/dashboard/+page.svelte +++ b/src/routes/(app)/dashboard/+page.svelte @@ -6,6 +6,7 @@ import Button from '$lib/components/Inputs/Button.svelte'; import ButtonText from '$lib/components/Inputs/ButtonText.svelte'; + import { fade } from 'svelte/transition'; export let data; @@ -30,18 +31,22 @@
- - - - - - - - - - - - + {#await data?.streamed?.statistics} +
+ {:then statistics} + + + + + + + + + + + + + {/await}
Registered Users{data?.statistics?.users}
Files Hosted{data?.statistics?.files}
File Storage{data?.statistics?.storage}
Registered Users{statistics?.users}
Files Hosted{statistics?.files}
File Storage{statistics?.storage}