Difference between revisions of "Dynamic Tags in QPR UI"

From Mea Wiki
Jump to navigation Jump to search
Line 47: Line 47:
 
* [[Panel Properties|Panel]] and any presentation object '''Name''' field (Variable tag and the short syntax)
 
* [[Panel Properties|Panel]] and any presentation object '''Name''' field (Variable tag and the short syntax)
 
* ProcessAnalyzer and QPR Suite web service queries in data grid presentation object's Query tab (Variable tag and the short syntax)
 
* ProcessAnalyzer and QPR Suite web service queries in data grid presentation object's Query tab (Variable tag and the short syntax)
 
== Expression tag ==
 
Expression tag is used to calculate an expression (formula) and show its result in place of the tag. It's possible to use context variables as parameters in the expressions. If the expression returns a date or numeric type of data, the data is converted into string using the browsers current locale settings. The expression is calculated again if the context variables used by the expression changes.
 
 
QPR uses Syncfusion Calculate expression language. See all available functions here: https://help.syncfusion.com/js/calculate/supported-formulas/supported-formulas
 
 
Parameters:
 
* '''value''': Expression string to calculate.
 
* '''escape''': Determines which escaping or encoding is applied to the calculation result so that the value is compatible with its context, e.g. inside string literal quotation marks. Available escapings are the same as in the Variable tag.
 
 
Note that the expression language works a bit incorrectly as it returns '''0''' for empty strings, and also string literals are returned enclosed by quotation marks. For example, '''<#expression value="\"abc\"">''' returns '''"abc"''' which is not correct (the result should not contain quotation marks). To workaround the issue, you can use '''concatenate''' function, for example '''<#expression value="concatenate(\"abc\", \"\")">''' (strings returned by functions work correctly).
 
 
Examples:
 
* <#expression value="SQRT([A] * [A] + [B] * [B])">
 
* <#expression value="LEFT(\"limit this string to 17 characters\", 17)">
 
* <#expression value="UPPER(\"show me in upper case\")">
 
* <#expression value="YEAR(NOW())">
 
* <#expression value="EDATE(NOW(), 12)">
 
  
 
== Action tag ==
 
== Action tag ==

Revision as of 14:34, 27 September 2017

QPR supports tags that are defined in this page.

Supported tags

General about dynamic tags

In some UI element textual settings it is possible to use some of the below defined tags to achieve more dynamic behaviour of dashboards.

Evaluating a tag means that

  1. The tag is parsed (detected) from the containing text
  2. Its intended behaviour is executed
  3. The tag definition is replaced by the tag's return value

Tags in textual settings are always evaluated before the setting value is used by the UI element. During the tag evaluation the setting value is treated as text only, although it might be JSON, SVG or CSS.

Tag definition syntax

Tag syntax has the following general form: <#tagname parameter1="value1" parameter2="value2" ... parameterN="valueN">

