2019-08-21 20:24:37 +02:00
|
|
|
import server from "../../services/server.js";
|
2019-10-20 10:00:18 +02:00
|
|
|
import toastService from "../../services/toast.js";
|
2019-08-21 20:24:37 +02:00
|
|
|
|
|
|
|
export default class SyncOptions {
|
|
|
|
constructor() {
|
|
|
|
this.$form = $("#sync-setup-form");
|
|
|
|
this.$syncServerHost = $("#sync-server-host");
|
|
|
|
this.$syncServerTimeout = $("#sync-server-timeout");
|
|
|
|
this.$syncProxy = $("#sync-proxy");
|
|
|
|
this.$testSyncButton = $("#test-sync-button");
|
|
|
|
|
|
|
|
this.$form.submit(() => this.save());
|
|
|
|
|
|
|
|
this.$testSyncButton.click(async () => {
|
|
|
|
const result = await server.post('sync/test');
|
|
|
|
|
|
|
|
if (result.success) {
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showMessage(result.message);
|
2019-08-21 20:24:37 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showError("Sync server handshake failed, error: " + result.message);
|
2019-08-21 20:24:37 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
optionsLoaded(options) {
|
|
|
|
this.$syncServerHost.val(options['syncServerHost']);
|
|
|
|
this.$syncServerTimeout.val(options['syncServerTimeout']);
|
|
|
|
this.$syncProxy.val(options['syncProxy']);
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
const opts = {
|
|
|
|
'syncServerHost': this.$syncServerHost.val(),
|
|
|
|
'syncServerTimeout': this.$syncServerTimeout.val(),
|
|
|
|
'syncProxy': this.$syncProxy.val()
|
|
|
|
};
|
|
|
|
|
2019-10-20 10:00:18 +02:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
2019-08-21 20:24:37 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|