From 3985f67fe7aeba9dba965263310656169be0c786 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 4 Dec 2017 18:05:07 +0100 Subject: [PATCH 1/3] Fix "Host not found" error refs #147 --- application/controllers/HostController.php | 24 +++++++++++++++++ application/controllers/ServiceController.php | 27 +++++++++++++++++++ application/views/scripts/host/show.phtml | 12 +++++++++ application/views/scripts/service/show.phtml | 17 ++++++++++++ library/Businessprocess/HostNode.php | 2 +- library/Businessprocess/ServiceNode.php | 2 +- 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 application/controllers/HostController.php create mode 100644 application/controllers/ServiceController.php create mode 100644 application/views/scripts/host/show.phtml create mode 100644 application/views/scripts/service/show.phtml diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php new file mode 100644 index 0000000..134ab5b --- /dev/null +++ b/application/controllers/HostController.php @@ -0,0 +1,24 @@ +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; + } +} diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php new file mode 100644 index 0000000..17bb474 --- /dev/null +++ b/application/controllers/ServiceController.php @@ -0,0 +1,27 @@ +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; + } +} diff --git a/application/views/scripts/host/show.phtml b/application/views/scripts/host/show.phtml new file mode 100644 index 0000000..1455c80 --- /dev/null +++ b/application/views/scripts/host/show.phtml @@ -0,0 +1,12 @@ + +
+ showOnlyCloseButton() ?> +
+
+

escape($this->translate('Access denied')) ?>

+

escape($this->translate('Access to host "%s" denied')), $host) ?>

+
diff --git a/application/views/scripts/service/show.phtml b/application/views/scripts/service/show.phtml new file mode 100644 index 0000000..5b0aee6 --- /dev/null +++ b/application/views/scripts/service/show.phtml @@ -0,0 +1,17 @@ + +
+ showOnlyCloseButton() ?> +
+
+

escape($this->translate('Access denied')) ?>

+

escape($this->translate('Access to service "%s" of host "%s" denied')), + $service, + $host + ) ?>

+
diff --git a/library/Businessprocess/HostNode.php b/library/Businessprocess/HostNode.php index d700a5b..130cebe 100644 --- a/library/Businessprocess/HostNode.php +++ b/library/Businessprocess/HostNode.php @@ -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() diff --git a/library/Businessprocess/ServiceNode.php b/library/Businessprocess/ServiceNode.php index b827835..517b059 100644 --- a/library/Businessprocess/ServiceNode.php +++ b/library/Businessprocess/ServiceNode.php @@ -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); } } From 4c0136eec8dab1dfa2fb9cd047a96e8b64368558 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 18 Feb 2019 15:20:42 +0100 Subject: [PATCH 2/3] Beautify displayed message for restricted hosts/services refs #147 --- application/views/scripts/host/show.phtml | 7 ++++--- application/views/scripts/service/show.phtml | 11 ++++------- public/css/module.less | 10 ++++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/application/views/scripts/host/show.phtml b/application/views/scripts/host/show.phtml index 1455c80..413baf2 100644 --- a/application/views/scripts/host/show.phtml +++ b/application/views/scripts/host/show.phtml @@ -6,7 +6,8 @@
showOnlyCloseButton() ?>
-
-

escape($this->translate('Access denied')) ?>

-

escape($this->translate('Access to host "%s" denied')), $host) ?>

+
+

translate('Access Denied') ?>

+

translate('You are lacking permission to access host "%s".'), $this->escape($host)) ?>

+ icon('cancel') ?>translate('Hide this message') ?>
diff --git a/application/views/scripts/service/show.phtml b/application/views/scripts/service/show.phtml index 5b0aee6..205b3f7 100644 --- a/application/views/scripts/service/show.phtml +++ b/application/views/scripts/service/show.phtml @@ -7,11 +7,8 @@
showOnlyCloseButton() ?>
-
-

escape($this->translate('Access denied')) ?>

-

escape($this->translate('Access to service "%s" of host "%s" denied')), - $service, - $host - ) ?>

+
+

escape($this->translate('Access Denied')) ?>

+

escape(sprintf($this->translate('You are lacking permission to access service "%s" on host "%s"'), $service, $host)) ?>

+ icon('cancel') ?>translate('Hide this message') ?>
diff --git a/public/css/module.less b/public/css/module.less index 68a58b3..5e18cbf 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -611,6 +611,16 @@ td > a > .badges { /** END of tiles **/ +.content.restricted { + h1 { + font-size: 2em; + } + + p > a { + margin-left: 1em; + } +} + /** BEGIN breadcrumb **/ .breadcrumb { From e76de6515e118542e3170d51654a0caec4702812 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 18 Feb 2019 15:24:12 +0100 Subject: [PATCH 3/3] Fix tests --- test/php/library/Businessprocess/HostNodeTest.php | 2 +- test/php/library/Businessprocess/ServiceNodeTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/php/library/Businessprocess/HostNodeTest.php b/test/php/library/Businessprocess/HostNodeTest.php index 72852dc..9146bee 100644 --- a/test/php/library/Businessprocess/HostNodeTest.php +++ b/test/php/library/Businessprocess/HostNodeTest.php @@ -35,7 +35,7 @@ class HostNodeTest extends BaseTestCase public function testRendersCorrectLink() { $this->assertEquals( - '' + '' . 'localhost', $this->localhost()->getLink()->render() ); diff --git a/test/php/library/Businessprocess/ServiceNodeTest.php b/test/php/library/Businessprocess/ServiceNodeTest.php index 152c256..c5fd719 100644 --- a/test/php/library/Businessprocess/ServiceNodeTest.php +++ b/test/php/library/Businessprocess/ServiceNodeTest.php @@ -35,7 +35,7 @@ class ServiceNodeTest extends BaseTestCase public function testRendersCorrectLink() { $this->assertEquals( - '' + '' . 'localhost: ping <> pong', $this->pingOnLocalhost()->getLink()->render() );