add backup feature

This commit is contained in:
2023-07-08 18:02:07 +02:00
parent 856c7115ed
commit 90daf64f51
4 changed files with 49 additions and 36 deletions

View File

@@ -0,0 +1,23 @@
<script>
import {getSharableUrl, stringifyCompressed} from "$lib/serial/serialization"
import {chords} from "$lib/serial/connection"
async function downloadBackup() {
const downloadUrl = URL.createObjectURL(await stringifyCompressed($chords))
const element = document.createElement("a")
element.setAttribute("download", "chords.chl")
element.href = downloadUrl
element.setAttribute("target", "_blank")
element.click()
URL.revokeObjectURL(downloadUrl)
}
async function createShareUrl() {
console.log(await getSharableUrl("chords", $chords))
}
</script>
<h1>Backup & Restore</h1>
<button on:click={downloadBackup}><span class="icon">save</span> Backup</button>
<button><span class="icon">settings_backup_restore</span> Restore</button>