#98, fixes in the wizard

This commit is contained in:
azivner 2018-07-22 14:49:59 +02:00
parent 6235a3c886
commit a201661ce5
3 changed files with 72 additions and 11 deletions

View File

@ -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'));
ko.applyBindings(new SetupModel(), document.getElementById('setup-dialog'));
$("#setup-dialog").show();

View File

@ -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() {

View File

@ -5,7 +5,7 @@
<title>Setup</title>
</head>
<body>
<div id="setup-dialog" style="width: 500px; margin: auto;">
<div id="setup-dialog" style="width: 500px; margin: auto; display:none;">
<h1>Trilium Notes setup</h1>
<div class="alert alert-warning" id="alert" style="display: none;">
@ -16,19 +16,21 @@
<label><input type="radio" name="setup-type" value="new-document" data-bind="checked: setupNewDocument">
I'm a new user and I want to create new Trilium document for my notes</label>
</div>
<div class="radio">
<div class="radio" data-bind="if: instanceType == 'server'">
<label><input type="radio" name="setup-type" value="sync-from-desktop" data-bind="checked: setupSyncFromDesktop">
I have server instance up and I want to setup sync with it</label>
</div>
<div class="radio">
<label><input type="radio" name="setup-type" value="sync-from-server" data-bind="checked: setupSyncFromServer">
I have desktop instance already and I want to setup sync with it</label>
</div>
<div class="radio" data-bind="if: instanceType == 'desktop'">
<label><input type="radio" name="setup-type" value="sync-from-server" data-bind="checked: setupSyncFromServer">
I have server instance up and I want to setup sync with it</label>
</div>
<button type="button" data-bind="disable: !setupTypeSelected(), click: selectSetupType" class="btn btn-primary">Next</button>
</div>
<div data-bind="visible: step() == 'new-document'">
<h2>New document</h2>
<p>You're almost done with the setup. The last thing is to choose username and password using which you'll login to the application.
This password is also used for generating encryption key which encrypts protected notes.</p>
@ -53,11 +55,36 @@
</div>
<div data-bind="visible: step() == 'sync-from-desktop'">
sync from desktop
<h2>Sync from Desktop</h2>
<p>This setup needs to be initiated from the desktop instance, please open it, go to settings in the top right, click on sync tab and then click on Setup sync with server instance.</p>
<button type="button" data-bind="click: back" class="btn btn-default">Back</button>
</div>
<div data-bind="visible: step() == 'sync-from-server'">
sync from server
<h2>Sync from Server</h2>
<p>Please enter Trilium server address and credentials below. This will download the whole Trilium document from server and setup sync to it. Depending on the document size and your connection speed, this may take a while.</p>
<div class="form-group">
<label for="username">Trilium server address</label>
<input type="text" class="form-control" data-bind="value: serverAddress" placeholder="https://<hostname>:<port>">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" data-bind="value: username" placeholder="Username">
</div>
<div class="form-group">
<label for="password1">Password</label>
<input type="password" class="form-control" data-bind="value: password1" placeholder="Password">
</div>
<button type="button" data-bind="click: back" class="btn btn-default">Back</button>
&nbsp;
<button type="button" data-bind="click: finish" class="btn btn-primary">Finish setup</button>
</div>
</div>