Fixed status of staticgraph in metaconsole

Former-commit-id: cf0b32c2c7cafaca8f4463d46d67c25c7a81fdc2
This commit is contained in:
Daniel Maya 2019-04-23 10:54:43 +02:00
parent d6bd44d1c0
commit 404fb19e35
1 changed files with 19 additions and 19 deletions

View File

@ -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;