mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-26 00:36:31 +02:00
more granular upgrade status
This commit is contained in:
@@ -606,8 +606,9 @@ class SafeUpgradeManager
|
||||
|
||||
try {
|
||||
$file = $this->download($package, $timeout);
|
||||
$this->setProgress('installing', 'Installing update...', null);
|
||||
$this->setProgress('installing', 'Installing update...', 80);
|
||||
$this->performInstall($file);
|
||||
$this->setProgress('installing', 'Preparing promotion...', 92);
|
||||
} catch (Throwable $e) {
|
||||
$this->setProgress('error', $e->getMessage(), null);
|
||||
|
||||
@@ -619,13 +620,14 @@ class SafeUpgradeManager
|
||||
$this->tmp = null;
|
||||
}
|
||||
|
||||
$this->setProgress('finalizing', 'Finalizing upgrade...', 100);
|
||||
$this->setProgress('finalizing', 'Finalizing upgrade...', 95);
|
||||
$safeUpgrade->clearRecoveryFlag();
|
||||
if ($this->recovery && method_exists($this->recovery, 'closeUpgradeWindow')) {
|
||||
$this->recovery->closeUpgradeWindow();
|
||||
}
|
||||
|
||||
$this->ensureExecutablePermissions();
|
||||
$this->setProgress('finalizing', 'Finalizing upgrade...', 98);
|
||||
|
||||
$manifest = $this->resolveLatestManifest();
|
||||
|
||||
@@ -851,6 +853,7 @@ class SafeUpgradeManager
|
||||
*/
|
||||
protected function performInstall(string $zip): void
|
||||
{
|
||||
$this->setProgress('installing', 'Unpacking archive...', 82);
|
||||
$folder = Installer::unZip($zip, $this->tmp . '/zip');
|
||||
if ($folder === false) {
|
||||
throw new RuntimeException(Installer::lastErrorMsg());
|
||||
@@ -867,7 +870,9 @@ class SafeUpgradeManager
|
||||
}
|
||||
|
||||
try {
|
||||
$this->setProgress('installing', 'Running installer...', 85);
|
||||
$install($zip);
|
||||
$this->setProgress('installing', 'Verifying files...', 88);
|
||||
} catch (Throwable $e) {
|
||||
throw new RuntimeException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
@@ -605,6 +605,7 @@ export default class SafeUpgrade {
|
||||
if (usingDirect && this.statusFailures >= 3) {
|
||||
this.preferDirectStatus = false;
|
||||
this.statusFailures = 0;
|
||||
this.statusIdleCount = 0;
|
||||
this.schedulePoll();
|
||||
} else {
|
||||
const delay = Math.min(5000, 1200 * Math.max(1, this.statusFailures));
|
||||
@@ -613,6 +614,7 @@ export default class SafeUpgrade {
|
||||
} else if ((!lastPayload || !lastPayload.job || !Object.keys(lastPayload.job).length) && usingDirect && this.statusIdleCount >= 5) {
|
||||
this.preferDirectStatus = false;
|
||||
this.statusFailures = 0;
|
||||
this.statusIdleCount = 0;
|
||||
this.schedulePoll();
|
||||
} else if (jobFailed) {
|
||||
this.stopPolling();
|
||||
@@ -650,8 +652,8 @@ export default class SafeUpgrade {
|
||||
}
|
||||
return 25;
|
||||
}
|
||||
if (stage === 'installing') { return percent !== null ? Math.max(percent, 80) : 80; }
|
||||
if (stage === 'finalizing') { return percent !== null ? Math.max(percent, 95) : 95; }
|
||||
if (stage === 'installing') { return percent !== null ? Math.min(Math.max(percent, 80), 94) : 80; }
|
||||
if (stage === 'finalizing') { return percent !== null ? Math.min(Math.max(percent, 95), 99) : 95; }
|
||||
if (stage === 'complete') { return 100; }
|
||||
if (stage === 'error') { return null; }
|
||||
return percent;
|
||||
@@ -661,13 +663,15 @@ export default class SafeUpgrade {
|
||||
const percentLabel = percent !== null ? `${percent}%` : '';
|
||||
|
||||
const statusLine = job && job.status ? `<p class="safe-upgrade-status">${t('SAFE_UPGRADE_JOB_STATUS', 'Status')}: <strong>${job.status.toUpperCase()}</strong>${job.error ? ` — ${job.error}` : ''}</p>` : '';
|
||||
const animateBar = stage !== 'complete' && stage !== 'error' && percent !== null;
|
||||
const barClass = `safe-upgrade-progress-bar${animateBar ? ' is-active' : ''}`;
|
||||
|
||||
this.steps.progress.html(`
|
||||
<div class="safe-upgrade-progress">
|
||||
<h3>${title}</h3>
|
||||
<p>${data.message || ''}</p>
|
||||
${statusLine}
|
||||
${percentLabel ? `<div class="safe-upgrade-progress-bar"><span style="width:${percent}%"></span></div><div class="progress-value">${percentLabel}</div>` : ''}
|
||||
${percentLabel ? `<div class="${barClass}"><span style="width:${percent}%"></span></div><div class="progress-value">${percentLabel}</div>` : ''}
|
||||
</div>
|
||||
`);
|
||||
|
||||
|
||||
15
themes/grav/css-compiled/template.css
vendored
15
themes/grav/css-compiled/template.css
vendored
@@ -7174,6 +7174,9 @@ body .changelog ul li:before {
|
||||
background: #4dbc8b;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
.remodal .safe-upgrade-body .safe-upgrade-progress .safe-upgrade-progress-bar.is-active span {
|
||||
animation: safe-upgrade-pulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
.remodal .safe-upgrade-body .safe-upgrade-progress .safe-upgrade-status {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.95rem;
|
||||
@@ -7189,4 +7192,16 @@ body .changelog ul li:before {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
@keyframes safe-upgrade-pulse {
|
||||
0% {
|
||||
filter: brightness(100%);
|
||||
}
|
||||
50% {
|
||||
filter: brightness(115%);
|
||||
}
|
||||
100% {
|
||||
filter: brightness(100%);
|
||||
}
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=template.css.map */
|
||||
|
||||
File diff suppressed because one or more lines are too long
12
themes/grav/js/admin.min.js
vendored
12
themes/grav/js/admin.min.js
vendored
@@ -5015,11 +5015,11 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
return;
|
||||
}
|
||||
var payload = response.data || {};
|
||||
lastPayload = payload;
|
||||
if (Object.prototype.hasOwnProperty.call(payload, 'context')) {
|
||||
_this6.statusContext = payload.context || null;
|
||||
}
|
||||
var job = payload.job || {};
|
||||
lastPayload = payload;
|
||||
var data = payload.progress || payload;
|
||||
nextStage = data.stage || null;
|
||||
if (!job || !Object.keys(job).length) {
|
||||
@@ -5065,6 +5065,7 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
if (usingDirect && _this6.statusFailures >= 3) {
|
||||
_this6.preferDirectStatus = false;
|
||||
_this6.statusFailures = 0;
|
||||
_this6.statusIdleCount = 0;
|
||||
_this6.schedulePoll();
|
||||
} else {
|
||||
var delay = Math.min(5000, 1200 * Math.max(1, _this6.statusFailures));
|
||||
@@ -5073,6 +5074,7 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
} else if ((!lastPayload || !lastPayload.job || !Object.keys(lastPayload.job).length) && usingDirect && _this6.statusIdleCount >= 5) {
|
||||
_this6.preferDirectStatus = false;
|
||||
_this6.statusFailures = 0;
|
||||
_this6.statusIdleCount = 0;
|
||||
_this6.schedulePoll();
|
||||
} else if (jobFailed) {
|
||||
_this6.stopPolling();
|
||||
@@ -5116,10 +5118,10 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
return 25;
|
||||
}
|
||||
if (stage === 'installing') {
|
||||
return percent !== null ? Math.max(percent, 80) : 80;
|
||||
return percent !== null ? Math.min(Math.max(percent, 80), 94) : 80;
|
||||
}
|
||||
if (stage === 'finalizing') {
|
||||
return percent !== null ? Math.max(percent, 95) : 95;
|
||||
return percent !== null ? Math.min(Math.max(percent, 95), 99) : 95;
|
||||
}
|
||||
if (stage === 'complete') {
|
||||
return 100;
|
||||
@@ -5132,7 +5134,9 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
percent = scaledPercent();
|
||||
var percentLabel = percent !== null ? "".concat(percent, "%") : '';
|
||||
var statusLine = job && job.status ? "<p class=\"safe-upgrade-status\">".concat(t('SAFE_UPGRADE_JOB_STATUS', 'Status'), ": <strong>").concat(job.status.toUpperCase(), "</strong>").concat(job.error ? " — ".concat(job.error) : '', "</p>") : '';
|
||||
this.steps.progress.html("\n <div class=\"safe-upgrade-progress\">\n <h3>".concat(title, "</h3>\n <p>").concat(data.message || '', "</p>\n ").concat(statusLine, "\n ").concat(percentLabel ? "<div class=\"safe-upgrade-progress-bar\"><span style=\"width:".concat(percent, "%\"></span></div><div class=\"progress-value\">").concat(percentLabel, "</div>") : '', "\n </div>\n "));
|
||||
var animateBar = stage !== 'complete' && stage !== 'error' && percent !== null;
|
||||
var barClass = "safe-upgrade-progress-bar".concat(animateBar ? ' is-active' : '');
|
||||
this.steps.progress.html("\n <div class=\"safe-upgrade-progress\">\n <h3>".concat(title, "</h3>\n <p>").concat(data.message || '', "</p>\n ").concat(statusLine, "\n ").concat(percentLabel ? "<div class=\"".concat(barClass, "\"><span style=\"width:").concat(percent, "%\"></span></div><div class=\"progress-value\">").concat(percentLabel, "</div>") : '', "\n </div>\n "));
|
||||
this.switchStep('progress');
|
||||
if (stage === 'complete') {
|
||||
this.renderResult({
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
background: #4dbc8b;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
&.is-active span {
|
||||
animation: safe-upgrade-pulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
.safe-upgrade-status {
|
||||
@@ -77,3 +81,15 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes safe-upgrade-pulse {
|
||||
0% {
|
||||
filter: brightness(100%);
|
||||
}
|
||||
50% {
|
||||
filter: brightness(115%);
|
||||
}
|
||||
100% {
|
||||
filter: brightness(100%);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user