Skip to content

Commit c78b386

Browse files
committed
Merge remote-tracking branch 'powerbi/master'
2 parents ea80f9e + 284ccc0 commit c78b386

8 files changed

Lines changed: 107 additions & 17 deletions

‎demo/v2-demo/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<body>
1717
<header>
1818
<div class="logo-text">
19-
<div class="logo-text-span">Microsoft Power BI Embedded Playground</div>
19+
<div class="logo-text-span">Microsoft Power BI Embedded Sample</div>
2020
</div>
2121
</header>
2222
<div id="navbar-content">

‎demo/v2-demo/scripts/report.js‎

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const EmbedCreateMode = "create";
99
const runEmbedCodeTimeout = 500;
1010
const interactTooltipTimeout = 2000;
1111

12-
const defualtTokenType = 1;
12+
const defaultTokenType = 1;
1313
const defaultQnaQuestion = "This year sales by store type by postal code as map";
1414
const defaultQnaMode = "Interactive";
1515

@@ -255,11 +255,6 @@ function showEmbedSettings(mode, entityType, tokenType)
255255
}
256256
}
257257

258-
function SetEmbedTypeToEmbedToken(tokenType)
259-
{
260-
SetSession(SessionKeys.TokenType, tokenType);
261-
}
262-
263258
function OpenEmbedMode(mode, entityType, tokenType)
264259
{
265260
if (entityType == EntityType.Report)
@@ -413,6 +408,74 @@ function ToggleQuestionBox(enabled) {
413408
}
414409
}
415410

