Nexeed

Web Portal

    • Developer documentation
      • Concepts
        • General
        • Navigation
        • Dashboard
        • Cross-module communication
        • Documents
        • Security
        • Limitations
      • How to…​
        • register your module & views
        • implement context contribution
        • develop a Web Portal-compatible frontend
        • use the iframe integration library
        • build widgets
        • check the integration status
        • develop from localhost
        • improve UI performance
      • Troubleshooting
    • API documentation
    • Glossary
Web Portal
  • Industrial Application System
  • Core Services
    • Block Management
    • Deviation Processor
    • ID Builder
    • Multitenant Access Control
    • Notification Service
    • Reporting Management
    • Ticket Management
    • Web Portal
  • Shopfloor Management
    • Andon Live
    • Global Production Overview
    • KPI Reporting
    • Operational Routines
    • Shift Book
    • Shopfloor Management Administration
  • Product & Quality
    • Product Setup Management
    • Part Traceability
    • Process Quality
    • Setup Specs
  • Execution
    • Line Control
    • Material Management
    • Order Management
    • Packaging Control
    • Rework Control
  • Intralogistics
    • AGV Control Center
    • Stock Management
    • Transport Management
  • Machine & Equipment
    • Condition Monitoring
    • Device Portal
    • Maintenance Management
    • Tool Management
  • Enterprise & Shopfloor Integration
    • Archiving Bridge
    • Data Publisher
    • Direct Data Link
    • Engineering UI
    • ERP Connectivity
    • Gateway
    • Information Router
    • Master Data Management
    • Orchestrator
Nexeed Learning Portal
  • Web Portal
  • Developer documentation
  • How to…​
  • use the iframe integration library
✎

How to use the iframe integration library

Web Portal provides front-end APIs to manage navigation events, receive user information, send notifications and more. A comprehensive documentation is available to provide details on how these APIs work in conjunction with the iframe integration library.

Iframe integration library

The API is accessible through the plain JavaScript NPM library @bci-portal/iframe-integration. While, all communication goes through the browser’s postMessage API and could be implemented manually, it is mandatory to use the iframe-integration library (IIL). This library handles correct initialization and ensures secure communication between the two parties.

The library’s major and minor version is aligned with the Web Portal version.

Installation

The library is currently only accessible to Bosch Developers. Efforts are underway to make it available in a more widely accessible manner, along with the appropriate licensing.

@bci-portal/iframe-integration is available in Bosch Cloud Artifactory.

Add library with yarn/npm

# Yarn
yarn add @bci-portal/iframe-integration

# NPM
npm install @bci-portal/iframe-integration

Initialization

During the initial start-up of your application, Web Portal or the view with an embedded view, will communicate the way a view will be using the postMessage API during an initial handshake between them.

Example for an Angular AppModule

// providers
{
  provide: APP_INITIALIZER,
  useFactory: IFrameLibraryInitFactory.initialize,
  deps: [Location],
  multi: true,
},

// the factory
export class IFrameLibraryInitFactory {
  public static initialize(location: Location): () => Promise<void> {
    return async (): Promise<void> => {
      await IframeIntegrationLibrary.init();

      if (IframeIntegrationLibrary.isFeatureAvailable('urlChange')) {
        location.onUrlChange(() => IframeIntegrationLibrary.urlChange());
      }
    };
  }
}

Example for static HTML or server side rendered sites, simply call urlChange() on startup and whenever JavaScript is altering the URL or history.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Some static site</title>
  </head>

  <body>
    <!-- your content -->
    <script src="iframe-integration/index.bundle.js"></script>
    <script>
      await iframeIntegration.IframeIntegrationLibrary.init();
      iframeIntegration.urlChange();
    </script>
  </body>
</html>

URL updates

The URL in the iframe typically changes frequently, such as when the user navigates within the module or updates filter states in the URL. Due to the iframe sandbox, Web Portal is unable to read the current URL of the iframe and must be informed by the module. This allows Web Portal to update the side navigation, header title, and its own URL. If Web Portal is not informed about the current URL, it may become out of sync with the content area, and deep-linking will not function properly.

