import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; const TPL = `

Sync configuration

Note: If you leave the proxy setting blank, the system proxy will be used (applies to desktop/electron build only)


Sync test

This will test the connection and handshake to the sync server. If the sync server isn't initialized, this will set it up to sync with the local document.

`; export default class SyncOptions { constructor() { $("#options-sync-setup").html(TPL); 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.on('submit', () => this.save()); this.$testSyncButton.on('click', async () => { const result = await server.post('sync/test'); if (result.success) { toastService.showMessage(result.message); } else { toastService.showError("Sync server handshake failed, error: " + result.message); } }); } 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() }; server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); return false; } }