import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; import OptionsTab from "./options_tab.js"; const TPL = `
`; export default class SyncOptions extends OptionsTab { get tabTitle() { return "Sync" } lazyRender() { this.$widget = $(TPL); this.$form = this.$widget.find("#sync-setup-form"); this.$syncServerHost = this.$widget.find("#sync-server-host"); this.$syncServerTimeout = this.$widget.find("#sync-server-timeout"); this.$syncProxy = this.$widget.find("#sync-proxy"); this.$testSyncButton = this.$widget.find("#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 change have been saved.")); return false; } }