mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Monitoring\Object: replace fromRequest with params
This is only a temporary solution, the Monitoring\Object should be fetched from the backend created in our front controller.
This commit is contained in:
parent
0ecd527e8c
commit
3ccfe347f3
@ -57,12 +57,12 @@ class Monitoring_ShowController extends Controller
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->getActionName() === 'host') {
|
if ($this->getRequest()->getActionName() === 'host') {
|
||||||
$this->view->object = new Host($this->getRequest());
|
$this->view->object = new Host($this->params);
|
||||||
} elseif ($this->getRequest()->getActionName() === 'service') {
|
} elseif ($this->getRequest()->getActionName() === 'service') {
|
||||||
$this->view->object = new Service($this->getRequest());
|
$this->view->object = new Service($this->params);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Well... this could be done better
|
// TODO: Well... this could be done better
|
||||||
$this->view->object = AbstractObject::fromRequest($this->getRequest());
|
$this->view->object = AbstractObject::fromParams($this->params);
|
||||||
}
|
}
|
||||||
if (Hook::has('ticket')) {
|
if (Hook::has('ticket')) {
|
||||||
$this->view->tickets = Hook::first('ticket');
|
$this->view->tickets = Hook::first('ticket');
|
||||||
|
@ -17,7 +17,8 @@ use Icinga\Module\Monitoring\DataView\Hostgroup;
|
|||||||
use Icinga\Module\Monitoring\DataView\Comment;
|
use Icinga\Module\Monitoring\DataView\Comment;
|
||||||
use Icinga\Module\Monitoring\DataView\Servicegroup;
|
use Icinga\Module\Monitoring\DataView\Servicegroup;
|
||||||
use Icinga\Module\Monitoring\DataView\Customvar;
|
use Icinga\Module\Monitoring\DataView\Customvar;
|
||||||
use Icinga\Web\Request;
|
use Icinga\Web\UrlParams;
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractObject
|
abstract class AbstractObject
|
||||||
{
|
{
|
||||||
@ -35,14 +36,14 @@ abstract class AbstractObject
|
|||||||
|
|
||||||
protected $view;
|
protected $view;
|
||||||
private $properties = array();
|
private $properties = array();
|
||||||
private $request = null;
|
protected $params;
|
||||||
|
|
||||||
// TODO: Fetching parent states if any would be nice
|
// TODO: Fetching parent states if any would be nice
|
||||||
// Same goes for host/service dependencies
|
// Same goes for host/service dependencies
|
||||||
|
|
||||||
public function __construct(Request $request)
|
public function __construct(UrlParams $params)
|
||||||
{
|
{
|
||||||
$this->request = $request;
|
$this->params = $params;
|
||||||
$this->properties = $this->getProperties();
|
$this->properties = $this->getProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +118,7 @@ abstract class AbstractObject
|
|||||||
|
|
||||||
public function fetchCustomvars()
|
public function fetchCustomvars()
|
||||||
{
|
{
|
||||||
$query = Customvar::fromRequest(
|
$query = Customvar::fromParams(array('backend' => null), array(
|
||||||
$this->request,
|
|
||||||
array(
|
|
||||||
'varname',
|
'varname',
|
||||||
'varvalue'
|
'varvalue'
|
||||||
)
|
)
|
||||||
@ -173,14 +172,13 @@ abstract class AbstractObject
|
|||||||
|
|
||||||
public function fetchServicegroups()
|
public function fetchServicegroups()
|
||||||
{
|
{
|
||||||
$query = Servicegroup::fromRequest(
|
$query = Servicegroup::fromParams(array('backend' => null), array(
|
||||||
$this->request,
|
|
||||||
array(
|
|
||||||
'servicegroup_name',
|
'servicegroup_name',
|
||||||
'servicegroup_alias',
|
'servicegroup_alias',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$query->where('service_host_name', $this->host_name);
|
||||||
|
$query->where('service_description', $this->service_description);
|
||||||
$this->servicegroups = $query->getQuery()->fetchPairs();
|
$this->servicegroups = $query->getQuery()->fetchPairs();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -226,7 +224,7 @@ abstract class AbstractObject
|
|||||||
'output',
|
'output',
|
||||||
'type'
|
'type'
|
||||||
)
|
)
|
||||||
)->sort('raw_timestamp', 'DESC');
|
)->sort('timestamp', 'DESC');
|
||||||
if ($this->type === 'service') {
|
if ($this->type === 'service') {
|
||||||
$query->where('service_host_name', $this->host_name);
|
$query->where('service_host_name', $this->host_name);
|
||||||
$query->where('service_description', $this->service_description);
|
$query->where('service_description', $this->service_description);
|
||||||
@ -253,12 +251,12 @@ abstract class AbstractObject
|
|||||||
return $this->$expandedName;
|
return $this->$expandedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromRequest(Request $request)
|
public static function fromParams(UrlParams $params)
|
||||||
{
|
{
|
||||||
if ($request->has('service') && $request->has('host')) {
|
if ($params->has('service') && $params->has('host')) {
|
||||||
return new Service($request);
|
return new Service($params);
|
||||||
} elseif ($request->has('host')) {
|
} elseif ($params->has('host')) {
|
||||||
return new Host($request);
|
return new Host($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class Host extends AbstractObject
|
|||||||
|
|
||||||
protected function getProperties()
|
protected function getProperties()
|
||||||
{
|
{
|
||||||
$this->view = HostStatus::fromRequest($this->request, array(
|
$this->view = HostStatus::fromParams(array('backend' => null), array(
|
||||||
'host_name',
|
'host_name',
|
||||||
'host_alias',
|
'host_alias',
|
||||||
'host_address',
|
'host_address',
|
||||||
|
@ -28,7 +28,7 @@ class Service extends AbstractObject
|
|||||||
|
|
||||||
protected function getProperties()
|
protected function getProperties()
|
||||||
{
|
{
|
||||||
$this->view = ServiceStatus::fromRequest($this->request, array(
|
$this->view = ServiceStatus::fromParams(array('backend' => null), array(
|
||||||
'host_name',
|
'host_name',
|
||||||
'host_state',
|
'host_state',
|
||||||
'host_state_type',
|
'host_state_type',
|
||||||
@ -111,7 +111,9 @@ class Service extends AbstractObject
|
|||||||
'service_flap_detection_enabled',
|
'service_flap_detection_enabled',
|
||||||
'service_flap_detection_enabled_changed',
|
'service_flap_detection_enabled_changed',
|
||||||
'service_modified_service_attributes',
|
'service_modified_service_attributes',
|
||||||
));
|
))->where('host_name', $this->params->get('host'))
|
||||||
|
->where('service_description', $this->params->get('service'));
|
||||||
|
|
||||||
return $this->view->getQuery()->fetchRow();
|
return $this->view->getQuery()->fetchRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user