From a201661ce534f264e3efca8cf0753c42081675d7 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 22 Jul 2018 14:49:59 +0200 Subject: [PATCH] #98, fixes in the wizard --- src/public/javascripts/setup.js | 39 ++++++++++++++++++++++++++++-- src/services/sql_init.js | 1 - src/views/setup.ejs | 43 +++++++++++++++++++++++++++------ 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/public/javascripts/setup.js b/src/public/javascripts/setup.js index 9ad976853..abf98c3f3 100644 --- a/src/public/javascripts/setup.js +++ b/src/public/javascripts/setup.js @@ -1,4 +1,5 @@ import server from './services/server.js'; +import utils from "./services/utils.js"; function SetupModel() { this.step = ko.observable("setup-type"); @@ -12,6 +13,10 @@ function SetupModel() { this.password1 = ko.observable(); this.password2 = ko.observable(); + this.serverAddress = ko.observable(); + + this.instanceType = utils.isElectron() ? "desktop" : "server"; + this.setupTypeSelected = this.getSetupType = () => this.setupNewDocument() || this.setupSyncFromDesktop() @@ -22,7 +27,13 @@ function SetupModel() { this.setupType(this.getSetupType()); }; - this.back = () => this.step("setup-type"); + this.back = () => { + this.step("setup-type"); + + this.setupNewDocument(false); + this.setupSyncFromServer(false); + this.setupSyncFromDesktop(false); + }; this.finish = () => { if (this.setupNewDocument()) { @@ -52,6 +63,28 @@ function SetupModel() { window.location.replace("/"); }); } + else if (this.setupSyncFromServer()) { + const serverAddress = this.serverAddress(); + const username = this.username(); + const password = this.password1(); + + if (!serverAddress) { + showAlert("Trilium server address can't be empty"); + return; + } + + if (!username) { + showAlert("Username can't be empty"); + return; + } + + if (!password) { + showAlert("Password can't be empty"); + return; + } + + showAlert("All OK"); + } }; } @@ -60,4 +93,6 @@ function showAlert(message) { $("#alert").show(); } -ko.applyBindings(new SetupModel(), document.getElementById('setup-dialog')); \ No newline at end of file +ko.applyBindings(new SetupModel(), document.getElementById('setup-dialog')); + +$("#setup-dialog").show(); \ No newline at end of file diff --git a/src/services/sql_init.js b/src/services/sql_init.js index cf49dc260..dfb1ffa47 100644 --- a/src/services/sql_init.js +++ b/src/services/sql_init.js @@ -5,7 +5,6 @@ const sqlite = require('sqlite'); const resourceDir = require('./resource_dir'); const appInfo = require('./app_info'); const sql = require('./sql'); -const options = require('./options'); const cls = require('./cls'); async function createConnection() { diff --git a/src/views/setup.ejs b/src/views/setup.ejs index 45b380364..1ac37d28e 100644 --- a/src/views/setup.ejs +++ b/src/views/setup.ejs @@ -5,7 +5,7 @@ Setup -
+