Commit ce6e3acf authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

translate interface names in Reporting->Health, closes https://github.com/opnsense/core/issues/1070

maybe, one day, we should refactor some of the JS code... but for now this will do the trick

(cherry picked from commit 6c8c91a1)
parent 48c51f2e
......@@ -32,6 +32,7 @@ namespace OPNsense\Diagnostics\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\Core\Config;
/**
* Class ServiceController
......@@ -585,4 +586,22 @@ class SystemhealthController extends ApiControllerBase
return ["sets" => [], "d3" => [], "title" => "error", "y-axis_label" => ""];
}
}
/**
* Retrieve network interfaces by key (lan, wan, opt1,..)
* @return array
*/
public function getInterfacesAction()
{
// collect interface names
$intfmap = array();
$config = Config::getInstance()->object() ;
if ($config->interfaces != null) {
foreach ($config->interfaces->children() as $key => $node) {
$intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key) ;
}
}
return $intfmap;
}
}
......@@ -210,11 +210,11 @@
rrd_name = subitem + '-' + category;
if (subitem==active_subitem) {
tabs += '<li class="active"><a data-toggle="tab" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
tabs += '<li class="active"><a data-toggle="tab" class="rrd-item" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
rrd=rrd_name;
getdata(rrd_name,0,0,120,false,0); // load initial data
} else {
tabs += '<li><a data-toggle="tab" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
tabs += '<li><a data-toggle="tab" class="rrd-item" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
}
}
tabs+='</ul>';
......@@ -222,6 +222,19 @@
}
$('#maintabs').html(tabs);
$('#tab_1').toggleClass('active');
// map interface descriptions
ajaxGet(url = "/api/diagnostics/systemhealth/getInterfaces" , sendData = {}, callback = function (data, status) {
$(".rrd-item").each(function(){
var rrd_item = $(this);
var rrd_item_name = $(this).attr('id').split('-')[0].toLowerCase();
$.map(data, function(value, key){
if (key.toLowerCase() == rrd_item_name) {
rrd_item.html('<i class="fa fa-check-square"></i> ' + value['descr']);
}
});
});
});
} else {
alert("Error while fetching RRD list : "+status);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment