mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +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()
|
||||
{
|
||||
if ($this->getRequest()->getActionName() === 'host') {
|
||||
$this->view->object = new Host($this->getRequest());
|
||||
$this->view->object = new Host($this->params);
|
||||
} elseif ($this->getRequest()->getActionName() === 'service') {
|
||||
$this->view->object = new Service($this->getRequest());
|
||||
$this->view->object = new Service($this->params);
|
||||
} else {
|
||||
// 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')) {
|
||||
$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\Servicegroup;
|
||||
use Icinga\Module\Monitoring\DataView\Customvar;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\UrlParams;
|
||||
|
||||
|
||||
abstract class AbstractObject
|
||||
{
|
||||
@ -35,14 +36,14 @@ abstract class AbstractObject
|
||||
|
||||
protected $view;
|
||||
private $properties = array();
|
||||
private $request = null;
|
||||
protected $params;
|
||||
|
||||
// TODO: Fetching parent states if any would be nice
|
||||
// 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();
|
||||
}
|
||||
|
||||
@ -117,9 +118,7 @@ abstract class AbstractObject
|
||||
|
||||
public function fetchCustomvars()
|
||||
{
|
||||
$query = Customvar::fromRequest(
|
||||
$this->request,
|
||||
array(
|
||||
$query = Customvar::fromParams(array('backend' => null), array(
|
||||
'varname',
|
||||
'varvalue'
|
||||
)
|
||||
@ -173,14 +172,13 @@ abstract class AbstractObject
|
||||
|
||||
public function fetchServicegroups()
|
||||
{
|
||||
$query = Servicegroup::fromRequest(
|
||||
$this->request,
|
||||
array(
|
||||
$query = Servicegroup::fromParams(array('backend' => null), array(
|
||||
'servicegroup_name',
|
||||
'servicegroup_alias',
|
||||
)
|
||||
);
|
||||
|
||||
$query->where('service_host_name', $this->host_name);
|
||||
$query->where('service_description', $this->service_description);
|
||||
$this->servicegroups = $query->getQuery()->fetchPairs();
|
||||
return $this;
|
||||
}
|
||||
@ -226,7 +224,7 @@ abstract class AbstractObject
|
||||
'output',
|
||||
'type'
|
||||
)
|
||||
)->sort('raw_timestamp', 'DESC');
|
||||
)->sort('timestamp', 'DESC');
|
||||
if ($this->type === 'service') {
|
||||
$query->where('service_host_name', $this->host_name);
|
||||
$query->where('service_description', $this->service_description);
|
||||
@ -253,12 +251,12 @@ abstract class AbstractObject
|
||||
return $this->$expandedName;
|
||||
}
|
||||
|
||||
public static function fromRequest(Request $request)
|
||||
public static function fromParams(UrlParams $params)
|
||||
{
|
||||
if ($request->has('service') && $request->has('host')) {
|
||||
return new Service($request);
|
||||
} elseif ($request->has('host')) {
|
||||
return new Host($request);
|
||||
if ($params->has('service') && $params->has('host')) {
|
||||
return new Service($params);
|
||||
} elseif ($params->has('host')) {
|
||||
return new Host($params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class Host extends AbstractObject
|
||||
|
||||
protected function getProperties()
|
||||
{
|
||||
$this->view = HostStatus::fromRequest($this->request, array(
|
||||
$this->view = HostStatus::fromParams(array('backend' => null), array(
|
||||
'host_name',
|
||||
'host_alias',
|
||||
'host_address',
|
||||
|
@ -28,7 +28,7 @@ class Service extends AbstractObject
|
||||
|
||||
protected function getProperties()
|
||||
{
|
||||
$this->view = ServiceStatus::fromRequest($this->request, array(
|
||||
$this->view = ServiceStatus::fromParams(array('backend' => null), array(
|
||||
'host_name',
|
||||
'host_state',
|
||||
'host_state_type',
|
||||
@ -111,7 +111,9 @@ class Service extends AbstractObject
|
||||
'service_flap_detection_enabled',
|
||||
'service_flap_detection_enabled_changed',
|
||||
'service_modified_service_attributes',
|
||||
));
|
||||
))->where('host_name', $this->params->get('host'))
|
||||
->where('service_description', $this->params->get('service'));
|
||||
|
||||
return $this->view->getQuery()->fetchRow();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user