Skip to content

Commit 6fd9b08

Browse files
committed
Merge remote-tracking branch 'powerbi/master'
2 parents ae46bac + f2365fb commit 6fd9b08

File tree

18 files changed

+210
-52
lines changed

18 files changed

+210
-52
lines changed

demo/bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"fetch": "^1.0.0",
2020
"es6-promise": "^3.2.2",
21-
"bootstrap": "^3.3.6",
21+
"bootstrap": "^4.1.2",
2222
"jquery": "^3.1.0",
2323
"powerbi-client": "2.4.3"
2424
},

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"tests"
3131
],
3232
"dependencies": {
33-
"bootstrap": "^3.3.6",
33+
"bootstrap": "^4.1.2",
3434
"es6-promise": "^3.2.2",
3535
"fetch": "^1.0.0",
3636
"http-server": "^0.10.0",
3737
"jquery": "^3.1.0",
38-
"powerbi-client": "^2.6.5",
38+
"powerbi-client": "^2.6.6",
3939
"syntaxhighlighter": "4.0.1"
4040
},
4141
"devDependencies": {}

demo/v2-demo/docs.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div class="docs-line">
44
<div class="docs-links">
55
<h2>Getting started</h2>
6+
<a href="https://app.powerbi.com/embedsetup">Set up your Power BI embedding environment</a><br>
67
<a href="https://github.com/Microsoft/powerbi-javascript/wiki">Power BI JavaScript API wiki</a><br>
78
<a href="https://docs.microsoft.com/en-us/power-bi/developer/embedding">Power BI embedding documentation</a><br>
89
</div>

demo/v2-demo/report.html

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,7 @@
7474
const mode = modeUrlParam ? modeUrlParam : "view";
7575

7676
const entityTypeUrlParam = GetParameterByName("entityType");
77-
let entityType;
78-
if (entityTypeUrlParam == "dashboard") {
79-
entityType = EntityType.Dashboard;
80-
} else if (entityTypeUrlParam == "tile") {
81-
entityType = EntityType.Tile;
82-
}
83-
else if (entityTypeUrlParam == "visual") {
84-
entityType = EntityType.Visual;
85-
} else {
86-
entityType = EntityType.Report;
87-
}
77+
let entityType = getEntityTypeFromParameter(entityTypeUrlParam);
8878

8979
// set mode and type in session.
9080
SetSession(SessionKeys.EntityType, entityType);
@@ -97,7 +87,7 @@
9787

