fix: warn users if no device is connected

fix: can't backup without a device
This commit is contained in:
2023-12-08 22:55:33 +01:00
parent af01426f43
commit f9a63a8724
4 changed files with 32 additions and 32 deletions

View File

@@ -8,6 +8,7 @@
import {loadLocaleAsync} from "../i18n/i18n-util.async" import {loadLocaleAsync} from "../i18n/i18n-util.async"
import {tick} from "svelte" import {tick} from "svelte"
import SyncOverlay from "./SyncOverlay.svelte" import SyncOverlay from "./SyncOverlay.svelte"
import {serialPort} from "$lib/serial/connection"
let locale = (browser && (localStorage.getItem("locale") as Locales)) || detectLocale() let locale = (browser && (localStorage.getItem("locale") as Locales)) || detectLocale()
$: if (browser) $: if (browser)
@@ -46,9 +47,14 @@
> >
</li> </li>
</ul> </ul>
<div>
<SyncOverlay /> {#if !$serialPort}
<div class="warning">
<span class="icon">warning</span>{$LL.deviceManager.NO_DEVICE()}
</div>
{/if}
<SyncOverlay />
</div>
<ul> <ul>
<li> <li>
<input use:action={{title: $LL.profile.theme.COLOR_SCHEME()}} type="color" bind:value={$theme.color} /> <input use:action={{title: $LL.profile.theme.COLOR_SCHEME()}} type="color" bind:value={$theme.color} />
@@ -87,6 +93,14 @@
opacity: 0; opacity: 0;
} }
.warning {
color: var(--md-sys-color-error);
gap: 8px;
display: flex;
align-items: center;
justify-content: center;
}
input[type="color"] { input[type="color"] {
cursor: pointer; cursor: pointer;
@@ -116,9 +130,10 @@
} }
footer { footer {
display: flex; display: grid;
align-items: center; align-items: center;
justify-content: space-between; justify-content: center;
grid-template-columns: 1fr auto 1fr;
width: 100%; width: 100%;
padding: 8px; padding: 8px;
@@ -137,6 +152,10 @@
padding: 0; padding: 0;
list-style: none; list-style: none;
&:last-child {
justify-content: flex-end;
}
} }
ul:last-child { ul:last-child {

View File

@@ -50,15 +50,13 @@
<PwaStatus /> <PwaStatus />
{/await} {/await}
{/if} {/if}
{#if $serialPort} <button use:action={{title: $LL.backup.TITLE()}} use:popup={BackupPopup} class="icon {$syncStatus}">
<button use:action={{title: $LL.backup.TITLE()}} use:popup={BackupPopup} class="icon {$syncStatus}"> {#if $userPreferences.backup}
{#if $userPreferences.backup} history
history {:else}
{:else} history_toggle_off
history_toggle_off {/if}
{/if} </button>
</button>
{/if}
<button <button
bind:this={connectButton} bind:this={connectButton}
use:action={{title: $LL.deviceManager.TITLE()}} use:action={{title: $LL.deviceManager.TITLE()}}

View File

@@ -1,17 +0,0 @@
<script>
import {serialPort} from "$lib/serial/connection"
import {LL} from "../../i18n/i18n-svelte"
</script>
{#if $serialPort}
<slot />
{:else}
<p>{$LL.deviceManager.NO_DEVICE()}</p>
{/if}
<style lang="scss">
p {
margin: auto;
opacity: 0.4;
}
</style>

View File

@@ -30,7 +30,7 @@
onHidden(instance) { onHidden(instance) {
instance.destroy() instance.destroy()
}, },
onDestroy(instance) { onDestroy() {
shareComponent.$destroy() shareComponent.$destroy()
}, },
}).show() }).show()