|
Use the following steps to create a new custom widget for use in your dashboards. If you'd like to add an existing widget, see Add a Widget. The default widget created will be a "Hello, World" widget that will require further programming. Refer to the Widget Library API below.
If you're creating a new dashboard, give it a name. |
|
||||||
|
Enter a name for the widget. For example, MyWidget. |
|
||||||
|
Select a category for the new widget. We recommend Custom for user-created widgets, but any category can be chosen or a new one created. |
|
||||||
Enter a class name. For example, MyWidgetClass. |
|
||||||
|
In the Type drop-down, select from among Unspecified, Composition/Result, Monitor, and Utility. If you're not sure, choose Utility. |
|
||||||
| Optionally, enter a description of the new widget. |
|
||||||
|
The Widget Editor populates the code field with sample code based on the class name provided. |
|
||||||
|
Click OK when you are done. The widget is created and added to the dashboard in the location where Add New Widget was clicked. |
|
||||||
Widget Library API ReferenceCreating a New Custom Widget in SOASTA CloudTest produces a new MyWidget widget that presents the API as a template and is intended for user editing. The template code defines a WidgetLogic() class for SOASTA CloudTest, MyWidget. It then instantiates the class and provides an example use of methods, parameters and arguments. For example, typing MyWidget as a class name will result in the following class: |
|
||||||
|
|
||||||
The Start Method
|
this.getResultIDs() |
returns the active result ID(s), if applicable (null otherwise) |
this.getMonitorIDs() |
returns the active monitor ID(s), if applicable (null otherwise) |
this.saveCustomSettings() |
saves the widget custom settings immediately (useful for persisting user settings/data) |
MyWidget.prototype.start = function()
{
}
this.canvas |
The HTML element into which the widget should add DOM elements |
this.widget |
The Widget Object, which contains:
an associative array (JS object) that contains any user-specified settings for this widget a unique identifer (whole number) for the widget the user-defined color of the widget the user-defined title of the widget the widget's default display name the user-specified custom height of the widget, or -1 if the user has not specified a height. |
destroyThis function, if defined, will be called once if the widget is removed from a dashboard.
MyWidget.prototype.destroy = function()
{
}
getCustomSettingsPanelHTMLThis function, if defined, can return a string of HTML which will be added to the widget's edit panel. This allows the user to specify widget custom settings that can be accessed in the start() method via the "customSettings" field.
MyWidget.prototype.getCustomSettingsPanelHTML = function()
{
}
hideLoadingIndicator()Hides the loading indicator image for the widget.
hidePausePlayButton()Hides a previously-shown pause/play button.
hidePausePlayButton()
isPaused()Returns true if the widget is paused. This function should be called prior to doing any refresh if the widget supports the pause / play button.
isPaused()
isWidgetVisibleReturns true if the widget is visible, false otherwise.
isWidgetVisible()
onChangeResultIDNotification()This is called when the current active result ID changes (either by user selection or by playing a composition)
onWidgetResizeThis function, if defined, will be called when a widget is resized. Usually this function does not need to be defined. You only need to do so if you have special rendering code in your widget that needs the size of the container.
MyWidget.prototype.onWidgetResize = function(newSize)
{
}
setPrintLayoutIf this widget needs to render itself differently for print layout, you can use this function to do so. When the widget is ready to be printed, call the "callbackFunction" that is passed in.
Parameters:
bForPrintingBoolean. True, if the widget should draw for print layout, false, if the widget should draw for normal screen layout.
oLayoutArgContains user-selected layout options:
.paperSize – paper size, such as "Letter", "Legal", "A4", etcetera.orientation – paper orientation, either "portrait" or "landscape"callbackFunctionThe function that must be called after the widget is finished with layout changes.
MyWidget.prototype.setPrintLayout = function(bForPrinting, oLayoutArgs, callbackFunction)
{
callbackFunction();
}
setPaused(bPaused)Sets the widget's pause / play state.
Parameters:
bPausedBoolean. True, if paused; false, for play.
setPaused(bPaused)
showLoadingIndicator()Shows a loading indicator image for the widget.
showLoadingIndicator()
showPausePlayButton()If desired, a widget can call this to show a pause/play button.
showPausePlayButton()
togglePaused()Toggles the widget's pause / play state.
togglePaused()