Skip to content

Commit 96a332f

Browse files
author
Jeffrey Lensen
committed
Only show report graphs on env_view dashboard as specified in json
config
1 parent d8da0d4 commit 96a332f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

env_view.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
if (!isset($g)) { print "<a href=\"/?$graph_args&c=$cluster_name&from=$gs&until=$ge\"><h3>$cluster_name</h3></a>"; }
2323
foreach ($graph_reports as $graph_report) {
24-
$current_graph_args = "$graph_args&c=$cluster_name";
25-
print print_graph($current_graph_args, "g=$graph_report", $width, $height, $from, $until);
24+
if ( show_on_dashboard($graph_report, $env, $cluster_name) ) {
25+
$current_graph_args = "$graph_args&c=$cluster_name";
26+
print print_graph($current_graph_args, "g=$graph_report", $width, $height, $from, $until);
27+
}
2628
}
2729
if (!isset($g)){ print "<br /><br />"; }
2830
}

functions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ function find_dashboards($environment, $cluster="") {
170170
return $graph_reports;
171171
}
172172

173+
function show_on_dashboard($report_name, $environment, $cluster) {
174+
global $conf;
175+
176+
$dash_config = json_decode(file_get_contents($conf['dashboard_config']), TRUE);
177+
foreach ($dash_config['dashboards'] as $dash) {
178+
if ( preg_match($dash['environments'], $environment) && preg_match($dash['clusters'], $cluster) ){
179+
if ( in_array($report_name, $dash['included_reports']) ) {
180+
return True;
181+
}
182+
}
183+
}
184+
return False;
185+
}
186+
173187
function find_metrics($search_string, $group_depth=0) {
174188
global $conf;
175189

0 commit comments

Comments
 (0)