more updates

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-10-16 13:49:53 -06:00
parent a4e0c83160
commit 6ff2c4576c
4 changed files with 128 additions and 31 deletions

View File

@@ -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();
}
}]);
}();