Using the Inter Panel Blackboard

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Using the Inter Panel Blackboard

Return to chapter overview

s-Dashboard has a simple messaging system, known as the blackboard, for panels to communicate with each other implemented as a blackboard containing JSON messages.

Panels Sending Messages to Blackboard

Two panel types are currently enabled to send messages to the blackboard.

Panel

Preference Field for Blackboard

User Event

Result

Geo > World Events

Event Clicks To

Clicks on event circle

Sends name of event and other information.

Geo > World Events

Region Clicks To

Clicks on region

Sends name of region and other information.

Table

Sent To

Clicks on cell

Sends value of the cell, along with the row and column in the table.

System > Button


Clicks on button

Custom

Each blackboard message includes a property channel containing a string used to control individual panels. If it’s filled in, it’s the channel string that this panel should listen to. Any message posted to the blackboad with a channel property equal to, in this case, “table_selection”, will cause the panel to be refreshed. You can use the other properties of the blackboard message to modify the SELECT statement.

input_preferences

Sample Process

The following steps walk you through using the Inter Panel Blackboard to modify the SELECT statement for a panel.

1.Begin by creating a dashboard with three panels in a horizontal layout frame. See the topic Creating Dashboard Layouts in this guide for more details on setting up layouts.

2.In the leftmost panel, for input select SALES.AGGT0 and for panel type select Table. In the panel preferences, set Maximum Rows to 100. From that panel’s menu, select Reopen Input to re-read the table. You should have 1 column with 20 rows.

3.In the middle panel, for input select SALES.AGGT0 and for panel type select Table. From that panel’s menu, select Reopen Input to re-read the table. You should have several columns and 25 rows.

4.In the rightmost panel, for panel select System > Blackboard. You do not need to select an input for this panel. This will display messages being posted to the blackboard.

5.Change the layout to “Horizontal, leftmost is 10%”.

You should have something that looks like this, except that your blackboard panel will be empty:

sd__blackboard_channel

6.In the single-column panel on the left, set the panel preference Send To to table_selection. Now when you click on cells in the table you should see messages in the blackboard panel.

Modifying a Panel’s Query Template Using a Blackbaord

You can use the Blackboard to change the output for a panel by modifying that panel's query template. In Input Preferences, each s-Dashboard panel has a field with that lets you modify a SELECT query for the panel. By default, the query selects all the columns from the input (the panel also lets you choose whether or not to include ROWTIME). See the topic Customizing the SELECT template for more details on this field.

The SELECT query uses the Underscore.js template function documented at http://documentcloud.github.io/underscore/#template .

You can use <%= … %>  to insert the result of a JavaScript expression and <% … %> to execute arbitrary JavaScript (with the function print() available to add text to the result of the template).  

There are a number of variables available for use in the template, as documented at Customizing the SELECT template.

The base query (an empty template is as follows:

 SELECT <%= selection %> FROM <%= from %>

 

<%= selection %> can contain “ * ”, “ STREAM ROWTIME,* “, or a similar statement given the type of the input and the input preferences, while <%= from %> should contain the fully qualified name of the input stream or table.

In order to make use of a blackboard message, you need to append a WHERE clause to this base query, using the msg variable.  

You incorporate the blackboard message using the variable msg. This variable contains the blackboard message posted to the channel the panel is listening to. In order to make sure you only output the WHERE clause if there is a message from the Blackboard, you also need to include JavaScript along the following lines:

<% if (msg) print('where "N" >= ' + msg.value); %>

 

The resulting clause will be WHERE “N” >= <the value currently selected in the other table>

Go to the Input Preferences for the middle panel (SALES.AGGT1) and paste in the following code as one line:

SELECT <%= selection %> FROM <%= from %> <% if (msg) print('where "N" >= ' + msg.value); %>

 

Set Listen To to table_selection.

input_preferences

Clicking on cells in the left table should now control which rows are shown in the middle panel.

This is a simple mechanism with a lot of possibilities. For more information on how to customize the SELECT statement, please contact support at tech.support@sqlstream.com.