migration to Svelte 5
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
nemunaire 2025-01-04 15:52:29 +01:00
parent a032d3a166
commit 1378636a98
28 changed files with 164 additions and 206 deletions

View File

@ -9,12 +9,9 @@
import { actions } from '$lib/stores/actions'; import { actions } from '$lib/stores/actions';
export let flush = false; let { flush = false, class: className = '' } = $props();
export { className as class }; let refreshInProgress = $state(false);
let className = '';
let refreshInProgress = false;
function refresh_actions() { function refresh_actions() {
refreshInProgress = true; refreshInProgress = true;
actions.refresh().then(() => { actions.refresh().then(() => {
@ -29,13 +26,12 @@
</h2> </h2>
<div> <div>
{#if !flush} {#if !flush}
<Button <a
href="routines/actions" href="routines/actions"
color="outline-info" class="btn btn-sm btn-outline-info"
size="sm"
> >
<Icon name="pencil" /> <Icon name="pencil" />
</Button> </a>
{/if} {/if}
<Button <Button
color="outline-dark" color="outline-dark"

View File

@ -10,21 +10,19 @@
import DateRangeFormat from '$lib/components/DateRangeFormat.svelte'; import DateRangeFormat from '$lib/components/DateRangeFormat.svelte';
import { alarmsExceptions } from '$lib/stores/alarmexceptions'; import { alarmsExceptions } from '$lib/stores/alarmexceptions';
export let flush = false; let { flush = false } = $props();
</script> </script>
<div class="d-flex justify-content-between align-items-center" class:mx-2={flush}> <div class="d-flex justify-content-between align-items-center" class:mx-2={flush}>
<h2> <h2>
Exceptions Exceptions
</h2> </h2>
<Button <a
href="alarms/exceptions/new" href="alarms/exceptions/new"
color="outline-primary" class="btn btn-sm btn-outline-primary float-end {($page.params.kind === 'single' && $page.url.pathname.endsWith('/new'))?'active':''}"
size="sm"
class="float-end {($page.params.kind === 'exceptions' && $page.url.pathname.endsWith('/new'))?'active':''}"
> >
<Icon name="plus-lg" /> <Icon name="plus-lg" />
</Button> </a>
</div> </div>
<div class="text-center"> <div class="text-center">
{#if $alarmsExceptions.list !== null} {#if $alarmsExceptions.list !== null}

View File

@ -10,21 +10,19 @@
import { weekdayStr } from '$lib/alarmrepeated'; import { weekdayStr } from '$lib/alarmrepeated';
import { alarmsRepeated } from '$lib/stores/alarmrepeated'; import { alarmsRepeated } from '$lib/stores/alarmrepeated';
export let flush = false; let { flush = false } = $props();
</script> </script>
<div class="d-flex justify-content-between align-items-center" class:mx-2={flush}> <div class="d-flex justify-content-between align-items-center" class:mx-2={flush}>
<h2> <h2>
Réveils habituels Réveils habituels
</h2> </h2>
<Button <a
href="alarms/repeated/new" href="alarms/repeated/new"
color="outline-primary" class="btn btn-sm btn-outline-primary float-end {($page.params.kind === 'single' && $page.url.pathname.endsWith('/new'))?'active':''}"
size="sm"
class="float-end {($page.params.kind === 'repeated' && $page.url.pathname.endsWith('/new'))?'active':''}"
> >
<Icon name="plus-lg" /> <Icon name="plus-lg" />
</Button> </a>
</div> </div>
<div class="text-center"> <div class="text-center">
{#if $alarmsRepeated.list !== null} {#if $alarmsRepeated.list !== null}

View File

@ -10,21 +10,19 @@
import DateFormat from '$lib/components/DateFormat.svelte'; import DateFormat from '$lib/components/DateFormat.svelte';
import { alarmsSingle } from '$lib/stores/alarmsingle'; import { alarmsSingle } from '$lib/stores/alarmsingle';
export let flush = false; let { flush = false } = $props();
</script> </script>
<div class="d-flex justify-content-between align-items-center" class:mx-2={flush}> <div class="d-flex justify-content-between align-items-center" class:mx-2={flush}>
<h2> <h2>
Réveils manuels Réveils manuels
</h2> </h2>
<Button <a
href="alarms/single/new" href="alarms/single/new"
color="outline-primary" class="btn btn-sm btn-outline-primary float-end {($page.params.kind === 'single' && $page.url.pathname.endsWith('/new'))?'active':''}"
size="sm"
class="float-end {($page.params.kind === 'single' && $page.url.pathname.endsWith('/new'))?'active':''}"
> >
<Icon name="plus-lg" /> <Icon name="plus-lg" />
</Button> </a>
</div> </div>
<div class="text-center"> <div class="text-center">
{#if $alarmsSingle.list !== null} {#if $alarmsSingle.list !== null}

View File

@ -15,10 +15,10 @@
import { actions_idx } from '$lib/stores/actions'; import { actions_idx } from '$lib/stores/actions';
export let routine = { let { routine = {
name: "Classique", name: "Classique",
steps: [], steps: [],
}; } } = $props();
</script> </script>
<Card> <Card>

View File

@ -7,12 +7,12 @@
Icon, Icon,
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
export let awakingList = [ let { awakingList = [
{ {
id: 1, id: 1,
date: new Date("2022-10-01T09:15:00.000Z"), date: new Date("2022-10-01T09:15:00.000Z"),
}, },
]; ] } = $props();
</script> </script>
<Card> <Card>

View File

@ -8,13 +8,13 @@
Icon, Icon,
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
export let routinesStats = [ let { routinesStats = [
{ {
id: 1, id: 1,
name: "Classique", name: "Classique",
nb: 10, nb: 10,
}, },
]; ] } = $props();
</script> </script>
<Card> <Card>

View File

@ -1,9 +1,6 @@
<script> <script lang="ts">
import { createEventDispatcher, onMount, onDestroy } from 'svelte'; import { createEventDispatcher, onMount, onDestroy } from 'svelte';
export let begins = null;
export let ends;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
let interval; let interval;
@ -24,8 +21,7 @@
} }
}); });
export { className as class }; let { begins = $bindable(null), ends, class: className = 'text-muted' } = $props();
let className = 'text-muted';
</script> </script>
{#if begins && ends} {#if begins && ends}

View File

@ -1,7 +1,5 @@
<script> <script>
export let date; let { date, dateStyle, timeStyle } = $props();
export let dateStyle;
export let timeStyle;
function formatDate(input, dateStyle, timeStyle) { function formatDate(input, dateStyle, timeStyle) {
if (typeof input === 'string') { if (typeof input === 'string') {

View File

@ -1,8 +1,10 @@
<script> <script>
export let startDate; let {
export let endDate; startDate,
export let dateStyle; endDate,
export let timeStyle; dateStyle,
timeStyle
} = $props();
function formatRange(startDate, endDate, dateStyle, timeStyle) { function formatRange(startDate, endDate, dateStyle, timeStyle) {
if (typeof input === 'string') { if (typeof input === 'string') {

View File

@ -5,16 +5,15 @@
Input, Input,
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
export let format = 'YYYY-MM-DD HH:mm'; let {
export let date = new Date(); format = 'YYYY-MM-DD HH:mm',
date = $bindable(new Date()),
class: className = '',
id = null,
required = false
} = $props();
let className = ''; let internal = $state();
export { className as class };
export let id = null;
export let required = false;
let internal;
const input = (x) => (internal = dayjs(x).format(format)); const input = (x) => (internal = dayjs(x).format(format));
const output = (x) => { const output = (x) => {
@ -24,8 +23,12 @@
} }
}; };
$: input(date) $effect(() => {
$: output(internal) input(date)
});
$effect(() => {
output(internal)
});
</script> </script>
<Input type="datetime-local" class={className} id={id} {required} bind:value={internal} /> <Input type="datetime-local" class={className} id={id} {required} bind:value={internal} />

View File

@ -14,8 +14,7 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
export let id = ""; let { id = "", value = $bindable({ }) } = $props();
export let value = { };
function changeKey(bak, to) { function changeKey(bak, to) {
if (bak === null && to.target.value) { if (bak === null && to.target.value) {
@ -29,7 +28,7 @@
} }
} }
const syncInProgress = { }; const syncInProgress = $state({ });
async function syncMusic(srv) { async function syncMusic(srv) {
syncInProgress[srv] = true; syncInProgress[srv] = true;
@ -64,12 +63,13 @@
bind:value={value[key].url} bind:value={value[key].url}
on:change={() => dispatch("input")} on:change={() => dispatch("input")}
/> />
<Button <a
href={value[key].url} href={value[key].url}
class="btn btn-secondary"
target="_blank" target="_blank"
> >
<Icon name="globe" /> <Icon name="globe" />
</Button> </a>
</InputGroup> </InputGroup>
</Col> </Col>
<Col> <Col>

View File

@ -16,13 +16,9 @@
}); });
} }
export let flush = false; let { flush = false, edit = false, class: className = '' } = $props();
export let edit = false;
export { className as class }; let refreshInProgress = $state(false);
let className = '';
let refreshInProgress = false;
function refresh_gongs() { function refresh_gongs() {
refreshInProgress = true; refreshInProgress = true;
gongs.refresh().then(() => { gongs.refresh().then(() => {
@ -37,26 +33,24 @@
</h2> </h2>
<div> <div>
{#if !edit} {#if !edit}
<Button <a
href="musiks/gongs" href="musiks/gongs"
color="outline-info" class="btn btn-sm btn-outline-info"
size="sm"
> >
<Icon name="pencil" /> <Icon name="pencil" />
</Button> </a>
{/if} {/if}
<Button <a
href="musiks/gongs/new" href="musiks/gongs/new"
color="outline-primary" class="btn btn-sm btn-outline-primary"
size="sm"
> >
<Icon name="plus-lg" /> <Icon name="plus-lg" />
</Button> </a>
<Button <Button
color="outline-dark" color="outline-dark"
size="sm" size="sm"
title="Rafraîchir la liste des gongs" title="Rafraîchir la liste des gongs"
on:click={refresh_gongs} onclick={refresh_gongs}
disabled={refreshInProgress} disabled={refreshInProgress}
> >
{#if !refreshInProgress} {#if !refreshInProgress}
@ -75,7 +69,7 @@
class="list-group-item list-group-item-action" class="list-group-item list-group-item-action"
class:active={(edit && $page.url.pathname.indexOf('/gongs/') !== -1 && $page.params.gid == gong.id) || (!edit && gong.enabled)} class:active={(edit && $page.url.pathname.indexOf('/gongs/') !== -1 && $page.params.gid == gong.id) || (!edit && gong.enabled)}
aria-current="true" aria-current="true"
on:click={() => { onclick={() => {
if (edit) { if (edit) {
goto('musiks/gongs/' + gong.id); goto('musiks/gongs/' + gong.id);
} else { } else {

View File

@ -12,15 +12,7 @@
const version = fetch('api/version', {headers: {'Accept': 'application/json'}}).then((res) => res.json()) const version = fetch('api/version', {headers: {'Accept': 'application/json'}}).then((res) => res.json())
export let activemenu = ""; let { class: className = '' } = $props();
$: {
const path = $page.url.pathname.split("/");
if (path.length > 1) {
activemenu = path[1];
}
}
export { className as class };
let className = '';
</script> </script>
<Navbar container={false} class="{className} px-md-2" color="primary" dark expand="xs" style="overflow-x: auto"> <Navbar container={false} class="{className} px-md-2" color="primary" dark expand="xs" style="overflow-x: auto">
@ -30,7 +22,7 @@
<Nav navbar> <Nav navbar>
<NavItem class="d-block d-md-none"> <NavItem class="d-block d-md-none">
<NavLink <NavLink
active={activemenu === ''} active={$page.route.id === '/'}
class="text-center" class="text-center"
href="." href="."
> >
@ -40,7 +32,7 @@
</NavItem> </NavItem>
<NavItem> <NavItem>
<NavLink <NavLink
active={activemenu === 'alarms'} active={$page.route.id.startsWith('/alarms')}
class="text-center" class="text-center"
href="alarms" href="alarms"
> >
@ -52,7 +44,7 @@
<NavLink <NavLink
href="musiks" href="musiks"
class="text-center" class="text-center"
active={activemenu === 'musiks'} active={$page.route.id.startsWith('/musiks')}
> >
<Icon name="music-note-list" /><br class="d-inline d-md-none"> <Icon name="music-note-list" /><br class="d-inline d-md-none">
Musiques Musiques
@ -62,7 +54,7 @@
<NavLink <NavLink
href="routines" href="routines"
class="text-center" class="text-center"
active={activemenu === 'routines'} active={$page.route.id.startsWith('/routines')}
> >
<Icon name="activity" /><br class="d-inline d-md-none"> <Icon name="activity" /><br class="d-inline d-md-none">
Routines Routines
@ -72,7 +64,7 @@
<NavLink <NavLink
href="history" href="history"
class="text-center" class="text-center"
active={activemenu === 'history'} active={$page.route.id.startsWith('/history')}
> >
<Icon name="clipboard-pulse" /><br class="d-inline d-md-none"> <Icon name="clipboard-pulse" /><br class="d-inline d-md-none">
Historique Historique
@ -82,7 +74,7 @@
<NavLink <NavLink
href="settings" href="settings"
class="text-center" class="text-center"
active={activemenu === 'settings'} active={$page.route.id.startsWith('/settings')}
> >
<Icon name="gear-fill" /><br class="d-inline d-md-none"> <Icon name="gear-fill" /><br class="d-inline d-md-none">
Paramètres Paramètres

View File

@ -10,13 +10,9 @@
import { tracks } from '$lib/stores/tracks'; import { tracks } from '$lib/stores/tracks';
export let flush = false; let { flush = false, edit = false, class: className = '' } = $props();
export let edit = false;
export { className as class }; let refreshInProgress = $state(false);
let className = '';
let refreshInProgress = false;
function refresh_tracks() { function refresh_tracks() {
refreshInProgress = true; refreshInProgress = true;
tracks.refresh().then(() => { tracks.refresh().then(() => {
@ -31,26 +27,24 @@
</h2> </h2>
<div> <div>
{#if !edit} {#if !edit}
<Button <a
href="musiks/tracks" href="musiks/tracks"
color="outline-info" class="btn btn-sm btn-outline-info"
size="sm"
> >
<Icon name="pencil" /> <Icon name="pencil" />
</Button> </a>
{/if} {/if}
<Button <a
href="musiks/tracks/new" href="musiks/tracks/new"
color="outline-primary" class="btn btn-sm btn-outline-primary"
size="sm"
> >
<Icon name="plus-lg" /> <Icon name="plus-lg" />
</Button> </a>
<Button <Button
color="outline-dark" color="outline-dark"
size="sm" size="sm"
title="Rafraîchir la liste des pistes" title="Rafraîchir la liste des pistes"
on:click={refresh_tracks} onclick={refresh_tracks}
disabled={refreshInProgress} disabled={refreshInProgress}
> >
{#if !refreshInProgress} {#if !refreshInProgress}
@ -69,7 +63,7 @@
class="list-group-item list-group-item-action" class="list-group-item list-group-item-action"
class:active={$page.url.pathname.indexOf('/tracks/') !== -1 && $page.params.tid == track.id} class:active={$page.url.pathname.indexOf('/tracks/') !== -1 && $page.params.tid == track.id}
aria-current="true" aria-current="true"
on:click={() => { onclick={() => {
if (edit) { if (edit) {
goto('musiks/tracks/' + track.id); goto('musiks/tracks/' + track.id);
} else { } else {

View File

@ -10,6 +10,8 @@
import Toaster from '$lib/components/Toaster.svelte'; import Toaster from '$lib/components/Toaster.svelte';
import { ToastsStore } from '$lib/stores/toasts'; import { ToastsStore } from '$lib/stores/toasts';
let { children } = $props();
window.onunhandledrejection = (e) => { window.onunhandledrejection = (e) => {
ToastsStore.addErrorToast({ ToastsStore.addErrorToast({
message: e.reason, message: e.reason,
@ -28,7 +30,7 @@
class="d-none d-lg-flex py-2" class="d-none d-lg-flex py-2"
/> />
<div class="flex-fill d-flex flex-column bg-light"> <div class="flex-fill d-flex flex-column bg-light">
<slot></slot> {@render children?.()}
<div class="d-flex d-lg-none mt-3 mb-5"></div> <div class="d-flex d-lg-none mt-3 mb-5"></div>
</div> </div>
<Toaster /> <Toaster />

View File

@ -13,8 +13,8 @@
import { alarmsSingle } from '$lib/stores/alarmsingle'; import { alarmsSingle } from '$lib/stores/alarmsingle';
import { quotes } from '$lib/stores/quotes'; import { quotes } from '$lib/stores/quotes';
let nextAlarmP = getNextAlarm(); let nextAlarmP = $state(getNextAlarm());
let isActiveP = isAlarmActive(); let isActiveP = $state(isAlarmActive());
function reloadNextAlarm() { function reloadNextAlarm() {
nextAlarmP = getNextAlarm(); nextAlarmP = getNextAlarm();
@ -53,7 +53,7 @@
}); });
} }
let extinctionInProgress = false; let extinctionInProgress = $state(false);
</script> </script>
<Container class="flex-fill d-flex flex-column justify-content-center text-center"> <Container class="flex-fill d-flex flex-column justify-content-center text-center">
@ -103,7 +103,7 @@
<button <button
class="btn btn-lg btn-link" class="btn btn-lg btn-link"
title="Supprimer ce prochain réveil" title="Supprimer ce prochain réveil"
on:click={dropNextAlarm} onclick={dropNextAlarm}
> >
<Icon name="x-circle-fill" /> <Icon name="x-circle-fill" />
</button> </button>
@ -123,14 +123,14 @@
</a> </a>
<button <button
class="btn btn-info" class="btn btn-info"
on:click={() => newCyclesAlarm(5)} onclick={() => newCyclesAlarm(5)}
> >
<Icon name="node-plus" /> <Icon name="node-plus" />
5 cycles 5 cycles
</button> </button>
<button <button
class="btn btn-info" class="btn btn-info"
on:click={() => newCyclesAlarm(6)} onclick={() => newCyclesAlarm(6)}
> >
<Icon name="node-plus" /> <Icon name="node-plus" />
6 cycles 6 cycles
@ -138,7 +138,7 @@
<button <button
class="btn btn-outline-warning" class="btn btn-outline-warning"
title="Lancer le réveil" title="Lancer le réveil"
on:click={() => { runAlarm(); setTimeout(reloadIsActiveAlarm, 500); }} onclick={() => { runAlarm(); setTimeout(reloadIsActiveAlarm, 500); }}
> >
<Icon name="play-circle" /> <Icon name="play-circle" />
Lancer <span class="d-none d-lg-inline">le réveil</span> Lancer <span class="d-none d-lg-inline">le réveil</span>
@ -148,14 +148,14 @@
<div class="d-flex gap-3 mt-3 justify-content-center"> <div class="d-flex gap-3 mt-3 justify-content-center">
<button <button
class="btn btn-outline-info" class="btn btn-outline-info"
on:click={alarmNextTrack} onclick={alarmNextTrack}
> >
<Icon name="skip-end-fill" /> <Icon name="skip-end-fill" />
Chanson suivante Chanson suivante
</button> </button>
<button <button
class="btn btn-danger" class="btn btn-danger"
on:click={stopAlarm} onclick={stopAlarm}
> >
{#if extinctionInProgress} {#if extinctionInProgress}
<Spinner size="sm" /> <Spinner size="sm" />

View File

@ -13,6 +13,8 @@
import AlarmRepeatedList from '$lib/components/AlarmRepeatedList.svelte'; import AlarmRepeatedList from '$lib/components/AlarmRepeatedList.svelte';
import AlarmExceptionList from '$lib/components/AlarmExceptionList.svelte'; import AlarmExceptionList from '$lib/components/AlarmExceptionList.svelte';
let { children } = $props();
function slugToComponent(slug) { function slugToComponent(slug) {
switch(slug) { switch(slug) {
case "single": case "single":
@ -37,7 +39,7 @@
<svelte:component this={slugToComponent($page.params["kind"])} flush={true} /> <svelte:component this={slugToComponent($page.params["kind"])} flush={true} />
</Col> </Col>
<Col md={9} class="d-flex py-2"> <Col md={9} class="d-flex py-2">
<slot></slot> {@render children?.()}
</Col> </Col>
</Row> </Row>
</Container> </Container>

View File

@ -1,4 +1,6 @@
<script> <script>
import { run } from 'svelte/legacy';
import { import {
Button, Button,
Col, Col,
@ -34,27 +36,20 @@
} }
} }
let objP; function callRightFunction(kind) {
let obj; switch(kind) {
$: {
switch ($page.params["kind"]) {
case "single": case "single":
objP = getAlarmSingle($page.params["aid"]); return getAlarmSingle;
break;
case "repeated": case "repeated":
objP = getAlarmRepeated($page.params["aid"]); return getAlarmRepeated;
break;
case "exceptions": case "exceptions":
objP = getAlarmException($page.params["aid"]); return getAlarmException;
break;
} }
objP.then((o) => obj = o);
} }
let edit = false; let edit = $state(false);
function deleteThis() { function deleteThis(obj) {
obj.delete().then(() => { obj.delete().then(() => {
switch($page.params["kind"]) { switch($page.params["kind"]) {
case "single": case "single":
@ -74,12 +69,12 @@
</script> </script>
<Container fluid class="flex-fill"> <Container fluid class="flex-fill">
{#if $page.params["kind"] == "single"} {#await callRightFunction($page.params["kind"])($page.params["aid"])}
{#await objP}
<div class="d-flex justify-content-center align-items-center gap-2"> <div class="d-flex justify-content-center align-items-center gap-2">
<Spinner color="primary" /> Chargement en cours&hellip; <Spinner color="primary" /> Chargement en cours&hellip;
</div> </div>
{:then alarm} {:then alarm}
{#if $page.params["kind"] == "single"}
<h2 class="mb-0"> <h2 class="mb-0">
{slugToTitle($page.params["kind"])} du <DateFormat date={alarm.time} dateStyle="long" /> {slugToTitle($page.params["kind"])} du <DateFormat date={alarm.time} dateStyle="long" />
</h2> </h2>
@ -97,16 +92,10 @@
</ListGroupItem> </ListGroupItem>
<ListGroupItem class="d-flex"> <ListGroupItem class="d-flex">
<strong>Fédération activée&nbsp;?</strong> <strong>Fédération activée&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"} <Input type="switch" class="ms-2" on:change={() => {alarm.enable_federation = !alarm.enable_federation; alarm.save();}} checked={alarm.enable_federation} /> {alarm.enable_federation?"oui":"non"}
</ListGroupItem> </ListGroupItem>
</ListGroup> </ListGroup>
{/await}
{:else if $page.params["kind"] == "repeated"} {:else if $page.params["kind"] == "repeated"}
{#await objP}
<div class="d-flex justify-content-center align-items-center gap-2">
<Spinner color="primary" /> Chargement en cours&hellip;
</div>
{:then alarm}
<h2 class="mb-0"> <h2 class="mb-0">
{slugToTitle($page.params["kind"])} des {weekdayStr(alarm.weekday)}s à {alarm.time} {slugToTitle($page.params["kind"])} des {weekdayStr(alarm.weekday)}s à {alarm.time}
</h2> </h2>
@ -124,19 +113,19 @@
</ListGroupItem> </ListGroupItem>
<ListGroupItem class="d-flex"> <ListGroupItem class="d-flex">
<strong>Alarme active&nbsp;?</strong> <strong>Alarme active&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.disabled = !obj.disabled; obj.save().then(() => {obj.next_time = null; alarmsRepeated.refresh()});}} checked={!obj.disabled} /> {!obj.disabled?"oui":"non"} <Input type="switch" class="ms-2" on:change={() => {alarm.disabled = !alarm.disabled; alarm.save().then(() => {alarm.next_time = null; alarmsRepeated.refresh()});}} checked={!alarm.disabled} /> {!alarm.disabled?"oui":"non"}
</ListGroupItem> </ListGroupItem>
<ListGroupItem class="d-flex"> <ListGroupItem class="d-flex">
<strong>Ignorer les exceptions&nbsp;?</strong> <strong>Ignorer les exceptions&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.ignore_exceptions = !obj.ignore_exceptions; obj.save();}} checked={obj.ignore_exceptions} /> {obj.ignore_exceptions?"oui":"non"} <Input type="switch" class="ms-2" on:change={() => {alarm.ignore_exceptions = !alarm.ignore_exceptions; alarm.save();}} checked={alarm.ignore_exceptions} /> {alarm.ignore_exceptions?"oui":"non"}
</ListGroupItem> </ListGroupItem>
<ListGroupItem class="d-flex"> <ListGroupItem class="d-flex">
<strong>Fédération activée&nbsp;?</strong> <strong>Fédération activée&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"} <Input type="switch" class="ms-2" on:change={() => {alarm.enable_federation = !alarm.enable_federation; alarm.save();}} checked={alarm.enable_federation} /> {alarm.enable_federation?"oui":"non"}
</ListGroupItem> </ListGroupItem>
{#if alarm.next_time} {#if alarm.next_time}
<ListGroupItem> <ListGroupItem>
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(obj.next_time)} dateStyle="long" /> <strong>Prochaine occurrence</strong> <DateFormat date={new Date(alarm.next_time)} dateStyle="long" />
</ListGroupItem> </ListGroupItem>
{/if} {/if}
</ListGroup> </ListGroup>
@ -150,13 +139,7 @@
{/each} {/each}
</ListGroup> </ListGroup>
{/if} {/if}
{/await}
{:else if $page.params["kind"] == "exceptions"} {:else if $page.params["kind"] == "exceptions"}
{#await objP}
<div class="d-flex justify-content-center align-items-center gap-2">
<Spinner color="primary" /> Chargement en cours&hellip;
</div>
{:then exception}
<h2 class="mb-0"> <h2 class="mb-0">
{slugToTitle($page.params["kind"])} du <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" /> {slugToTitle($page.params["kind"])} du <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" />
</h2> </h2>
@ -166,11 +149,8 @@
</p> </p>
{/if} {/if}
Entre le <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" /> Entre le <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" />
{/await}
{/if} {/if}
{#if !edit} {#if !edit}
{#await objP then alarm}
<ListGroup class="my-2 text-center"> <ListGroup class="my-2 text-center">
<ListGroupItem <ListGroupItem
action action
@ -185,12 +165,12 @@
action action
tag="button" tag="button"
class="text-danger fw-bold" class="text-danger fw-bold"
on:click={deleteThis} on:click={() => deleteThis(alarm)}
> >
<Icon name="trash" /> <Icon name="trash" />
Supprimer ce {slugToTitle($page.params["kind"]).toLowerCase()} Supprimer ce {slugToTitle($page.params["kind"]).toLowerCase()}
</ListGroupItem> </ListGroupItem>
</ListGroup> </ListGroup>
{/await}
{/if} {/if}
{/await}
</Container> </Container>

View File

@ -35,7 +35,7 @@
} }
} }
let obj; let obj = $state();
const vtime = new Date(Date.now() + 7.6*3600000); const vtime = new Date(Date.now() + 7.6*3600000);
@ -56,7 +56,8 @@
break; break;
} }
function submit() { function submit(e) {
e.preventDefault();
obj.save().then((res) => { obj.save().then((res) => {
switch($page.params["kind"]) { switch($page.params["kind"]) {
case "single": case "single":
@ -76,7 +77,7 @@
</script> </script>
<Container fluid class="flex-fill"> <Container fluid class="flex-fill">
<form on:submit|preventDefault={submit}> <form onsubmit={submit}>
<Button type="submit" color="link" class="d-block d-md-none float-end"> <Button type="submit" color="link" class="d-block d-md-none float-end">
Ajouter Ajouter
</Button> </Button>

View File

@ -8,6 +8,8 @@
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
import GongsList from '$lib/components/GongsList.svelte'; import GongsList from '$lib/components/GongsList.svelte';
let { children } = $props();
</script> </script>
<div class="d-flex flex-fill flex-column"> <div class="d-flex flex-fill flex-column">
@ -22,7 +24,7 @@
<GongsList edit flush /> <GongsList edit flush />
</Col> </Col>
<Col md={9} class="d-flex py-2"> <Col md={9} class="d-flex py-2">
<slot></slot> {@render children?.()}
</Col> </Col>
</Row> </Row>
</Container> </Container>

View File

@ -22,7 +22,7 @@
}) })
} }
let confirmDeletion = false; let confirmDeletion = $state(false);
</script> </script>
{#await getGong($page.params.gid)} {#await getGong($page.params.gid)}

View File

@ -15,7 +15,9 @@
import { gongs } from '$lib/stores/gongs'; import { gongs } from '$lib/stores/gongs';
import { uploadGong } from '$lib/gong'; import { uploadGong } from '$lib/gong';
function submitGong() { function submitGong(e) {
e.preventDefault();
if (files.length == 0) { if (files.length == 0) {
alert("Vous n'avez sélectionné aucun fichier !") alert("Vous n'avez sélectionné aucun fichier !")
return false; return false;
@ -27,7 +29,7 @@
}) })
} }
export let files = []; let { files = $bindable([]) } = $props();
</script> </script>
<Container> <Container>
@ -35,7 +37,7 @@
Nouveau gong Nouveau gong
</h2> </h2>
<form on:submit|preventDefault={submitGong}> <form onsubmit={submitGong}>
<Input type="file" bind:files /> <Input type="file" bind:files />
<Button type="submit" color="primary" class="mt-2" disabled={files.length == 0}> <Button type="submit" color="primary" class="mt-2" disabled={files.length == 0}>

View File

@ -8,6 +8,8 @@
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
import TrackList from '$lib/components/TrackList.svelte'; import TrackList from '$lib/components/TrackList.svelte';
let { children } = $props();
</script> </script>
<div class="d-flex flex-fill flex-column"> <div class="d-flex flex-fill flex-column">
@ -22,7 +24,7 @@
<TrackList edit flush /> <TrackList edit flush />
</Col> </Col>
<Col md={9} class="d-flex py-2"> <Col md={9} class="d-flex py-2">
<slot></slot> {@render children?.()}
</Col> </Col>
</Row> </Row>
</Container> </Container>

View File

@ -28,7 +28,7 @@
}) })
} }
let confirmDeletion = false; let confirmDeletion = $state(false);
</script> </script>
{#await getTrack($page.params.tid)} {#await getTrack($page.params.tid)}

View File

@ -15,7 +15,9 @@
import { tracks } from '$lib/stores/tracks'; import { tracks } from '$lib/stores/tracks';
import { uploadTrack } from '$lib/track'; import { uploadTrack } from '$lib/track';
function submitTrack() { function submitTrack(e) {
e.preventDefault();
if (files.length == 0) { if (files.length == 0) {
alert("Vous n'avez sélectionné aucun fichier !") alert("Vous n'avez sélectionné aucun fichier !")
return false; return false;
@ -27,7 +29,7 @@
}) })
} }
export let files = []; let { files = $bindable([]) } = $props();
</script> </script>
<Container> <Container>
@ -35,7 +37,7 @@
Nouvelle musique Nouvelle musique
</h2> </h2>
<form on:submit|preventDefault={submitTrack}> <form onsubmit={submitTrack}>
<Input type="file" bind:files /> <Input type="file" bind:files />
<Button type="submit" color="primary" class="mt-2" disabled={files.length == 0}> <Button type="submit" color="primary" class="mt-2" disabled={files.length == 0}>

View File

@ -8,6 +8,8 @@
} from '@sveltestrap/sveltestrap'; } from '@sveltestrap/sveltestrap';
import ActionList from '$lib/components/ActionList.svelte'; import ActionList from '$lib/components/ActionList.svelte';
let { children } = $props();
</script> </script>
<div class="d-flex flex-fill flex-column"> <div class="d-flex flex-fill flex-column">
@ -22,7 +24,7 @@
<ActionList edit flush /> <ActionList edit flush />
</Col> </Col>
<Col md={9} class="d-flex py-2"> <Col md={9} class="d-flex py-2">
<slot></slot> {@render children?.()}
</Col> </Col>
</Row> </Row>
</Container> </Container>

View File

@ -17,13 +17,7 @@
import { getSettings } from '$lib/settings'; import { getSettings } from '$lib/settings';
import FederationSettings from '$lib/components/FederationSettings.svelte'; import FederationSettings from '$lib/components/FederationSettings.svelte';
let settingsP = getSettings(); async function submitSettings(settings) {
$: settingsP.then((s) => settings = s);
let settings;
async function submitSettings() {
await tick(); await tick();
settings.save(); settings.save();
} }
@ -33,12 +27,12 @@
<h2> <h2>
Paramètres Paramètres
</h2> </h2>
<Form on:submit={submitSettings}> {#await getSettings()}
{#await settingsP}
<div class="d-flex justify-content-center align-items-center gap-2"> <div class="d-flex justify-content-center align-items-center gap-2">
<Spinner color="primary" /> Chargement en cours&hellip; <Spinner color="primary" /> Chargement en cours&hellip;
</div> </div>
{:then} {:then settings}
<Form on:submit={() => submitSettings(settings)}>
<FormGroup> <FormGroup>
<Label for="gongIntervals">Intervalle entre les gongs</Label> <Label for="gongIntervals">Intervalle entre les gongs</Label>
<InputGroup> <InputGroup>
@ -47,7 +41,7 @@
id="gongIntervals" id="gongIntervals"
placeholder="20" placeholder="20"
bind:value={settings.gong_interval} bind:value={settings.gong_interval}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
<InputGroupText>min</InputGroupText> <InputGroupText>min</InputGroupText>
</InputGroup> </InputGroup>
@ -61,7 +55,7 @@
id="weatherDelay" id="weatherDelay"
placeholder="5" placeholder="5"
bind:value={settings.weather_delay} bind:value={settings.weather_delay}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
<InputGroupText>min</InputGroupText> <InputGroupText>min</InputGroupText>
</InputGroup> </InputGroup>
@ -74,7 +68,7 @@
type="select" type="select"
id="weatherRituel" id="weatherRituel"
bind:value={settings.weather_action} bind:value={settings.weather_action}
on:input={submitSettings} on:input={() => submitSettings(settings)}
> >
{#each $actions.list as action (action.id)} {#each $actions.list as action (action.id)}
<option value="{action.path}">{action.name}</option> <option value="{action.path}">{action.name}</option>
@ -97,7 +91,7 @@
id="preAlarmDelay" id="preAlarmDelay"
placeholder="5" placeholder="5"
bind:value={settings.pre_alarm_delay} bind:value={settings.pre_alarm_delay}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
<InputGroupText>min</InputGroupText> <InputGroupText>min</InputGroupText>
</InputGroup> </InputGroup>
@ -110,7 +104,7 @@
type="select" type="select"
id="preAlarmRituel" id="preAlarmRituel"
bind:value={settings.pre_alarm_action} bind:value={settings.pre_alarm_action}
on:input={submitSettings} on:input={() => submitSettings(settings)}
> >
{#each $actions.list as action (action.id)} {#each $actions.list as action (action.id)}
<option value="{action.path}">{action.name}</option> <option value="{action.path}">{action.name}</option>
@ -129,7 +123,7 @@
type="select" type="select"
id="greetingLanguage" id="greetingLanguage"
bind:value={settings.language} bind:value={settings.language}
on:input={submitSettings} on:input={() => submitSettings(settings)}
> >
<option value="fr_FR">Français</option> <option value="fr_FR">Français</option>
<option value="en_US">Anglais</option> <option value="en_US">Anglais</option>
@ -146,7 +140,7 @@
id="maxRunTime" id="maxRunTime"
placeholder="60" placeholder="60"
bind:value={settings.max_run_time} bind:value={settings.max_run_time}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
<InputGroupText>min</InputGroupText> <InputGroupText>min</InputGroupText>
</InputGroup> </InputGroup>
@ -161,7 +155,7 @@
min="0" min="0"
max="65535" max="65535"
bind:value={settings.max_volume} bind:value={settings.max_volume}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
</InputGroup> </InputGroup>
</FormGroup> </FormGroup>
@ -171,9 +165,9 @@
<FederationSettings <FederationSettings
id="federation" id="federation"
bind:value={settings.federation} bind:value={settings.federation}
on:input={submitSettings} on:input={() => submitSettings(settings)}
/> />
</FormGroup> </FormGroup>
{/await}
</Form> </Form>
{/await}
</Container> </Container>