411+
function OnTokenTypeRadioClicked(tokenType) {
412+
SetSession(SessionKeys.TokenType, tokenType);
413+
const entityType = GetSession(SessionKeys.EntityType);
414+
415+
if (tokenType == 0 /* AAD Token */) {
416+
$('.inputLine input').each(function () {
417+
$(this).val("");
418+
let onChangeFunc = $(this).attr("onchange");
419+
if (onChangeFunc) {
420+
// Change 'this' to button's identifier
421+
onChangeFunc = onChangeFunc.replace("this", "'input#" + $(this).attr('id') + "'");
422+
eval(onChangeFunc);
423+
}
424+
});
425+
426+
} else {
427+
// Moving to embed token will reload the sample
428+
ReloadSample(entityType);
429+
}
430+
}
431+
432+
function ReloadSample(entityType) {
433+
const mode = GetSession(SessionKeys.EmbedMode);
434+
SetIsSample(true);
435+
436+
if (entityType == EntityType.Report)
437+
{
438+
if (mode == EmbedCreateMode)
439+
{
440+
LoadSampleDatasetIntoSession().then(function (response) {
441+
SetTextBoxesFromSessionOrUrlParam("#txtCreateAccessToken", "#txtCreateReportEmbed", "#txtEmbedDatasetId");
442+
});
443+
}
444+
else
445+
{
446+
LoadSampleReportIntoSession().then(function (response) {
447+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtReportEmbed", "#txtEmbedReportId");
448+
});
449+
}
450+
}
451+
else if (entityType == EntityType.Visual)
452+
{
453+
LoadSampleVisualIntoSession().then(function (response) {
454+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtReportEmbed", "#txtEmbedReportId");
455+
SetTextboxFromSessionOrUrlParam(SessionKeys.PageName, "#txtPageName");
456+
SetTextboxFromSessionOrUrlParam(SessionKeys.VisualName, "#txtVisualName");
457+
});
458+
}
459+
else if (entityType == EntityType.Dashboard)
460+
{
461+
LoadSampleDashboardIntoSession().then(function (response) {
462+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtDashboardEmbed", "#txtEmbedDashboardId");
463+
});
464+
}
465+
else if (entityType == EntityType.Tile)
466+
{
467+
LoadSampleTileIntoSession().then(function (response) {
468+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtTileEmbed", "#txtEmbedTileId", "#txtEmbedDashboardId");
469+
});
470+
}
471+
else if (entityType == EntityType.Qna)
472+
{
473+
LoadSampleQnaIntoSession().then(function (response) {
474+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
475+
});
476+
}
477+
}
478+
416479
function EmbedAreaDesktopView() {
417480
if ($(".desktop-view").hasClass(active_class)) {
418481
return;
@@ -504,7 +567,7 @@ function updateRunFuncSessionParameters(runFunc) {
504567

505568
let code = BodyCodeOfFunction(runFunc);
506569
let tokenType = GetSession(SessionKeys.TokenType);
507-
tokenType = tokenType? tokenType : defualtTokenType;
570+
tokenType = (tokenType != undefined)? tokenType : defaultTokenType;
508571
code = code.replace("$('#txtAccessToken').val()", accessToken)
509572
.replace("$('input:radio[name=tokenType]:checked').val()", tokenType);
510573

‎demo/v2-demo/scripts/session_utils.js‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,35 @@ function GetSession(key) {
4444

4545
function UpdateSession(button, sessionKey) {
4646
const value = $(button).val();
47-
if (value)
47+
if (value || value === "")
4848
{
4949
SetSession(sessionKey, value);
50+
SetIsSample(false);
51+
}
52+
}
53+
54+
function SetIsSample(value) {
55+
const entityType = GetSession(SessionKeys.EntityType);
56+
57+
if (entityType == EntityType.Report)
58+
{
59+
SetSession(SessionKeys.IsSampleReport, value);
60+
}
61+
else if (entityType == EntityType.Visual)
62+
{
63+
SetSession(SessionKeys.IsSampleReport, value);
64+
}
65+
else if (entityType == EntityType.Dashboard)
66+
{
67+
SetSession(SessionKeys.IsSampleDashboard, value);
68+
}
69+
else if (entityType == EntityType.Tile)
70+
{
71+
SetSession(SessionKeys.IsSampleTile, value);
72+
}
73+
else if (entityType == EntityType.Qna)
74+
{
75+
SetSession(SessionKeys.IsSampleQna, value);
5076
}
5177
}
5278

‎demo/v2-demo/scripts/step_samples.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function LoadSampleQnaIntoSession() {
157157

158158
function OpenCodeStepWithSample(entityType) {
159159
SetSession(SessionKeys.EntityType, entityType);
160+
SetSession(SessionKeys.TokenType, defaultTokenType);
160161

161162
if (entityType == EntityType.Report)
162163
{

‎demo/v2-demo/settings_embed_dashboard.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
<div id="typeSelector">
66
<label class="radioContainer">
7-
<div onclick="SetSession(SessionKeys.TokenType, 1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
7+
<div onclick="OnTokenTypeRadioClicked(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
88
<span class="checkmark"></span></div>
99
</label>
1010
<label class="radioContainer">
11-
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
11+
<div onclick="OnTokenTypeRadioClicked(0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
1212
<span class="checkmark"></span></div>
1313
</label>
1414
</div>

‎demo/v2-demo/settings_embed_report.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
<div id="typeSelector">
2222
<label class="radioContainer">
23-
<div onclick="SetEmbedTypeToEmbedToken(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
23+
<div onclick="OnTokenTypeRadioClicked(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
2424
<span class="checkmark"></span></div>
2525
</label>
2626
<label class="radioContainer">
27-
<div onclick="SetEmbedTypeToEmbedToken(0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
27+
<div onclick="OnTokenTypeRadioClicked(0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
2828
<span class="checkmark"></span></div>
2929
</label>
3030
</div>

‎demo/v2-demo/settings_embed_tile.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
<div id="typeSelector">
66
<label class="radioContainer">
7-
<div onclick="SetSession(SessionKeys.TokenType, 1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
7+
<div onclick="OnTokenTypeRadioClicked(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
88
<span class="checkmark"></span></div>
99
</label>
1010
<label class="radioContainer">
11-
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
11+
<div onclick="OnTokenTypeRadioClicked(0);"><input type="radio" name="tokenType" value="0"> AAD token </input>
1212
<span class="checkmark"></span></div>
1313
</label>
1414
</div>

‎demo/v2-demo/settings_embed_visual.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
<div id="typeSelector">
66
<label class="radioContainer">
7-
<div onclick="SetEmbedTypeToEmbedToken(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
7+
<div onclick="OnTokenTypeRadioClicked(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input>
88
<span class="checkmark"></span></div>
99
</label>
1010
<label class="radioContainer">
11-
<div onclick="SetEmbedTypeToEmbedToken(0);"><input type="radio" name="tokenType" value="0"> AAD token</input>
11+
<div onclick="OnTokenTypeRadioClicked(0);"><input type="radio" name="tokenType" value="0"> AAD token</input>
1212
<span class="checkmark"></span></div>
1313
</label>
1414
</div>

0 commit comments

Comments
 (0)