Skip to content

Commit 67458c8

Browse files
author
Amit Shuster
committed
Merged PR 13832: Fix InteractiveNoQuestion for Q&A url param, and Q&A Aad token
Fix InteractiveNoQuestion for Q&A url param, and Q&A Aad token using id instead of val for "InteractiveNoQuestion" radio button
1 parent 9ab6852 commit 67458c8

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

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: 5 additions & 3 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
}
@@ -361,9 +362,10 @@ function OpenEmbedMode(mode, entityType, tokenType)
361362
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
362363
let qnaMode = GetParameterByName(SessionKeys.QnaMode);
363364
if (qnaMode) {
364-
SetSession(SessionKeys.QnaMode, qnaMode);
365365
let modesRadios = $('input:radio[name=qnaMode]');
366-
modesRadios.filter('[value=' + qnaMode + ']').prop('checked', true);
366+
modesRadios.filter('[id=' + qnaMode + ']').prop('checked', true);
367+
qnaMode = qnaMode !== interactiveNoQuestionMode ? qnaMode : defaultQnaMode;
368+
SetSession(SessionKeys.QnaMode, qnaMode);
367369
}
368370
};
369371

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>

0 commit comments

Comments
 (0)