Add feature detection and warnings, run formatter

This commit is contained in:
Fred Boniface
2024-06-23 11:21:45 +01:00
parent 98c9b5cc03
commit 8560d61348
10 changed files with 108 additions and 85 deletions

View File

@@ -4,7 +4,7 @@
import { dev } from "$app/environment";
import DevBanner from "$lib/DevBanner.svelte";
import { page } from "$app/stores";
import { Toaster } from 'svelte-french-toast'
import { Toaster } from "svelte-french-toast";
</script>
<svelte:head>
@@ -31,8 +31,13 @@
<link rel="manifest" href="/manifest.json" />
<title>OwlBoard</title>
</svelte:head>
<Toaster />
{#if dev}
<DevBanner />
{/if}
<slot />
<style>
</style>

View File

@@ -6,6 +6,7 @@
import Welcome from "$lib/overlays/welcome.svelte";
import { welcome } from "$lib/stores/welcome";
import { version, showWelcome } from "$lib/stores/version";
import { featureDetect } from "$lib/scripts/featureDetect";
import { onMount } from "svelte";
import toast from "svelte-french-toast";
@@ -25,15 +26,16 @@
},
];
onMount(() => {
toast(
"Registration soon required for some features.\n\nClick 'Register' in the menu.",
{
duration: 3000,
}
)
})
onMount(async () => {
const featureSupport = featureDetect();
console.log(featureSupport);
if (!featureSupport.critical) {
toast.error("Your browser is missing critical features, OwlBoard might not work properly. Consider updating your browser.");
} else if (!featureSupport.nice) {
toast.error("Your browser is missing some features, OwlBoard may run slower or be missing some features.");
}
});
</script>
{#if showWelcome && ($welcome === "null" || !$welcome || parseInt($welcome.replace(/\./g, "")) < parseInt(version.replace(/\./g, "")))}

View File

@@ -42,14 +42,11 @@
}
function send() {
toast.promise(
request(),
{
loading: "Contacting Server...",
success: "Request Answered.",
error: "Unable to contact server."
}
)
toast.promise(request(), {
loading: "Contacting Server...",
success: "Request Answered.",
error: "Unable to contact server.",
});
}
onMount(async () => {

View File

@@ -45,28 +45,28 @@
const res = await fetch(url, options); // Enable Auth
if (res.status == 401) {
errMsg = "You must be logged in to the staff version";
toast.error("You must be registered")
toast.error("You must be registered");
error = true;
return false;
} else if (res.status == 500) {
errMsg = "Server Error, try again later";
toast.error("Server Error.", {duration: 7500})
toast.error("Server Error.", { duration: 7500 });
error = true;
return false;
}
const jsonData = await res.json();
if (jsonData.ERROR == "offline") {
errMsg = "Connection error, check your internet connection and try again";
toast.error("You are offline.")
toast.error("You are offline.");
error = true;
return false;
}
data = jsonData;
let count = data.length
let count = data.length;
if (!count) {
toast.error("No PIS Codes found.")
toast.error("No PIS Codes found.");
} else {
toast.success(`${count} PIS Codes found`)
toast.success(`${count} PIS Codes found`);
}
}
@@ -76,18 +76,15 @@
entryPIS = "";
entryStartCRS = "";
entryEndCRS = "";
toast.success("Form reset")
toast.success("Form reset");
isLoading = false;
}
onMount(() => {
toast(
"Registration soon required for PIS features.\n\nClick 'Register' in the menu.",
{
duration: 3000,
}
)
})
toast("Registration soon required for PIS features.\n\nClick 'Register' in the menu.", {
duration: 3000,
});
});
</script>
<Header {title} />

View File

@@ -42,12 +42,9 @@
}
isLoading = false;
toast(
"Registration soon required for timetable features.\n\nClick 'Register' in the menu.",
{
duration: 3000,
}
)
toast("Registration soon required for timetable features.\n\nClick 'Register' in the menu.", {
duration: 3000,
});
});
async function fetchData(id = "") {