To inform Web Portal about the current URL, utilize the IframeIntegrationLibrary.urlChange() function for all navigation events inside the module.
Simply call the function as demonstrated in the examples above, and it will handle the rest of the process.

Usage of Functionality

This code block demonstrates how to use the iframe-integration library in a TypeScript project, calling one of the provided functions.

Example for TypeScript

import { IframeIntegrationLibrary } from '@bci-portal/iframe-integration'; // import the view module

IframeIntegrationLibrary.showMessage('My Title', 'success', 'My Description'); // display a toast banner, using the common API

Functionalities

Starting with version 5.10, Web Portal performs a handshake with the application during iframe initialization to inform it about the host it will communicate with and how the view is currently being displayed within the application.

This enables the use of a common API called IframeIntegrationLibrary. This new common API allows developers to be informed of how and where their view is being used, and which features are currently available. Below is a list of functionalities, their descriptions, where they are available, and code examples.

Table 1. UI API functionalities
Function + Description Available for Example

init

Sets up the view so that it can be made aware of how it is being used, and is used to establish a trusted connection with Web Portal. In addition, iframe ping message communication will be started between the module’s active iframe view and the portal frame, and the portal frame will attempt to reload the iframe view if it enters an unresponsive state based on the UnresponsiveViewReloadTimeoutInSeconds (optional field) set by the module as part of the module views registration

name usage

onBreadcrumbClick

This function is used to react to the clicks that users can make on Web Portal’s breadcrumbs. The ID of the clicked item is passed to this callback so that you may react accordingly.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const callBackFns = {
  onBreadcrumbClick: (id) => {
    console.log(id); // prints the id of the breadcrumb element the user clicked on
  }
};

IframeIntegrationLibrary.init(callBackFns).then(() => {
    console.log(IframeIntegrationLibrary.getMode()); // prints mode it got from Web Portal
});

initWidget

Set up a widget with or without settings

Parameter Description Required

callbackFns

Callback functions that will be used to handle events from Web Portal

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { WidgetInitResult, IframeIntegrationLibrary } from '@bci-portal/iframe-integration';


async ngOnInit(): Promise<void> {
    const settings: WidgetInitResult<BaseStaticSettings> = await IframeIntegrationLibrary.initWidget<BaseStaticSettings>();
    console.log(settings.staticSettings);
}


async ngOnInit(): Promise<void> {
    const settings: WidgetInitResult<BaseStaticSettings, ExampleWidgetSettings> = await IframeIntegrationLibrary.initWidget<BaseStaticSettings, ExampleWidgetSettings>({
        onConfigChanged: (userSettings) => {
            console.log(userSettings);
        },
        onFilterChanged: () => {},
    });
    console.log(settings.staticSettings);
    console.log(settings.userSettings);
}

initWidgetSettings

This function is used to set up a widget settings instance, including what is returned when widget settings are queried about setting state. It should be implemented when a widget requires more than the default settings, such as width and height.

Parameter Description Required

callbackFns

Callback functions that will be used to handle events from Web Portal

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { WidgetConfiguration, IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

async ngOnInit(): Promise<void> {
    const settings: WidgetConfiguration<BaseStaticSettings, ExampleWidgetSettings> = await IframeIntegrationLibrary.initWidgetSettings<BaseStaticSettings, ExampleWidgetSettings>({
        onGetWidgetConfigRequest: () => //return form data here,
    });
    console.log(settings.userSettings);
    console.log(settings.staticSettings);
}

getMode

This function returns the mode in which the module view is currently being used. Depending on the mode, different features are available (see the "Available for" column of this documentation or use 'isFeatureAvailable' of the iframe integration library).

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const currentMode = IframeIntegrationLibrary.getMode();
console.log(currentMode); // depending where it is being used, view, embedded-view, dialog, widget, widget-settings

isFeatureAvailable

Returns a boolean value, indicating if a feature from IframeIntegrationLibrary is available or not.

Parameter Description Required

feature

The feature to check for availability

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const isEmbedViewAvailable = IframeIntegrationLibrary.isFeatureAvailable('embedView');
console.log(isEmbedViewAvailable); // true if mode === view, else false

setBreadcrumbs

Inform portal about the current breadcrumbs that should be present in the header of portal. Web Portal will maintain its own breadcrumbs, a module is able to extend it with its own. The full history of the breadcrumbs should always be provided in terms of the module, as they will overwrite what is presented in the portal. If an empty list is given, the breadcrumbs will be reset to the state that is within the portal, and the module’s breadcrumbs will be removed.

Parameter Description Required

label

Label that will be used within the portal header

id

ID that will be used for callback identifier when a user clicks on the breadcrumb. A listener must be set during the init of the iframeintegrationlibrary to fully utilize this function.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary, Breadcrumb } from '@bci-portal/iframe-integration';

