Hook/Grapher: Rework hook interface
Rework interface based on specification and changed consumer calls. refs #6932
This commit is contained in:
parent
376e9aa160
commit
7e5b5a0b30
|
@ -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 GrapherHook
|
||||
abstract class GrapherHook
|
||||
{
|
||||
/**
|
||||
* Whether this grapher provides preview images
|
||||
|
@ -56,9 +58,13 @@ class GrapherHook
|
|||
/**
|
||||
* 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 GrapherHook
|
|||
/**
|
||||
* 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 GrapherHook
|
|||
*
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue