Merge branch 'bugfix/host-not-found-147'

fixes #147
This commit is contained in:
Johannes Meyer 2019-02-18 15:36:14 +01:00
commit c8a6eee054
9 changed files with 92 additions and 4 deletions

View file

@ -0,0 +1,24 @@
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
class HostController extends Controller
{
public function showAction()
{
$host = $this->params->getRequired('host');
$query = $this->backend->select()
->from('hoststatus', array('host_name'))
->where('host_name', $host);
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
$this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params));
}
$this->view->host = $host;
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
class ServiceController extends Controller
{
public function showAction()
{
$host = $this->params->getRequired('host');
$service = $this->params->getRequired('service');
$query = $this->backend->select()
->from('servicestatus', array('service_description'))
->where('host_name', $host)
->where('service_description', $service);
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
$this->redirectNow(Url::fromPath('monitoring/service/show')->setParams($this->params));
}
$this->view->host = $host;
$this->view->service = $service;
}
}

View file

@ -0,0 +1,13 @@
<?php
/** @var \Icinga\Web\View $this */
/** @var \Icinga\Web\Widget\Tabs $tabs */
/** @var string $host */
?>
<div class="controls">
<?= $tabs->showOnlyCloseButton() ?>
</div>
<div class="content restricted">
<h1><?= $this->translate('Access Denied') ?></h1>
<p><?= sprintf($this->translate('You are lacking permission to access host "%s".'), $this->escape($host)) ?></p>
<a href="#" class="close-container-control action-link"><?= $this->icon('cancel') ?><?= $this->translate('Hide this message') ?></a>
</div>

View file

@ -0,0 +1,14 @@
<?php
/** @var \Icinga\Web\View $this */
/** @var \Icinga\Web\Widget\Tabs $tabs */
/** @var string $host */
/** @var string $service */
?>
<div class="controls">
<?= $tabs->showOnlyCloseButton() ?>
</div>
<div class="content restricted">
<h1><?= $this->escape($this->translate('Access Denied')) ?></h1>
<p><?= $this->escape(sprintf($this->translate('You are lacking permission to access service "%s" on host "%s"'), $service, $host)) ?></p>
<a href="#" class="close-container-control action-link"><?= $this->icon('cancel') ?><?= $this->translate('Hide this message') ?></a>
</div>

View file

@ -64,7 +64,7 @@ class HostNode extends MonitoredNode
$params['backend'] = $this->bp->getBackendName();
}
return Url::fromPath('monitoring/host/show', $params);
return Url::fromPath('businessprocess/host/show', $params);
}
public function getLink()

View file

@ -51,6 +51,6 @@ class ServiceNode extends MonitoredNode
$params['backend'] = $this->bp->getBackendName();
}
return Url::fromPath('monitoring/service/show', $params);
return Url::fromPath('businessprocess/service/show', $params);
}
}

View file

@ -611,6 +611,16 @@ td > a > .badges {
/** END of tiles **/
.content.restricted {
h1 {
font-size: 2em;
}
p > a {
margin-left: 1em;
}
}
/** BEGIN breadcrumb **/
.breadcrumb {

View file

@ -35,7 +35,7 @@ class HostNodeTest extends BaseTestCase
public function testRendersCorrectLink()
{
$this->assertEquals(
'<a href="/icingaweb2/monitoring/host/show?host=localhost">'
'<a href="/icingaweb2/businessprocess/host/show?host=localhost">'
. 'localhost</a>',
$this->localhost()->getLink()->render()
);

View file

@ -35,7 +35,7 @@ class ServiceNodeTest extends BaseTestCase
public function testRendersCorrectLink()
{
$this->assertEquals(
'<a href="/icingaweb2/monitoring/service/show?host=localhost&amp;service=ping%20%3C%3E%20pong">'
'<a href="/icingaweb2/businessprocess/service/show?host=localhost&amp;service=ping%20%3C%3E%20pong">'
. 'localhost: ping &lt;&gt; pong</a>',
$this->pingOnLocalhost()->getLink()->render()
);