Add maintenance mode during update

This commit is contained in:
Jay Trees 2022-01-18 10:51:40 +01:00
parent b8c5ef0419
commit b65ea3a8be
4 changed files with 78 additions and 0 deletions

View file

@ -12,3 +12,10 @@
.ui.modal > .actions {
text-align: inherit;
}
/**
* Progress
*/
.ui.progress.nolabel:last-child {
margin: 0;
}

View file

@ -0,0 +1,28 @@
$(function() {
const urlParams = new URLSearchParams(window.location.search);
var retryIn = urlParams.has('interval') ? urlParams.get('interval') : 5;
var value = 0;
var total = retryIn * 1000;
$('#retryIn').html(retryIn);
setTimeout(function step() {
$('.ui.progress').progress({
total: total,
value: value
});
if (value >= total) {
setTimeout(function() {
urlParams.set('interval', parseInt(retryIn) + 5);
window.location.href = window.location.origin + '/?' + urlParams.toString();
}, 1000);
} else {
value += 100;
setTimeout(step, 100);
}
}, 100)
});

41
includes/pages/update.php Normal file
View file

@ -0,0 +1,41 @@
<?php
/**
* home.php
*
* @author Jay Trees <github.jay@grandel.anonaddy.me>
*/
use wishthis\{Page, User};
$page = new page(__FILE__, 'Update');
$page->header();
$page->navigation();
?>
<main>
<div class="ui container">
<h1 class="ui header"><?= $page->title ?></h1>
<?php if ($user->isLoggedIn()) { ?>
<?php } else { ?>
<div class="ui segment">
<h2 class="ui header">Maintenance</h2>
<p>
The administrator of this site is currently running an update.
This usually just takes a couple of seconds.
</p>
<p>
Trying again in <span id="retryIn">5</span> seconds...
</p>
<div class="ui primary progress nolabel" data-percent="74" id="example1">
<div class="bar"></div>
</div>
</div>
<?php } ?>
</div>
</main>
<?php
$page->footer();
?>

View file

@ -73,6 +73,7 @@ if (!$options) {
if ($options) {
if (-1 === version_compare($options->version, '0.2.0')) {
$options->updateAvailable = true;
$page = 'update';
}
}
@ -92,5 +93,6 @@ if (file_exists($pagePath)) {
<h1>Not found</h1>
<p>The requested URL was not found on this server.</p>
<?php
echo $pagePath;
die();
}