From ea898accf1e96cab3d1d2e10beca1191578f846c Mon Sep 17 00:00:00 2001 From: vuksan Date: Mon, 17 Oct 2011 12:26:45 -0400 Subject: [PATCH] Move views to be on the same level as clusters --- functions.php | 2 +- ganglia.php | 6 +- get_context.php | 16 ++- header.php | 196 +++++++++++++++++-------------- index.php | 6 + js/ganglia.js | 16 +++ templates/default/host_view.tpl | 11 -- templates/default/meta_view.tpl | 5 + templates/default/views_view.tpl | 33 ++++++ version.php.in | 2 +- views_view.php | 60 ++++++++++ 11 files changed, 249 insertions(+), 104 deletions(-) create mode 100644 templates/default/views_view.tpl create mode 100644 views_view.php diff --git a/functions.php b/functions.php index 0e15607a..4d853291 100644 --- a/functions.php +++ b/functions.php @@ -1330,7 +1330,7 @@ function retrieve_metrics_cache () { } } - if ( ! isset($index_array) ) { + if ( ! isset($index_array) || sizeof($index_array) == 0 ) { if ( $debug == 1 ) { echo("DEBUG: Querying GMond for new data\n"); diff --git a/ganglia.php b/ganglia.php index 873e0dde..7f43d59c 100644 --- a/ganglia.php +++ b/ganglia.php @@ -9,7 +9,9 @@ # information as we need to make the page. # -include_once($conf['ganglia_dir'] . "/version.php"); +$ganglia_dir = dirname(__FILE__); + +include_once($ganglia_dir . "/version.php"); $error=""; @@ -35,7 +37,7 @@ $version = array(); # The web frontend version, from conf.php. -$version["webfrontend"] = "$ganglia_version"; +$version["webfrontend"] = $GLOBALS["ganglia_version"]; # Get rrdtool version $rrdtool_version = array(); diff --git a/get_context.php b/get_context.php index 0cb08dca..00b508dc 100644 --- a/get_context.php +++ b/get_context.php @@ -1,16 +1,24 @@ assign("server_utc_offset", date('Z')); +// $data->assign("page_title", $title); $data->assign("refresh", $conf['default_refresh']); @@ -125,24 +128,19 @@ $data->assign("cluster_url", $cluster_url); $alt_view = ""; -if ($context=="cluster") - { - $alt_view = "Physical View"; - } -elseif ($context=="physical") - { - $alt_view = "Full View"; - } -elseif ($context=="node") - { - $alt_view = - "Host View"; - } -elseif ($context=="host") - { - $alt_view = - "Node View"; +if ($context == "cluster") { + $alt_view = "Physical View"; +} elseif ($context == "physical") { + $alt_view = "Full View"; +} elseif ($context=="node") { + $alt_view = "Host View"; +} elseif ($context=="host") { + $alt_view = "Node View"; +} elseif ( $context = "views") { + if( checkAccess( GangliaAcl::ALL_VIEWS, GangliaAcl::EDIT, $conf ) ) { + $alt_view = ''; } +} $data->assign("alt_view", $alt_view); @@ -164,76 +162,100 @@ if ($physical) $node_menu .= hiddenvar("p", $physical); -if ( $clustername ) - { - $url = rawurlencode($clustername); - $node_menu .= "$clustername "; - $node_menu .= ">\n"; - $node_menu .= hiddenvar("c", $clustername); - } -else - { - # No cluster has been specified, so drop in a list - $node_menu .= "\n"; - } - -if ( $clustername && !$hostname ) - { - # Drop in a host list if we have hosts - if (!$showhosts) { - $node_menu .= "[Summary Only]"; +////////////////////////////////////////////////////////////////////////////// +// Cluster name has been specified. It comes right after +// Grid > +////////////////////////////////////////////////////////////////////////////// +if ( $clustername ) { + $url = rawurlencode($clustername); + $node_menu .= "$clustername "; + $node_menu .= ">\n"; + $node_menu .= hiddenvar("c", $clustername); +} else if ( $viewname) { + $url = "Views"; + $node_menu .= "Views "; + $node_menu .= ">\n"; +} else { + # No cluster has been specified, so drop in a list + $node_menu .= ""; - $node_menu .= "