diff --git a/src/config.yml b/src/config.yml index 0867a84..6d777db 100644 --- a/src/config.yml +++ b/src/config.yml @@ -56,3 +56,4 @@ services: url: 'http://pihole.lan/admin' type: 'pihole' keywords: 'dns ads blocker internet' + api_token: a3996b80e3d9cdb86b338396a164a8814e8d6f44d2986261fe573bfea53a75fb diff --git a/src/lib/components/Brand.svelte b/src/lib/components/Brand.svelte index 0590485..9f26beb 100644 --- a/src/lib/components/Brand.svelte +++ b/src/lib/components/Brand.svelte @@ -9,7 +9,6 @@ } function logoURL(): string { - console.log(brand.logo); if (brand.logo == undefined) { return ''; } diff --git a/src/lib/services/pihole/+content.svelte b/src/lib/services/pihole/+content.svelte index ad8cce5..2f0710b 100644 --- a/src/lib/services/pihole/+content.svelte +++ b/src/lib/services/pihole/+content.svelte @@ -2,4 +2,9 @@ export let data; -pihole status placeholder +pihole status +{#await data.raw} + waiting +{:then value} +
{JSON.stringify(value, null, 2)}
+{/await} diff --git a/src/lib/services/pihole/+service.ts b/src/lib/services/pihole/+service.ts index 70b2896..194be11 100644 --- a/src/lib/services/pihole/+service.ts +++ b/src/lib/services/pihole/+service.ts @@ -1,7 +1,11 @@ import { type ServiceHandler } from '../service'; -export const handle: ServiceHandler = () => { - const res = { logo: 'https://cdn.rawgit.com/pi-hole/graphics/master/Vortex/Vortex.svg' }; +export const handle: ServiceHandler = ({ fetch, config }) => { + const url = config.url + '/api.php?summaryRaw&auth=' + config.api_token; - return res; + return { + logo: 'https://cdn.rawgit.com/pi-hole/graphics/master/Vortex/Vortex.svg', + raw: fetch(url).then((raw) => raw.json()), + url: url + }; }; diff --git a/src/lib/services/service.ts b/src/lib/services/service.ts index 9312483..163c0cf 100644 --- a/src/lib/services/service.ts +++ b/src/lib/services/service.ts @@ -5,4 +5,6 @@ interface ServiceHandlerArgs { config: ServiceConfig; } -export type ServiceHandler = (input: ServiceHandlerArgs) => Record; +export type ServiceHandler = ( + input: ServiceHandlerArgs +) => Record | Promise>; diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 6aa9ae2..aea2769 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -2,7 +2,7 @@ import { clientAddressIsPrivate, clientConfig, serverConfig } from '$lib/server/ import type { PageServerLoad } from './$types'; import { getServiceHandler } from '$lib/services/services'; -export const load: PageServerLoad = ({ fetch, getClientAddress }) => { +export const load: PageServerLoad = async ({ fetch, getClientAddress }) => { const serviceData: Array> = []; const config = clientConfig(); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 555b99f..f33aa67 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -16,6 +16,8 @@ {#each data.config.services as group, i} {/each} + +
{JSON.stringify(data, null, 2)}