aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPim van den Berg2012-12-28 20:25:29 +0100
committerPim van den Berg2012-12-28 20:25:29 +0100
commit79ac52d54a51acdbd469f2d48890eb11e04ac991 (patch)
tree2bed6c9c58d6279a0f6da9083107017312d5bfe5
parentdon't show plugins the host doesn't have (diff)
downloadapt-panopticon_cgp-79ac52d54a51acdbd469f2d48890eb11e04ac991.zip
apt-panopticon_cgp-79ac52d54a51acdbd469f2d48890eb11e04ac991.tar.gz
apt-panopticon_cgp-79ac52d54a51acdbd469f2d48890eb11e04ac991.tar.bz2
apt-panopticon_cgp-79ac52d54a51acdbd469f2d48890eb11e04ac991.tar.xz
remove arguments overview_plugins and other_plugins from plugins_list function
Those can be gathered within the function.
-rw-r--r--detail.php10
-rw-r--r--host.php9
-rw-r--r--inc/html.inc.php35
3 files changed, 28 insertions, 26 deletions
diff --git a/detail.php b/detail.php
index b824d1d..fdeb777 100644
--- a/detail.php
+++ b/detail.php
@@ -21,12 +21,7 @@ $width = GET('x');
21$heigth = GET('y'); 21$heigth = GET('y');
22$seconds = GET('s'); 22$seconds = GET('s');
23 23
24if (!$plugin) { 24$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
25 $selected_plugins = $CONFIG['overview'];
26}
27else {
28 $selected_plugins = array($plugin);
29}
30 25
31html_start(); 26html_start();
32 27
@@ -39,8 +34,7 @@ if(!$plugins) {
39 return false; 34 return false;
40} 35}
41 36
42plugins_list($host, $CONFIG['overview'], $plugins, $selected_plugins); 37plugins_list($host, $selected_plugins);
43
44 38
45echo '<div class="graphs">'; 39echo '<div class="graphs">';
46plugin_header($host, $plugin); 40plugin_header($host, $plugin);
diff --git a/host.php b/host.php
index 42121ea..71d786a 100644
--- a/host.php
+++ b/host.php
@@ -7,12 +7,7 @@ require_once 'inc/collectd.inc.php';
7$host = validate_get(GET('h'), 'host'); 7$host = validate_get(GET('h'), 'host');
8$plugin = validate_get(GET('p'), 'plugin'); 8$plugin = validate_get(GET('p'), 'plugin');
9 9
10if (!$plugin) { 10$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
11 $selected_plugins = $CONFIG['overview'];
12}
13else {
14 $selected_plugins = array($plugin);
15}
16 11
17html_start(); 12html_start();
18 13
@@ -25,7 +20,7 @@ if(!$plugins) {
25 return false; 20 return false;
26} 21}
27 22
28plugins_list($host, $CONFIG['overview'], $plugins, $selected_plugins); 23plugins_list($host, $selected_plugins);
29 24
30echo '<div class="graphs">'; 25echo '<div class="graphs">';
31foreach ($selected_plugins as $selected_plugin) { 26foreach ($selected_plugins as $selected_plugin) {
diff --git a/inc/html.inc.php b/inc/html.inc.php
index fd32b38..a9e6a94 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -63,29 +63,42 @@ function plugin_header($host, $plugin) {
63 return printf("<h3><a href='%shost.php?h=%s&p=%s'>%s</a></h3>\n", $CONFIG['weburl'], $host, $plugin, $plugin); 63 return printf("<h3><a href='%shost.php?h=%s&p=%s'>%s</a></h3>\n", $CONFIG['weburl'], $host, $plugin, $plugin);
64} 64}
65 65
66function plugins_list($host, $overview_plugins, $other_plugins, $selected_plugins = array()) { 66function plugins_list($host, $selected_plugins = array()) {
67 global $CONFIG; 67 global $CONFIG;
68 68
69 $plugins = collectd_plugins($host);
70
69 echo '<div class="plugins">'; 71 echo '<div class="plugins">';
70 echo '<h3>Plugins</h3>'; 72 echo '<h3>Plugins</h3>';
71 echo '<ul>'; 73 echo '<ul>';
72 74
73 $selected = selected_overview($selected_plugins); 75 printf("<li><a %s href='%shost.php?h=%s'>overview</a></li>\n",
74 printf("<li><a %s href='%shost.php?h=%s'>%s</a></li>\n", $selected, $CONFIG['weburl'], $host, 'overview'); 76 selected_overview($selected_plugins),
77 $CONFIG['weburl'],
78 $host
79 );
75 80
76 # first the ones defined as ordered 81 # first the ones defined as ordered
77 foreach($overview_plugins as $plugin) { 82 foreach($CONFIG['overview'] as $plugin) {
78 if (in_array($plugin, $other_plugins)) { 83 if (in_array($plugin, $plugins)) {
79 $selected = selected_plugin($plugin, $selected_plugins); 84 printf("<li><a %s href='%shost.php?h=%s&p=%s'>%4\$s</a></li>\n",
80 printf("<li><a %s href='%shost.php?h=%s&p=%s'>%s</a></li>\n", $selected, $CONFIG['weburl'], $host, $plugin, $plugin); 85 selected_plugin($plugin, $selected_plugins),
86 $CONFIG['weburl'],
87 $host,
88 $plugin
89 );
81 } 90 }
82 } 91 }
83 92
84 # other plugins 93 # other plugins
85 foreach($other_plugins as $plugin) { 94 foreach($plugins as $plugin) {
86 if (!in_array($plugin, $overview_plugins)) { 95 if (!in_array($plugin, $CONFIG['overview'])) {
87 $selected = selected_plugin($plugin, $selected_plugins); 96 printf("<li><a %s href='%shost.php?h=%s&p=%s'>%4\$s</a></li>\n",
88 printf("<li><a %s href='%shost.php?h=%s&p=%s'>%s</a></li>\n", $selected, $CONFIG['weburl'], $host, $plugin, $plugin); 97 selected_plugin($plugin, $selected_plugins),
98 $CONFIG['weburl'],
99 $host,
100 $plugin
101 );
89 } 102 }
90 } 103 }
91 104