Display currently active workers as a dashboard widget
Introduction
Historically, Cerb displayed a list of currently active workers at the bottom of every workspace page. There was no way to customize, move, copy, or disable this content.
This built-in feature was removed in 9.1.4 in favor of dashboard widgets, which are completely customizable.
In the simplest implementation, the “Who’s Online” widget is just a worker worklist with a filter like:
lastActivity:"-30 minutes" sort:firstName,lastName
The exact style of the original feature can be reproduced with a bot-powered dashboard widget.
We’ve provided a complete example below.
Import the bot package
The following package includes a “Who’s Online” bot with a “Dashboard render widget” behavior.
Follow these instructions to import it.
{
"package": {
"name": "Who's Online Bot",
"revision": 1,
"requires": {
"cerb_version": "9.1.5",
"plugins": [
]
},
"configure": {
"placeholders": [
],
"prompts": [
]
}
},
"bots": [
{
"uid": "bot_whos_online",
"name": "Who's Online Bot",
"owner": {
"context": "cerberusweb.contexts.app",
"id": 0
},
"is_disabled": false,
"params": {
"config": null,
"events": {
"mode": "allow",
"items": [
"event.dashboard.widget.render"
]
},
"actions": {
"mode": "all",
"items": [
]
}
},
"image": null,
"behaviors": [
{
"uid": "behavior_render_widget",
"title": "Render: Currently active workers",
"is_disabled": false,
"is_private": false,
"priority": 50,
"event": {
"key": "event.dashboard.widget.render",
"label": "Dashboard render widget"
},
"nodes": [
{
"type": "action",
"title": "Load currently active workers",
"status": "live",
"params": {
"actions": [
{
"action": "core.bot.action.record.search",
"context": "worker",
"query": "lastActivity:\"-30 minutes\" isDisabled:n sort:firstName,lastName limit:500",
"expand": "",
"object_placeholder": "_workers"
}
]
}
},
{
"type": "action",
"title": "Render",
"status": "live",
"params": {
"actions": [
{
"action": "render_html",
"html": "<div id=\"widget{{widget_id}}ActiveWorkers\">\r\n{% for worker in _workers %}\r\n<span style=\"margin-right:5px;\">\r\n<span style=\"text-decoration:underline;font-weight:bold;cursor:pointer;\" class=\"cerb-peek-trigger\" data-context=\"worker\" data-context-id=\"{{worker.id}}\">{{worker._label}}</span> {% if worker.title %} ({{worker.title}}){% endif %}\r\n</span>\r\n{% endfor %}\r\n</div>\r\n\r\n<script type=\"text/javascript\">\r\n$(function() {\r\n\tvar $div = $('#widget{{widget_id}}ActiveWorkers');\r\n\t$div.find('.cerb-peek-trigger').cerbPeekTrigger();\r\n});\r\n</script>"
}
]
}
}
]
}
]
}
]
}
You should see the following created records:
Create a dashboard widget
You can now display the “Currently active workers” widget on any dashboard.
-
Navigate to an existing dashboard, or create one by adding a tab to an existing workspace page.
-
Click the (+) Add Widget button at the top.
-
Select the Build option at the top.
-
Use the following details:
Field Value Name: Currently Active Workers
Type: Bot Custom Widget Behavior: Render: Currently active workers -
Click the Save Changes button.
You should now see a list of the workers who have been active within the past 30 minutes. Clicking on a worker’s name will open their card.
You can customize the widget’s output by editing the Render: Currently active workers behavior on Who’s Online Bot.