Skip to content

Commit 29df742

Browse files
authored
Merge pull request #75 from NETWAYS/remove-legacy
Remove dashboard logic for Monitoring module
2 parents 624ff03 + ff1e289 commit 29df742

File tree

2 files changed

+5
-42
lines changed

2 files changed

+5
-42
lines changed

application/controllers/DashboardController.php

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22

33
namespace Icinga\Module\Grafana\Controllers;
44

5-
use Icinga\Module\Grafana\ProvidedHook\Icingadb\IcingadbSupport;
6-
7-
use Icinga\Application\Modules\Module;
8-
use Icinga\Module\Monitoring\Controller;
9-
use Icinga\Module\Monitoring\Object\Host;
10-
use Icinga\Module\Monitoring\Object\Service;
5+
use Icinga\Module\Grafana\Web\Controller\IcingadbGrafanaController;
116

127
use ipl\Web\Url;
138

149
/**
1510
* DashboardController for showing graphs for Monitoring Module dashboards
1611
*/
17-
class DashboardController extends Controller
12+
class DashboardController extends IcingadbGrafanaController
1813
{
1914
public function init()
2015
{
@@ -24,32 +19,8 @@ public function init()
2419

2520
public function indexAction()
2621
{
27-
// Redirect to IcingaDB if it is enabled
28-
if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) {
29-
$this->redirectNow(Url::fromPath('grafana/icingadbdashboard')->setQueryString($this->params));
30-
}
31-
32-
$this->getTabs()->add('graphs', [
33-
'active' => true,
34-
'label' => $this->translate('Graphs'),
35-
'url' => $this->getRequest()->getUrl()
36-
]);
37-
38-
$hostname = $this->params->getRequired('host');
39-
$servicename = $this->params->get('service');
40-
41-
if ($servicename != null) {
42-
$object = new Service($this->backend, $hostname, $servicename);
43-
} else {
44-
$object = new Host($this->backend, $this->params->getRequired('host'));
45-
}
46-
47-
$this->applyRestriction('monitoring/filter/objects', $object);
48-
if ($object->fetch() === false) {
49-
$this->httpNotFound($this->translate('Host or Service not found'));
50-
}
51-
52-
$graph = new Grapher();
53-
$this->view->graph = $graph->getPreviewHtml($object);
22+
// This is an old controller that was used in the Monitoring module.
23+
// So we redirect to IcingaDB, just to that older dashboards don't break.
24+
$this->redirectNow(Url::fromPath('grafana/icingadbdashboard')->setQueryString($this->params));
5425
}
5526
}

application/controllers/IcingadbdashboardController.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
use Icinga\Module\Grafana\ProvidedHook\Icingadb\ServiceDetailExtension;
77
use Icinga\Module\Grafana\Web\Controller\IcingadbGrafanaController;
88

9-
use Icinga\Module\Icingadb\Model\Host;
10-
11-
use ipl\Web\Url;
12-
139
/**
1410
* IcingadbdashboardController for showing graphs for IcingaDB Module dashboards
1511
*/
@@ -23,10 +19,6 @@ public function init()
2319

2420
public function indexAction()
2521
{
26-
if (! $this->useIcingadbAsBackend) {
27-
$this->redirectNow(Url::fromPath('grafana/dashboard')->setQueryString($this->params));
28-
}
29-
3022
$this->getTabs()->add(
3123
'graphs',
3224
[

0 commit comments

Comments
 (0)