Skip to content

Commit 0a01c23

Browse files
committed
Merged PR 40176: Use powerbi.bootstrap in playground.
Use powerbi.bootstrap in playground. - one bug which will be treated with low priority for now: When clicking on phone-layout without clicking on run, report is embedded. - one important change is: Demo folder is now installing the powerbi-client package from parent folder.
1 parent eb3a5c0 commit 0a01c23

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"fetch": "^1.0.0",
3636
"http-server": "^0.10.0",
3737
"jquery": "^3.1.0",
38-
"powerbi-client": "^2.7.0",
38+
"powerbi-client": "file:..",
3939
"powerbi-report-authoring": "^1.0.0",
4040
"syntaxhighlighter": "4.0.1"
4141
},

demo/v2-demo/scripts/codesamples.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ function _Mock_Embed_BasicEmbed(isEdit) {
367367
// Get a reference to the embedded report HTML element
368368
var embedContainer = $('#embedContainer')[0];
369369

370-
powerbi.reset(embedContainer);
371-
372370
// Embed the report and display it within the div container.
373371
var report = powerbi.embed(embedContainer, config);
374372

@@ -2958,7 +2956,7 @@ function _Report_Authoring_ResetProperty() {
29582956
// Reset visual legend position
29592957
// Documentation link: https://github.com/microsoft/powerbi-report-authoring/wiki/Properties
29602958
visual.resetProperty({ objectName: "legend", propertyName: "position" })
2961-
.then(function () {
2959+
.then(function () {
29622960
Log.logText("Last visual legend position property was reset to default value.");
29632961
})
29642962
.catch(function (errors) {

demo/v2-demo/scripts/report.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ function OpenCodeStep(mode, entityType, tokenType) {
8181
LoadEmbedSettings(mode, entityType, tokenType);
8282
}
8383

84+
function bootstrapIframe(entityType) {
85+
const activeContainer = getActiveEmbedContainer();
86+
87+
// Bootstrap iframe - for better performance.
88+
let embedUrl = GetSession(SessionKeys.EmbedUrl);
89+
config = {
90+
type: entityType.toLowerCase(),
91+
embedUrl: embedUrl
92+
};
93+
94+
const isMobile = $(".mobile-view").hasClass(active_class);
95+
if (isMobile) {
96+
config.settings = {
97+
layoutType: models.LayoutType.MobilePortrait
98+
};
99+
}
100+
101+
// Hide the container in order to hide the spinner.
102+
$(activeContainer).css({"visibility":"hidden"});
103+
powerbi.bootstrap(activeContainer, config);
104+
}
105+
84106
function LoadEmbedSettings(mode, entityType, tokenType) {
85107
if (entityType == EntityType.Report)
86108
{
@@ -392,6 +414,7 @@ function OpenEmbedMode(mode, entityType, tokenType)
392414
function setCodeAndShowEmbedSettings(mode, entityType, tokenType) {
393415
setCodeArea(mode, entityType);
394416
showEmbedSettings(mode, entityType, tokenType);
417+
bootstrapIframe(entityType);
395418
}
396419

397420
function OpenViewMode() {
@@ -521,7 +544,7 @@ function EmbedAreaDesktopView() {
521544

522545
$(".desktop-view").show();
523546
$(".mobile-view").hide();
524-
547+
525548
$(".desktop-view").addClass(active_class);
526549
$(".mobile-view").removeClass(active_class);
527550

demo/v2-demo/scripts/utils.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const textCodeTimeout = 100;
66
function BodyCodeOfFunction(func) {
77
let lines = func.toString().split('\n');
88
lines = lines.slice(1, lines.length-1);
9-
9+
1010
for (let i = 0; i < lines.length; ++i)
1111
{
1212
// remove trailing spaces.
@@ -68,6 +68,7 @@ function SetCode(func) {
6868

6969
$('#btnRunCode').off('click');
7070
$('#btnRunCode').click(function() {
71+
showEmbedContainer();
7172
elementClicked('#btnRunCode');
7273
runFunc();
7374
});
@@ -134,6 +135,13 @@ function getEmbedContainerClassPrefix(entityType) {
134135
}
135136
}
136137

138+
function getActiveEmbedContainer() {
139+
const entityType = GetSession(SessionKeys.EntityType);
140+
const classPrefix = getEmbedContainerClassPrefix(entityType);
141+
const activeContainer = classPrefix + ($(".desktop-view").hasClass(active_class) ? 'Container' : 'MobileContainer');
142+
return $(activeContainer)[0];
143+
}
144+
137145
function getEntityTypeFromParameter(urlParam) {
138146
switch (urlParam) {
139147
case "visual":
@@ -156,6 +164,11 @@ function elementClicked(element) {
156164
}, elementClickedTimeout);
157165
}
158166

167+
function showEmbedContainer() {
168+
const activeContainer = getActiveEmbedContainer();
169+
$(activeContainer).css({"visibility":"visible"});
170+
}
171+
159172
function SetAuthoringPageActive(report) {
160173
return new Promise(function(resolve, reject) {
161174

0 commit comments

Comments
 (0)