Skip to content
This repository was archived by the owner on Jul 13, 2022. It is now read-only.

Commit 9ae72e5

Browse files
author
submarine-launched
authored
Merge pull request microsoft#379 from microsoft/release-2.18.6
Release version 2.18.6
2 parents 32b6e73 + 0c0c349 commit 9ae72e5

File tree

8 files changed

+200
-77
lines changed

8 files changed

+200
-77
lines changed

dist/powerbi-client.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.18.4
1+
// powerbi-client v2.18.6
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
declare module "config" {
@@ -1564,6 +1564,16 @@ declare module "report" {
15641564
* @hidden
15651565
*/
15661566
private isMobileSettings;
1567+
/**
1568+
* Return the current zoom level of the report.
1569+
* @returns {Promise<number>}
1570+
*/
1571+
getZoom(): Promise<number>;
1572+
/**
1573+
* Sets the report's zoom level.
1574+
* @param zoomLevel zoom level to set
1575+
*/
1576+
setZoom(zoomLevel: number): Promise<void>;
15671577
}
15681578
}
15691579
declare module "create" {

dist/powerbi.js

+151-63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/powerbi.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.18.4",
3+
"version": "2.18.6",
44
"description": "JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and responding to data selection.",
55
"main": "dist/powerbi.js",
66
"types": "dist/powerbi-client.d.ts",
@@ -81,7 +81,7 @@
8181
},
8282
"dependencies": {
8383
"http-post-message": "^0.2",
84-
"powerbi-models": "^1.9.3",
84+
"powerbi-models": "^1.9.5",
8585
"powerbi-router": "^0.1",
8686
"window-post-message-proxy": "^0.2"
8787
},

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @ignore *//** */
55
const config = {
6-
version: '2.18.4',
6+
version: '2.18.6',
77
type: 'js'
88
};
99

src/embed.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,12 @@ export abstract class Embed {
227227
this.commands = [];
228228
this.groups = [];
229229

230-
const registerQueryCallback = !!(<IEmbedConfiguration>config).eventHooks?.applicationContextProvider;
231-
delete (<IEmbedConfiguration>config).eventHooks;
232-
233230
this.populateConfig(config, isBootstrap);
234231

235232
if (this.embedtype === 'create') {
236-
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
233+
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap);
237234
} else {
238-
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
235+
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap);
239236
}
240237
}
241238

@@ -540,6 +537,11 @@ export abstract class Embed {
540537
this.config.accessToken = this.getAccessToken(this.service.accessToken);
541538
}
542539

540+
const registerQueryCallback = !!(<IEmbedConfiguration>this.config).eventHooks?.applicationContextProvider;
541+
delete (<IEmbedConfiguration>this.config).eventHooks;
542+
if (registerQueryCallback && this.embedtype === "report")
543+
this.config.embedUrl = addParamToUrl(this.config.embedUrl, "registerQueryCallback", "true");
544+
543545
this.configChanged(isBootstrap);
544546
}
545547

@@ -710,9 +712,6 @@ export abstract class Embed {
710712
const iframeContent = document.createElement("iframe");
711713
let embedUrl = this.config.uniqueId ? addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl;
712714

713-
if (!isBootstrap && registerQueryCallback)
714-
embedUrl = addParamToUrl(embedUrl, "registerQueryCallback", "true");
715-
716715
iframeContent.style.width = '100%';
717716
iframeContent.style.height = '100%';
718717
iframeContent.setAttribute("src", embedUrl);

src/report.ts

+21
Original file line numberDiff line numberDiff line change
@@ -1112,4 +1112,25 @@ export class Report extends Embed implements IReportNode, IFilterable {
11121112
private isMobileSettings(settings: IEmbedSettings): boolean {
11131113
return settings && (settings.layoutType === LayoutType.MobileLandscape || settings.layoutType === LayoutType.MobilePortrait);
11141114
}
1115+
1116+
/**
1117+
* Return the current zoom level of the report.
1118+
* @returns {Promise<number>}
1119+
*/
1120+
async getZoom(): Promise<number> {
1121+
try {
1122+
const response = await this.service.hpm.get<number>(`/report/zoom`, { uid: this.config.uniqueId }, this.iframe.contentWindow);
1123+
return response.body;
1124+
} catch (response) {
1125+
throw response.body;
1126+
}
1127+
}
1128+
1129+
/**
1130+
* Sets the report's zoom level.
1131+
* @param zoomLevel zoom level to set
1132+
*/
1133+
async setZoom(zoomLevel: number): Promise<void> {
1134+
await this.updateSettings({ zoomLevel: zoomLevel });
1135+
}
11151136
}

src/service.ts

+5
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ export class Service implements IService {
326326
* @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token.
327327
*/
328328
bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | IBootstrapEmbedConfiguration): Embed {
329+
this.registerApplicationContextHook(config as IEmbedConfiguration);
329330
return this.embedInternal(element, config, /* phasedRender */ false, /* isBootstrap */ true);
330331
}
331332

@@ -451,6 +452,10 @@ export class Service implements IService {
451452
return;
452453
}
453454

455+
if (config?.type.toLowerCase() !== "report") {
456+
throw new Error("applicationContextProvider is only supported in report embed");
457+
}
458+
454459
if (typeof applicationContextProvider !== 'function') {
455460
throw new Error("applicationContextProvider must be a function");
456461
}

0 commit comments

Comments
 (0)