adjust to new api

This commit is contained in:
Akis 2022-12-13 17:37:58 +02:00
parent 5a76748208
commit 5ab0e2ecdc
Signed by untrusted user: akis
GPG Key ID: 267BF5C6677944ED
2 changed files with 57 additions and 46 deletions

View File

@ -2,5 +2,8 @@ import type { PageServerLoad } from "./$types";
import { env } from "$env/dynamic/private"; import { env } from "$env/dynamic/private";
export const load: PageServerLoad = async () => { export const load: PageServerLoad = async () => {
return await fetch(env.VITE_API_URL + "/api/v1/status").then((res) => res.json()); return {
state: await fetch(env.VITE_API_URL + "/api/v1/state/status").then((res) => res.json()),
instances: await fetch(env.VITE_API_URL + "/api/v1/status").then((res) => res.json())
}
} }

View File

@ -13,10 +13,12 @@
</svelte:head> </svelte:head>
<h1>Our instances</h1> <h1>Our instances</h1>
<div class="flex flex-col gap-4">
{#if data.state.enabled}
<div class="flex flex-col gap-4">
<CardOuter> <CardOuter>
<div class="wrapper"> <div class="wrapper">
{#each data.status as group} {#each data.instances.status as group}
<h2>{group.name}</h2> <h2>{group.name}</h2>
<div class="items"> <div class="items">
{#each group.data as item} {#each group.data as item}
@ -44,12 +46,12 @@
</CardOuter> </CardOuter>
<span>Last updated: {dayjs <span>Last updated: {dayjs
.unix(data.updated) .unix(data.instances.updated)
.format("DD/MM/YYYY HH:mm:ss")} .format("DD/MM/YYYY HH:mm:ss")}
</span> </span>
</div> </div>
<style> <style>
.wrapper { .wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -61,4 +63,10 @@
flex-wrap: wrap; flex-wrap: wrap;
gap: 2rem; gap: 2rem;
} }
</style> </style>
{:else}
<div class="flex items-center gap-1 mt-16">
<div class="i-fa6-solid:circle-info" />
<span>Instances are currently disabled.</span>
</div>
{/if}