9888
if (GetParameterByName("embedUrl") || GetParameterByName("embedId") || GetParameterByName("accessToken") || GetParameterByName("entityType"))
9989
{
100-
OpenCodeStep(mode, entityType, 0);
90+
OpenCodeStep(mode, entityType, GetParameterByName("tokenType") || 0);
10191
}
10292
else
10393
{

demo/v2-demo/scripts/codesamples.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,45 @@ function _Embed_QnaEmbed() {
687687
powerbi.embed(qnaContainer, config);
688688
}
689689

690+
function _Embed_QnaEmbed_Aad() {
691+
// Read embed application token from textbox
692+
var txtAccessToken = $('#txtAccessToken').val();
693+
694+
// Read embed URL from textbox
695+
var txtEmbedUrl = $('#txtQnaEmbed').val();
696+
697+
// Read dataset Id from textbox
698+
var txtDatasetId = $('#txtDatasetId').val();
699+
700+
// Read question from textbox
701+
var txtQuestion = $('#txtQuestion').val();
702+
703+
// Read Qna mode
704+
var qnaMode = $("input[name='qnaMode']:checked").val();
705+
706+
// Get models. models contains enums that can be used.
707+
var models = window['powerbi-client'].models;
708+
709+
// Embed configuration used to describe the what and how to embed.
710+
// This object is used when calling powerbi.embed.
711+
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
712+
var config= {
713+
type: 'qna',
714+
tokenType: models.TokenType.Aad,
715+
accessToken: txtAccessToken,
716+
embedUrl: txtEmbedUrl,
717+
datasetIds: [txtDatasetId],
718+
viewMode: models.QnaMode[qnaMode],
719+
question: txtQuestion
720+
};
721+
722+
// Get a reference to the embedded Q&A HTML element
723+
var qnaContainer = $('#qnaContainer')[0];
724+
725+
// Embed the Q&A and display it within the div container.
726+
powerbi.embed(qnaContainer, config);
727+
}
728+
690729
// ---- Report Operations ----------------------------------------------------
691730

692731
function _Report_GetId() {

demo/v2-demo/scripts/report.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const interactTooltipTimeout = 2000;
1313
const defaultTokenType = 1;
1414
const defaultQnaQuestion = "2014 total units YTD var % by month, manufacturer as clustered column chart";
1515
const defaultQnaMode = "Interactive";
16+
const interactiveNoQuestionMode = "InteractiveNoQuestion";
1617

1718
function OpenSamplesStep() {
1819
$('#steps-ul a').removeClass(active_class);
@@ -230,7 +231,7 @@ function getEmbedCode(mode, entityType)
230231
}
231232
else if (entityType == EntityType.Qna)
232233
{
233-
code = _Embed_QnaEmbed;
234+
code = GetParameterByName(SessionKeys.TokenType) === '0' /* AAD Token */ ? _Embed_QnaEmbed_Aad : _Embed_QnaEmbed;
234235
}
235236
return code;
236237
}
@@ -355,17 +356,32 @@ function OpenEmbedMode(mode, entityType, tokenType)
355356
}
356357
else if (entityType == EntityType.Qna)
357358
{
359+
LoadSettings = function() {
360+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
361+
SetTextboxFromSessionOrUrlParam(SessionKeys.QnaQuestion, "#txtQuestion");
362+
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
363+
let qnaMode = GetParameterByName(SessionKeys.QnaMode);
364+
if (qnaMode) {
365+
let modesRadios = $('input:radio[name=qnaMode]');
366+
modesRadios.filter('[id=' + qnaMode + ']').prop('checked', true);
367+
qnaMode = qnaMode !== interactiveNoQuestionMode ? qnaMode : defaultQnaMode;
368+
SetSession(SessionKeys.QnaMode, qnaMode);
369+
}
370+
};
371+
358372
if (IsEmbeddingSampleQna())
359373
{
360374
LoadSampleQnaIntoSession().then(function (response) {
361-
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
362-
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
375+
if (!GetSession(SessionKeys.QnaQuestion)) {
376+
SetSession(SessionKeys.QnaQuestion, defaultQnaQuestion);
377+
}
378+
379+
LoadSettings();
363380
});
364381
}
365382
else
366383
{
367-
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
368-
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
384+
LoadSettings();
369385
}
370386
}
371387
}
@@ -411,7 +427,7 @@ function ToggleQuestionBox(enabled) {
411427
let txtQuestion = $("#txtQuestion");
412428
if (enabled === true) {
413429
let question = GetSession(SessionKeys.QnaQuestion);
414-
question = question? question : defaultQnaQuestion;
430+
question = question ? question : defaultQnaQuestion;
415431
txtQuestion.val(question);
416432
txtQuestion.prop('disabled', false);
417433
}

demo/v2-demo/scripts/utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function getEmbedContainerID(entityType) {
121121
}
122122
}
123123

