Skip to content

Commit d4b08ff

Browse files
committed
Merged PR 3813: adding swipe events
adding swipe events & has layout to support report mobile layout
1 parent b9caffc commit d4b08ff

File tree

10 files changed

+154
-78
lines changed

10 files changed

+154
-78
lines changed

demo/v2-demo/scripts/codesamples.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,24 @@ function _Page_RemoveFilters() {
11351135
});
11361136
}
11371137

1138+
function _Page_HasLayout() {
1139+
// Get models. models contains enums that can be used.
1140+
var models = window['powerbi-client'].models;
1141+
1142+
// Get a reference to the embedded report HTML element
1143+
var embedContainer = $('#embedContainer')[0];
1144+
1145+
// Get a reference to the embedded report.
1146+
report = powerbi.get(embedContainer);
1147+
1148+
// Retrieve the page collection and check if the first page has a MobilePortrait layout.
1149+
report.getPages().then(function (pages) {
1150+
pages[0].hasLayout(models.LayoutType.MobilePortrait).then(function(hasLayout) {
1151+
Log.log(hasLayout);
1152+
})
1153+
});
1154+
}
1155+
11381156
// ---- Event Listener ----------------------------------------------------
11391157

11401158
function _Events_PageChanged() {

demo/v2-demo/scripts/step_embed.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ function Page_RemoveFilters() {
8181
SetCode(_Page_RemoveFilters);
8282
}
8383

84+
function Page_HasLayout() {
85+
SetCode(_Page_HasLayout);
86+
}
8487
// ---- Event Listener ----------------------------------------------------
8588

8689
function Events_PageChanged() {

demo/v2-demo/settings_interact.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<li onclick="Page_SetFilters()">Set Filters</li>
4646
<li onclick="Page_GetFilters()">Get Filters</li>
4747
<li onclick="Page_RemoveFilters()">Remove Filters</li>
48+
<li onclick="Page_HasLayout()">Check Layout</li>
4849
<li class="newOperation" onclick="Page_GetVisuals()">Get Visuals</li>
4950
</ul>
5051
</div>

dist/powerbi-client.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! powerbi-client v2.4.6 | (c) 2016 Microsoft Corporation MIT */
1+
/*! powerbi-client v2.4.7 | (c) 2016 Microsoft Corporation MIT */
22
declare module "config" {
33
const config: {
44
version: string;
@@ -619,6 +619,17 @@ declare module "page" {
619619
* @returns {Promise<VisualDescriptor[]>}
620620
*/
621621
getVisuals(): Promise<VisualDescriptor[]>;
622+
/**
623+
* Checks if page has layout.
624+
*
625+
* ```javascript
626+
* page.hasLayout(layoutType)
627+
* .then(hasLayout: boolean => { ... });
628+
* ```
629+
*
630+
* @returns {(Promise<boolean>)}
631+
*/
632+
hasLayout(layoutType: any): Promise<boolean>;
622633
}
623634
}
624635
declare module "defaults" {

dist/powerbi.js

Lines changed: 89 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/powerbi.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.4.6",
3+
"version": "2.4.7",
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
"typings": "dist/powerbi-client.d.ts",
@@ -75,7 +75,7 @@
7575
},
7676
"dependencies": {
7777
"http-post-message": "^0.2",
78-
"powerbi-models": "^1.0.1",
78+
"powerbi-models": "^1.0.2",
7979
"powerbi-router": "^0.1",
8080
"window-post-message-proxy": "^0.2"
8181
},

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const config = {
2-
version: '2.4.6',
2+
version: '2.4.7',
33
type: 'js'
44
};
55

src/page.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,23 @@ export class Page implements IPageNode, IFilterable {
157157
throw response.body;
158158
});
159159
}
160+
161+
/**
162+
* Checks if page has layout.
163+
*
164+
* ```javascript
165+
* page.hasLayout(layoutType)
166+
* .then(hasLayout: boolean => { ... });
167+
* ```
168+
*
169+
* @returns {(Promise<boolean>)}
170+
*/
171+
hasLayout(layoutType): Promise<boolean> {
172+
let layoutTypeEnum = models.LayoutType[layoutType];
173+
return this.report.service.hpm.get<boolean>(`/report/pages/${this.name}/layoutTypes/${layoutTypeEnum}`, { uid: this.report.config.uniqueId }, this.report.iframe.contentWindow)
174+
.then(response => response.body,
175+
response => {
176+
throw response.body;
177+
});
178+
}
160179
}

src/report.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface IReportNode {
3131
* @implements {IFilterable}
3232
*/
3333
export class Report extends embed.Embed implements IReportNode, IFilterable {
34-
static allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered"];
34+
static allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered", "swipeStart", "swipeEnd"];
3535
static reportIdAttribute = 'powerbi-report-id';
3636
static filterPaneEnabledAttribute = 'powerbi-settings-filter-pane-enabled';
3737
static navContentPaneEnabledAttribute = 'powerbi-settings-nav-content-pane-enabled';
@@ -306,6 +306,8 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
306306
*/
307307
populateConfig(baseConfig: embed.IEmbedConfigurationBase): void {
308308
let config = <embed.IEmbedConfiguration>baseConfig;
309+
if (config.settings && (config.settings.layoutType === models.LayoutType.MobileLandscape || config.settings.layoutType === models.LayoutType.MobilePortrait))
310+
config.embedUrl = utils.addParamToUrl(config.embedUrl, "isMobile", "true")
309311

310312
super.populateConfig(config);
311313

0 commit comments

Comments
 (0)