mirror of
https://github.com/gurucomputing/headscale-ui.git
synced 2026-01-23 02:34:43 +00:00
placed api results in toast alerts
This commit is contained in:
parent
05de11cedd
commit
778fc38a51
3 changed files with 19 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
10
src/lib/components/layout/toast.svelte.ts
Normal file
10
src/lib/components/layout/toast.svelte.ts
Normal 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
|
||||
}));
|
||||
}
|
||||
|
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue