aboutsummaryrefslogtreecommitdiff
path: root/src/routes/settings/+page.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/settings/+page.svelte')
-rw-r--r--src/routes/settings/+page.svelte52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
index 03dcedde..342e73a3 100644
--- a/src/routes/settings/+page.svelte
+++ b/src/routes/settings/+page.svelte
@@ -16,6 +16,8 @@
import locale from '$stores/locale.js';
import settings from '$stores/settings';
import LogInRestricted from '$lib/Error/LogInRestricted.svelte';
+ import root from '$lib/Utility/root';
+ import identity from '$stores/identity.js';
export let data;
@@ -66,6 +68,56 @@
{#if data.user === undefined}
<LogInRestricted />
{:else}
+ <button
+ on:click={() => {
+ if (!$settings.settingsSync) {
+ $settings.settingsSync = true;
+
+ fetch(root(`/api/configuration?id=${$identity.id}`)).then((response) => {
+ if (response.ok) {
+ response.json().then((data) => {
+ if (data && data.configuration) {
+ $settings = data.configuration;
+
+ addNotification(
+ options({
+ heading: 'Pulled remote configuration'
+ })
+ );
+ } else {
+ fetch(root(`/api/configuration`), {
+ method: 'PUT',
+ body: JSON.stringify($settings)
+ }).then((response) => {
+ if (response.ok)
+ addNotification(
+ options({
+ heading: 'Created remote configuration'
+ })
+ );
+ });
+ }
+ });
+ }
+ });
+ } else {
+ $settings.settingsSync = false;
+
+ addNotification(
+ options({
+ heading: 'Disabled settings sync'
+ })
+ );
+ }
+ }}
+ >
+ {$settings.settingsSync ? 'Disable' : 'Enable'} Settings Sync &amp; {$settings.settingsSync
+ ? 'Keep Local Configuration'
+ : 'Pull Remote Configuration'}
+ </button>
+
+ <p />
+
<Category title={$locale().settings.rssFeeds.title} id="feeds">
<button
on:click={() => {