mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-09 19:42:48 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a167030da | |||
| e38e63222c | |||
| 7c74831647 |
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -3,7 +3,6 @@ name: Build
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
tags: ["v*"]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ jobs:
|
|||||||
path: build
|
path: build
|
||||||
deploy:
|
deploy:
|
||||||
name: 🚀 Deploy
|
name: 🚀 Deploy
|
||||||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
if: github.event_name == 'push' && contains(github.event.head_commit.message, '[deploy]')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cccs",
|
"name": "cccs",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
color: var(--md-sys-color-tertiary);
|
color: var(--md-sys-color-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button:hover:not(:active),
|
||||||
a:hover:not(:active),
|
a:hover:not(:active),
|
||||||
button:hover:not(:active) {
|
button:hover:not(:active) {
|
||||||
filter: brightness(70%);
|
filter: brightness(70%);
|
||||||
|
|||||||
@@ -1,23 +1,100 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import {getSharableUrl, stringifyCompressed} from "$lib/serial/serialization"
|
import {getSharableUrl, parseCompressed, stringifyCompressed} from "$lib/serial/serialization"
|
||||||
import {chords} from "$lib/serial/connection"
|
import {chords, layout} from "$lib/serial/connection"
|
||||||
|
|
||||||
async function downloadBackup() {
|
async function downloadBackup() {
|
||||||
const downloadUrl = URL.createObjectURL(await stringifyCompressed($chords))
|
const downloadUrl = URL.createObjectURL(
|
||||||
|
await stringifyCompressed({
|
||||||
|
isCharaBackup: "v1.0",
|
||||||
|
chords: $chords,
|
||||||
|
layout: $layout,
|
||||||
|
}),
|
||||||
|
)
|
||||||
const element = document.createElement("a")
|
const element = document.createElement("a")
|
||||||
element.setAttribute("download", "chords.chl")
|
element.setAttribute("download", "chords.chb")
|
||||||
element.href = downloadUrl
|
element.href = downloadUrl
|
||||||
element.setAttribute("target", "_blank")
|
element.setAttribute("target", "_blank")
|
||||||
element.click()
|
element.click()
|
||||||
URL.revokeObjectURL(downloadUrl)
|
URL.revokeObjectURL(downloadUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function restoreBackup(event: InputEvent) {
|
||||||
|
const input = (event.target as HTMLInputElement).files![0]
|
||||||
|
if (!input) return
|
||||||
|
const backup = await parseCompressed(input)
|
||||||
|
if (backup.isCharaBackup !== "v1.0") throw new Error("Invalid Backup")
|
||||||
|
if (backup.chords) {
|
||||||
|
$chords = backup.chords
|
||||||
|
}
|
||||||
|
if (backup.layout) {
|
||||||
|
$layout = backup.layout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function createShareUrl() {
|
async function createShareUrl() {
|
||||||
console.log(await getSharableUrl("chords", $chords))
|
console.log(await getSharableUrl("chords", $chords))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>Backup & Restore</h1>
|
<section>
|
||||||
|
<h1>Backup & Restore</h1>
|
||||||
|
|
||||||
<button on:click={downloadBackup}><span class="icon">save</span> Backup</button>
|
<p class="disclaimer">
|
||||||
<button><span class="icon">settings_backup_restore</span> Restore</button>
|
<i
|
||||||
|
>We automatically backup your device settings. Backups remain on your computer and are never shared or
|
||||||
|
uploaded to our servers.</i
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="save">
|
||||||
|
<button class="primary" on:click={downloadBackup}><span class="icon">save</span> Download Backup</button>
|
||||||
|
<label class="button"
|
||||||
|
><input on:input={restoreBackup} type="file" /><span class="icon">settings_backup_restore</span> Restore</label
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.disclaimer {
|
||||||
|
max-width: 16cm;
|
||||||
|
font-size: 12px;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="file"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button,
|
||||||
|
button {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
padding-block: 8px;
|
||||||
|
padding-inline: 16px;
|
||||||
|
|
||||||
|
font-family: "Noto Sans Mono", monospace;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--md-sys-color-on-background);
|
||||||
|
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 32px;
|
||||||
|
|
||||||
|
transition: all 250ms ease;
|
||||||
|
|
||||||
|
&.primary {
|
||||||
|
color: var(--md-sys-color-on-primary);
|
||||||
|
background: var(--md-sys-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user