Skip to content

Commit e7c4c1e

Browse files
committed
1. Add new method to original SDK to return instance of new
SDK. 2. Rename original demo to multi frame demo 3. Rename new demo to single frame demo 4. Change title of message example tp Embed Message API Demo
1 parent 6483368 commit e7c4c1e

File tree

8 files changed

+62
-32
lines changed

8 files changed

+62
-32
lines changed

demo/demo_v1.html renamed to demo/demo_multi_frame.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Looker Embed SDK Demo (V1)</title>
6+
<title>Looker Embed SDK Multi Frame Demo</title>
77
<link href="components.css" rel="stylesheet" />
88
<link href="demo.css" rel="stylesheet" type="text/css" />
9-
<script src="demo_v1.js"></script>
9+
<script src="demo_multi_frame.js"></script>
1010
</head>
1111
<body class="pt-5">
12-
<h1 class="main-heading">Looker Embed SDK Demo Page (V1)</h1>
12+
<h1 class="main-heading">Looker Embed SDK Multi Frame Demo</h1>
1313
<div id="controls" class="flex pt-5 gap-5 px-5">
1414
<div class="flex-auto flex gap-2">
1515
<div class="flex flex-col text-left">
@@ -71,8 +71,8 @@ <h1 class="main-heading">Looker Embed SDK Demo Page (V1)</h1>
7171
</div>
7272
</div>
7373
<div class="flex-auto text-right flex flex-col">
74-
<a href="index.html" class="link">Embed SDK Demo (V2)</a>
75-
<a href="message_example.html" class="link">Window Message Example</a>
74+
<a href="index.html" class="link">Single Frame Demo</a>
75+
<a href="message_example.html" class="link">Embed Message API Demo</a>
7676
</div>
7777
</div>
7878
<div class="embed-container">

demo/demo_v1.ts renamed to demo/demo_multi_frame.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
// IDs for content to demonstrate are configured in demo_config.ts
2828

2929
import type {
30-
LookerEmbedLook,
31-
LookerEmbedDashboard,
32-
LookerEmbedExplore,
3330
SessionStatus,
31+
ILookerConnection,
32+
ILookerEmbedDashboard,
33+
ILookerEmbedExplore,
34+
ILookerEmbedLook,
3435
} from '../src/index'
3536
import { LookerEmbedSDK } from '../src/index'
3637
import type { RuntimeConfig } from './demo_config'
@@ -41,9 +42,9 @@ import {
4142
resetConfiguration,
4243
} from './demo_config'
4344

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
4748

