From d6116f2f985c372a9e1aad3bdd44516a32270719 Mon Sep 17 00:00:00 2001 From: Joni Lee Date: Thu, 26 Nov 2015 17:56:14 +0800 Subject: [PATCH 1/2] Sort by Traffic in "Device Port" page --- html/pages/device/ports.inc.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 56d3ee5426..1c86c3ced5 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -121,8 +121,19 @@ else { if ($vars['view'] == 'details') { $port_details = 1; } +?> +
+ + + + + + + + + +
Port">TrafficSpeedMediaMac Address
"; $i = '1'; global $port_cache, $port_index_cache; @@ -130,11 +141,15 @@ else { $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); // As we've dragged the whole database, lets pre-populate our caches :) // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) { + + foreach ($ports as $key => $port) { $port_cache[$port['port_id']] = $port; $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + $ports[$key]["ifOctets_rate"] = $port["ifInOctets_rate"] + $port["ifOutOctets_rate"]; } + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + foreach ($ports as $port) { include 'includes/print-interface.inc.php'; $i++; From 5a6f05b0a0e856d02622284afc4d6fc737c0cff9 Mon Sep 17 00:00:00 2001 From: nokoya Date: Thu, 26 Nov 2015 20:05:58 +0800 Subject: [PATCH 2/2] Update ports.inc.php --- html/pages/device/ports.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 1c86c3ced5..50d21e1e59 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -124,7 +124,7 @@ else { ?>
- + @@ -148,7 +148,14 @@ else { $ports[$key]["ifOctets_rate"] = $port["ifInOctets_rate"] + $port["ifOutOctets_rate"]; } - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + switch ($vars["sort"]) { + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + default: + $ports = array_sort($ports, 'ifIndex', SORT_ASC); + break; + } foreach ($ports as $port) { include 'includes/print-interface.inc.php';
Port">Port ">Traffic Speed