Set delayed loading spinner and additional CSP headers

This commit is contained in:
thiloho
2024-09-25 16:02:12 +02:00
parent 0e3c0f094c
commit a9e2bd4cb7
14 changed files with 83 additions and 33 deletions

View File

@@ -27,6 +27,7 @@
};
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -52,9 +53,10 @@
method="POST"
enctype="multipart/form-data"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -108,9 +110,10 @@
method="POST"
enctype="multipart/form-data"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -160,9 +163,10 @@
action="?/updateHome"
method="POST"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -193,9 +197,10 @@
action="?/updateFooter"
method="POST"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}

View File

@@ -10,6 +10,7 @@
const { data, form }: { data: PageServerData; form: ActionData } = $props();
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -36,9 +37,10 @@
method="POST"
action="?/createArticle"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -135,9 +137,10 @@
method="POST"
action="?/deleteArticle"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};

View File

@@ -28,6 +28,7 @@
};
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -54,9 +55,10 @@
action="?/editArticle"
enctype="multipart/form-data"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}

View File

@@ -9,6 +9,7 @@
const { data, form }: { data: PageServerData; form: ActionData } = $props();
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -35,9 +36,10 @@
method="POST"
action="?/createCategory"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -79,9 +81,10 @@
method="POST"
action="?/updateCategory"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -117,9 +120,10 @@
method="POST"
action="?/deleteCategory"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};

View File

@@ -9,6 +9,7 @@
const { data, form }: { data: PageServerData; form: ActionData } = $props();
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -35,9 +36,10 @@
method="POST"
action="?/addCollaborator"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -83,9 +85,10 @@
method="POST"
action="?/updateCollaborator"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -114,9 +117,10 @@
method="POST"
action="?/removeCollaborator"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};

View File

@@ -18,6 +18,7 @@
};
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -62,9 +63,10 @@
method="POST"
action="?/createUpdateLegalInformation"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -93,9 +95,10 @@
action="?/deleteLegalInformation"
method="post"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};

View File

@@ -9,6 +9,7 @@
const { data, form }: { data: PageServerData; form: ActionData } = $props();
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -37,9 +38,10 @@
method="POST"
action="?/publishWebsite"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -68,9 +70,10 @@
method="POST"
action="?/createUpdateCustomDomainPrefix"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
sending = false;
};
}}
@@ -96,9 +99,10 @@
action="?/deleteCustomDomainPrefix"
method="post"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};