Frontend: Reading from backend pictures.

This commit is contained in:
Yohan Boujon 2025-06-01 12:42:23 +02:00
parent 64818f0970
commit 7549aa7bea
2 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,31 @@
// Server Side Rendering
export async function load(context) {
async function fetchData(data) {
try {
const resTemp = await context.fetch(`http://0.0.0.0:8085/${data}`);
if (resTemp.ok == false) {
return {
status: resTemp.status,
}
}
return {
status: 0, data: await resTemp.json(),
}
} catch (error) {
return {
status: 500,
}
}
}
const res = (await fetchData("photo_list"));
if (res.status == 500) return {
status: res.status
}
return {
status: 0,
content: res.data,
};
}

View file

@ -18,7 +18,9 @@
import SvgIcon from "@jamescoyle/svelte-icon/src/svg-icon.svelte"; import SvgIcon from "@jamescoyle/svelte-icon/src/svg-icon.svelte";
import { mdiChevronRight, mdiChevronLeft } from "@mdi/js"; import { mdiChevronRight, mdiChevronLeft } from "@mdi/js";
let photoList = filterPhotos(hubjson.photos); export let data;
const photoData = data.status == 0 ? data : undefined;
let photoList = filterPhotos(photoData.content);
$: index = 0; $: index = 0;
let photoDiv; let photoDiv;
let tempPhotoDiv; let tempPhotoDiv;