mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix the installation template.
This commit is contained in:
@@ -19,10 +19,7 @@
|
||||
*/
|
||||
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
//var status = $('#status-box');
|
||||
// set HTML to "migrating...":
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
console.log('Starting...');
|
||||
startRunningCommands(0);
|
||||
});
|
||||
@@ -30,57 +27,81 @@ $(function () {
|
||||
function startRunningCommands(index) {
|
||||
console.log('Now in startRunningCommands with index' + index);
|
||||
if (0 === index) {
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Running first command...');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Running first command...';
|
||||
}
|
||||
runCommand(index);
|
||||
}
|
||||
|
||||
function runCommand(index) {
|
||||
console.log('Now in runCommand(' + index + '): ' + runCommandUrl);
|
||||
$.post(runCommandUrl, {_token: token, index: parseInt(index)}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
// increase index
|
||||
index++;
|
||||
|
||||
if(data.hasNextCommand) {
|
||||
// inform user
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Just executed ' + data.previous + '...');
|
||||
console.log('Will call next command.');
|
||||
runCommand(index);
|
||||
fetch(runCommandUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token, index: parseInt(index)}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
index++;
|
||||
if (response.hasNextCommand) {
|
||||
// inform user
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Just executed ' + response.previous + '...';
|
||||
console.log('Will call next command.');
|
||||
runCommand(index);
|
||||
} else {
|
||||
completeDone();
|
||||
console.log('Finished!');
|
||||
}
|
||||
} else {
|
||||
completeDone();
|
||||
console.log('Finished!');
|
||||
displaySoftFail(response.errorMessage);
|
||||
console.error(response);
|
||||
}
|
||||
} else {
|
||||
displaySoftFail(data.errorMessage);
|
||||
console.error(data);
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> Command failed! See log files :(');
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function startMigration() {
|
||||
console.log('Now in startMigration');
|
||||
$.post(migrateUrl, {_token: token}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
|
||||
fetch(migrateUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
// move to decrypt routine.
|
||||
startDecryption();
|
||||
} else {
|
||||
displaySoftFail(data.message);
|
||||
displaySoftFail(response.message);
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> Migration failed! See log files :(');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> Migration failed! See log files :(';
|
||||
});
|
||||
}
|
||||
|
||||
function startDecryption() {
|
||||
console.log('Now in startDecryption');
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Setting up DB #2...');
|
||||
$.post(decryptUrl, {_token: token}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Setting up DB #2...';
|
||||
fetch(decryptUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
// move to decrypt routine.
|
||||
startPassport();
|
||||
} else {
|
||||
@@ -88,7 +109,7 @@ function startDecryption() {
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> Migration failed! See log files :(');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> Migration failed! See log files :(';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,16 +117,25 @@ function startDecryption() {
|
||||
*
|
||||
*/
|
||||
function startPassport() {
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Setting up OAuth2...');
|
||||
$.post(keysUrl, {_token: token}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Setting up OAuth2...';
|
||||
fetch(keysUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
startUpgrade();
|
||||
} else {
|
||||
displaySoftFail(data.message);
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> OAuth2 failed! See log files :(');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> OAuth2 failed! See log files :(';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,15 +143,24 @@ function startPassport() {
|
||||
*
|
||||
*/
|
||||
function startUpgrade() {
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Upgrading database...');
|
||||
$.post(upgradeUrl, {_token: token}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Upgrading database...';
|
||||
fetch(upgradeUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
startVerify();
|
||||
} else {
|
||||
displaySoftFail(data.message);
|
||||
}
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> Upgrade failed! See log files :(');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> Upgrade failed! See log files :(';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -129,15 +168,24 @@ function startUpgrade() {
|
||||
*
|
||||
*/
|
||||
function startVerify() {
|
||||
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Verify database integrity...');
|
||||
$.post(verifyUrl, {_token: token}).done(function (data) {
|
||||
if (data.error === false) {
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-spin fa-spinner"></span> Verify database integrity...';
|
||||
fetch(veifyUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({_token: token}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.error === false) {
|
||||
completeDone();
|
||||
} else {
|
||||
displaySoftFail(data.message);
|
||||
}
|
||||
}).fail(function () {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> Verification failed! See log files :(');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> Verification failed! See log files :(';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,14 +193,14 @@ function startVerify() {
|
||||
*
|
||||
*/
|
||||
function completeDone() {
|
||||
$('#status-box').html('<span class="fa fa-thumbs-up"></span> Installation + upgrade complete! Wait to be redirected...');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-thumbs-up"></span> Installation + upgrade complete! Wait to be redirected...';
|
||||
setTimeout(function () {
|
||||
window.location = homeUrl;
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function displaySoftFail(message) {
|
||||
$('#status-box').html('<span class="fa fa-warning"></span> ' + message + '<br /><br />Please read the ' +
|
||||
'<a href="https://docs.firefly-iii.org/">' +
|
||||
'documentation</a> about this, and upgrade by hand.');
|
||||
document.querySelector('#status-box').innerHTML = '<span class="fa fa-warning"></span> ' + message + '<br /><br />Please read the ' +
|
||||
'<a href="https://docs.firefly-iii.org/">' +
|
||||
'documentation</a> about this, and upgrade by hand.';
|
||||
}
|
||||
|
Reference in New Issue
Block a user