This commit is contained in:
Fran Jurmanović
2025-02-08 15:43:57 +01:00
parent face750b7d
commit e2fa9d2f7e
37 changed files with 5183 additions and 128 deletions

View File

@@ -0,0 +1,46 @@
import { updateConfig, getConfigFiles } from '$api/serverService';
import type { Actions } from './$types';
import { checkAuth } from '$api/authService';
import { getTracks } from '$api/lookupService';
import { redirect } from '@sveltejs/kit';
export const load = async ({ params }) => {
const isAuth = await checkAuth();
if (!isAuth) return redirect(308, '/login');
const config = await getConfigFiles(params.id);
const tracks = await getTracks();
return {
id: params.id,
config,
tracks
};
};
export const actions = {
event: async ({ request }) => {
const formData = await request.formData();
const id = formData.get('id') as string;
const object: any = {};
formData.forEach((value, key) => {
switch (key) {
case 'id':
return;
case 'sessions':
object[key] = tryParse(value as string);
break;
default:
object[key] = !Number.isNaN(+value) ? +value : value;
}
});
await updateConfig(id, 'event.json', object, false, true);
redirect(303, '/dashboard');
}
} satisfies Actions;
function tryParse(str: string) {
try {
return JSON.parse(str);
} catch {
return str;
}
}