placed api results in toast alerts

This commit is contained in:
Chris Bisset 2025-03-15 00:45:22 +00:00
parent 05de11cedd
commit 778fc38a51
3 changed files with 19 additions and 5 deletions

View file

@ -3,7 +3,8 @@ import { SvelteMap } from "svelte/reactivity";
export class PersistentAppSettingsObject {
daisyUITheme = "" // for setting the UI theme. See https://daisyui.com/docs/themes/
headscaleAPIKey = "" // sensitive, allows for administrative access to headscale
headscaleURL = "" //url for headscale to use
headscaleURL = "" // url for headscale to use
debugLogging = false // to turn on additional messages
public constructor(init?: Partial<PersistentAppSettingsObject>) {
Object.assign(this, init);

View file

@ -0,0 +1,10 @@
import { appSettings } from "../common/state.svelte";
import { toastAlert } from "../common/classes.svelte";
export function newToastAlert(message: string) {
let uuid = crypto.randomUUID();
appSettings.toastAlerts.set(uuid, new toastAlert({
id: uuid,
message: message
}));
}

View file

@ -1,4 +1,4 @@
import { toastAlert } from "../common/classes.svelte";
import { newToastAlert } from "../layout/toast.svelte.ts";
import { persistentAppSettings } from "../common/state.svelte";
export async function testAPIConnectivity(submission: SubmitEvent) {
@ -12,12 +12,15 @@ export async function testAPIConnectivity(submission: SubmitEvent) {
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
newToastAlert(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
console.log('API Key Response:', data);
newToastAlert('success!');
if (persistentAppSettings.debugLogging) {
newToastAlert(`API Response: ${JSON.stringify(data)}`);
}
} catch (error) {
console.error('Error fetching API key:', error);
newToastAlert(`Error fetching API key: ${error}`);
}
}