diff --git a/install/ajax/get-migration-ajax.php b/install/ajax/get-migration-ajax.php new file mode 100644 index 00000000..5e49928c --- /dev/null +++ b/install/ajax/get-migration-ajax.php @@ -0,0 +1,12 @@ + key($allMigrations))); \ No newline at end of file diff --git a/install/index.php b/install/index.php index 7e80de85..47589f69 100644 --- a/install/index.php +++ b/install/index.php @@ -83,7 +83,7 @@ if (hesk_dbNumRows($tableSql) > 0) {

Let's get started.

-

By continuing, I agree to the terms of the +

By continuing, you agree to the terms of the MIT License.

-
-
+
@@ -166,5 +168,6 @@ if (hesk_dbNumRows($tableSql) > 0) {
+ \ No newline at end of file diff --git a/install/js/install-script.js b/install/js/install-script.js index 13688100..5fb2ac0d 100644 --- a/install/js/install-script.js +++ b/install/js/install-script.js @@ -7,12 +7,14 @@ var steps = [ { name: 'db-confirm', text: 'Confirm the information below', + backPossible: true, callback: undefined }, { name: 'install-or-update', text: 'Updating to the latest version...', - callback: undefined + backPossible: false, + callback: installOrUpdate } ]; @@ -38,6 +40,10 @@ function goToStep(step) { } else { $('#tools-button').hide(); $('#back-button').show(); + + if (!steps[step].backPossible) { + $('#back-button').addClass('disabled').attr('disabled', 'disabled'); + } } if (step === steps.length - 1) { @@ -47,4 +53,50 @@ function goToStep(step) { } $('#header-text').text(steps[step].text); + + if (steps[step].callback !== undefined) { + steps[step].callback(); + } +} + +function installOrUpdate() { + var startingMigrationNumber = $('input[name="starting-migration-number"]').val(); + + var heskPath = $('p#hesk-path').text(); + + $.ajax({ + url: heskPath + 'install/ajax/get-migration-ajax.php', + method: 'GET', + success: function(data) { + data = JSON.parse(data); + + $('[data-step="install-or-update"] > .fa-spinner').hide(); + $('[data-step="install-or-update"] > .progress').show(); + + console.log(data.lastMigrationNumber); + + // Recursive call that will increment by 1 each time + //executeMigration(startingMigrationNumber, startingMigrationNumber, data.latestMigrationNumber); + } + }) +} + +function executeMigration(startingMigrationNumber, migrationNumber, latestMigrationNumber) { + $.ajax({ + url: '', + method: 'POST', + data: { + migrationNumber: migrationNumber, + direction: 'up' + }, + success: function(data) { + updateProgressBar(migrationNumber, latestMigrationNumber); + + if (migrationNumber === latestMigrationNumber) { + // done + } else { + executeMigration(startingMigrationNumber, migrationNumber + 1, latestMigrationNumber); + } + } + }) } \ No newline at end of file diff --git a/install/migrations/core.php b/install/migrations/core.php new file mode 100644 index 00000000..c7ddb212 --- /dev/null +++ b/install/migrations/core.php @@ -0,0 +1,7 @@ + null + ); +} \ No newline at end of file