4849
const initializeRunAllButton = () => {
4950
// Add a listener to the "Run All" button and send 'xxxx:run' messages when clicked
@@ -66,7 +67,8 @@ const initializeRunAllButton = () => {
6667
/**
6768
* Set up the dashboard after the SDK connects
6869
*/
69-
const setupDashboard = (dashboard: LookerEmbedDashboard) => {
70+
const setupDashboard = (connection: ILookerConnection) => {
71+
const dashboard = connection.asDashboardConnection()
7072
currentDashboard = dashboard
7173

7274
// 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) => {
101103
/**
102104
* Set up the look after the SDK connects.
103105
*/
104-
const setupLook = (look: LookerEmbedLook) => {
106+
const setupLook = (connection: ILookerConnection) => {
107+
const look = connection.asLookConnection()
105108
currentLook = look
106109

107110
// 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) => {
124127
/**
125128
* Set up the explore after the SDK connects.
126129
*/
127-
const setupExplore = (explore: LookerEmbedExplore) => {
130+
const setupExplore = (connection: ILookerConnection) => {
131+
const explore = connection.asExploreConnection()
128132
currentExplore = explore
129133

130134
// 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) => {
354358
if (runtimeConfig.showDashboard) {
355359
document.querySelector<HTMLDivElement>('#demo-dashboard')!.style.display =
356360
''
357-
LookerEmbedSDK.createDashboardWithId(runtimeConfig.dashboardId)
361+
LookerEmbedSDK.getSDK()
362+
.createDashboardWithId(runtimeConfig.dashboardId)
358363
// When true scrolls the top of the IFRAME into view
359364
.withDialogScroll(runtimeConfig.useDynamicHeights)
360365
// When true updates the IFRAME height to reflect the height of the
@@ -427,7 +432,8 @@ const renderLook = (runtimeConfig: RuntimeConfig) => {
427432
// Create an embedded Look
428433
if (runtimeConfig.showLook) {
429434
document.querySelector<HTMLDivElement>('#demo-look')!.style.display = ''
430-
LookerEmbedSDK.createLookWithId(parseInt(runtimeConfig.lookId, 10))
435+
LookerEmbedSDK.getSDK()
436+
.createLookWithId(parseInt(runtimeConfig.lookId, 10))
431437
// Append to the #look element
432438
.appendTo('#look')
433439
// Listen to messages to display progress
@@ -469,7 +475,8 @@ const renderExplore = (runtimeConfig: RuntimeConfig) => {
469475
// Create an embedded Explore
470476
if (runtimeConfig.showExplore) {
471477
document.querySelector<HTMLDivElement>('#demo-explore')!.style.display = ''
472-
LookerEmbedSDK.createExploreWithId(runtimeConfig.exploreId)
478+
LookerEmbedSDK.getSDK()
479+
.createExploreWithId(runtimeConfig.exploreId)
473480
// Append to the #explore element
474481
.appendTo('#explore')
475482
// Listen to messages to display progress
@@ -510,7 +517,8 @@ const renderExtension = (runtimeConfig: RuntimeConfig) => {
510517
if (runtimeConfig.showExtension) {
511518
document.querySelector<HTMLDivElement>('#demo-extension')!.style.display =
512519
''
513-
LookerEmbedSDK.createExtensionWithId(runtimeConfig.extensionId)
520+
LookerEmbedSDK.getSDK()
521+
.createExtensionWithId(runtimeConfig.extensionId)
514522
// Append to the #extension element
515523
.appendTo('#extension')
516524
.on('session:status', (event: SessionStatus) => {
@@ -542,14 +550,14 @@ const renderExtension = (runtimeConfig: RuntimeConfig) => {
542550
const initializeEmbedSdk = (runtimeConfig: RuntimeConfig) => {
543551
if (runtimeConfig.useCookieless) {
544552
// Use cookieless embed
545-
LookerEmbedSDK.initCookieless(
546-
runtimeConfig.lookerHost,
553+
LookerEmbedSDK.getSDK().initCookieless(
554+
runtimeConfig.getSDK().lookerHost,
547555
'/acquire-embed-session',
548556
'/generate-embed-tokens'
549557
)
550558
} else {
551559
// Use SSO embed
552-
LookerEmbedSDK.init(runtimeConfig.lookerHost, '/auth')
560+
LookerEmbedSDK.getSDK().init(runtimeConfig.lookerHost, '/auth')
553561
}
554562
}
555563

File renamed without changes.

demo/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Looker Embed SDK Demo (V2)</title>
6+
<title>Looker Embed SDK Single Frame Demo</title>
77
<link href="components.css" rel="stylesheet" />
88
<style>
99
#embed-container {
@@ -13,10 +13,10 @@
1313
}
1414
}
1515
</style>
16-
<script src="demo.js"></script>
16+
<script src="demo_single_frame.js"></script>
1717
</head>
1818
<body class="p-5 h-dvh flex flex-col">
19-
<h1 class="main-heading">Looker Embed SDK Demo Page (V2)</h1>
19+
<h1 class="main-heading">Looker Embed SDK Single Frame Demo</h1>
2020
<div id="controls" class="flex pt-5">
2121
<div class="flex-auto flex space-x-5">
2222
<div class="pt-1">
@@ -39,8 +39,8 @@ <h1 class="main-heading">Looker Embed SDK Demo Page (V2)</h1>
3939
</div>
4040
</div>
4141
<div class="flex-auto flex flex-col text-right">
42-
<a href="demo_v1.html" class="link">Embed SDK Demo (V1)</a>
43-
<a href="message_example.html" class="link">Window Message Example</a>
42+
<a href="demo_multi_frame.html" class="link">Multi Frame Demo</a>
43+
<a href="message_example.html" class="link">Embed Message API Demo</a>
4444
</div>
4545
</div>
4646
<div class="tabs-container">

demo/message_example.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Looker Embed Window Message Example</title>
6+
<title>Looker Embed Message API Demo</title>
77
<link href="components.css" rel="stylesheet" />
88
<link href="demo.css" rel="stylesheet" type="text/css" />
99
<script src="message_example.js"></script>
1010
</head>
1111
<body class="pt-5">
12-
<h1 class="main-heading">Looker Embed Window Message Example</h1>
12+
<h1 class="main-heading">Looker Embed Message API Demo</h1>
1313
<div id="controls" class="flex pt-5 gap-5 px-5">
1414
<div class="flex-auto flex flex-col text-left">
1515
<div class="pt-2">
@@ -47,8 +47,8 @@ <h1 class="main-heading">Looker Embed Window Message Example</h1>
4747
</div>
4848
</div>
4949
<div class="flex-auto text-right flex flex-col">
50-
<a href="demo_v1.html" class="link">Embed SDK Demo (V1)</a>
51-
<a href="index.html" class="link">Embed SDK Demo (V2)</a>
50+
<a href="index.html" class="link">Single Frame Demo</a>
51+
<a href="demo_multi_frame.html" class="link">Multi Frame Demo</a>
5252
</div>
5353
</div>
5454
<div class="embed-container">

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import type {
3434
CookielessCallback,
3535
CookielessRequestInit,
3636
} from './types'
37+
import { getSDKFactory } from './v2/LookerEmbedSDKFactory'
3738

3839
export type { LookerEmbedDashboard } from './dashboard_client'
3940
export type { LookerEmbedExplore } from './explore_client'
@@ -210,6 +211,20 @@ export class LookerEmbedSDK {
210211
).withId(id)
211212
}
212213

214+
/**
215+
* Create an instance of the new combined connection Embed SDK. The combined
216+
* connection Embed SDK allows a developer to create a single connection for
217+
* all Looker object types (dashboard, explores, looks, extensions). The
218+
* developer can use the connection to navigate to different object types
219+
* within Looker without having to recreate the IFRAME.
220+
*
221+
* Requires Looker version 25.0 or above.
222+
*/
223+
224+
static getSDK() {
225+
return getSDKFactory().getSDK()
226+
}
227+
213228
/**
214229
* @hidden
215230
*/

tests/v2/LookerEmbedSDKFactory.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
2525
*/
2626

27+
import { LookerEmbedSDK } from '../../src'
2728
import {
2829
getSDKFactory,
2930
LookerEmbedSDKFactory,
@@ -41,4 +42,10 @@ describe('LookerEmbedSDKFactory', () => {
4142
const factory = new LookerEmbedSDKFactory(sdk)
4243
expect(sdk === factory.getSDK()).toBeTruthy()
4344
})
45+
46+
it('returns an instance of the new SDK from the original SDK', () => {
47+
const sdk = LookerEmbedSDK.getSDK()
48+
expect(sdk).toBeDefined()
49+
expect(LookerEmbedSDK.getSDK()).toBe(sdk)
50+
})
4451
})

webpack-devserver.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var webpackConfig = {
1010
mode: 'development',
1111
devtool: 'source-map',
1212
entry: {
13-
demo: './demo/demo.ts',
14-
demo_v1: './demo/demo_v1.ts',
13+
demo_single_frame: './demo/demo_single_frame.ts',
14+
demo_multi_frame: './demo/demo_multi_frame.ts',
1515
message_example: './demo/message_example.ts',
1616
},
1717
output: {

0 commit comments

Comments
 (0)