mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	options split into individual classes
This commit is contained in:
		
							
								
								
									
										43
									
								
								src/public/javascripts/dialogs/options/sync.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/public/javascripts/dialogs/options/sync.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
import server from "../../services/server.js";
 | 
			
		||||
import infoService from "../../services/info.js";
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
                infoService.showMessage(result.message);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                infoService.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(()  => infoService.showMessage("Options change have been saved."));
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user