system.kanoa.dashboard.addWidget
Description
Creates a new widgetSyntax
addWidget(widgetInfo, userId)Parameters:
Returns:
Dictionary
| Parameter | Type | Required | Notes | 
|---|---|---|---|
| widgetName | string | The name of the widget | |
| widgetDescription | string | Some information about the widget | |
| viewPath | string | path to the widget view created in the designer | |
| viewParams | string | the view paramters for this widget | |
| sortOrder | int | ||
| enabled | bool | ||
| widgetCategoryName | string | Name of the widget category to store this widget under | 
Code Examples
# Example usage
userId = 123
widgetInfo = {
  "widgetName": "Asset Downtime Bar Chart",
  "widgetDescription": "Display Downtime By Asset",
  "enabled": True,
  "sortOrder": None,
  "viewParams": "{"assetPath": None, "downtimeBy": "Interval", "showDowntimeBySelector": True}",
  "viewPath": "kanoa/core/dbp/widgets/analytics/assetDowntimeBarChart",
  "widgetCategoryName": 'Analysis'
}
widgetId, msg = system.kanoa.dashboard.addWidget(widgetInfo, userId)
if msg: system.perspective.sendMessage('showFailerToast', msg)
else: system.perspective.sendMessage('showSuccessfulToast', 'Widget parameter has been saved')