ChartController: use correct ActionController

...and some code cleanup
This commit is contained in:
Thomas Gelf 2014-06-22 14:04:03 +02:00
parent de19745eb2
commit 2a0e72273a

View File

@ -31,14 +31,13 @@ use Icinga\Application\Icinga;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Logger\Logger; use Icinga\Logger\Logger;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Controller\ActionController; use Icinga\Module\Monitoring\Controller;
use Icinga\Chart\SVGRenderer; use Icinga\Chart\SVGRenderer;
use Icinga\Chart\GridChart; use Icinga\Chart\GridChart;
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
use Icinga\Module\Monitoring\Backend;
use Icinga\Chart\Palette; use Icinga\Chart\Palette;
use Icinga\Chart\Axis; use Icinga\Chart\Axis;
use Icinga\Chart\PieChart; use Icinga\Chart\PieChart;
use Icinga\Chart\Unit\StaticAxis;
/** /**
* Class Monitoring_CommandController * Class Monitoring_CommandController
@ -46,36 +45,11 @@ use Icinga\Chart\PieChart;
* Interface to send commands and display forms * Interface to send commands and display forms
*/ */
class Monitoring_ChartController extends ActionController class Monitoring_ChartController extends Controller
{ {
/**
* The backend used for this controller
*
* @var Backend
*/
protected $backend;
/**
* Set to a string containing the compact layout name to use when
* 'compact' is set as the layout parameter, otherwise null
*
* @var string
*/
private $compactView;
/**
* Retrieve backend and hooks for this controller
*
* @see ActionController::init
*/
public function init()
{
}
public function testAction() { public function testAction() {
$this->chart = new GridChart(); $this->chart = new GridChart();
$this->chart->setAxisLabel("X axis label", "Y axis label") $this->chart->setAxisLabel('X axis label', 'Y axis label')->setXAxis(new StaticAxis());
->setXAxis(new \Icinga\Chart\Unit\StaticAxis());
$data1 = array(); $data1 = array();
$data2 = array(); $data2 = array();
$data3 = array(); $data3 = array();
@ -125,8 +99,8 @@ class Monitoring_ChartController extends ActionController
public function hostgroupAction() public function hostgroupAction()
{ {
$query = GroupsummaryView::fromRequest( $query = $this->backend->select()->from(
$this->_request, 'groupsummary',
array( array(
'hostgroup', 'hostgroup',
'hosts_up', 'hosts_up',
@ -156,8 +130,8 @@ class Monitoring_ChartController extends ActionController
public function servicegroupAction() public function servicegroupAction()
{ {
$query = GroupsummaryView::fromRequest( $query = $this->backend->select()->from(
$this->_request, 'groupsummary',
array( array(
'servicegroup', 'servicegroup',
'services_ok', 'services_ok',
@ -231,8 +205,7 @@ class Monitoring_ChartController extends ActionController
$unreachableBars[] = array($hostgroup->hostgroup, $hostgroup->hosts_unreachable_unhandled); $unreachableBars[] = array($hostgroup->hostgroup, $hostgroup->hosts_unreachable_unhandled);
} }
$this->view->chart = new GridChart(); $this->view->chart = new GridChart();
$this->view->chart->setAxisLabel('', 'Hosts') $this->view->chart->setAxisLabel('', 'Hosts')->setXAxis(new StaticAxis());
->setXAxis(new \Icinga\Chart\Unit\StaticAxis());
$this->view->chart->drawBars( $this->view->chart->drawBars(
array( array(
'label' => 'Up', 'label' => 'Up',