Scripts of Type Widget Visualization

Scripts of the type Widget visualization enable the use of generic widgets on dashboards.

Example use cases for generic widgets are:

Widget visualization scripts can use resources, e.g., images, stylesheets, JavaScript libraries, or other files, which are stored in the file system. Alternatively, the resources can also be retrieved using URLs.

Steps to use a widget visualization script:

  1. Write a script of the type Widget visualization in the Scripts section of the Admin Tool.
  2. Reference the script in the attribute visualizationScript of the widget’s scope in the page customization, see Attributes for Generic Widgets.

Writing the Widget Visualization Script

Widget visualization scripts have to implement two methods:

The methods provide the following parameter:

Example: Display Weather Information

The following example script creates a weather widget using https://weatherwidget.io/.

def render(String pParams) {

return """

<div>

<a class="weatherwidget-io" href="https://forecast7.com/en/40d71n74d01/new-york/" data-label_1="NEW YORK" data-label_2="WEATHER" data-theme="original" >NEW YORK WEATHER</a>

<script>

!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://weatherwidget.io/js/widget.min.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weatherwidget-io-js');

</script><div>

</div>

""" as String

 

}

def resources(String pParams) {

List<String> resources = [

] as String[];

return resources;

}

Code example 78: Script for a generic widget displaying weather data

In the Web Client, the widget is displayed as follows:

Figure 401: ConSol CM Web Client - Generic widget on the Web Client Dashboard