Dashboard Service (opendash/services/dashboard)
The Dashboard Service allows you to:
- Get a list of all dashboards.
- Switch between dashboards.
- Modify the current dashboard by creating, deleting and editing widgets.
Contents:
Usage
Use the Dashboard Service by injecting opendash/services/dashboard
as an Angular Service. We suggest using $dashboard
as a name for the variable.
Example:
class controller {
static get $inject() { return ['opendash/services/dashboard']; }
constructor($dashboard) {
// ...
}
}
Properties & Methods
$dashboard.dasboards
An array listing all existing dashboards.
$dashboard.changeDashboard(name: String)
Will change the dashboard depending on the given name.
Response
Nothing will happen, if you try to change to the current dashboard.
If a dashboard with the given name exists, the existing dashboard will be loaded, otherwise the dashboard will be created. Either way the browser will do a reload.
$dashboard.deleteCurrentDashboard()
Use this method to delete the current dashboard.
Response
The browser will reload.
$dashboard.addWidget(widget: OpenDashWidget)
Adds a widget to the current dashboard.
Parameter
widget - Object which looks like this:
{
name: 'Widget Name', // Display name of the widget
type: 'widget-type', // Type of the widget
grid: [0,0,0,0], // Height, Width, Y- und X- coordinate. Should not be set.
config: {}, // Config which will be used by the widget.
}
Response
Returns true
if the widget was added to the dashboard, false
if not.
$dashboard.onWidgetResize(callback: Function)
Deprecated - use the opendash/services/event
instead.
$event.on('od-widgets-resize', callback);