Make AJAX calls alert on lost connection

This commit is contained in:
Disassembler 2018-11-07 14:37:03 +01:00
parent a4bf77a00a
commit bd066710f5
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -24,6 +24,10 @@ $(function() {
}
});
function lost_connection_alert() {
alert('Spojení se serverem bylo ztraceno');
}
function update_host() {
$('#host-submit').hide();
$('#host-message').hide();
@ -36,7 +40,7 @@ function update_host() {
$('input').prop('disabled', true);
$('.setup-box').slice(1).css('opacity', '0.5');
}
});
}).fail(lost_connection_alert);
return false;
}
@ -52,7 +56,7 @@ function verify_dns() {
} else {
$('#dns-message').attr('class','info').html(data.ok).show();
}
});
}).fail(lost_connection_alert);
return false;
}
@ -68,7 +72,7 @@ function _verify_http(proto) {
} else {
$('#'+proto+'-message').attr('class','info').html(data.ok).show();
}
});
}).fail(lost_connection_alert);
return false;
}
@ -100,7 +104,7 @@ function update_cert() {
} else {
$('#cert-message').attr('class','info').html(data.ok).show();
}
}});
}}).fail(lost_connection_alert);
return false;
}
@ -113,7 +117,7 @@ function _update_app(item, ev) {
el.prop('checked', !value);
alert(data.error);
}
});
}).fail(lost_connection_alert);
}
function update_app_visibility(ev) {
@ -137,9 +141,7 @@ function _do_app(url, ev) {
$('#app-manager tbody').html(data.ok);
}
status_interval = setInterval(get_app_status, 1000);
}).fail(function() {
alert('Spojení se serverem bylo ztraceno');
});
}).fail(lost_connection_alert);
return false;
}
@ -174,7 +176,7 @@ function get_app_status() {
}).fail(function() {
conn_fail_counter++;
if (conn_fail_counter == 10) {
alert('Spojení se serverem bylo ztraceno');
lost_connection_alert();
clearInterval(status_interval);
}
});
@ -192,14 +194,14 @@ function update_password() {
} else {
$('#password-message').attr('class','info').html(data.ok).show();
}
});
}).fail(lost_connection_alert);
return false;
}
function _do_vm(action) {
$.get('/'+action+'-vm', function(data) {
$('#vm-message').attr('class','info').html(data.ok).show();
});
}).fail(lost_connection_alert);
}
function reboot_vm() {