mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 19:06:16 +01:00
73
themes/grav/js/admin.min.js
vendored
73
themes/grav/js/admin.min.js
vendored
@@ -4600,6 +4600,8 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
this.urls = this.buildUrls();
|
||||
this.decisions = {};
|
||||
this.pollTimer = null;
|
||||
this.statusRequest = null;
|
||||
this.isPolling = !1;
|
||||
this.active = false;
|
||||
this.registerEvents();
|
||||
}
|
||||
@@ -4810,9 +4812,7 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
});
|
||||
this.buttons.start.prop('disabled', true);
|
||||
this.stopPolling();
|
||||
this.pollTimer = setInterval(function () {
|
||||
_this4.fetchStatus(true);
|
||||
}, 1200);
|
||||
this.beginPolling();
|
||||
var body = {
|
||||
decisions: this.decisions
|
||||
};
|
||||
@@ -4849,28 +4849,75 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
_this4.fetchStatus(true);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "beginPolling",
|
||||
value: function beginPolling() {
|
||||
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1200;
|
||||
if (this.isPolling) {
|
||||
return;
|
||||
}
|
||||
this.isPolling = !0;
|
||||
this.schedulePoll(delay);
|
||||
}
|
||||
}, {
|
||||
key: "schedulePoll",
|
||||
value: function schedulePoll() {
|
||||
var _this5 = this;
|
||||
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1200;
|
||||
this.clearPollTimer();
|
||||
if (!this.isPolling) {
|
||||
return;
|
||||
}
|
||||
this.pollTimer = setTimeout(function () {
|
||||
_this5.fetchStatus(true);
|
||||
}, delay);
|
||||
}
|
||||
}, {
|
||||
key: "clearPollTimer",
|
||||
value: function clearPollTimer() {
|
||||
if (this.pollTimer) {
|
||||
clearTimeout(this.pollTimer);
|
||||
this.pollTimer = null;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "fetchStatus",
|
||||
value: function fetchStatus() {
|
||||
var _this5 = this;
|
||||
var _this6 = this;
|
||||
var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||
utils_request(this.urls.status, function (response) {
|
||||
if (this.statusRequest) {
|
||||
return;
|
||||
}
|
||||
this.pollTimer = null;
|
||||
var nextStage = null;
|
||||
this.statusRequest = utils_request(this.urls.status, function (response) {
|
||||
if (response.status === 'error') {
|
||||
if (!silent) {
|
||||
_this5.renderProgress({
|
||||
_this6.renderProgress({
|
||||
stage: 'error',
|
||||
message: response.message || t('SAFE_UPGRADE_GENERIC_ERROR', 'Safe upgrade could not complete. See Grav logs for details.'),
|
||||
percent: null
|
||||
});
|
||||
}
|
||||
nextStage = 'error';
|
||||
return;
|
||||
}
|
||||
var data = response.data || {};
|
||||
_this5.renderProgress(data);
|
||||
if (data.stage === 'complete') {
|
||||
_this5.stopPolling();
|
||||
}
|
||||
nextStage = data.stage || null;
|
||||
_this6.renderProgress(data);
|
||||
});
|
||||
var finalize = function finalize() {
|
||||
_this6.statusRequest = null;
|
||||
if (!_this6.isPolling) {
|
||||
return;
|
||||
}
|
||||
if (nextStage === 'complete' || nextStage === 'error') {
|
||||
_this6.stopPolling();
|
||||
} else {
|
||||
_this6.schedulePoll();
|
||||
}
|
||||
};
|
||||
this.statusRequest.then(finalize, finalize);
|
||||
}
|
||||
}, {
|
||||
key: "renderProgress",
|
||||
@@ -4935,10 +4982,8 @@ var SafeUpgrade = /*#__PURE__*/function () {
|
||||
}, {
|
||||
key: "stopPolling",
|
||||
value: function stopPolling() {
|
||||
if (this.pollTimer) {
|
||||
clearInterval(this.pollTimer);
|
||||
this.pollTimer = null;
|
||||
}
|
||||
this.isPolling = !1;
|
||||
this.clearPollTimer();
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
|
||||
Reference in New Issue
Block a user