Skip to content

Commit

Permalink
Merge pull request #379 from microsoft/release-2.18.6
Browse files Browse the repository at this point in the history
Release version 2.18.6
  • Loading branch information
submarine-launched authored Oct 13, 2021
2 parents 32b6e73 + 0c0c349 commit 9ae72e5
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 77 deletions.
12 changes: 11 additions & 1 deletion dist/powerbi-client.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// powerbi-client v2.18.4
// powerbi-client v2.18.6
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
declare module "config" {
Expand Down Expand Up @@ -1564,6 +1564,16 @@ declare module "report" {
* @hidden
*/
private isMobileSettings;
/**
* Return the current zoom level of the report.
* @returns {Promise<number>}
*/
getZoom(): Promise<number>;
/**
* Sets the report's zoom level.
* @param zoomLevel zoom level to set
*/
setZoom(zoomLevel: number): Promise<void>;
}
}
declare module "create" {
Expand Down
214 changes: 151 additions & 63 deletions dist/powerbi.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/powerbi.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-client",
"version": "2.18.4",
"version": "2.18.6",
"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.",
"main": "dist/powerbi.js",
"types": "dist/powerbi-client.d.ts",
Expand Down Expand Up @@ -81,7 +81,7 @@
},
"dependencies": {
"http-post-message": "^0.2",
"powerbi-models": "^1.9.3",
"powerbi-models": "^1.9.5",
"powerbi-router": "^0.1",
"window-post-message-proxy": "^0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/** @ignore *//** */
const config = {
version: '2.18.4',
version: '2.18.6',
type: 'js'
};

Expand Down
15 changes: 7 additions & 8 deletions src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,12 @@ export abstract class Embed {
this.commands = [];
this.groups = [];

const registerQueryCallback = !!(<IEmbedConfiguration>config).eventHooks?.applicationContextProvider;
delete (<IEmbedConfiguration>config).eventHooks;

this.populateConfig(config, isBootstrap);

if (this.embedtype === 'create') {
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap);
} else {
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap);
}
}

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

const registerQueryCallback = !!(<IEmbedConfiguration>this.config).eventHooks?.applicationContextProvider;
delete (<IEmbedConfiguration>this.config).eventHooks;
if (registerQueryCallback && this.embedtype === "report")
this.config.embedUrl = addParamToUrl(this.config.embedUrl, "registerQueryCallback", "true");

this.configChanged(isBootstrap);
}

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

if (!isBootstrap && registerQueryCallback)
embedUrl = addParamToUrl(embedUrl, "registerQueryCallback", "true");

iframeContent.style.width = '100%';
iframeContent.style.height = '100%';
iframeContent.setAttribute("src", embedUrl);
Expand Down
21 changes: 21 additions & 0 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,25 @@ export class Report extends Embed implements IReportNode, IFilterable {
private isMobileSettings(settings: IEmbedSettings): boolean {
return settings && (settings.layoutType === LayoutType.MobileLandscape || settings.layoutType === LayoutType.MobilePortrait);
}

/**
* Return the current zoom level of the report.
* @returns {Promise<number>}
*/
async getZoom(): Promise<number> {
try {
const response = await this.service.hpm.get<number>(`/report/zoom`, { uid: this.config.uniqueId }, this.iframe.contentWindow);
return response.body;
} catch (response) {
throw response.body;
}
}

/**
* Sets the report's zoom level.
* @param zoomLevel zoom level to set
*/
async setZoom(zoomLevel: number): Promise<void> {
await this.updateSettings({ zoomLevel: zoomLevel });
}
}
5 changes: 5 additions & 0 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export class Service implements IService {
* @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token.
*/
bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | IBootstrapEmbedConfiguration): Embed {
this.registerApplicationContextHook(config as IEmbedConfiguration);
return this.embedInternal(element, config, /* phasedRender */ false, /* isBootstrap */ true);
}

Expand Down Expand Up @@ -451,6 +452,10 @@ export class Service implements IService {
return;
}

if (config?.type.toLowerCase() !== "report") {
throw new Error("applicationContextProvider is only supported in report embed");
}

if (typeof applicationContextProvider !== 'function') {
throw new Error("applicationContextProvider must be a function");
}
Expand Down

0 comments on commit 9ae72e5

Please sign in to comment.