Skip to content

Commit eb3a5c0

Browse files
Amit Shusterali-hamud
authored andcommitted
Merged PR 34725: Prepare iframe for embedding
Prepare iframe for embedding
1 parent 9a4cd71 commit eb3a5c0

File tree

14 files changed

+768
-348
lines changed

14 files changed

+768
-348
lines changed

dist/powerbi-client.d.ts

Lines changed: 92 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! powerbi-client v2.7.5 | (c) 2016 Microsoft Corporation MIT */
1+
/*! powerbi-client v2.9.0 | (c) 2016 Microsoft Corporation MIT */
22
declare module "util" {
33
import { HttpPostMessage } from 'http-post-message';
44
/**
@@ -82,6 +82,20 @@ declare module "util" {
8282
*/
8383
export function isRDLEmbed(embedUrl: string): boolean;
8484
}
85+
declare module "config" {
86+
const config: {
87+
version: string;
88+
type: string;
89+
};
90+
export default config;
91+
}
92+
declare module "defaults" {
93+
import * as models from 'powerbi-models';
94+
export abstract class Defaults {
95+
static defaultSettings: models.ISettings;
96+
static defaultQnaSettings: models.IQnaSettings;
97+
}
98+
}
8599
declare module "embed" {
86100
import * as service from "service";
87101
import * as models from 'powerbi-models';
@@ -96,19 +110,30 @@ declare module "embed" {
96110
}
97111
}
98112
/**
99-
* Base Configuration settings for Power BI embed components
113+
* Prepare configuration for Power BI embed components.
100114
*
101115
* @export
102-
* @interface IEmbedConfigurationBase
116+
* @interface IBootstrapEmbedConfiguration
103117
*/
104-
export interface IEmbedConfigurationBase {
105-
settings?: ISettings;
118+
export interface IBootstrapEmbedConfiguration {
119+
hostname?: string;
106120
embedUrl?: string;
121+
settings?: ISettings;
107122
uniqueId?: string;
108123
type?: string;
124+
groupId?: string;
125+
bootstrapped?: boolean;
126+
}
127+
/**
128+
* Base Configuration settings for Power BI embed components
129+
*
130+
* @export
131+
* @interface IEmbedConfigurationBase
132+
* @extends IBootstrapEmbedConfiguration
133+
*/
134+
export interface IEmbedConfigurationBase extends IBootstrapEmbedConfiguration {
109135
accessToken?: string;
110136
tokenType?: models.TokenType;
111-
groupId?: string;
112137
}
113138
/**
114139
* Configuration settings for Power BI embed components
@@ -173,6 +198,7 @@ declare module "embed" {
173198
static embedUrlAttribute: string;
174199
static nameAttribute: string;
175200
static typeAttribute: string;
201+
static defaultEmbedHostName: string;
176202
static type: string;
177203
static maxFrontLoadTimes: number;
178204
allowedEvents: any[];
@@ -206,6 +232,12 @@ declare module "embed" {
206232
* @type {IEmbedConfigurationBase}
207233
*/
208234
config: IEmbedConfigurationBase;
235+
/**
236+
* Gets or sets the bootstrap configuration for the Power BI embed component received by powerbi.bootstrap().
237+
*
238+
* @type {IBootstrapEmbedConfiguration}
239+
*/
240+
bootstrapConfig: IBootstrapEmbedConfiguration;
209241
/**
210242
* Gets or sets the configuration settings for creating report.
211243
*
@@ -238,7 +270,7 @@ declare module "embed" {
238270
* @param {HTMLElement} element
239271
* @param {IEmbedConfigurationBase} config
240272
*/
241-
constructor(service: service.Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean);
273+
constructor(service: service.Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean, isBootstrap?: boolean);
242274
/**
243275
* Sends createReport configuration data.
244276
*
@@ -355,7 +387,7 @@ declare module "embed" {
355387
* @param {IEmbedConfiguration}
356388
* @returns {void}
357389
*/
358-
populateConfig(config: IEmbedConfigurationBase): void;
390+
populateConfig(config: IBootstrapEmbedConfiguration, isBootstrap: boolean): void;
359391
/**
360392
* Adds locale parameters to embedUrl
361393
*
@@ -369,7 +401,8 @@ declare module "embed" {
369401
* @private
370402
* @returns {string}
371403
*/
372-
private getEmbedUrl();
404+
private getEmbedUrl(isBootstrap);
405+
private getDefaultEmbedUrl(hostname);
373406
/**
374407
* Gets a unique ID from the first available location: options, attribute.
375408
* If neither is provided generate a unique string.
@@ -392,6 +425,20 @@ declare module "embed" {
392425
* @returns {string}
393426
*/
394427
abstract getId(): string;
428+
/**
429+
* Raise a config changed event.
430+
*
431+
* @returns {void}
432+
*/
433+
abstract configChanged(isBootstrap: boolean): void;
434+
/**
435+
* Gets default embed endpoint for each entity.
436+
* For example: report embed endpoint is reportEmbed.
437+
* This will help creating a default embed URL such as: https://app.powerbi.com/reportEmbed
438+
*
439+
* @returns {string} endpoint.
440+
*/
441+
abstract getDefaultEmbedUrlEndpoint(): string;
395442
/**
396443
* Requests the browser to render the component's iframe in fullscreen mode.
397444
*/
@@ -416,7 +463,7 @@ declare module "embed" {
416463
/**
417464
* Sets Iframe for embed
418465
*/
419-
private setIframe(isLoad, phasedRender?);
466+
private setIframe(isLoad, phasedRender?, isBootstrap?);
420467
/**
421468
* Sets Iframe's title
422469
*/
@@ -764,13 +811,6 @@ declare module "page" {
764811
hasLayout(layoutType: any): Promise<boolean>;
765812
}
766813
}
767-
declare module "defaults" {
768-
import * as models from 'powerbi-models';
769-
export abstract class Defaults {
770-
static defaultSettings: models.ISettings;
771-
static defaultQnaSettings: models.IQnaSettings;
772-
}
773-
}
774814
declare module "report" {
775815
import * as service from "service";
776816
import * as embed from "embed";
@@ -814,7 +854,7 @@ declare module "report" {
814854
* @param {HTMLElement} element
815855
* @param {embed.IEmbedConfiguration} config
816856
*/
817-
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, iframe?: HTMLIFrameElement);
857+
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean, iframe?: HTMLIFrameElement);
818858
/**
819859
* Adds backwards compatibility for the previous load configuration, which used the reportId query parameter to specify the report ID
820860
* (e.g. http://embedded.powerbi.com/appTokenReportEmbed?reportId=854846ed-2106-4dc2-bc58-eb77533bf2f1).
@@ -961,12 +1001,12 @@ declare module "report" {
9611001
*/
9621002
validate(config: embed.IEmbedConfigurationBase): models.IError[];
9631003
/**
964-
* Populate config for load config
1004+
* Handle config changes.
9651005
*
966-
* @param {IEmbedConfigurationBase}
9671006
* @returns {void}
9681007
*/
969-
populateConfig(baseConfig: embed.IEmbedConfigurationBase): void;
1008+
configChanged(isBootstrap: boolean): void;
1009+
getDefaultEmbedUrlEndpoint(): string;
9701010
/**
9711011
* Switch Report view mode.
9721012
*
@@ -1009,14 +1049,15 @@ declare module "report" {
10091049
resetTheme(): Promise<void>;
10101050
private applyThemeInternal(theme);
10111051
private viewModeToString(viewMode);
1052+
private isMobileSettings(settings);
10121053
}
10131054
}
10141055
declare module "create" {
10151056
import * as service from "service";
10161057
import * as models from 'powerbi-models';
10171058
import * as embed from "embed";
10181059
export class Create extends embed.Embed {
1019-
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfiguration, phasedRender?: boolean);
1060+
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfiguration, phasedRender?: boolean, isBootstrap?: boolean);
10201061
/**
10211062
* Gets the dataset ID from the first available location: createConfig or embed url.
10221063
*
@@ -1028,12 +1069,12 @@ declare module "create" {
10281069
*/
10291070
validate(config: embed.IEmbedConfigurationBase): models.IError[];
10301071
/**
1031-
* Populate config for create
1072+
* Handle config changes.
10321073
*
1033-
* @param {IEmbedConfigurationBase}
10341074
* @returns {void}
10351075
*/
1036-
populateConfig(baseConfig: embed.IEmbedConfigurationBase): void;
1076+
configChanged(isBootstrap: boolean): void;
1077+
getDefaultEmbedUrlEndpoint(): string;
10371078
/**
10381079
* checks if the report is saved.
10391080
*
@@ -1092,7 +1133,7 @@ declare module "dashboard" {
10921133
* @param {service.Service} service
10931134
* @param {HTMLElement} element
10941135
*/
1095-
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean);
1136+
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean);
10961137
/**
10971138
* This adds backwards compatibility for older config which used the dashboardId query param to specify dashboard id.
10981139
* E.g. https://powerbi-df.analysis-df.windows.net/dashboardEmbedHost?dashboardId=e9363c62-edb6-4eac-92d3-2199c5ca2a9e
@@ -1115,12 +1156,12 @@ declare module "dashboard" {
11151156
*/
11161157
validate(baseConfig: embed.IEmbedConfigurationBase): models.IError[];
11171158
/**
1118-
* Populate config for load config
1159+
* Handle config changes.
11191160
*
1120-
* @param {IEmbedConfigurationBase}
11211161
* @returns {void}
11221162
*/
1123-
populateConfig(baseConfig: embed.IEmbedConfigurationBase): void;
1163+
configChanged(isBootstrap: boolean): void;
1164+
getDefaultEmbedUrlEndpoint(): string;
11241165
/**
11251166
* Validate that pageView has a legal value: if page view is defined it must have one of the values defined in models.PageView
11261167
*/
@@ -1141,7 +1182,7 @@ declare module "tile" {
11411182
export class Tile extends embed.Embed {
11421183
static type: string;
11431184
static allowedEvents: string[];
1144-
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean);
1185+
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean);
11451186
/**
11461187
* The ID of the tile
11471188
*
@@ -1153,12 +1194,12 @@ declare module "tile" {
11531194
*/
11541195
validate(config: embed.IEmbedConfigurationBase): models.IError[];
11551196
/**
1156-
* Populate config for load config
1197+
* Handle config changes.
11571198
*
1158-
* @param {IEmbedConfigurationBase}
11591199
* @returns {void}
11601200
*/
1161-
populateConfig(baseConfig: embed.IEmbedConfigurationBase): void;
1201+
configChanged(isBootstrap: boolean): void;
1202+
getDefaultEmbedUrlEndpoint(): string;
11621203
/**
11631204
* Adds the ability to get tileId from url.
11641205
* By extracting the ID we can ensure that the ID is always explicitly provided as part of the load configuration.
@@ -1184,7 +1225,7 @@ declare module "qna" {
11841225
export class Qna extends embed.Embed {
11851226
static type: string;
11861227
static allowedEvents: string[];
1187-
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean);
1228+
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean);
11881229
/**
11891230
* The ID of the Qna embed component
11901231
*
@@ -1198,6 +1239,13 @@ declare module "qna" {
11981239
* @returns {string}
11991240
*/
12001241
setQuestion(question: string): Promise<void>;
1242+
/**
1243+
* Handle config changes.
1244+
*
1245+
* @returns {void}
1246+
*/
1247+
configChanged(isBootstrap: boolean): void;
1248+
getDefaultEmbedUrlEndpoint(): string;
12011249
/**
12021250
* Validate load configuration.
12031251
*/
@@ -1227,7 +1275,7 @@ declare module "visual" {
12271275
* @param {HTMLElement} element
12281276
* @param {embed.IEmbedConfiguration} config
12291277
*/
1230-
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, iframe?: HTMLIFrameElement);
1278+
constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean, iframe?: HTMLIFrameElement);
12311279
load(baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean): Promise<void>;
12321280
/**
12331281
* Gets the list of pages within the report - not supported in visual embed.
@@ -1363,7 +1411,6 @@ declare module "service" {
13631411
wpmp: wpmp.WindowPostMessageProxy;
13641412
private router;
13651413
private uniqueSessionId;
1366-
private static DefaultInitEmbedUrl;
13671414
/**
13681415
* Creates an instance of a Power BI Service.
13691416
*
@@ -1409,7 +1456,14 @@ declare module "service" {
14091456
* @returns {embed.Embed}
14101457
*/
14111458
load(element: HTMLElement, config?: embed.IEmbedConfigurationBase): embed.Embed;
1412-
embedInternal(element: HTMLElement, config?: embed.IEmbedConfigurationBase, phasedRender?: boolean): embed.Embed;
1459+
/**
1460+
* Given an HTML element and entityType, creates a new component instance, and bootstrap the iframe for embedding.
1461+
*
1462+
* @param {HTMLElement} element
1463+
* @param {embed.IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token.
1464+
*/
1465+
bootstrap(element: HTMLElement, config: embed.IBootstrapEmbedConfiguration): embed.Embed;
1466+
embedInternal(element: HTMLElement, config?: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean): embed.Embed;
14131467
getNumberOfComponents(): number;
14141468
getSdkSessionId(): string;
14151469
/**
@@ -1420,7 +1474,7 @@ declare module "service" {
14201474
* @param {embed.IEmbedConfigurationBase} config
14211475
* @returns {embed.Embed}
14221476
*/
1423-
private embedNew(element, config, phasedRender?);
1477+
private embedNew(element, config, phasedRender?, isBootstrap?);
14241478
/**
14251479
* Given an element that already contains an embed component, load with a new configuration.
14261480
*
@@ -1570,13 +1624,6 @@ declare module "bookmarksManager" {
15701624
applyState(state: string): Promise<void>;
15711625
}
15721626
}
1573-
declare module "config" {
1574-
const config: {
1575-
version: string;
1576-
type: string;
1577-
};
1578-
export default config;
1579-
}
15801627
declare module "factories" {
15811628
/**
15821629
* TODO: Need to find better place for these factory functions or refactor how we handle dependency injection

0 commit comments

Comments
 (0)