mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
Reporting/Health - sort interfaces by description. closes https://github.com/opnsense/core/issues/6434
As we rather don't want to change the api dataformat too much at the moment, we could sort by description in the controller for packets and traffic and move the interface mapping into the getRRDlistAction() response. This should keep all backwards compatible and offers improved sorting with limited impact.
This commit is contained in:
parent
16492ceddd
commit
9f2ad523b5
@ -495,16 +495,36 @@ class SystemhealthController extends ApiControllerBase
|
||||
$response = $backend->configdRun('health list');
|
||||
$healthList = json_decode($response, true);
|
||||
|
||||
$interfaces = $this->getInterfacesAction();
|
||||
|
||||
$result['data'] = array();
|
||||
if (is_array($healthList)) {
|
||||
foreach ($healthList as $healthItem => $details) {
|
||||
if (!array_key_exists($details['topic'], $result['data'])) {
|
||||
$result['data'][$details['topic']] = array();
|
||||
$result['data'][$details['topic']] = [];
|
||||
}
|
||||
if (in_array($details['topic'], ['packets', 'traffic'])) {
|
||||
if (isset($interfaces[$details['itemName']])) {
|
||||
$desc = $interfaces[$details['itemName']]['descr'];
|
||||
} else {
|
||||
$desc = $details['itemName'];
|
||||
}
|
||||
$result['data'][$details['topic']][$details['itemName']] = $desc;
|
||||
} else {
|
||||
$result['data'][$details['topic']][] = $details['itemName'];
|
||||
}
|
||||
$result['data'][$details['topic']][] = $details['itemName'];
|
||||
}
|
||||
}
|
||||
foreach (['packets', 'traffic'] as $key) {
|
||||
if (isset($result['data'][$key])) {
|
||||
natcasesort($result['data'][$key]);
|
||||
$result['data'][$key] = array_keys($result['data'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
ksort($result['data']);
|
||||
|
||||
$result["interfaces"] = $interfaces;
|
||||
$result["result"] = "ok";
|
||||
|
||||
// Category => Items
|
||||
@ -603,7 +623,7 @@ class SystemhealthController extends ApiControllerBase
|
||||
$config = Config::getInstance()->object();
|
||||
if ($config->interfaces->count() > 0) {
|
||||
foreach ($config->interfaces->children() as $key => $node) {
|
||||
$intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key);
|
||||
$intfmap[(string)$key] = ["descr" => !empty((string)$node->descr) ? (string)$node->descr : $key];
|
||||
}
|
||||
}
|
||||
return $intfmap;
|
||||
|
||||
@ -187,16 +187,13 @@
|
||||
$('#maintabs').html(tabs);
|
||||
$('#tab_1').toggleClass('active');
|
||||
// map interface descriptions
|
||||
ajaxGet("/api/diagnostics/systemhealth/getInterfaces" , {}, 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(value['descr']);
|
||||
}
|
||||
|
||||
});
|
||||
$(".rrd-item").each(function(){
|
||||
var rrd_item = $(this);
|
||||
var rrd_item_name = $(this).attr('id').split('-')[0].toLowerCase();
|
||||
$.map(data['interfaces'], function(value, key){
|
||||
if (key.toLowerCase() == rrd_item_name) {
|
||||
rrd_item.html(value['descr']);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user