Guest User

Untitled

a guest
Dec 15th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php
  2. index 4110d66..7a66326 100644
  3. --- a/html/pages/device/ports.inc.php
  4. +++ b/html/pages/device/ports.inc.php
  5. @@ -12,6 +12,23 @@ if (!$vars['view']) {
  6. $vars['view'] = trim($config['ports_page_default'], '/');
  7. }
  8.  
  9. +$quickfilter_conditions = array(
  10. + 'down' => FALSE,
  11. + 'shutdown' => FALSE,
  12. + 'ignored' => FALSE,
  13. + 'disabled' => FALSE,
  14. + 'deleted' => FALSE,
  15. +);
  16. +if (isset($vars['filters'])) {
  17. + foreach (explode(',', $vars['filters']) as $filter) {
  18. + $quickfilter_conditions[$filter] = TRUE;
  19. + }
  20. +} else {
  21. + foreach (array('deleted', 'disabled', 'shutdown') as $filter) {
  22. + $quickfilter_conditions[$filter] = TRUE;
  23. + }
  24. +}
  25. +
  26. $link_array = array(
  27. 'page' => 'device',
  28. 'device' => $device['device_id'],
  29. @@ -88,8 +105,38 @@ foreach ($graph_types as $type => $descr) {
  30. $type_sep = ' | ';
  31. }//end foreach
  32.  
  33. +if (in_array($vars['view'], array('basic', 'details', 'graphs', 'minigraphs')))
  34. + echo '<div class="dropdown pull-right">
  35. +<button class="btn btn-default dropdown-toggle" type="button" data-toggle="drop
  36. +Quick Filters
  37. +<span class="caret"></span></button>
  38. +<ul class="dropdown-menu">';
  39. +
  40. + foreach ($quickfilter_conditions as $name => $enabled) {
  41. + echo '<li>';
  42. + echo $enabled ? "<span class='pagemenu-selected'>" : "<span>";
  43. + $filter = $quickfilter_conditions;
  44. + $filter[$name] = !$filter[$name];
  45. + echo generate_link("Hide ".strtoupper($name), $link_array, array($option
  46. + echo "</span>";
  47. + echo "</li>\n";
  48. + }
  49. + echo "</ul></div>\n";
  50. +}
  51. +
  52. print_optionbar_end();
  53.  
  54. +function port_filter($port)
  55. +{
  56. + global $quickfilter_conditions;
  57. + $is_filtered =
  58. + ($quickfilter_conditions['down'] && $port['ifOperStatus'] != 'up' && $p
  59. + ($quickfilter_conditions['shutdown'] && $port['ifAdminStatus'] == 'down
  60. + ($quickfilter_conditions['ignored'] && $port['ignore']) ||
  61. + ($quickfilter_conditions['deleted'] && $port['deleted']);
  62. + return !$is_filtered;
  63. +}
  64. +
  65. if ($vars['view'] == 'minigraphs') {
  66. $timeperiods = array(
  67. '-1day',
  68. @@ -104,6 +151,7 @@ if ($vars['view'] == 'minigraphs') {
  69. // FIXME - FIX THIS. UGLY.
  70. foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIn
  71. $port = cleanPort($port, $device);
  72. + if (!port_filter($port)) { continue; }
  73. echo "<div style='display: block; padding: 3px; margin: 3px; min-width:
  74. <div style='font-weight: bold;'>".makeshortif($port['ifDescr']).'</
  75. <a href="'.generate_port_url($port)."\" onmouseover=\"return overli
  76. @@ -146,6 +194,8 @@ if ($vars['view'] == 'minigraphs') {
  77. // As we've dragged the whole database, lets pre-populate our caches :)
  78. // FIXME - we should probably split the fetching of link/stack/etc into fun
  79.  
  80. +$ports = array_filter($ports, port_filter);
  81. +
  82. foreach ($ports as $key => $port) {
  83. $port_cache[$port['port_id']] = $port;
  84. $port_index_cache[$port['device_id']][$port['ifIndex']] = $port;
Add Comment
Please, Sign In to add comment