aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-02-12 09:06:49 -0800
committerFuwn <[email protected]>2024-02-12 09:06:49 -0800
commitf4e343053420b90503b3366eb92d1952db4fadb8 (patch)
tree907af6ed1160efed7c5c85339abe6bc5f820e307
parentfeat(settings): settings sync (diff)
downloaddue.moe-f4e343053420b90503b3366eb92d1952db4fadb8.tar.xz
due.moe-f4e343053420b90503b3366eb92d1952db4fadb8.zip
feat(settings): remote or local settings sync toggle
-rw-r--r--src/routes/settings/+page.svelte48
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 &amp; 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 &amp; 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 &amp; {$settings.settingsSync
- ? 'Keep Local Configuration'
- : 'Pull Remote Configuration'}
- </button>
+ }}
+ >
+ Disable Settings Sync &amp; Keep Local Configuration
+ </button>
+ {/if}
<p />