Skip to content

Commit

Permalink
added flag to disable paneltitle
Browse files Browse the repository at this point in the history
  • Loading branch information
Griesbacher committed Nov 23, 2016
1 parent 8746546 commit 9264a9f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions histou.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ specialChar = "&"
; set the backend: influxdb, elasticsearch
databaseType = "influxdb"
forecastDatasourceName = "nagflux_forecast"
; disable the Panel Titel globally
disablePanelTitel = false

[folder]
defaultTemplateFolder = "templates/default/"
Expand Down
9 changes: 8 additions & 1 deletion histou.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ return function (callback) {
}

var url = 'http://localhost/histou/';
var configUrl = url+'index.php?host='+host+'&service='+service+'&height='+height+'&legend='+legend+debug+'&annotations='+annotations;
var configUrl = url+'index.php?host='+host+'&service='+service+'&height='+height+'&legend='+legend+debug+disablePanelTitel+'&annotations='+annotations;

var flotAddons = url + 'flotAddons.js';
$.getScript(flotAddons, function (){});
Expand Down Expand Up @@ -149,6 +149,13 @@ function parseArgs()
} else {
annotations = false;
}

if(_.isUndefined(ARGS.disablePanelTitel)) {
disablePanelTitel = '';
}else{
disablePanelTitel = "&disablePanelTitel";
}

}

function clearUi()
Expand Down
10 changes: 10 additions & 0 deletions histou/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Basic
1 => array("pipe", "w"), // STDOUT
2 => array("pipe", "w") // STERR
);
public static $disablePanelTitel = false;

/**
Parses the GET parameter.
Expand Down Expand Up @@ -94,6 +95,10 @@ public static function parsArgs()
}
}

if (isset($_GET['disablePanelTitel'])) {
static::$disablePanelTitel = true;
}

if (isset($_GET['debug'])) {
\histou\Debug::enable();
}
Expand Down Expand Up @@ -175,6 +180,10 @@ public static function parsIni($filename)
if (!empty($phpCommand)) {
static::$phpCommand = $phpCommand;
}
$disablePanelTitel = Basic::getConfigKey($config, 'general', 'disablePanelTitel');
if (!empty($disablePanelTitel)) {
static::$disablePanelTitel = $disablePanelTitel;
}
Basic::setConstant(
"TMP_FOLDER",
Basic::getConfigKey($config, 'general', 'tmpFolder'),
Expand All @@ -195,6 +204,7 @@ public static function parsIni($filename)
strtolower(Basic::getConfigKey($config, 'general', 'forecastDatasourceName')),
"nagflux_forecast"
);

Basic::setConstant(
"URL",
Basic::getConfigKey($config, DATABASE_TYPE, 'url'),
Expand Down
3 changes: 3 additions & 0 deletions histou/grafana/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function __construct($title, $type, $id = -1)
**/
public function toArray()
{
if (\histou\Basic::$disablePanelTitel) {
$this->data['title'] = "";
}
return $this->data;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/histou/basicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public function testTestConfig()
{
$file_contents = file_get_contents('histou.ini.example');
$file_contents = str_replace('phpCommand = "php"', 'phpCommand = "foo"', $file_contents);
$file_contents = str_replace('disablePanelTitel = false', 'disablePanelTitel = true', $file_contents);
file_put_contents('histou.ini.example.tmp', $file_contents);
\histou\Basic::parsIni('histou.ini.example.tmp');
unlink('histou.ini.example.tmp');
$this->assertTrue((boolean)\histou\Basic::$disablePanelTitel);
$this->assertSame(\histou\Basic::$phpCommand, "foo");
ob_start();
$this->assertSame(1, \histou\Basic::testConfig());
Expand Down
2 changes: 2 additions & 0 deletions tests/histou/grafana/panelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public function testCreatePanel()
{
$panel1 = new \histou\grafana\graphpanel\GraphPanelInfluxdb('p1', 'test');
$this->assertSame('p1', $panel1->toArray()['title']);
\histou\Basic::$disablePanelTitel = true;
$this->assertSame('', $panel1->toArray()['title']);
$panel1->setSpan(20);
$this->assertSame(20, $panel1->toArray()['span']);
$panel1->setEditable(false);
Expand Down

0 comments on commit 9264a9f

Please sign in to comment.