blob: d69eab09e08b9fb6eb9cb78a0ea3ee2a55f1a10b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<script lang="ts">
import Spacer from '$lib/Layout/Spacer.svelte';
import { options } from '$lib/Notification/options';
import root from '$lib/Utility/root';
import identity from '$stores/identity';
import settings from '$stores/settings';
import { addNotification } from '$lib/Notification/store';
import SettingHint from '../SettingHint.svelte';
import locale from '$stores/locale';
import settingsSyncTimes from '$stores/settingsSyncTimes';
</script>
{#if !$settings.settingsSync}
<button
onclick={() => {
$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'
})
);
});
}
});
}
});
}}
>
{$locale().settings.settingsSync.buttons.pull.title}
</button>
<SettingHint lineBreak>
{$locale().settings.settingsSync.buttons.pull.hint}
</SettingHint>
<Spacer />
<button
onclick={() => {
$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'
})
);
});
}}
>
{$locale().settings.settingsSync.buttons.push.title}
</button>
<SettingHint lineBreak>
{$locale().settings.settingsSync.buttons.push.hint}
</SettingHint>
{:else}
<button
onclick={() => {
$settings.settingsSync = false;
addNotification(
options({
heading: 'Settings sync disabled'
})
);
}}
>
{$locale().settings.settingsSync.buttons.disable}
</button>
<button
onclick={() => {
fetch(root(`/api/configuration?id=${$identity.id}`), {
method: 'DELETE'
}).then((response) => {
if (response.ok) {
$settings.settingsSync = false;
addNotification(
options({
heading: 'Remote configuration deleted and settings sync disabled'
})
);
}
});
}}
>
{$locale().settings.settingsSync.buttons.delete}
</button>
<Spacer />
<b>Last Push</b>: {$locale().dateFormatter($settingsSyncTimes.lastPush)}
<br />
<b>Last Pull</b>: {$locale().dateFormatter($settingsSyncTimes.lastPull)}
{/if}
|