mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-08-02 16:49:25 +02:00
Merge pull request #1806 from RaspAP/fix/fetch-update-response
Fix: Revise fetchUpdateResponse() and modal dialog
This commit is contained in:
commit
a2b8dfe551
@ -332,47 +332,42 @@ $('#performupdateModal').on('shown.bs.modal', function (e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function fetchUpdateResponse() {
|
function fetchUpdateResponse() {
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
const complete = 6;
|
const complete = 6;
|
||||||
const error = 7;
|
const error = 7;
|
||||||
let phpFile = 'ajax/system/sys_read_logfile.php';
|
let phpFile = 'ajax/system/sys_read_logfile.php';
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: phpFile,
|
url: phpFile,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
let endPolling = false;
|
|
||||||
for (let i = 1; i <= 6; i++) {
|
for (let i = 1; i <= 6; i++) {
|
||||||
let divId = '#updateStep' + i;
|
let divId = '#updateStep' + i;
|
||||||
if (response.includes(i.toString())) {
|
if (response.includes(i.toString())) {
|
||||||
$(divId).removeClass('invisible');
|
$(divId).removeClass('invisible');
|
||||||
}
|
}
|
||||||
if (response.includes(complete)) {
|
|
||||||
var successMsg = $('#successMsg').data('message');
|
|
||||||
$('#updateMsg').after('<span class="small">' + successMsg + '</span>');
|
|
||||||
$('#updateMsg').addClass('fa-check');
|
|
||||||
$('#updateMsg').removeClass('invisible');
|
|
||||||
$('#updateStep6').removeClass('invisible');
|
|
||||||
$('#updateSync2').removeClass("fa-spin");
|
|
||||||
$('#updateOk').removeAttr('disabled');
|
|
||||||
endPolling = true;
|
|
||||||
break;
|
|
||||||
} else if (response.includes(error)) {
|
|
||||||
var errorMsg = $('#errorMsg').data('message');
|
|
||||||
$('#updateMsg').after('<span class="small">' + errorMsg + '</span>');
|
|
||||||
$('#updateMsg').addClass('fa-times');
|
|
||||||
$('#updateMsg').removeClass('invisible');
|
|
||||||
$('#updateSync2').removeClass("fa-spin");
|
|
||||||
$('#updateOk').removeAttr('disabled');
|
|
||||||
endPolling = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!endPolling) {
|
// check if the update is complete or if there's an error
|
||||||
|
if (response.includes(complete)) {
|
||||||
|
var successMsg = $('#successMsg').data('message');
|
||||||
|
$('#updateMsg').after('<span class="small">' + successMsg + '</span>');
|
||||||
|
$('#updateMsg').addClass('fa-check');
|
||||||
|
$('#updateMsg').removeClass('invisible');
|
||||||
|
$('#updateStep6').removeClass('invisible');
|
||||||
|
$('#updateSync2').removeClass("fa-spin");
|
||||||
|
$('#updateOk').removeAttr('disabled');
|
||||||
|
} else if (response.includes(error)) {
|
||||||
|
var errorMsg = $('#errorMsg').data('message');
|
||||||
|
$('#updateMsg').after('<span class="small">' + errorMsg + '</span>');
|
||||||
|
$('#updateMsg').addClass('fa-times');
|
||||||
|
$('#updateMsg').removeClass('invisible');
|
||||||
|
$('#updateSync2').removeClass("fa-spin");
|
||||||
|
$('#updateOk').removeAttr('disabled');
|
||||||
|
} else {
|
||||||
setTimeout(fetchUpdateResponse, 500);
|
setTimeout(fetchUpdateResponse, 500);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
console.error(error);
|
console.error("AJAX Error:", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ require_once 'app/lib/Parsedown.php';
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="col-md-12 mb-3 mt-1" id="msg-check-update"><?php echo _("Application is being updated..."); ?></div>
|
<div class="col-md-12 mb-3 mt-1" id="msg-check-update"><?php echo _("Application is being updated..."); ?></div>
|
||||||
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep1"></i><?php echo _("Configuring update"); ?></div>
|
<div class="ms-5"><i class="fas fa-check me-2" id="updateStep1"></i><?php echo _("Configuring update"); ?></div>
|
||||||
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep2"></i><?php echo _("Updating sources"); ?></div>
|
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep2"></i><?php echo _("Updating sources"); ?></div>
|
||||||
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep3"></i><?php echo _("Installing package updates"); ?></div>
|
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep3"></i><?php echo _("Installing package updates"); ?></div>
|
||||||
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep4"></i><?php echo _("Downloading latest files"); ?></div>
|
<div class="ms-5"><i class="fas fa-check me-2 invisible" id="updateStep4"></i><?php echo _("Downloading latest files"); ?></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user