webui: Added auto width and height dimensions parameters to generic image dashboard widget (#8314)

Added the ability to substituted special parameters for width and height of the Generic-image widget to be added to an Image URL.
This commit is contained in:
BlackDex
2018-03-01 23:12:46 +01:00
committed by Neil Lathwood
parent 9459eeb55f
commit 5af51fa46f
2 changed files with 15 additions and 0 deletions

View File

@@ -67,3 +67,12 @@ In the dashboard, you want to create an interface graph select the widget called
* Note: you can map the port by description or the alias or by port id. You will need to know this in order to map the port to the graph.
![port-bits-graph](/img/port-bits-port.png)
### Dimension parameter replacement for Generic-image widget
When using the Generic-image widget you can provide the width and height of the widget with your request.
This will ensure that the image will fit nicely with the dimensions if the Generic-image widget.
You can add @AUTO_HEIGHT@ and @AUTO_WIDTH@ to the Image URL as parameters.
Examples:
+ http://librenms.example.com/graph.php?id=333%2C444&type=multiport_bits_separate&legend=no&absolute=1&from=-14200&width=@AUTO_WIDTH@&height=@AUTO_HEIGHT@
+ http://example.com/myimage.php?size=@AUTO_WIDTH@x@AUTO_HEIGHT@

View File

@@ -57,6 +57,12 @@ if (defined('SHOW_SETTINGS') || empty($widget_settings)) {
</form>';
} else {
$widget_settings['title'] = $widget_settings['image_title'];
if (strstr($widget_settings['image_url'], '@AUTO_HEIGHT@')) {
$widget_settings['image_url'] = str_replace('@AUTO_HEIGHT@', $widget_dimensions['y'], $widget_settings['image_url']);
}
if (strstr($widget_settings['image_url'], '@AUTO_WIDTH@')) {
$widget_settings['image_url'] = str_replace('@AUTO_WIDTH@', $widget_dimensions['x'], $widget_settings['image_url']);
}
if (strstr($widget_settings['image_url'], '?')) {
$widget_settings['image_url'] .= "&".mt_rand();
} else {