How to implement context contributions
DATA contribution type
To implement context contributions of the DATA type, the provider should handle the form URL to provide data to its own contribution page in Web Portal through iframe messaging concepts.
The context provider can utilize the context iframe page to contribute their context data by sending "ContextContributionDataResponseFromIframe" postMessages.
Here is an example URL format for the context contribution page: https://example.example/{TENANT_ID}/somedatacontribution?param_1={PARAM_1}¶m_n={PARAM_N}&callbackId={CALLBACK_ID}
The above-mentioned URL should be rendered in a temporary iframe created by Web Portal frame in order to access the context data.
The context provider can define query parameters to return the response data. The response context contribution data can be changed based on the input parameter value, depending on the context provider’s decision.
For example, the test module "Portal Enigma" has defined the following query parameters for the response of the context meta-data:
Example meta URL: https://example.example/portal-enigma/somedatacontribution?tenantId=##tenant_id##&contextDataType=Meta&callbackId={CALLBACK_ID}
-
In the above URL, ##tenant_id## will be replaced by Web Portal frame before rendering this URL in the iframe.
-
The CALLBACK_ID will be attached by Web Portal, and the same ID will be used to respond back with the response data section for each request.
-
Here is an example of how to use the iframe integration library to provide meta data from the context iframe page:
Iframe integration library usage to provide meta data from context iframe page
import { getDataForContextContributionResponseFromIframe } from './bci-portal-iframe-integration-context-iframe'; let data = { callbackId: '12335', responseData: { label: "string", description: "string" } }; getDataForContextContributionResponseFromIframe(data);
Module view example to provide meta data from context iframe page
window.parent.postMessage( { name: 'ContextContributionDataResponseFromIframe' value: { callbackId: '113314564', responseData: { label: "string", description: "string" } }, version: 1 }, '*' );
example value url: https://example.example/portal-enigma/somedatacontribution?contextDataType=Meta&facilityIds=##facilityIds##&timeStart=##timeStart=##&timeEnd=##timeEnd##&callbackId={CALLBACK_ID}
-
##facilityIds##, ##timeStart## and ##timeEnd## will be replaced by Web Portal frame before render this url in iframe
-
{CALLBACK_ID} will be attached by Web Portal the same id will respond back with response data section for each request
Below sample value data response can be provided by provider in context iframe page
Iframe integration library usage to provide meta-data from context iframe page
import { getDataForContextContributionResponseFromIframe } from './bci-portal-iframe-integration-context-iframe'; let data = { callbackId: '113314564', responseData: { metadata: { label: "string", format: "string", formatType: "Percent" }, items: [ { deviceTagId: "string", color: "Red", actualValue: 0, targetValue: 0 } ] } }; getDataForContextContributionResponseFromIframe(data);
Module view example to provide meta-data from context iframe page
parent.postMessage( { name: 'ContextContributionDataResponseFromIframe' value: { callbackId: '113314564', responseData: { metadata: { label: "string", format: "string", formatType: "Percent" }, items: [ { deviceTagId: "string", color: "Red", actualValue: 0, targetValue: 0 } ] } }, version: 1 }, '*' );