Skip to main content

system.kanoa.dashboard.updateWidget

Description

Updates a widget

Syntax

updateWidget(attrInfo, userId)

Parameters:
  • attrInfo (dict)
  • userId (int)

  • Returns:
  • widgetId (int)
  • msg (str): error message, None if successful
  • Dictionary

    ParameterTypeRequiredNotes
    widgetIdint
    widgetNamestringThe name of the widget
    widgetDescriptionstringSome information about the widget
    viewPathstringpath to the widget view created in the designer
    viewParamsstringthe view paramters for this widget
    sortOrderint
    enabledbool
    widgetCategoryNamestringName of the widget category to store this widget under

    Code Examples

    # Example usage
    userId = 123
    widgetInfo = {
    "widgetId": 36,
    "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'
    }
    retVal, msg = system.kanoa.dashboard.updateWidget(widgetInfo, userId)
    if msg: system.perspective.sendMessage('showFailerToast', msg)
    else: system.perspective.sendMessage('showSuccessfulToast', 'Widget parameter has been saved')