124-
function getEmbedContainerClassPrefix(entityType, isMobile) {
124+
function getEmbedContainerClassPrefix(entityType) {
125125
switch (entityType) {
126126
case EntityType.Visual:
127127
return ".visual";
@@ -136,6 +136,21 @@ function getEmbedContainerClassPrefix(entityType, isMobile) {
136136
}
137137
}
138138

139+
function getEntityTypeFromParameter(urlParam) {
140+
switch (urlParam) {
141+
case "visual":
142+
return EntityType.Visual;
143+
case "dashboard":
144+
return EntityType.Dashboard;
145+
case "tile":
146+
return EntityType.Tile;
147+
case "qna":
148+
return EntityType.Qna;
149+
default:
150+
return EntityType.Report;
151+
}
152+
}
153+
139154
function elementClicked(element) {
140155
$(element).addClass('elementClicked');
141156
setTimeout(function() {

demo/v2-demo/settings_embed_qna.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<div class="spacer" />
55
<div id="modeSelector">
66
<label class="radioContainer">
7-
<div onclick="ToggleQuestionBox(false);"><input type="radio" name="qnaMode" value="Interactive"> Show Q&A </input>
7+
<div onclick="ToggleQuestionBox(false);"><input type="radio" name="qnaMode" value="Interactive" id="InteractiveNoQuestion"> Show Q&A </input>
88
<span class="checkmark"></span></div>
99
</label>
1010
<label class="radioContainer">
11-
<div onclick="ToggleQuestionBox(true);"><input type="radio" name="qnaMode" value="Interactive" checked="checked"> Show Q&A, use predefined question </input>
11+
<div onclick="ToggleQuestionBox(true);"><input type="radio" name="qnaMode" value="Interactive" checked="checked" id="Interactive"> Show Q&A, use predefined question </input>
1212
<span class="checkmark"></span></div>
1313
</label>
1414
<label class="radioContainer">
15-
<div onclick="ToggleQuestionBox(true);"><input type="radio" name="qnaMode" value="ResultOnly"> Show answer only, use predefined question </input>
15+
<div onclick="ToggleQuestionBox(true);"><input type="radio" name="qnaMode" value="ResultOnly" id="ResultOnly"> Show answer only, use predefined question </input>
1616
<span class="checkmark"></span></div>
1717
</label>
1818
</div>

demo/v2-demo/shareBookmark.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<link rel="stylesheet" type="text/css" href="style/style.css">
22
<link rel="stylesheet" type="text/css" href="style/layout.css">
33

4-
<div id="embedContainer" class="iframeContainer active"></div>
4+
<div id="share-bookmark">
5+
<div id="embedContainer" class="iframeContainer active"></div>
6+
</div>
57

68
<script src="../node_modules/jquery/dist/jquery.js"></script>
79
<script src="../node_modules/es6-promise/dist/es6-promise.js"></script>

demo/v2-demo/style/style.css

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,42 @@ body {
1010
margin:0;
1111
padding:0;
1212
height:100%;
13+
font-size: 14px;
14+
line-height: 1.42857143;
15+
color: #333;
1316
}
1417

1518
h1 {
1619
margin-bottom: 15px;
1720
}
1821

22+
h2 {
23+
margin-top: 20px;
24+
margin-bottom: 10px;
25+
}
26+
1927
h3 {
2028
margin: 0;
29+
font-size: 24px;
30+
font-family: inherit;
31+
font-weight: 500;
32+
line-height: 1.1;
33+
color: inherit;
2134
}
2235

2336
h8 {
2437
font-weight: 600;
2538
}
2639

40+
button:focus {
41+
outline: none !important;
42+
}
43+
44+
a {
45+
color: #337ab7;
46+
text-decoration: none;
47+
}
48+
2749
a:hover, a:visited, a:link, a:active
2850
{
2951
text-decoration: none !important;
@@ -85,10 +107,6 @@ a:hover, a:visited, a:link, a:active
85107
padding-left: 4px;
86108
}
87109

88-
a {
89-
text-decoration: none;
90-
}
91-
92110
.pbi-line {
93111
float: left;
94112
width: 384px;
@@ -317,11 +335,13 @@ a {
317335
background: url('../images/expand.svg') center left;
318336
background-repeat: no-repeat;
319337
padding-right: 18px;
338+
cursor: pointer;
320339
}
321340

322341
.operations-ul > li.active:before {
323342
background: url('../images/collapse.svg') center left;
324343
background-repeat: no-repeat;
344+
cursor: pointer;
325345
}
326346

327347
.operations-ul a {
@@ -470,11 +490,13 @@ a {
470490
.textAreaControl {
471491
background-color: transparent;
472492
border: none;
473-
outline:none;
493+
outline: none;
474494
margin-right: 40px;
475495
height: 40px;
476496
opacity: 1;
477497
min-width: 80px;
498+
font-weight: bold;
499+
cursor: pointer;
478500
}
479501

480502
.textAreaControl img {
@@ -536,6 +558,7 @@ a {
536558
width: 160px;
537559
height: 32px;
538560
text-align: center;
561+
cursor: pointer;
539562
}
540563

541564
.selectButton:hover {
@@ -618,7 +641,7 @@ a {
618641
cursor: default;
619642
}
620643

621-
.desktop-view iframe, .mobile-view iframe, #showcase-embedded-view iframe, #bookmark-embedded-view iframe {
644+
.desktop-view iframe, .mobile-view iframe, #showcase-embedded-view iframe, #bookmark-embedded-view iframe, #share-bookmark iframe {
622645
border: none;
623646
}
624647

0 commit comments

Comments
 (0)