dpinger STDEV GUI Additions (#2399)

This commit is contained in:
Martin Wasley 2018-05-08 17:42:47 +01:00 committed by Franco Fichtner
parent 8fda660bce
commit 48628288f9
3 changed files with 49 additions and 3 deletions

View File

@ -297,6 +297,11 @@ $( document ).ready(function() {
<th class="hidden-xs hidden-sm hidden-md"><?=gettext("Gateway"); ?></th>
<th class="hidden-xs hidden-sm hidden-md"><?=gettext("Monitor IP"); ?></th>
<th class="text-nowrap hidden-xs"><?=gettext("RTT"); ?></th>
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
<th class="text-nowrap hidden-xs"><?=gettext("STDEV"); ?></th>
<?php
endif;?>
<th class="text-nowrap hidden-xs"><?=gettext("Loss"); ?></th>
<th><?=gettext("Status"); ?></th>
<th class="hidden-xs hidden-sm hidden-md"><?=gettext("Description"); ?></th>
@ -349,6 +354,13 @@ $( document ).ready(function() {
<td class="text-nowrap hidden-xs">
<?= !empty($gateways_status[$gateway['gname']]) ? $gateways_status[$gateway['gname']]['delay'] : gettext("Pending") ;?>
</td>
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
<td class="text-nowrap hidden-xs">
<?=!empty($gateways_status[$gateway['gname']]) ? $gateways_status[$gateway['gname']]['stddev'] : gettext("Pending") ;?>
</td>
<?php
endif;?>
<td class="text-nowrap hidden-xs">
<?= !empty($gateways_status[$gateway['gname']]) ? $gateways_status[$gateway['gname']]['loss'] : gettext("Pending"); ?>
</td>

View File

@ -39,6 +39,7 @@ function gateway_api()
$gatewayItem['status'] = strtolower($gateways_status[$gname]['status']);
$gatewayItem['loss'] = $gateways_status[$gname]['loss'];
$gatewayItem['delay'] = $gateways_status[$gname]['delay'];
$gatewayItem['stddev'] = $gateways_status[$gname]['stddev'];
switch ($gatewayItem['status']) {
case "none":
$gatewayItem['status_translated'] = gettext("Online");
@ -49,6 +50,9 @@ function gateway_api()
case "delay":
$gatewayItem['status_translated'] = gettext("Latency");
break;
case "stdev":
$gatewayItem['status_translated'] = gettext("StDev");
break;
case "loss":
$gatewayItem['status_translated'] = gettext("Packetloss");
break;
@ -61,6 +65,7 @@ function gateway_api()
$gatewayItem['status'] = "~";
$gatewayItem['status_translated'] = gettext("Unknown");
$gatewayItem['loss'] = "~";
$gatewayItem['stddev'] = "~";
$gatewayItem['delay'] = "unknown";
}
$result[] = $gatewayItem;

View File

@ -40,6 +40,11 @@
tr_content.push('<tr id="'+tr_id+'">');
tr_content.push('<td><small><strong>'+gateway['name']+'</strong><br/>'+gateway['address']+'</small></td>');
tr_content.push('<td class="text-nowrap">'+gateway['delay']+'</td>');
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
tr_content.push('<td class="text-nowrap">'+gateway['stddev']+'</td>');
<?php
endif;?>
tr_content.push('<td class="text-nowrap">'+gateway['loss']+'</td>');
tr_content.push('<td><span>'+gateway['status_translated']+'</span></td>');
tr_content.push('</tr>');
@ -47,8 +52,17 @@
} else {
// update existing gateway
$("#"+tr_id+" > td:eq(1)").html(gateway['delay']);
$("#"+tr_id+" > td:eq(2)").html(gateway['loss']);
$("#"+tr_id+" > td:eq(3)").html('<span>'+gateway['status_translated']+'</span>');
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
$("#"+tr_id+" > td:eq(2)").html(gateway['stddev']);
$("#"+tr_id+" > td:eq(3)").html(gateway['loss']);
$("#"+tr_id+" > td:eq(4)").html('<span>'+gateway['status_translated']+'</span>');
<?php else:?>
$("#"+tr_id+" > td:eq(2)").html(gateway['loss']);
$("#"+tr_id+" > td:eq(3)").html('<span>'+gateway['status_translated']+'</span>');
<?php
endif;?>
}
// set color on status text
switch (gateway['status']) {
@ -64,10 +78,20 @@
status_color = 'success';
break;
}
$("#"+tr_id+" > td:eq(3) > span").removeClass("label-danger label-warning label-success label");
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
$("#"+tr_id+" > td:eq(4) > span").removeClass("label-danger label-warning label-success label");
if (status_color != '') {
$("#"+tr_id+" > td:eq(4) > span").addClass("label label-" + status_color);
}
<?php else:?>
$("#"+tr_id+" > td:eq(3) > span").removeClass("label-danger label-warning label-success label");
if (status_color != '') {
$("#"+tr_id+" > td:eq(3) > span").addClass("label label-" + status_color);
}
<?php
endif;?>
});
}
</script>
@ -78,6 +102,11 @@
<tr>
<th><?=gettext('Name')?></th>
<th><?=gettext('RTT')?></th>
<?php
if (isset($config['system']['prefer_dpinger'])) :?>
<th><?=gettext('STDEV')?></th>
<?php
endif;?>
<th><?=gettext('Loss')?></th>
<th><?=gettext('Status')?></th>
</tr>