mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-08 11:02:50 +00:00
@@ -14,6 +14,7 @@ const de = {
|
||||
sync: {
|
||||
TITLE_READ: "Neueste Änderungen werden abgerufen",
|
||||
TITLE_WRITE: "Änderungen werden gespeichert",
|
||||
RELOAD: "Neu laden",
|
||||
},
|
||||
backup: {
|
||||
TITLE: "Verlauf speichern",
|
||||
|
||||
@@ -21,6 +21,7 @@ const en = {
|
||||
sync: {
|
||||
TITLE_READ: "Reading latest changes",
|
||||
TITLE_WRITE: "Saving changes to device",
|
||||
RELOAD: "Reload",
|
||||
},
|
||||
modal: {
|
||||
CLOSE: "Close",
|
||||
|
||||
@@ -55,6 +55,12 @@ export async function initSerial(manual = false) {
|
||||
const device = get(serialPort) ?? new CharaDevice()
|
||||
await device.init(manual)
|
||||
serialPort.set(device)
|
||||
sync()
|
||||
}
|
||||
|
||||
export async function sync() {
|
||||
const device = get(serialPort)
|
||||
if (!device) return
|
||||
const chordCount = await device.getChordCount()
|
||||
syncStatus.set("downloading")
|
||||
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
<script lang="ts">
|
||||
import {syncProgress, syncStatus} from "$lib/serial/connection"
|
||||
import {serialPort, syncProgress, syncStatus, sync} from "$lib/serial/connection"
|
||||
import LL from "../i18n/i18n-svelte"
|
||||
import {fly} from "svelte/transition"
|
||||
import {slide} from "svelte/transition"
|
||||
</script>
|
||||
|
||||
{#if $syncStatus !== "done"}
|
||||
<div transition:fly={{y: 40}}>
|
||||
<progress max={$syncProgress?.max ?? 1} value={$syncProgress?.current ?? 1}></progress>
|
||||
{#if $syncStatus === "downloading"}
|
||||
<div>{$LL.sync.TITLE_READ()}</div>
|
||||
{:else}
|
||||
<div>{$LL.sync.TITLE_WRITE()}</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="container">
|
||||
{#if $syncStatus !== "done"}
|
||||
<div transition:slide>
|
||||
<progress max={$syncProgress?.max ?? 1} value={$syncProgress?.current ?? 1}></progress>
|
||||
{#if $syncStatus === "downloading"}
|
||||
<div>{$LL.sync.TITLE_READ()}</div>
|
||||
{:else}
|
||||
<div>{$LL.sync.TITLE_WRITE()}</div>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if $serialPort}
|
||||
<button transition:slide on:click={sync}><span class="icon">refresh</span>{$LL.sync.RELOAD()}</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
div {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user