mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Refactor installer.
This commit is contained in:
46
public/v1/js/ff/install/index.js
vendored
46
public/v1/js/ff/install/index.js
vendored
@@ -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);
|
||||
|
Reference in New Issue
Block a user