diff options
| author | Fuwn <[email protected]> | 2024-02-12 09:06:49 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-12 09:06:49 -0800 |
| commit | f4e343053420b90503b3366eb92d1952db4fadb8 (patch) | |
| tree | 907af6ed1160efed7c5c85339abe6bc5f820e307 | |
| parent | feat(settings): settings sync (diff) | |
| download | due.moe-f4e343053420b90503b3366eb92d1952db4fadb8.tar.xz due.moe-f4e343053420b90503b3366eb92d1952db4fadb8.zip | |
feat(settings): remote or local settings sync toggle
| -rw-r--r-- | src/routes/settings/+page.svelte | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 342e73a3..4b0cb91b 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -68,9 +68,9 @@ {#if data.user === undefined} <LogInRestricted /> {:else} - <button - on:click={() => { - if (!$settings.settingsSync) { + {#if !$settings.settingsSync} + <button + on:click={() => { $settings.settingsSync = true; fetch(root(`/api/configuration?id=${$identity.id}`)).then((response) => { @@ -100,21 +100,45 @@ }); } }); - } else { + }} + > + Enable Settings Sync & Pull Remote Configuration + </button> + <button + on:click={() => { + $settings.settingsSync = true; + + fetch(root(`/api/configuration`), { + method: 'PUT', + body: JSON.stringify($settings) + }).then((response) => { + if (response.ok) + addNotification( + options({ + heading: 'Settings Sync', + description: 'Pushed local configuration to remote' + }) + ); + }); + }} + > + Enable & Push Local Configuration + </button> + {:else} + <button + on:click={() => { $settings.settingsSync = false; addNotification( options({ - heading: 'Disabled settings sync' + heading: 'Settings sync disabled' }) ); - } - }} - > - {$settings.settingsSync ? 'Disable' : 'Enable'} Settings Sync & {$settings.settingsSync - ? 'Keep Local Configuration' - : 'Pull Remote Configuration'} - </button> + }} + > + Disable Settings Sync & Keep Local Configuration + </button> + {/if} <p /> |