Skip to content

Commit

Permalink
Cancel XHR timeout if received a 401 error
Browse files Browse the repository at this point in the history
  • Loading branch information
liaralabs committed Nov 27, 2021
1 parent 97cefd3 commit 8788d9e
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ <h5 class="text-center">{{ mount }}</h5>
//getdisks()

function appstatus(){
$.get("{{ url_for('app_status') }}", function(data){
$.get("{{ url_for('app_status') }}", function(data, xhr){
if(xhr.status==401)
{
clearTimeout(timer);
return
}
for (var apps in data) {
var name = data[apps]["name"];
var enabled = data[apps]["enabled"];
Expand All @@ -292,7 +297,12 @@ <h5 class="text-center">{{ mount }}</h5>
appstatus();

(function loadavg() {
$.get('{{ url_for('loadavg') }}', function(data) {
$.get('{{ url_for('loadavg') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
}
$("#load1m").html(data['1m']);
$("#load5m").html(data['5m']);
$("#load15m").html(data['15m']);
Expand All @@ -310,7 +320,12 @@ <h5 class="text-center">{{ mount }}</h5>
})();

(function diskusage() {
$.get('{{ url_for('disk_free') }}', function(data) {
$.get('{{ url_for('disk_free') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
}
for (var mount in data) {
var percent = Math.trunc(data[mount]['perutil']);
$("#"+$.escapeSelector(mount)+"diskfree").html(data[mount]['diskfree']);
Expand All @@ -333,7 +348,12 @@ <h5 class="text-center">{{ mount }}</h5>
})();

(function ramusage() {
$.get('{{ url_for('ram_stats') }}', function(data) {
$.get('{{ url_for('ram_stats') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
}
var percent = Math.trunc(data['perutil']);
$("#ramfree").html(data['ramfree']);
$("#ramused").html(data['ramused']);
Expand All @@ -355,7 +375,12 @@ <h5 class="text-center">{{ mount }}</h5>
})();

(function vnstat_top10() {
$.get('{{ url_for('vnstat') }}', function(data) {
$.get('{{ url_for('vnstat') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
}
$("#top10").html(data);
setTimeout(function(){vnstat_top10()}, 600000);
}
Expand All @@ -364,7 +389,7 @@ <h5 class="text-center">{{ mount }}</h5>


window.onload = function() {
$.get('{{ url_for('boot_time') }}', function(data) {
$.get('{{ url_for('boot_time') }}', function(data, xhr) {
countUpFromTime(data, 'uptime');
})
};
Expand Down Expand Up @@ -412,7 +437,12 @@ <h5 class="text-center">{{ mount }}</h5>

{% macro build_widget_js_shared() %}
(function netusage() {
$.get('{{ url_for('network_quota') }}', function(data) {
$.get('{{ url_for('network_quota') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
}
var percent = Math.trunc(data['perutil']);
$("#netfree").html(data['netfree']);
$("#netused").html(data['netused']);
Expand Down

0 comments on commit 8788d9e

Please sign in to comment.