1- <div >
2- Configure settings here.
3- </div >
1+ <script >
2+ import { onMount } from " svelte" ;
3+ import { clearStorage , getConfiguration , setConfiguration } from " ../scripts/storageService" ;
4+
5+ function handleSubmit (event ) {
6+ event .preventDefault ();
7+ const formData = new FormData (event .target );
8+ const sleepTimer = formData .get (" sleepTimer" );
9+ const fetchTimer = formData .get (" fetchTimer" );
10+ const byPassCache = formData .get (" byPassCache" ) === " on" ;
11+
12+ configuarion .sleepTimer = sleepTimer;
13+ configuarion .fetchTimer = fetchTimer;
14+ configuarion .byPassCache = byPassCache;
15+
16+ setConfiguration (configuarion);
17+ }
18+
19+ let configuarion;
20+ let sleepTimer = $state (0 );
21+ let fetchTimer = $state (0 );
22+ let byPassCache = $state (false );
23+
24+ onMount (() => {
25+ configuarion = getConfiguration ();
26+ sleepTimer = configuarion .sleepTimer ;
27+ fetchTimer = configuarion .fetchTimer ;
28+ byPassCache = configuarion .byPassCache ;
29+ });
30+ </script >
31+
32+ <!-- svelte-ignore event_directive_deprecated -->
33+ <form on:submit |preventDefault ={handleSubmit } class =" p-2 rounded rounded-2 tile-bg" >
34+ <div class =" mb-3" >
35+ <label for =" sleepTimer" class =" form-label" >Sleep Timer (Minutes)</label >
36+ <input type ="number" required class ="form-control" id ="sleepTimer" name ="sleepTimer" value ={sleepTimer } placeholder =" Stop music after some time" />
37+ </div >
38+ <div class =" mb-3" >
39+ <label for =" fetchTimer" class =" form-label" >Fetch Timer (Seconds)</label >
40+ <input type ="number" required class ="form-control" id ="fetchTimer" name ="fetchTimer" value ={fetchTimer } placeholder =" Api interval time" />
41+ </div >
42+ <div class =" mt-3 mb-3 p-2 rounded rounded-2 tile-bg" >
43+ <label for =" byPassCache" class =" form-label" >Ignore Cached urls</label >
44+ <input type ="checkbox" checked ={byPassCache } id =" byPassCache" name =" byPassCache" class =" form-check-input" />
45+ </div >
46+ <button type =" submit" class =" btn btn-primary" >Save Settings</button >
47+ </form >
48+
49+ <div class =" mt-3 mb-3 p-2 rounded rounded-2 tile-bg" >
50+ <label for =" localStorageClear" class =" form-label" >Local Storage !Expirmental</label >
51+ <!-- This is causing some issues, playback breaks and updating ui freezes -->
52+ <!-- svelte-ignore event_directive_deprecated -->
53+ <button id ="localStorageClear" class ="btn btn-danger" on:click ={() => clearStorage ()}>Clear Local Storage</button >
54+ </div >
55+
56+ <div class =" mt-3 mb-3 p-2 rounded rounded-2 tile-bg" >
57+ <button id =" exportData" class =" btn btn-secondary" >View Server Logs</button >
58+ </div >
59+
60+ <style >
61+ label {
62+ font-weight : bold ;
63+ font-size : 1.1rem ;
64+ }
65+
66+ .tile-bg {
67+ background-color : #2c2c2c ;
68+ }
69+ </style >
0 commit comments