diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index 24ac906ebe..0e81faafba 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -156,6 +156,14 @@ final class Group extends Item ) ); + // If the width and height are equal to 0. + // We need to know the width and height of the image. + if ($data['width'] == 0 && $data['height'] == 0) { + $sizeImage = getimagesize($data['statusImageSrc']); + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; + } + return $data; } diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php index 5d9814af64..85b49279f5 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php @@ -116,6 +116,14 @@ final class Icon extends Item \visual_map_get_image_status_element($data) ); + // If the width and height are equal to 0. + // We need to know the width and height of the image. + if ($data['width'] == 0 && $data['height'] == 0) { + $sizeImage = getimagesize($data['imageSrc']); + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; + } + return $data; } 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 8611b14ce9..bf64fa2f98 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php @@ -181,6 +181,14 @@ final class StaticGraph extends Item \visual_map_get_image_status_element($data) ); + // If the width and height are equal to 0. + // We need to know the width and height of the image. + if ($data['width'] == 0 && $data['height'] == 0) { + $sizeImage = getimagesize($data['statusImageSrc']); + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; + } + // Get last value. if (isset($data['show_last_value']) && $data['show_last_value'] !== 2) { $img_style_title = ''; diff --git a/visual_console_client/src/Item.ts b/visual_console_client/src/Item.ts index ee8a191aec..ef6b016b40 100644 --- a/visual_console_client/src/Item.ts +++ b/visual_console_client/src/Item.ts @@ -117,7 +117,7 @@ abstract class VisualConsoleItem { private itemProps: Props; // Reference to the DOM element which will contain the item. public elementRef: HTMLElement; - private readonly labelElementRef: HTMLElement; + public readonly labelElementRef: HTMLElement; // Reference to the DOM element which will contain the view of the item which extends this class. protected readonly childElementRef: HTMLElement; // Event manager for click events. diff --git a/visual_console_client/src/VisualConsole.ts b/visual_console_client/src/VisualConsole.ts index dad7488164..dbdb148e97 100644 --- a/visual_console_client/src/VisualConsole.ts +++ b/visual_console_client/src/VisualConsole.ts @@ -502,9 +502,14 @@ export default class VisualConsole { // Get the items center. const startX = parent.props.x + parent.elementRef.clientWidth / 2; - const startY = parent.props.y + parent.elementRef.clientHeight / 2; + const startY = + parent.props.y + + (parent.elementRef.clientHeight + parent.labelElementRef.clientHeight) / + 2; const endX = child.props.x + child.elementRef.clientWidth / 2; - const endY = child.props.y + child.elementRef.clientHeight / 2; + const endY = + child.props.y + + (child.elementRef.clientHeight + child.labelElementRef.clientHeight) / 2; const line = new Line( linePropsDecoder({