const breadcrumbs: Breadcrumb[] = [
    {
      label: 'Page',
      id: '123',
    },
    {
      label: 'Sub Page',
      id: '456',
    }
  ];

const breadcrumbData = { breadcrumbs };
IframeIntegrationLibrary.setBreadcrumbs(breadcrumbData);

getUserSettings

Return a user setting value defined by any module. Asynchronously returned as a promise, so that caching mechanisms are transparent for the SCS UIs.

Parameter Description Required

key

Provided keys:

  • bci.system.language

  • bci.system.timezone

  • bci.system.timeformat

  • bci.system.timeformatiso

  • bci.system.dateformat

  • bci.system.dateformatiso

  • bci.system.autologouttime

  • bci.system.firstdayofweek

  • bci.system.timezoneoffset

  • bci.dashboard.recentSearches

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.getUserSettings('bci.system.dateformatiso').then((userSetting) =>
  console.log(userSetting);
);

getCookieSettings

Return the cookie settings that the user has chosen in the cookie dialog.

User settings and other data that is not technically necessary are only to be stored to local storage/cookie if the comfort cookie setting is set to true!

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary, CookieSettings } from '@bci-portal/iframe-integration';

const cookieSettings: CookieSettings = await IframeIntegrationLibrary.getCookieSettings();
console.log(cookieSettings);
Example Cookie Settings
{
  marketing: true,
  comfort: false, // Deprecated: Same value as convenience.
  convenience: false,
  analysis: true
}

getCookieSettings$

Returns an observable that one can observe to be informed about cookie settings changes.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.getCookieSettings$().subscribe((cookieSettings) => {
          console.log('privacy settings changed: ' + cookieSettings);
        });

showMessage

Emit a message to the user e.g. if a update was successful or new data was received.

Parameter Description Required

eventClass

One of

  • info

  • success

  • warning

  • error

Determines the icon to be displayed in the toast

title

The Message to be displayed in the toast

description

An additional text to be displayed in the message history. Should typically help the user to solve their error if an action failed. See also https://brandguide.bosch.com/document/118#/writing/capitalization

link

Currently not implemented. An additional link to a view that produced the error or the warning

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.showMessage('Ticket created successfully', 'success', 'description');

showBanner

Displays a banner with the passed text and returns a banner id.

Parameter Description Required

bannerClass

text

Banner text message

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const bannerId = await IframeIntegrationLibrary.showBanner('Banner Message', 'info');

hideBanner

Hides a banner which is shown previously with showBanner function.

Parameter Description Required

bannerId

Id of the banner to hide

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.hideBanner(bannerId);

getContextContribution

The context concept can be used to show data contributed by other modules for a given context.

Parameter Description Required

type

Supported types are

  • DATA

  • LINK

  • ACTION

  • DIALOG_VIEW

  • EMBEDDED_VIEW

name

Unique identifier for context.

version

Version of context’s specification.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import { IframeIntegrationLibrary, Context } from '@bci-portal/iframe-integration';

const contextContributions: Context[] = await IframeIntegrationLibrary.getContextContribution('DATA', 'NEXEED_MDM_FACILITY_BASED_KPI', '1.0');

getDataForContextContribution

The context contribution data can be used by modules (context consumers) to get the data from the context contributor.

The default timeout to try and get context contribution data is set to 3s and Web Portal will reject the promise if it didn’t receive the data by this time.

The caller of the method has to handle the reject scenario as well.

