Dashboard Widget

The Dashboard widget in the Backoffice Administration Cockpit is a layout widget serving as a place to put other widgets, mainly some charts with statistics or similar.

Widget Definition

Name

Dashboard

ID

com.hybris.cockpitng.dashboard

Category

Layout

Description

This is a Dashboard Layout available in Backoffice Application

Applied In

backoffice

Based On

Not applicable

Author

SAP

Inputs

Refresh
  • Type: java.lang.Object
  • Multiplicity: Single
  • Description: Items passed in through this socket trigger forward to the refresh socket of the dashboard

Outputs

Refresh
  • Type: java.lang.Object
  • Multiplicity: Single
  • Description: Socket used to inform the child widgets that refresh is required

Forwards

From: refresh To: refresh

Generated Events

Not applicable

Configuration

The Dashboard is a generic container for widgets, nevertheless its main purpose is to show charts and some statistics of the running system. The sample configuration of the Dashboard is presented below.

Widgets

widgets.xml
<widget id="my_dashboard" widgetDefinitionId="com.hybris.cockpitng.dashboard" slotId="some_slot" template="false">
      <widget id="childWidget1" widgetDefinitionId="sample.widgets.id" slotId="dashboardWidgets" template="false">
           <!-- widget's setting -->
      </widget>
      <widget id="childWidget2" widgetDefinitionId="sample.widgets.id" slotId="dashboardWidgets" template="false">
           <!-- widget's setting -->
      </widget>
      <!-- and so on -->
      <widget id="childWidgetN" widgetDefinitionId="sample.widgets.id" slotId="dashboardWidgets" template="false">
           <!-- widget's setting -->
      </widget>
      <virtual-sockets>
         <!-- if the Refresh action is configured to be displayed on the dashboard, you need to expose its output socket-->
         <output id="com.hybris.cockpitng.action.misc.refresh.success" type="java.lang.Object" visibility="external"/>
      </virtual-sockets>
 </widget>

If no additional configuration is provided, all visible child widgets of the Dashboard are displayed to the user. By default, the widgets are presented in a three-column layout and each of the widgets takes exactly one cell of the Dashboard (see the layout preview scheme below). The default layout is also applied in the case when wrong configuration is provided (overlapping widgets or impossible layout - examples further in the document).

Grid

Assuming that you want to configure the layout of the grid, you have to provide a configuration for dashboard component, as in the example below:

cockpit.config.xml
<context component="dashboard">
	<dsb:dashboard defaultGridId="regular">
		<dsb:grid minScreenWidth="0" maxScreenWidth="700" id="small" unassigned="exclude" rowHeight="250">
			<dsb:placement widgetId="childWidget1" height="1" width="1" x="0" y="0"/>
			<dsb:placement widgetId="childWidgetN" height="1" width="1" x="0" y="1"/>
		</dsb:grid>
		<dsb:grid minScreenWidth="701" id="regular" unassigned="append">
			<dsb:placement widgetId="childWidgetN" height="1" width="2" x="0" y="0"/>
			<dsb:placement widgetId="childWidget2" height="1" width="1" x="0" y="1"/>
			<dsb:placement widgetId="childWidget1" height="1" width="1" x="1" y="1"/>
		</dsb:grid>
	</dsb:dashboard>
</context>

The above configuration allows you to define different layouts respective to the browser size. This is very useful for configuring the application for many devices. When a configuration for a size range is applied, it is not re-rendered until re-rendering is forced by a user (refresh), therefore after the initial rendering, media queries may be used to achieve responsive design.

In the configuration of a grid, you may define which of the widgets configured in the widgets.xml file are to be displayed (placement:widgetId). All the unassigned ones would be either visible (grid:unassigned=append - the default configuration) or would not appear at all (grid:unassigned=exclude).

Each of the widgets can be positioned. You are able to define the cell to place the widget in and to define how many rows and columns it should take (the width and height attributes). The dashboard always takes the full width of the slot it resides in, it means that having N columns set, each would have the width of (100 / N)% of available space.

The rowHeight attribute of the Grid defines the width of each of the rows. If undefined, the default value is 500 (expressed in px).

The number of columns of the Dashboard depends on the defined placements of the widgets.

For example:

  • If in one of the rows, there are two widgets placed next to each other and one is of width=2 and the other of width=5, the total width (and also the number of columns) is equal 7.
  • If there are no floating elements (or the unassigned widgets are excluded) and the calculated width is equal 2, the number of the columns is equal 2.
  • If there are unassigned and appended widgets, the width by default is set to 3 when the calculated width is less than 3.

In the case of appending the unassigned elements, they always take the first free slot and have both width and height set to 1.

Limitations

The algorithm used for rendering the widgets of the Dashboard uses div components to create the layout and is based on the divide and conquer strategy. It tries to divide the widgets placed in Dashboard vertically and if this is not possible, it tries to divide them horizontally. The first successful division is implemented and the algorithm is used recursively.

In some cases, neither horizontal nor vertical division is possible, therefore the layout cannot be expressed using div components. The obvious example is when at least two widgets overlap each other. However, even distant and non-overlapping widgets may unintendenly prevent the division algorithm from succeeding, because of the layout's div-based structure. See the example:

Figure: Impossible Division. The blue blocks represent widgets placed in the Dashboard, green lines represent how the algorithm seeks layout division, whereas the red dotted lines show how the algorithm breaks.

Actions

The below snippet shows a sample configuration for Dashboard actions:

cockpit-config.xml

<context component="dashboard-actions" principal="admin">
	<y:actions>
	<y:group qualifier="common">
	<y:label>actiongroup.common</y:label>
	<y:action action-id="com.hybris.cockpitng.action.misc.refresh" property="currentObject"/>      
	</y:group>
	</y:actions>
</context>

Widget Preview

Figure: Sample dashboard with some charts.

Figure: Grid cells positioning used in configuration.

Settings

Setting

Type

Description

actionSlotComponentId

java.lang.String

Defines the component id for actions configuration to be used with the dashboard. Default value: dashboard-actions.

dashboardConfigContext

java.lang.String

Allows for configuring the component used for dashboard configuration fetching. Default value: dashboard.

Widget Slots

slotID

Multiplicity

Type

Slots Composition

cockpitWidgetChildrenInvisible

multi

Not applicable

This is a general-purpose slot available for widgets. The widget placed on this slot is not be displayed in the application view but can be accessed through its socket API.

dashboardWidgets

multi

Not Applicable

All widgets to be displayed on the Dashboard should be placed in this slot.