From 404fb19e3538f1de1e92569dea17218b4108d9fd Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 23 Apr 2019 10:54:43 +0200 Subject: [PATCH] Fixed status of staticgraph in metaconsole Former-commit-id: cf0b32c2c7cafaca8f4463d46d67c25c7a81fdc2 --- .../VisualConsole/Items/StaticGraph.php | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php index 255c1a5636..139608a491 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php @@ -163,21 +163,6 @@ final class StaticGraph extends Item throw new \InvalidArgumentException('missing module Id'); } - // Maybe connect to node. - $nodeConnected = false; - if (\is_metaconsole() === true && $metaconsoleId !== null) { - $nodeConnected = \metaconsole_connect( - null, - $metaconsoleId - ) === NOERR; - - if ($nodeConnected === false) { - throw new \InvalidArgumentException( - 'error connecting to the node' - ); - } - } - // Get the img src. $imagePath = \visual_map_get_image_status_element($data); $data['statusImageSrc'] = \ui_get_full_url( @@ -198,6 +183,21 @@ final class StaticGraph extends Item // Get last value. $showLastValueTooltip = static::extractShowLastValueTooltip($data); if ($showLastValueTooltip !== 'disabled' && $moduleId > 0) { + // Maybe connect to node. + $nodeConnected = false; + if (\is_metaconsole() === true && $metaconsoleId !== null) { + $nodeConnected = \metaconsole_connect( + null, + $metaconsoleId + ) === NOERR; + + if ($nodeConnected === false) { + throw new \InvalidArgumentException( + 'error connecting to the node' + ); + } + } + $imgTitle = ''; $unit = \trim(\io_safe_output(\modules_get_unit($moduleId))); @@ -219,11 +219,11 @@ final class StaticGraph extends Item $data['lastValue'] = $imgTitle; } - } - // Restore connection. - if ($nodeConnected === true) { - \metaconsole_restore_db(); + // Restore connection. + if ($nodeConnected === true) { + \metaconsole_restore_db(); + } } return $data;