In more details, tags have the following syntax:

  • Tag starts with <#tagname, where tagname is the name of the tag. There is always a space after the tagName.
  • Tag ends with > character.
  • Tag contains one or many parameters as name-value pairs (parameters are separated by space).
  • Parameter name is followed by = which is followed by parameter value in double-quotes (").
  • If parameter value contains double-quotes they are escaped with \ character, example \". \ character is escaped with \\.
  • Newline characters are not allowed in tags (if a newline character is encountered, the searched text ends)

Tag is assumed if tag start <#tagname (including the space) appears in the text. If the syntax doesn't continue according to the syntax rules, an error is caused. This means that the tag parser needs to know which tags names are available in the parsed content.

Examples of syntaxes that cause tag parsing error:

  • <#variable name="var1"
  • <#variable name="var1"escape="json">
  • <#variable name="var1" escape=json">
  • <#variable name="var1" escape=json>
  • <#variable name="var"1" escape="json">

Examples of syntax that doesn't cause error, because the beginning is not interpreted as a tag (assuming "variable" tags can be used in the parsed content):

  • <variable (hash character missing)
  • <#variables (no space after "variable")

Escaping examples:

  • <#action name="drill\\down\"abc\""> (name parameter contents: drill\down"abc")

Settings where tags can be used

Dynamic tags can be used in following settings:

  • Data Grid presentation object JSON settings field (Variable tag and the short syntax)
  • SVG presentation object SVG code field (Action tag, Variable tag and and the short syntax)
  • Panel and any presentation object Name field (Variable tag and the short syntax)
  • ProcessAnalyzer and QPR Suite web service queries in data grid presentation object's Query tab (Variable tag and the short syntax)

Action tag

Action tag references to a QPR MobileDashboard action. The tag can be used in a javascript code, because the replaced value is a call to a QPR MobileDashboard's internal javascript function which triggers the action. All context variables in the effective context are automatically passed to the triggered action.

Parameters:

  • name: Referenced action identifier. This parameter is mandatory.
  • [action parameters] are name-value pairs of assigned action parameters. (will be supported in future)

An error is caused, if the referenced action is not found.

Examples:

  • Tag <#action name="DrilldownToDetails"> can be embedded into SVG code as follows: <svg onclick="<#action name="DrilldownToDetails">">
  • Action with parameter assignments: <#action name="drilldownToCities" param1="value1" param2="value2">

Tags supported in future

Dataset tag

Dataset tag is used to convert a dataset into a JSON format to be used in a JSON configuration, for example in a chart or datagrid.

Parameters:

  • identifier: Dataset name
  • grouping: When the grouping is defined, JSON is structured in a two level hierarchy described below. Following format is used: [Group column name in dataset];[Group attribute name in JSON];[Inner array attribute name in JSON]. In the hierarchy the outer level contains an object array where the objects have two attributes: the defined "Group attribute name in JSON" and "Inner array attribute name in JSON". "Group attribute name in JSON" contains the group name, and "Group attribute name in JSON" contains an object array where there is data of that single group.
  • [all other parameters]: All other parameters define column mappings from the dataset to the JSON presentation. Parameter name is the column name in the formatted JSON and parameter value is column name in the dataset. If referenced column is not found, an error is returned. All unmapped columns in the dataset are mapped with same names in JSON. Empty value means that if the dataset contains the defined column, it is not mapped.

Examples:

  • <#dataset identifier="scorecards" name="scorecardName" x="" y="revenue" color="statusColor">
  • If there is a dataset with columns A, B and C, and there is a tag <#dataset identifier="datasetname" D="A" B="">, the resulting JSON contains columns D and C. Column A as mapped with the name D, column B is not mapped at all and C as mapped with the same name.
  • Grouping example:

There is the following dataset with identifier MetricsQuery (presented here in CSV format):

Country;Year;Efficiency
India;2015;28
India;2016;25
India;2017;26
Germany;2015;31
Germany;2016;28
Germany;2017;30
England;2015;36
England;2016;32
England;2017;34

With tag <#dataset identifier="MetricsQuery" grouping="Country;name;points" x="Year" y="Efficiency"> the result is as follows:

[
  {
    "points": [{"x": 2015, "y": 28}, {"x": 2016, y: 25}, {"x": 2017, "y": 26}],						 
    "name": "India"
  },						
  {
    "points": [{"x": 2015, "y": 31}, {"x": 2016, "y": 28}, {"x": 2017, "y": 30}],						 
    "name": "Germany"
  },
  {
    "points": [{"x": 2015, "y": 36}, {"x": 2016, "y": 32}, {"x": 2017, "y": 34}],						 
    "name": "England"
  }
]

Translate tag

Translate tag is used to get a translated value for a string from a translation table (translation table is a separate feature). This tag is helpful in building multilingual dashboards. If translation text is not found from the translations table, the original translatable text is returned.

Parameters:

  • text: Text to translate. This parameter is mandatory.
  • context: Defined in which context the translatable text appears. This enables to have different translations for same translatable text. If omitted, empty context is assumed.
  • language: Language name to which translate the text. This parameter is optional, and if omitted, the current UI language is assumed.

Examples:

  • <#translate text="Renenue">
  • <#translate text="Renenue" context="bookkeeping">
  • <#translate text="Renenue" language="FI">

Functions supported in future

Cell function

Cell function is used to retrieve a single cell value from a dataset. It's usually used when there is a query to retreave a single value, such as object name - in that case the returned dataset contains only one row and column.

Parameters:

  1. name: Identifier of the referenced dataset. This parameter is mandatory.
  2. columnName/columnIndex: Referenced column name or index in the dataset. This parameter is optional, and if omitted, the first column of the dataset is referenced. If the provided parameter is string, it means column name; if it's numerical, it means column index.
  3. rowIndex: Referenced row number in the dataset (starting from 1). This parameter is optional and if omitted, the first row is used.

Error is caused if the referenced dataset identifier, columnName, columnIndex or rowIndex is not found.

Examples:

  • <#expression value="cell(\"scorecard\")">
  • <#expression value="cell(\"scorecard\", \"symbol\", 3)">
  • <#expression value="cell(\"scorecard\", 2, 3)">

Info function

Info function is used to access different kinds of user, session and context related information, that may be needed to build the user interface logic. The function has one string valued parameter with following options:

  • sessionId: QPR MobileDashboard session id.
  • meaSessionId: QPR Suite session id (empty if there is no active session to QPR Suite).
  • paSessionId: QPR ProcessAnalyzer session id (empty if there is no active session to QPR ProcessAnalyzer).
  • baseUrl: Beginning part of the QPR MobileDashboard url (until the hash sign). Url is fetched using JavaScript command window.location.href. Example: https://demo.qpr.com/mobiledash/.
  • urlParameters: Parameters of the currently opened QPR MobileDashboard view encoded to a url form, i.e. the effective session context. Example: sys:dashboard=1234&var1=value1&val2=value2.
  • username: User name of the currently logged in user.
  • userFullname: Full name of the currently logged in user.
  • userGroups: Groups of the the currently logged in user as a JSON array. Example: ["group1", "group2", "group3"].
  • userId: QPR MobileDashboard user id. Note that this is not a QPR Suite or QPR ProcessAnalyzer user id.
  • uiLanguage: Language code of the currently active UI language. Available UI language codes: en_US (English), fi_FI (Finnish), ar (Arabic).
  • meaWsUrl: QPR Suite web services url. Example: https://demo.qpr.com/QPR2017-1/Portal/QPR.Isapi.dll/wsforward/MainService.svc/webHttp.
  • paWsUrl: QPR ProcessAnalyzer web services url.
  • version: QPR MobileDashbaord version: Example: 2017.6.1.3402.

Examples:

  • <#expression value="info(\"meaSessionId\")">
  • <#expression value="info(\"baseUrl\" & \"#/dashboard?<#\" & info\"baseUrl\")">