This document describes how a dashboard component should be defined and implemented in order to use it for dynamic aggregation of widgets.
A widget is a component that may supply, if needed, methods for publishing and accepting configuration parameters. Each widget should supply a refresh method that is called by the dashboard when the widget is moved or its parent size is manually changed.
The dashboard uses layouts and widgets that are dynamically obtained and allows the creation of a master component. The master component must be able to save its configuration.
A layout is an html file that should be automatically detected. It supplies placeholders to inform where the widgets can be placed. The layouts should behave the same way independent of the screen size.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <div class="layout yui-skin-sam">
<div id="doc3" class="yui-t7">
<div id="bd">
<div class="yui-gc">
<div class="yui-u first">
<div id="p1" class="widgetplaceholder">Row 1 Column 1</div>
</div>
<div class="yui-u">
<div id="p2" class="widgetplaceholder">Row 1 Column 2</div>
</div>
</div>
<div class="yui-g">
<div id="p3" class="widgetplaceholder">Row 2 Column 1</div>
</div>
<div class="yui-gb">
<div class="yui-u first">
<div id="p4" class="widgetplaceholder">Row 3 Column 1</div>
</div>
<div class="yui-u">
<div id="p5" class="widgetplaceholder">Row 3 Column 2</div>
</div>
<div class="yui-u">
<div id="p6" class="widgetplaceholder">Row 3 Column 3</div>
</div>
</div>
</div>
</div>
</div>
|
In the previous example we have a custom layout that has 3 rows: the first row has 2 columns, the second has 1 column and the third has 3 columns. The placeholders are identified by the widgetplaceholder class. Each placeholder has an id that is used when remembering where a widget is located. When the user adds two widgets to the same placeholder they should be place one above the other.
The user should be able to switch between available layouts. The widgets already added will be moved automatically to the placeholder with the same id. If the old placeholder is not present in the new layout, the first available layout will be used.
Each widget should supply the following methods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [
{
"name": "min",
"type": "number",
"text": "Min value",
"defaultValue": 10
},
{
"name": "max",
"type": "number",
"text": "Max value",
"defaultValue": 100
}
]
|
This JSON defines two parameters: min and max, that are numbers and have different default values. The text field is used when generating the configuration view.
configure(options) - configures the widget. The options parameter is a JSON object. e.g.: {“min”: 10, “max”: 100}.
refresh() - refreshes the widget.