22
33namespace  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
127use  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}
0 commit comments