#98, sync setup now doesn't copy the whole DB file, but sets up minimal database and starts off sync

This commit is contained in:
azivner
2018-07-23 21:15:32 +02:00
parent a06618d851
commit 1fe7c62f5a
12 changed files with 185 additions and 100 deletions

View File

@@ -34,7 +34,7 @@ function SetupModel() {
this.setupSyncFromDesktop(false);
};
this.finish = () => {
this.finish = async () => {
if (this.setupNewDocument()) {
const username = this.username();
const password1 = this.password1();
@@ -84,20 +84,33 @@ function SetupModel() {
}
// not using server.js because it loads too many dependencies
$.post('/api/setup/sync-from-server', {
const resp = await $.post('/api/setup/sync-from-server', {
serverAddress: serverAddress,
username: username,
password: password
}).then(() => {
window.location.replace("/");
}).catch((err) => {
alert("Error, see dev console for details.");
console.error(err);
});
if (resp.result === 'success') {
this.step('sync-in-progress');
checkOutstandingSyncs();
setInterval(checkOutstandingSyncs, 1000);
}
else {
showAlert('Sync setup failed: ', resp.error);
}
}
};
}
async function checkOutstandingSyncs() {
const stats = await $.get('/api/sync/stats');
const totalOutstandingSyncs = stats.outstandingPushes + stats.outstandingPulls;
$("#outstanding-syncs").html(totalOutstandingSyncs);
}
function showAlert(message) {
$("#alert").html(message);
$("#alert").show();