From 5b4056e1b2b4b0465657426bb9943b52643fd240 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 4 Oct 2022 10:23:55 +0200 Subject: [PATCH 1/2] ServiceNode: `getAlias()` returns null if host or service alias is null --- library/Businessprocess/ServiceNode.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/Businessprocess/ServiceNode.php b/library/Businessprocess/ServiceNode.php index 6160bce..53cef21 100644 --- a/library/Businessprocess/ServiceNode.php +++ b/library/Businessprocess/ServiceNode.php @@ -65,6 +65,10 @@ class ServiceNode extends MonitoredNode public function getAlias() { + if ($this->getHostAlias() === null || $this->alias === null) { + return null; + } + return $this->getHostAlias() . ': ' . $this->alias; } From 2f730cc52669262d564710abb2eda2a41d982260 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 4 Oct 2022 10:54:32 +0200 Subject: [PATCH 2/2] Display node name if alias is missing This fixes the issue that the name of a missing monitoring node is not displayed in forms and in Tree/Tile view. --- application/forms/DeleteNodeForm.php | 9 +++++---- application/forms/EditNodeForm.php | 3 ++- application/forms/SimulationForm.php | 2 +- library/Businessprocess/MonitoredNode.php | 4 ++-- .../Businessprocess/Renderer/TileRenderer/NodeTile.php | 6 +++++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/application/forms/DeleteNodeForm.php b/application/forms/DeleteNodeForm.php index dada9d3..67635bb 100644 --- a/application/forms/DeleteNodeForm.php +++ b/application/forms/DeleteNodeForm.php @@ -31,15 +31,16 @@ class DeleteNodeForm extends QuickForm public function setup() { $node = $this->node; + $nodeName = $node->getAlias() ?? $node->getName(); $view = $this->getView(); $this->addHtml( '

' . $view->escape( - sprintf($this->translate('Delete "%s"'), $node->getAlias()) + sprintf($this->translate('Delete "%s"'), $nodeName) ) . '

' ); $biLink = $view->qlink( - $node->getAlias(), + $nodeName, 'businessprocess/node/impact', array('name' => $node->getName()), array('data-base-target' => '_next') @@ -61,7 +62,7 @@ class DeleteNodeForm extends QuickForm } else { $yesMsg = sprintf( $this->translate('Delete root node "%s"'), - $this->node->getAlias() + $nodeName ); } @@ -74,7 +75,7 @@ class DeleteNodeForm extends QuickForm 'multiOptions' => $this->optionalEnum(array( 'no' => $this->translate('No'), 'yes' => $yesMsg, - 'all' => sprintf($this->translate('Delete all occurrences of %s'), $node->getAlias()), + 'all' => sprintf($this->translate('Delete all occurrences of %s'), $nodeName), )) )); } diff --git a/application/forms/EditNodeForm.php b/application/forms/EditNodeForm.php index f26dd04..b22117e 100644 --- a/application/forms/EditNodeForm.php +++ b/application/forms/EditNodeForm.php @@ -48,9 +48,10 @@ class EditNodeForm extends QuickForm } $view = $this->getView(); + $nodeName = $this->getNode()->getAlias() ?? $this->getNode()->getName(); $this->addHtml( '

' . $view->escape( - sprintf($this->translate('Modify "%s"'), $this->getNode()->getAlias()) + sprintf($this->translate('Modify "%s"'), $nodeName) ) . '

' ); diff --git a/application/forms/SimulationForm.php b/application/forms/SimulationForm.php index 263976b..47c9f52 100644 --- a/application/forms/SimulationForm.php +++ b/application/forms/SimulationForm.php @@ -44,7 +44,7 @@ class SimulationForm extends QuickForm } $this->addHtml( '

' - . $view->escape(sprintf($title, $node->getAlias())) + . $view->escape(sprintf($title, $node->getAlias() ?? $node->getName())) . '

' ); diff --git a/library/Businessprocess/MonitoredNode.php b/library/Businessprocess/MonitoredNode.php index 3c4167d..7047e5d 100644 --- a/library/Businessprocess/MonitoredNode.php +++ b/library/Businessprocess/MonitoredNode.php @@ -11,9 +11,9 @@ abstract class MonitoredNode extends Node public function getLink() { if ($this->isMissing()) { - return Html::tag('a', ['href' => '#'], $this->getAlias()); + return Html::tag('a', ['href' => '#'], $this->getAlias() ?? $this->getName()); } else { - return Html::tag('a', ['href' => $this->getUrl()], $this->getAlias()); + return Html::tag('a', ['href' => $this->getUrl()], $this->getAlias() ?? $this->getName()); } } } diff --git a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php index 67bb4a6..a9d67b7 100644 --- a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php +++ b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php @@ -180,7 +180,11 @@ class NodeTile extends BaseHtmlElement $node = $this->node; $url = $this->getMainNodeUrl($node); if ($node instanceof MonitoredNode) { - $link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getAlias()); + $link = Html::tag( + 'a', + ['href' => $url, 'data-base-target' => '_next'], + $node->getAlias() ?? $node->getName() + ); } else { $link = Html::tag('a', ['href' => $url], $node->getAlias()); }