Parameter Description Required

contributionId

Unique id of the contribution. You can get the contributionId with getContextContribution

urlSelector

Key of the url

placeholderParams

Key-value pair of placeholder name and its value

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const placeholderParams: Record<string, string> = { 'facilityId': '9434ebcd-c740-4376-962d-5556896e68b1' };
const data: any = await IframeIntegrationLibrary.getDataForContextContribution('8de4a4ed-0e45-4315-94b1-9fbc1f6e60b1','meta', placeholderParams);

Note: the data returned depends on the context contributor

getDataForContextContributionResponseFromIframe

The ContextContributionDataResponseFromIframe can be used by modules (context contributors) to give the data back to Web Portal

Parameter Description Required

callbackId

callbackid is set in iframe src by Web Portal. While responding back with data to Web Portal, this callback id needs to be sent back to correlate request and response

responseData

Data depends on the contributor

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library usage for metadata response
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

let data = {
  callbackId: '12335',
   responseData: {
     label: "string",
     description: "string"
   }
};
IframeIntegrationLibrary.getDataForContextContributionResponseFromIframe(data);

showContextMenu

Displays a context menu next to a certain html element. The context menu will contain links to all SCS views that provide actions for the given context.

Parameter Description Required

htmlElement

The HTML element next to which the context menu should be displayed

context

a known SCS Linking Context

contextParams

a list of parameters necessary for the SCS Linking Context

Configuring the SCS views from a consumer side, see

  • How to implement context contributions

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const htmlElement = document.querySelector('button');

IframeIntegrationLibrary.showContextMenu(htmlElement , 'device', { deviceId: '42' });

isContextMenuEmpty

Returns true when no actions are registered for the given context and the context menu would be empty.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

const isMenuEmptyForContextDevice = await IframeIntegrationLibrary.isContextMenuEmpty( 'device');

enableBrowserFullscreen

Enable Browser fullscreen. Returns status of operation (successful or not). It is the only way to trigger browser fullscreen as allowfullscreen attribute is not set on IFrame.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.enableBrowserFullscreen();

disableBrowserFullscreen

Disable Browser fullscreen and returns status of operation (successful or not).

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.disableBrowserFullscreen();

isBrowserFullscreenEnabled

Returns if browser is in fullscreen mode or not.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.isBrowserFullscreenEnabled().then((isFullscreen) => {
          console.log('isBrowserFullscreenEnabled: ' + isFullscreen);
        });

isBrowserFullscreenEnabled$

Returns an observable that one can observe to be informed about browser fullscreen enabled changes.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.isBrowserFullscreenEnabled$().subscribe((enabled) => {
          console.log('isBrowserFullscreenEnabled: ' + enabled);
        });

enablePortalFullscreen

Enables Web Portal fullscreen and returns the status of operation (successful or not).

Web Portal fullscreen is a maximized mode, where Web Portal hides the navigation sidebar, the header and the footer. The supergraphic stays visible on top.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.enablePortalFullscreen();

disablePortalFullscreen

Disables Web Portal fullscreen and returns status of operation (successful or not).

Web Portal fullscreen is a maximized mode, where Web Portal hides the navigation sidebar, the header and the footer. The supergraphic stays visible on top.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.disablePortalFullscreen();

isPortalFullscreenEnabled

Returns if Web Portal is in fullscreen mode or not.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.isPortalFullscreenEnabled().then((isFullscreen) => {
          console.log('isPortalFullscreenEnabled: ' + isFullscreen);
        });

isPortalFullscreenEnabled$

Returns an observable that one can observe to be informed about portal fullscreen enabled changes.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.isPortalFullscreenEnabled$().subscribe((enabled) => {
          console.log('isPortalFullscreenEnabled: ' + enabled);
        });

getDashboardWidgetsMetaData

Returns available widget metadata to modules which integrate via Iframe

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary, WidgetMetaData } from '@bci-portal/iframe-integration';

const widgetMetaData: WidgetMetaData[] = await IframeIntegrationLibrary.getDashboardWidgetsMetaData();

Example Widget Meta Data

