Merge branch 'bugfix/hook-interface-6932'

fixes #6932
fixes #6928
This commit is contained in:
Marius Hein 2014-08-27 09:39:56 +02:00
commit 89541f5727
6 changed files with 65 additions and 21 deletions

View File

@ -4,6 +4,8 @@
namespace Icinga\Web\Hook;
use Icinga\Exception\ProgrammingError;
/**
* Icinga Web Grapher Hook base class
*
@ -14,7 +16,7 @@ namespace Icinga\Web\Hook;
* @author Icinga-Web Team <info@icinga.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*/
class Grapher
abstract class GrapherHook
{
/**
* Whether this grapher provides preview images
@ -56,9 +58,13 @@ class Grapher
/**
* Whether a graph for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return bool
*/
public function hasGraph($host, $service = null, $plot = null)
public function has($host, $service = null, $plot = null)
{
return false;
}
@ -66,13 +72,47 @@ class Grapher
/**
* Get a preview image for the given host[, service [, plot]] exists
*
* WARNING: We are not sure yet whether this will remain as is
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
* @return string
*
* @throws ProgrammingError
*/
public function getPreviewImage($host, $service = null, $plot = null)
public function getPreviewHtml($host, $service = null, $plot = null)
{
throw new Exception('This backend has no preview images');
throw new ProgrammingError('This backend has no preview images');
}
/**
* Whether a tiny graph for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return bool
*/
public function hasTinyPreview($host, $service = null, $plot = null)
{
return false;
}
/**
* Get a tiny preview image for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
*
* @throws ProgrammingError
*/
public function getTinyPreviewHtml($host, $service = null, $plot = null)
{
throw new ProgrammingError('This backend has no tiny preview images');
}
/**
@ -80,10 +120,11 @@ class Grapher
*
* WARNING: We are not sure yet whether this will remain as is
*
* @return string
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
*/
public function getGraphUrl($host, $service = null, $plot = null)
{
throw new Exception('This backend has no images');
}
abstract function getGraphUrl($host, $service = null, $plot = null);
}

View File

@ -14,7 +14,7 @@ namespace Icinga\Web\Hook;
* @author Icinga-Web Team <info@icinga.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*/
abstract class Ticket
abstract class TicketHook
{
/**
* Constructor must live without arguments right now

View File

@ -10,7 +10,7 @@ use \Zend_View;
/**
* Hook to extend topbar items
*/
interface TopBar
abstract class TopBarHook
{
/**
* Function to generate top bar content
@ -20,5 +20,5 @@ interface TopBar
*
* @return string
*/
public function getHtml($request, $view);
abstract public function getHtml($request, $view);
}

View File

@ -25,6 +25,9 @@ class Monitoring_ShowController extends Controller
*/
protected $backend;
/**
* @var Hook\GrapherHook
*/
protected $grapher;
/**
@ -61,8 +64,8 @@ class Monitoring_ShowController extends Controller
. ' on ' . $o->host_name;
$this->getTabs()->activate('service');
$o->populate();
if ($this->grapher && $this->grapher->hasGraph($o->host_name, $o->service_description)) {
$this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name, $o->service_description);
if ($this->grapher && $this->grapher->hasPreviews($o->host_name, $o->service_description)) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o->host_name, $o->service_description);
}
}
@ -76,8 +79,8 @@ class Monitoring_ShowController extends Controller
$this->getTabs()->activate('host');
$this->view->title = $o->host_name;
$o->populate();
if ($this->grapher && $this->grapher->hasGraph($o->host_name)) {
$this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name);
if ($this->grapher && $this->grapher->hasPreviews($o->host_name)) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o->host_name);
}
}

View File

@ -9,7 +9,7 @@ use Icinga\Module\Monitoring\Timeline\TimeRange;
/**
* Base class for TimeLine providers
*/
abstract class TimelineProvider
abstract class TimelineProviderHook
{
/**
* Return the names by which to group entries

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Web\Hook;
use Icinga\Web\Hook\TopBar as IcingaTopBar;
use Icinga\Web\Hook\TopBarHook;
use Icinga\Module\Monitoring\DataView\StatusSummary as StatusSummaryView;
use Icinga\Web\Request;
use Zend_View;
@ -12,7 +12,7 @@ use Zend_View;
/**
* Render status summary into the topbar of icinga
*/
class TopBar implements IcingaTopBar
class TopBar extends TopBarHook
{
/**
* Function to generate top bar content