aboutsummaryrefslogtreecommitdiff
path: root/src/components/FileUploads.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/FileUploads.svelte')
-rw-r--r--src/components/FileUploads.svelte23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/components/FileUploads.svelte b/src/components/FileUploads.svelte
index 2c246f7..df952df 100644
--- a/src/components/FileUploads.svelte
+++ b/src/components/FileUploads.svelte
@@ -37,7 +37,7 @@
snackbar.open();
}
})
- .finally( () => {
+ .finally(() => {
snackbarText = "Sucessfullyed imported Peer Teacher/s!";
snackbar.open();
});
@@ -80,7 +80,7 @@
}
}
- function exportDB() {
+ function dbStringify(): string {
const peerTeachers = [...$ptStore.values()];
const labs = [...$labStore.values()];
const database = {
@@ -98,6 +98,11 @@
return value;
});
+ return dbObj;
+ }
+
+ function exportDB() {
+ const dbObj = dbStringify();
const blob = new Blob([dbObj], { type: "text/json" });
const anchor = document.createElement("a");
const url = window.URL.createObjectURL(blob);
@@ -109,6 +114,11 @@
document.body.removeChild(anchor);
window.URL.revokeObjectURL(url);
}
+
+ function exportDB2LocalStorage() {
+ const db = dbStringify();
+ localStorage.setItem("db", db);
+ }
</script>
<div class="flex flex-col items-center justify-center h-full ">
@@ -154,6 +164,15 @@
>
<button class="btn btn-warning" on:click={exportDB}>Download</button>
</Card>
+
+ <Card
+ title="Export to Local Storage"
+ desc="Save current DB to local storage. Local storage db should only be used for testing purposes to avoid data anomalies"
+ >
+ <button class="btn btn-warning" on:click={exportDB2LocalStorage}
+ >LocalStorage</button
+ >
+ </Card>
</div>
</div>