Skip to content

Instantly share code, notes, and snippets.

@aidanlister
Created September 13, 2020 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aidanlister/9faa1036a87338fd81deb710828b1a8d to your computer and use it in GitHub Desktop.
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
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