monitoring: Deprecate the host and service action of the `ShowController'

There are the `HostController' and the `ServiceController' now instead.
This commit is contained in:
Eric Lippmann 2014-09-23 22:37:14 -07:00
parent 3034ac5257
commit 0b723bb57d

View File

@ -5,6 +5,7 @@
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;
use Icinga\Module\Monitoring\Object\MonitoredObject; use Icinga\Module\Monitoring\Object\MonitoredObject;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabs; use Icinga\Web\Widget\Tabs;
use Icinga\Web\Widget\Tabextension\OutputFormat; use Icinga\Web\Widget\Tabextension\OutputFormat;
use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\DashboardAction;
@ -35,14 +36,11 @@ class Monitoring_ShowController extends Controller
*/ */
public function init() public function init()
{ {
if ($this->getRequest()->getActionName() === 'host') { $this->view->object = MonitoredObject::fromParams($this->params);
$this->view->object = new Host($this->params); if ($this->view->object->fetch() === false) {
} elseif ($this->getRequest()->getActionName() === 'service') { throw new Zend_Controller_Action_Exception($this->translate('Host or service not found'));
$this->view->object = new Service($this->params);
} else {
// TODO: Well... this could be done better
$this->view->object = MonitoredObject::fromParams($this->params);
} }
if (Hook::has('ticket')) { if (Hook::has('ticket')) {
$this->view->tickets = Hook::first('ticket'); $this->view->tickets = Hook::first('ticket');
} }
@ -57,36 +55,19 @@ class Monitoring_ShowController extends Controller
} }
/** /**
* Service overview * @deprecated
*/ */
public function serviceAction() public function serviceAction()
{ {
$o = $this->view->object; $this->redirectNow(Url::fromRequest()->setPath('monitoring/service/show'));
$this->setAutorefreshInterval(10);
$this->view->title = $o->service_description
. ' on ' . $o->host_name;
$this->getTabs()->activate('service');
$o->populate();
if ($this->grapher) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o);
}
$this->fetchHostStats();
} }
/** /**
* Host overview * @deprecated
*/ */
public function hostAction() public function hostAction()
{ {
$o = $this->view->object; $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/show'));
$this->setAutorefreshInterval(10);
$this->getTabs()->activate('host');
$this->view->title = $o->host_name;
$o->populate();
if ($this->grapher) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o);
}
$this->fetchHostStats();
} }
public function historyAction() public function historyAction()
@ -206,16 +187,17 @@ class Monitoring_ShowController extends Controller
if (($object = $this->view->object) === null) { if (($object = $this->view->object) === null) {
return; return;
} }
if ($object->getType() === $object::TYPE_HOST) {
$tabs = $this->getTabs(); $params = array(
$params = array( 'host' => $object->getName()
'host' => $object->host_name, );
); } else {
if ($object instanceof Service) { $params = array(
$params['service'] = $object->service_description; 'host' => $object->getHost()->getName(),
} elseif ($service = $this->_getParam('service')) { 'service' => $object->getName()
$params['service'] = $service; );
} }
$tabs = $this->getTabs();
$tabs->add( $tabs->add(
'host', 'host',
array( array(