The reference shows the full usage of the custom widgets for Squirro dashboards. In this reference the command line utility
Table of Contents
On the local disk a Squirro widget is a folder. That folder contains a number of files that all have their purpose.
|CSS||Styling of the widget. This file must exist even when no styles are used for the widget.|
|HTML||Template for the HTML code of the widget. Even if no custom template is used, this file must exist.|
Automatically created file - do not create yourself. These files keep track of the widget metadata.
Managing Widgets (
The Toolbox comes with a command line utility
squirro_widget which is used to manage custom widgets on a Squirro installation.
The full reference of this command can be found in the separate section squirro_widget Command Line Reference.
Custom widgets are implemented as Backbone.js views. Despite this, no prior experience with the Backbone.js framework is required.
The template for a new
widget.js file is as follows:
This example extends from the
Widgets.Text base class. The full list of base classes from which widgets can inherit is documented in Base Widgets.
widget.css file contains Cascading Style Sheet instructions for styling of the dashboard.
Widgets are namespaced by adding a CSS class
name is the widget name. For example the clock widget from the tutorial would receive the CSS class
custom-clock which from CSS can be styled as follows:
Use the namespacing for any styling that is local to the widget.
It is also possible to add global styles (without the namespace). These styles will affect the whole dashboard on which the custom widget is embedded. Note however that the class names, elements, etc. are not guaranteed to remain the same and will change between releases without notice. So if you choose to style global elements of the dashboard, test with every new Squirro release if the styles still work.
The CSS declarations from custom widgets are applied in sequence, by the widgets position in the dashboard (top-left to bottom-right). This can be meaningful when
!important clauses are used, as the latest CSS definition one will override the former.
The HTML file
widget.html is treated as a template file. The underscore.js template method is used for this.
The return value of the
getCustomTemplateParams method is passed in as parameters into the template and its values are accessible in the template as local variables.
As an example take the following method template parameters method in the
With this parameters the following is a valid template HTML file:
This example highlights the three main template features.
Insert the variable contents with escaping.
This escapes any HTML code using the Underline.js escape function.
Insert the variable contents in raw form.
Any HTML code is passed through verbatim.
Only use this for data that's from safe locations. Your default method should be to use