[
    {
    "id": "52bd60c3-e8ea-4111-bd4a-18f76fc809a8",
    "catalog": {
      "title": "Markdown IFrame Widget",
      "description": "Markdown iframe widget",
      "categoryId": "cat_others",
      "imageUrl": "/portal-enigma/assets/img/preview-markdown.png"
    },
    "widgetType": "IFrame",
    "configuration": {
      "availableWidths": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
      "availableHeights": [1, 2, 3, 4, 5, 6, 7]
    },
    "settings": {
      "widgetUrl": "/iframe-widget/#/widgets/noteswidget?isWidget=true&&tenantId=##tenantId##",
      "widgetConfigUrl": "/iframe-widget/#/widgets/noteswidgetsettings?isWidget=true"
    }
  },
  {
    "id": "99bd60c3-e8ea-4111-bd4a-18f76fc809a8",
    "catalog": {
      "title": "test IFrame Widget",
      "description": "test iframe widget",
      "categoryId": "cat_others",
      "imageUrl": "/portal-enigma/assets/img/preview-markdown.png"
    },
    "widgetType": "iframe",
    "configuration": {
      "availableWidths": [3, 6, 9, 12],
      "availableHeights": [2, 4, 6]
    },
    "settings": {
      "widgetUrl": "/portal-enigma/assets/mocks/iframe-test.html?tenantId=##tenantId##",
      "widgetConfigUrl": "/portal-enigma/assets/mocks/iframe-test.html?tenantId=##tenantId##"
    }
  }
]

embedView

Show an iframe view from another module

Parameter Description Required

context

an embedded view context which should be shown

iframe

an iframe element that will be populated with the provided context

params

a key value pair object that is used to fill placeholders in the iframe url.

How placeholders are treated

Placeholder in the path

Such placeholders are considered mandatory and if not provided Web Portal will simply do nothing.

const pathValue = '/##deviceId##/process/chart';
const contextParams = {};
const replaceResult = '/##deviceId##/process/chart';

Placeholder in the query parameters

Such placeholders are considered optional and if not provided are removed from the URL.

const pathValue = '/ticket?priority=##priority##&severity=##severity##';
const contextParams = { severity: 'medium' };
const replaceResult = '/ticket?severity=medium';

Values for not existing placeholders

Web Portal ignores all values that are provided and no placeholder is present.

const pathValue = '/##deviceId##/process/chart';
const contextParams = { toolId: 1234};
const replaceResult = '/##deviceId##/process/chart';

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary, Context } from '@bci-portal/iframe-integration';

const contexts: Context[] =  await IframeIntegrationLibrary.getContextContribution("EMBEDDED_VIEW", "<name of context>", "<context version>");

const htmlElement = document.querySelector('iframe');
IframeIntegrationLibrary.embedView(contexts[0], htmlElement, { key: "value" });

listenToEmbeddedView

Listen for events from an embedded view that is loaded into the page.

Parameter Description Required

parentWindow

reference to the window object of the page the embedded view is hosted in

embeddedViewIframe

an iframe element reference to the embedded view which events will be listened to

customEventHandler

optional event handler that will be used to handle events that are custom to the embedded view (events not specified in embeddedView table)

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

customEventHandler = (messageEvent) => {
    const eventName = messageEvent.data.name;
    switch(eventName) {
        case "someEventName": {
            console.log(messageEvent.data);
            break;
        }
        default: {
            console.error('unsupported event from embedded view');
        }
    }
}

const htmlElement = document.querySelector('iframe');
const embeddedViewListener =  IframeIntegrationLibrary.listenToEmbeddedView(this.window,  htmlElement, customEventHandler.bind(this));

embeddedViewListener.unsubscribe() // stop listening to events from embedded view

sendEventToEmbeddedView

Send an event to the embedded view, optionally data can be included

Parameter Description Required

embeddedViewIframe

embedded iframe element to send the event to

name

name of the event

value

a key value pair object that will be sent to the embedded view

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.sendEventToEmbeddedView(iframe, 'dataFromHost', { key: 'value' });
IframeIntegrationLibrary.sendEventToEmbeddedView(iframe, 'dataFromHost');

requestBrowseToLink

