Refactor installer.

This commit is contained in:
James Cole
2019-03-30 11:03:39 +01:00
parent 5b1fb5354e
commit c07ef3658b
18 changed files with 230 additions and 327 deletions

View File

@@ -23,13 +23,45 @@ $(function () {
"use strict";
//var status = $('#status-box');
// set HTML to "migrating...":
startMigration();
startRunningCommands();
});
function startRunningCommands() {
if (0 === index) {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Running first command...');
}
runCommand(index);
}
function runCommand(index) {
$.post(runCommandUri, {_token: token, index: index}).done(function (data) {
if (data.error === false) {
// increase index
index++;
if(data.hasNextCommand) {
// inform user
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Just executed ' + data.previous + '...');
console.log('Will call next command.');
runCommand(index);
} else {
completeDone();
console.log('Finished!');
}
} else {
displaySoftFail(data.errorMessage);
console.error(data);
}
}).fail(function () {
$('#status-box').html('<i class="fa fa-warning"></i> Command failed! See log files :(');
});
}
function startMigration() {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up DB...');
$.post(migrateUri, {_token: token}).done(function (data) {
if(data.error === false) {
if (data.error === false) {
// move to decrypt routine.
startDecryption();
} else {
@@ -44,7 +76,7 @@ function startMigration() {
function startDecryption() {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up DB #2...');
$.post(decryptUri, {_token: token}).done(function (data) {
if(data.error === false) {
if (data.error === false) {
// move to decrypt routine.
startPassport();
} else {
@@ -62,7 +94,7 @@ function startDecryption() {
function startPassport() {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up OAuth2...');
$.post(keysUri, {_token: token}).done(function (data) {
if(data.error === false) {
if (data.error === false) {
startUpgrade();
} else {
displaySoftFail(data.message);
@@ -79,7 +111,7 @@ function startPassport() {
function startUpgrade() {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Upgrading database...');
$.post(upgradeUri, {_token: token}).done(function (data) {
if(data.error === false) {
if (data.error === false) {
startVerify();
} else {
displaySoftFail(data.message);
@@ -95,7 +127,7 @@ function startUpgrade() {
function startVerify() {
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Verify database integrity...');
$.post(verifyUri, {_token: token}).done(function (data) {
if(data.error === false) {
if (data.error === false) {
completeDone();
} else {
displaySoftFail(data.message);