27
27
// IDs for content to demonstrate are configured in demo_config.ts
28
28
29
29
import type {
30
- LookerEmbedLook ,
31
- LookerEmbedDashboard ,
32
- LookerEmbedExplore ,
33
30
SessionStatus ,
31
+ ILookerConnection ,
32
+ ILookerEmbedDashboard ,
33
+ ILookerEmbedExplore ,
34
+ ILookerEmbedLook ,
34
35
} from '../src/index'
35
36
import { LookerEmbedSDK } from '../src/index'
36
37
import type { RuntimeConfig } from './demo_config'
@@ -41,9 +42,9 @@ import {
41
42
resetConfiguration ,
42
43
} from './demo_config'
43
44
44
- let currentDashboard : LookerEmbedDashboard | undefined
45
- let currentLook : LookerEmbedLook | undefined
46
- let currentExplore : LookerEmbedExplore | undefined
45
+ let currentDashboard : ILookerEmbedDashboard | undefined
46
+ let currentLook : ILookerEmbedLook | undefined
47
+ let currentExplore : ILookerEmbedExplore | undefined
47
48
48
49
const initializeRunAllButton = ( ) => {
49
50
// Add a listener to the "Run All" button and send 'xxxx:run' messages when clicked
@@ -66,7 +67,8 @@ const initializeRunAllButton = () => {
66
67
/**
67
68
* Set up the dashboard after the SDK connects
68
69
*/
69
- const setupDashboard = ( dashboard : LookerEmbedDashboard ) => {
70
+ const setupDashboard = ( connection : ILookerConnection ) => {
71
+ const dashboard = connection . asDashboardConnection ( )
70
72
currentDashboard = dashboard
71
73
72
74
// Add a listener to the dashboard's "Run" button and send a 'dashboard:run' message when clicked
@@ -101,7 +103,8 @@ const setupDashboard = (dashboard: LookerEmbedDashboard) => {
101
103
/**
102
104
* Set up the look after the SDK connects.
103
105
*/
104
- const setupLook = ( look : LookerEmbedLook ) => {
106
+ const setupLook = ( connection : ILookerConnection ) => {
107
+ const look = connection . asLookConnection ( )
105
108
currentLook = look
106
109
107
110
// Add a listener to the look's "Run" button and send a 'look:run' message when clicked
@@ -124,7 +127,8 @@ const setupLook = (look: LookerEmbedLook) => {
124
127
/**
125
128
* Set up the explore after the SDK connects.
126
129
*/
127
- const setupExplore = ( explore : LookerEmbedExplore ) => {
130
+ const setupExplore = ( connection : ILookerConnection ) => {
131
+ const explore = connection . asExploreConnection ( )
128
132
currentExplore = explore
129
133
130
134
// Add a listener to the explore's "Run" button and send a 'explore:run' message when clicked
@@ -354,7 +358,8 @@ const renderDashboard = (runtimeConfig: RuntimeConfig) => {
354
358
if ( runtimeConfig . showDashboard ) {
355
359
document . querySelector < HTMLDivElement > ( '#demo-dashboard' ) ! . style . display =
356
360
''
357
- LookerEmbedSDK . createDashboardWithId ( runtimeConfig . dashboardId )
361
+ LookerEmbedSDK . getSDK ( )
362
+ . createDashboardWithId ( runtimeConfig . dashboardId )
358
363
// When true scrolls the top of the IFRAME into view
359
364
. withDialogScroll ( runtimeConfig . useDynamicHeights )
360
365
// When true updates the IFRAME height to reflect the height of the
@@ -427,7 +432,8 @@ const renderLook = (runtimeConfig: RuntimeConfig) => {
427
432
// Create an embedded Look
428
433
if ( runtimeConfig . showLook ) {
429
434
document . querySelector < HTMLDivElement > ( '#demo-look' ) ! . style . display = ''
430
- LookerEmbedSDK . createLookWithId ( parseInt ( runtimeConfig . lookId , 10 ) )
435
+ LookerEmbedSDK . getSDK ( )
436
+ . createLookWithId ( parseInt ( runtimeConfig . lookId , 10 ) )
431
437
// Append to the #look element
432
438
. appendTo ( '#look' )
433
439
// Listen to messages to display progress
@@ -469,7 +475,8 @@ const renderExplore = (runtimeConfig: RuntimeConfig) => {
469
475
// Create an embedded Explore
470
476
if ( runtimeConfig . showExplore ) {
471
477
document . querySelector < HTMLDivElement > ( '#demo-explore' ) ! . style . display = ''
472
- LookerEmbedSDK . createExploreWithId ( runtimeConfig . exploreId )
478
+ LookerEmbedSDK . getSDK ( )
479
+ . createExploreWithId ( runtimeConfig . exploreId )
473
480
// Append to the #explore element
474
481
. appendTo ( '#explore' )
475
482
// Listen to messages to display progress
@@ -510,7 +517,8 @@ const renderExtension = (runtimeConfig: RuntimeConfig) => {
510
517
if ( runtimeConfig . showExtension ) {
511
518
document . querySelector < HTMLDivElement > ( '#demo-extension' ) ! . style . display =
512
519
''
513
- LookerEmbedSDK . createExtensionWithId ( runtimeConfig . extensionId )
520
+ LookerEmbedSDK . getSDK ( )
521
+ . createExtensionWithId ( runtimeConfig . extensionId )
514
522
// Append to the #extension element
515
523
. appendTo ( '#extension' )
516
524
. on ( 'session:status' , ( event : SessionStatus ) => {
@@ -542,14 +550,14 @@ const renderExtension = (runtimeConfig: RuntimeConfig) => {
542
550
const initializeEmbedSdk = ( runtimeConfig : RuntimeConfig ) => {
543
551
if ( runtimeConfig . useCookieless ) {
544
552
// Use cookieless embed
545
- LookerEmbedSDK . initCookieless (
546
- runtimeConfig . lookerHost ,
553
+ LookerEmbedSDK . getSDK ( ) . initCookieless (
554
+ runtimeConfig . getSDK ( ) . lookerHost ,
547
555
'/acquire-embed-session' ,
548
556
'/generate-embed-tokens'
549
557
)
550
558
} else {
551
559
// Use SSO embed
552
- LookerEmbedSDK . init ( runtimeConfig . lookerHost , '/auth' )
560
+ LookerEmbedSDK . getSDK ( ) . init ( runtimeConfig . lookerHost , '/auth' )
553
561
}
554
562
}
555
563
0 commit comments