Request Web Portal to navigate to given contribution of type link by its id

Parameter Description Required

linkId

contribution id of the link contribution to navigate to

parameters

parameters to be passed into the path of the link contribution

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary, Context } from '@bci-portal/iframe-integration';

const contexts: Context[] = await IframeIntegrationLibrary.getContextContribution('LINK', 'NEXEED_REPORTING_MANAGEMENT_REPORT_LINK', '1.0');

const context = contexts[0];
const parameterMap: Record<string, string> = {
  prop: 'Some parameter'
};

IframeIntegrationLibrary.requestBrowseToLink(context.contributionId, parameterMap);
});

informHostViewWithCallback

Used to send a custom event where you expect a reply from the host view

Parameter Description Required

name

name of the event

data

object of data to send

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

id = 'someid';
const dataToHostView: Record<string, unknown> = {
  id: this.id,
 };

IframeIntegrationLibrary.informHostViewWithCallback('embeddedviewevent', dataToHostView).then((data) => console.log(data));

informHostView

Used to send a custom event from an embedded view to its host view.

Parameter Description Required

name

name of the event

data

object of data to send

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

id = 'someid';

const dataToHostView: Record<string, unknown> = {
  id: this.id,
 };

IframeIntegrationLibrary.informHostView('embeddedviewevent', dataToHostView);

showViewInDialog

Requests Web Portal to show a specific view in a dialog. showViewInDialog returns a promise that is fulfilled with data provided by the view when the dialog is closed. See closeDialog for an example on how to pass data to the dialog opener.

Parameter Description Required

context

A context of type 'DIALOG_VIEW' containing the url of the view to show.

dialogTitle

A title for the dialog to show

viewParams

A key value pair object that is used to fill placeholders in the view url.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary, Context } from '@bci-portal/iframe-integration';

const contexts: Context[] = await IframeIntegrationLibrary.getContextContribution('DIALOG_VIEW', 'VIEW1', '1.0');

const context = contexts[0] as ContextDialogViewWithContribution;
const viewParams: Record<string, string> = {
  key: 'value',
};

const data: DialogData | null = await IframeIntegrationLibrary.showViewInDialog(context , 'Title', viewParams);
console.log(dialogData);

closeDialog

Requests Web Portal to close the dialog where this view is at the moment shown in.

Parameter Description Required

data

Some data that should be passed to the opener of the dialog

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.closeDialog({ key: 'value' });

setNavigationMenuState

Requests Web Portal to open or close the Side Navigation.

Parameter Description Required

openMenu

Boolean to open or close the Side Navigation

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.setNavigationMenuState(false);

navigationRequest$

Returns an observable that one can observe to be informed about portal navigation requests. "explicitLeaveEventing" for the view needs to be enabled.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.navigationRequest$().subscribe(() => {
   console.log('navigationRequest$'); // send back IframeIntegrationLibrary.performNavigation() or IframeIntegrationLibrary.cancelNavigation()
});

performNavigation

Used to inform portal to perform the planned navigation. This is a response to a navigationRequest$.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.navigationRequest$().subscribe(() => {
    if (this.hasUnsavedChanges()) {
        // maybe ask the user with a dialog if he really wants to leave or cancel
        IframeIntegrationLibrary.cancelNavigation();
    } else {
        IframeIntegrationLibrary.performNavigation();
    }
});

cancelNavigation

Used to inform portal to cancel the planned navigation. This is a response to a navigationRequest$.

View
EmbeddedView
Dialog View
Widget
WidgetSettings
ContextContribution

Iframe Integration Library
import {  IframeIntegrationLibrary } from '@bci-portal/iframe-integration';

IframeIntegrationLibrary.navigationRequest$().subscribe(() => {
    if (this.hasUnsavedChanges()) {
        // maybe ask the user with a dialog if he really wants to leave or cancel
        IframeIntegrationLibrary.cancelNavigation();
    } else {
        IframeIntegrationLibrary.performNavigation();
    }
});

Contents

© Robert Bosch Manufacturing Solutions GmbH 2023-2025, all rights reserved

Changelog Corporate information Legal notice Data protection notice Third party licenses