Getting started on the AJAX portion
This commit is contained in:
parent
5aeb90852b
commit
dbf9baca75
12
install/ajax/get-migration-ajax.php
Normal file
12
install/ajax/get-migration-ajax.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
define('IN_SCRIPT', 1);
|
||||||
|
define('HESK_PATH', '../../');
|
||||||
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
|
require(HESK_PATH . 'install/migrations/core.php');
|
||||||
|
hesk_load_database_functions();
|
||||||
|
|
||||||
|
$allMigrations = getAllMigrations();
|
||||||
|
end($allMigrations);
|
||||||
|
|
||||||
|
print json_encode(array("lastMigrationNumber" => key($allMigrations)));
|
||||||
@ -83,7 +83,7 @@ if (hesk_dbNumRows($tableSql) > 0) {
|
|||||||
<?php // BEGIN INSTALL SCREENS ?>
|
<?php // BEGIN INSTALL SCREENS ?>
|
||||||
<div data-step="intro" class="login-box-msg">
|
<div data-step="intro" class="login-box-msg">
|
||||||
<h4>Let's get started.</h4>
|
<h4>Let's get started.</h4>
|
||||||
<p>By continuing, I agree to the terms of the
|
<p>By continuing, you agree to the terms of the
|
||||||
<a href="http://opensource.org/licenses/MIT" target="_blank">MIT License</a>.</p>
|
<a href="http://opensource.org/licenses/MIT" target="_blank">MIT License</a>.</p>
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
@ -121,14 +121,16 @@ if (hesk_dbNumRows($tableSql) > 0) {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div data-step="install-or-update" style="display: none">
|
<div data-step="install-or-update" class="text-center" style="display: none">
|
||||||
<div class="progress">
|
<i class="fa fa-spin fa-spinner fa-4x"></i>
|
||||||
|
<div class="progress" style="display: none">
|
||||||
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"
|
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"
|
||||||
style="min-width: 2em; width: 100%">
|
style="min-width: 2em; width: 100%">
|
||||||
<span class="sr-only">100% Complete</span>
|
<span class="sr-only">100% Complete</span>
|
||||||
100%
|
100%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="starting-migration-number" value="<?php echo $startingMigrationNumber; ?>">
|
||||||
</div>
|
</div>
|
||||||
<?php // END INSTALL SCREENS ?>
|
<?php // END INSTALL SCREENS ?>
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
@ -166,5 +168,6 @@ if (hesk_dbNumRows($tableSql) > 0) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<p id="hesk-path-for-js" style="display: none"><?php echo '../../'; ?></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -7,12 +7,14 @@ var steps = [
|
|||||||
{
|
{
|
||||||
name: 'db-confirm',
|
name: 'db-confirm',
|
||||||
text: 'Confirm the information below',
|
text: 'Confirm the information below',
|
||||||
|
backPossible: true,
|
||||||
callback: undefined
|
callback: undefined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'install-or-update',
|
name: 'install-or-update',
|
||||||
text: 'Updating to the latest version...',
|
text: 'Updating to the latest version...',
|
||||||
callback: undefined
|
backPossible: false,
|
||||||
|
callback: installOrUpdate
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -38,6 +40,10 @@ function goToStep(step) {
|
|||||||
} else {
|
} else {
|
||||||
$('#tools-button').hide();
|
$('#tools-button').hide();
|
||||||
$('#back-button').show();
|
$('#back-button').show();
|
||||||
|
|
||||||
|
if (!steps[step].backPossible) {
|
||||||
|
$('#back-button').addClass('disabled').attr('disabled', 'disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step === steps.length - 1) {
|
if (step === steps.length - 1) {
|
||||||
@ -47,4 +53,50 @@ function goToStep(step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#header-text').text(steps[step].text);
|
$('#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
7
install/migrations/core.php
Normal file
7
install/migrations/core.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function getAllMigrations() {
|
||||||
|
return array(
|
||||||
|
1 => null
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user