-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleDashboard.jsx
41 lines (35 loc) · 1.21 KB
/
SimpleDashboard.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { LookerEmbedSDK } from '@looker/embed-sdk'
import { useCallback, useState} from 'react'
import { lookerConfig } from '../../lookerConfig'
import React from 'react'
import Loading from '../Loading/Loading';
const EmbedDashboard = () => {
const [dashboardStatus, setDashboardStatus] = useState('Loading...')
const setupDashboard = useCallback((div) => {
if (!div) {
return
}
LookerEmbedSDK.createDashboardWithId(lookerConfig.dashboardId)
.withAllowAttr('fullscreen')
.appendTo(div)
.on('dashboard:loaded', () => setDashboardStatus('Loaded'))
.on('dashboard:run:start', () => setDashboardStatus('Running'))
.on('dashboard:run:complete', () => setDashboardStatus('Done'))
.on('dashboard:edit:start', () => setDashboardStatus('Editing'))
// Give the embedded content a class for styling purposes
.withClassName('looker-embed')
.withTheme('LookerEmbed')
.build()
.connect()
.catch((error) => {
console.error('Connection error', error)
})
}, [])
return (
<>
{dashboardStatus === 'Loading...' && <Loading />}
<div id="dashboard" ref={setupDashboard}></div>
</>
)
}
export default EmbedDashboard