Created
September 13, 2020 00:58
-
-
Save aidanlister/9faa1036a87338fd81deb710828b1a8d to your computer and use it in GitHub Desktop.
A react component for embedding sisense where you have a tenant-per-subdomain multitenancy architecture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from 'react' | |
import PropTypes from 'prop-types' | |
const BI_BASE_URL = 'https://sisense.onuptick.com' | |
const BIDashboard = ({ defaultDashboard, jwt }) => { | |
// This component creates an iframe element setting the initial src to log the user in via a JWT | |
// once that load has finished, the onLoad handler is called (loadDashboard). This then | |
// hands over to the SiSense API to initialise the iframe and complete the embedding. | |
const src = BI_BASE_URL + '/jwt?jwt=' + jwt | |
const iFrameElement = useRef(null) | |
const loadDashboard = () => { | |
const embed = window['sisense.embed'] | |
const SisenseFrame = embed.SisenseFrame | |
const frame = new SisenseFrame({ // eslint-disable-line | |
url: BI_BASE_URL, | |
dashboard: defaultDashboard, | |
settings: { | |
showLeftPane: false, | |
showToolbar: false, | |
showRightPane: false, | |
}, | |
element: iFrameElement.current, | |
}) | |
} | |
return ( | |
<iframe ref={iFrameElement} id="sisense-frame" src={src} className="w-100 h-100" data-jwt="{{ jwt }}" onLoad={loadDashboard} /> | |
) | |
} | |
BIDashboard.propTypes = { | |
defaultDashboard: PropTypes.string, | |
jwt: PropTypes.string, | |
} | |
export default BIDashboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment