Uninstaller works
This commit is contained in:
parent
e98213ad4c
commit
109a4fa25f
@ -31,7 +31,7 @@ hesk_dbConnect();
|
||||
</div>
|
||||
<div class="panel panel-success" id="all-good" style="display: none">
|
||||
<div class="panel-heading">
|
||||
<h4>w00t!</h4>
|
||||
<h4>Success</h4>
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<i class="fa fa-check-circle fa-4x" style="color: green"></i><br>
|
||||
@ -40,7 +40,7 @@ hesk_dbConnect();
|
||||
</div>
|
||||
<div class="panel panel-danger" id="not-good" style="display: none">
|
||||
<div class="panel-heading">
|
||||
<h4>RIP</h4>
|
||||
<h4>Failure</h4>
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<i class="fa fa-times-circle fa-4x" style="color: red"></i><br>
|
||||
|
@ -85,12 +85,12 @@ function installOrUpdate() {
|
||||
$('[data-step="install-or-update"] > .progress').show();
|
||||
|
||||
// Recursive call that will increment by 1 each time
|
||||
executeMigration(startingMigrationNumber, data.lastMigrationNumber, 'up');
|
||||
executeMigration(startingMigrationNumber, startingMigrationNumber, data.lastMigrationNumber, 'up');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
function executeMigration(startingMigrationNumber, migrationNumber, latestMigrationNumber, direction) {
|
||||
var heskPath = $('p#hesk-path').text();
|
||||
|
||||
$.ajax({
|
||||
@ -104,13 +104,13 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
console.log('migrationNumber: ' + migrationNumber);
|
||||
console.log('latestMigrationNumber: ' + latestMigrationNumber);
|
||||
console.info('---');
|
||||
if (migrationNumber === latestMigrationNumber || (migrationNumber === 1 && direction === 'down')) {
|
||||
if (migrationNumber === latestMigrationNumber || (migrationNumber === startingMigrationNumber && direction === 'down')) {
|
||||
updateProgressBar(migrationNumber, latestMigrationNumber, direction === 'down', true);
|
||||
console.log('%c Success! ', 'color: white; background-color: green; font-size: 2em');
|
||||
} else {
|
||||
updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
|
||||
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
|
||||
executeMigration(newMigrationNumber, latestMigrationNumber, direction);
|
||||
executeMigration(startingMigrationNumber, newMigrationNumber, latestMigrationNumber, direction);
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
@ -126,7 +126,7 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
|
||||
if (direction === 'up') {
|
||||
// Revert!
|
||||
executeMigration(migrationNumber - 1, latestMigrationNumber, 'down');
|
||||
executeMigration(startingMigrationNumber, migrationNumber - 1, latestMigrationNumber, 'down');
|
||||
} else {
|
||||
console.error("I even failed to roll back. Yikes! :'(");
|
||||
}
|
||||
|
@ -85,12 +85,12 @@ function uninstall() {
|
||||
$('[data-step="uninstall"] > .progress').show();
|
||||
|
||||
// Recursive call that will increment by 1 each time
|
||||
executeMigration(startingMigrationNumber, 1, 'down');
|
||||
executeMigration(startingMigrationNumber, startingMigrationNumber, 1, 'down');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
function executeMigration(startingMigrationNumber, migrationNumber, latestMigrationNumber, direction) {
|
||||
var heskPath = $('p#hesk-path').text();
|
||||
|
||||
$.ajax({
|
||||
@ -105,12 +105,12 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
console.log('latestMigrationNumber: ' + latestMigrationNumber);
|
||||
console.info('---');
|
||||
if (migrationNumber === latestMigrationNumber) {
|
||||
updateProgressBar(migrationNumber, latestMigrationNumber, false, true);
|
||||
updateProgressBar(startingMigrationNumber, migrationNumber, false, true);
|
||||
console.log('%c Success! ', 'color: white; background-color: green; font-size: 2em');
|
||||
} else {
|
||||
updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
|
||||
updateProgressBar(startingMigrationNumber, migrationNumber, false, false);
|
||||
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
|
||||
executeMigration(newMigrationNumber, latestMigrationNumber, direction);
|
||||
executeMigration(startingMigrationNumber, newMigrationNumber, latestMigrationNumber, direction);
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
@ -122,14 +122,14 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
||||
$errorBlock = $('#error-block');
|
||||
$errorBlock.html($errorBlock.html() + "<br><br>An error occurred! (Error Code: " + migrationNumber + ")<br>" + message).show();
|
||||
|
||||
updateProgressBar(migrationNumber, latestMigrationNumber, true, false);
|
||||
updateProgressBar(startingMigrationNumber, migrationNumber, true, false);
|
||||
|
||||
console.error(message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function updateProgressBar(migrationNumber, latestMigrationNumber, isError, isFinished) {
|
||||
function updateProgressBar(startingMigrationNumber, migrationNumber, isError, isFinished) {
|
||||
var $progressBar = $('#progress-bar');
|
||||
|
||||
if (isError === true) {
|
||||
@ -141,7 +141,7 @@ function updateProgressBar(migrationNumber, latestMigrationNumber, isError, isFi
|
||||
$errorBlock.html($errorBlock.html() + '<br><br>Successfully reverted database to before uninstalling.');
|
||||
}
|
||||
} else {
|
||||
var percentage = Math.round(migrationNumber / latestMigrationNumber * 100);
|
||||
var percentage = Math.round((startingMigrationNumber - migrationNumber) / startingMigrationNumber * 100);
|
||||
$progressBar.find('.progress-bar').css('width', percentage + '%');
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ if (hesk_dbNumRows($tableSql) > 0) {
|
||||
</div>
|
||||
<?php // BEGIN INSTALL SCREENS ?>
|
||||
<div data-step="intro" class="login-box-msg">
|
||||
<h4>I hoped you wouldn't be here, but let's continue anyway. 😭</h4>
|
||||
<h4>I hoped you wouldn't be here, but let's continue anyway.</h4>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="usage-stats" checked>
|
||||
@ -146,7 +146,7 @@ if (hesk_dbNumRows($tableSql) > 0) {
|
||||
</div>
|
||||
<?php // END INSTALL SCREENS ?>
|
||||
<div id="buttons">
|
||||
<a href="<?php echo HESK_PATH; ?>/install/index.php" class="btn btn-default" id="tools-button">
|
||||
<a href="<?php echo HESK_PATH; ?>install/index.php" class="btn btn-default" id="tools-button">
|
||||
<i class="fa fa-chevron-left"></i> Back to installer
|
||||
</a>
|
||||
<div class="btn btn-primary" id="back-button" style="display: none;"><i class="fa fa-chevron-left"></i> Back</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user