mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 15:10:22 +00:00
Catch update complete + error states
This commit is contained in:
parent
37dcaa41f1
commit
f6d7e9a2d1
2 changed files with 21 additions and 13 deletions
|
@ -262,7 +262,3 @@ button > i.fas {
|
|||
border-bottom-right-radius: 0.35rem;
|
||||
}
|
||||
|
||||
.cmd-copy {
|
||||
width: 95%;
|
||||
height: 6rem;
|
||||
}
|
||||
|
|
|
@ -320,27 +320,39 @@ $('#performupdateModal').on('shown.bs.modal', function (e) {
|
|||
|
||||
function fetchUpdateResponse() {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const complete = 6;
|
||||
const error = 7;
|
||||
let phpFile = 'ajax/system/sys_read_logfile.php';
|
||||
$.ajax({
|
||||
url: phpFile,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
let endPolling = false;
|
||||
for (let i = 1; i <= 6; i++) {
|
||||
let divId = '#updateStep' + i;
|
||||
if (response.includes(i)) {
|
||||
if (response.includes(i.toString())) {
|
||||
$(divId).removeClass('invisible');
|
||||
if (response.includes('6')) {
|
||||
$('#updateStep6').removeClass('invisible');
|
||||
$('#updateSync2').removeClass("fa-spin");
|
||||
break;
|
||||
} else {
|
||||
setTimeout(fetchUpdateResponse, 1000);
|
||||
}
|
||||
}
|
||||
if (response.includes(complete)) {
|
||||
$('#updateStep6').removeClass('invisible');
|
||||
$('#updateSync2').removeClass("fa-spin");
|
||||
endPolling = true;
|
||||
break;
|
||||
} else if (response.includes(error)) {
|
||||
var errorMsg = $('#errorMsg').data('message');
|
||||
$('#updateErr').after('<span class="small">' + errorMsg + '</span>');
|
||||
$('#updateErr').removeClass('invisible');
|
||||
$('#updateSync2').removeClass("fa-spin");
|
||||
endPolling = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!endPolling) {
|
||||
setTimeout(fetchUpdateResponse, 500);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
setTimeout(fetchUpdateResponse, 1000);
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue