Embedding Core Intelligence Aviator
Overview
This document provides a detailed guide for embedding a React application within another application by using a custom web component. By defining a custom HTML element, such as <intelligence-aviator>, you can encapsulate the React application, making it easier to integrate and reuse across different platforms and frameworks. This approach separates the React application from the host environment, ensuring better modularity and simplifying integration.
Custom element definition
The custom element named "IntelligenceAviator" is implemented with the following code:
import ReactDOM from "react-dom";
import EmbedEntry from "./components/entry/EmbedEntry";
class IntelligenceAviator extends HTMLElement {
connectedCallBack() {
const mountPoint = document.createElement("div");
ReactDOM(<EmbedEntry/>, mountPoint);
}
}
customElements.define("intelligence-aviator", IntelligenceAviator);
<EmbedEntry/>is the entry point to the Aviator application, and it renders into themountPointelement.<intelligence-aviator>is the custom HTML tag that renders the Aviator UI.
Using custom element
- Add the script that defines the
IntelligenceAviatorcustom element in the host application through ascripttag.
Link to Aviator JSAPI<script src="https://mbir-cia-app-mbir.dev.ca.opentext.com/aviator/jsapi"></script> - Add the custom element to the host application's HTML. This can be done in two ways, with
botIdparameter and withoutbotIdparameter. Following are the examples:
WithbotId
Without<intelligence-aviator token={token} host={"https://mbir-cia-app-mbir.dev.ca.opentext.com"} botId={"400920000100"} enableExploreData={"true"} enablePinning={"true"} > </intelligence-aviator>botId
The parameters required are:<intelligence-aviator token={token} host={"https://mbir-cia-app-mbir.dev.ca.opentext.com"} enableExploreData={"true"} enablePinning={"true"} > </intelligence-aviator>Parameter Required Description tokenMandatory A valid OTDS token to access Aviator. hostMandatory The host URL where aviator is deployed. botIdOptional If botId is provided, the selection page is not displayed. enableExploreDataOptional Enables or disables the Explore Data panel. Default is true. enablePinningOptional Enables or disables the Pinned panel. Default is true. - The size of the Aviator container depends on the wrapping parent container. Aviator takes the full width of the container.
Sizing
In this scenario, height and width will be 1000 px and 400 px.<div style="height: 1000px; width: 400px"> <intelligence-aviator token={token} host={"https://mbir-cia-app-mbir.dev.ca.opentext.com"} enableExploreData={"true"} enablePinning={"true"} ></intelligence-aviator> </div>
Screenshots post embedding
Screenshots post embedding
Host application requirements
- The browser must support custom elements (available in all modern browsers).
- Any global styles in the host application can affect the React application. Use CSS scoping or libraries like CSS Modules to isolate styles.
- The OTDS token passed as the token parameter must include the user roles. To include roles in the token, add
otds:rolesto the scope during the OAuth/OIDC authentication flow.