From 213f897ffc2b1249e80aa5247055c35a514fda49 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 27 Oct 2020 01:18:18 +0100 Subject: [PATCH] HostController: details for external services... ...when clicking "Modify" in the monitoring module fixes #1531 --- application/controllers/HostController.php | 34 +++++++++++++++++++--- doc/82-Changelog.md | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index cecfe25c..fe304ec5 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -117,14 +117,40 @@ class HostController extends ObjectController */ public function invalidserviceAction() { - $this->content()->add(Hint::error(sprintf( - $this->translate('No such service: %s'), - $this->params->get('service') - ))); + if (! $this->showInfoForNonDirectorService()) { + $this->content()->add(Hint::error(sprintf( + $this->translate('No such service: %s'), + $this->params->get('service') + ))); + } $this->servicesAction(); } + protected function showInfoForNonDirectorService() + { + try { + $api = $this->getApiIfAvailable(); + if ($api) { + $name = $this->params->get('name') . '!' . $this->params->get('service'); + $info = $api->getObject($name, 'Services'); + if (isset($info->attrs->source_location)) { + $source = $info->attrs->source_location; + $this->content()->add(Hint::info(Html::sprintf( + 'The configuration for this object has not been rendered by' + . ' Icinga Director. You can find it on line %s in %s.', + Html::tag('strong', null, $source->first_line), + Html::tag('strong', null, $source->path) + ))); + } + } + + return true; + } catch (Exception $e) { + return false; + } + } + /** * @throws \Icinga\Exception\NotFoundError */ diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index 34185e3e..57984c43 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -21,6 +21,7 @@ next (will be 1.8.0) * FEATURE: Endpoints table now shows the object type (e.g. external) (#2050) * FEATURE: make sure that form label and fields stay close together (#2136) * FEATURE: show more content, reduce padding (expect on mobile) (#2140) +* FEATURE: location details for non-Director services on "Modify" (#1531) ### Import and Sync * FEATURE: allow to define update-only Sync Rules (#2059)