diff --git a/demo/v2-demo/scripts/codesamples.js b/demo/v2-demo/scripts/codesamples.js index 5acb6696..5c9f4b8b 100644 --- a/demo/v2-demo/scripts/codesamples.js +++ b/demo/v2-demo/scripts/codesamples.js @@ -687,6 +687,45 @@ function _Embed_QnaEmbed() { powerbi.embed(qnaContainer, config); } +function _Embed_QnaEmbed_Aad() { + // Read embed application token from textbox + var txtAccessToken = $('#txtAccessToken').val(); + + // Read embed URL from textbox + var txtEmbedUrl = $('#txtQnaEmbed').val(); + + // Read dataset Id from textbox + var txtDatasetId = $('#txtDatasetId').val(); + + // Read question from textbox + var txtQuestion = $('#txtQuestion').val(); + + // Read Qna mode + var qnaMode = $("input[name='qnaMode']:checked").val(); + + // Get models. models contains enums that can be used. + var models = window['powerbi-client'].models; + + // Embed configuration used to describe the what and how to embed. + // This object is used when calling powerbi.embed. + // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details. + var config= { + type: 'qna', + tokenType: models.TokenType.Aad, + accessToken: txtAccessToken, + embedUrl: txtEmbedUrl, + datasetIds: [txtDatasetId], + viewMode: models.QnaMode[qnaMode], + question: txtQuestion + }; + + // Get a reference to the embedded Q&A HTML element + var qnaContainer = $('#qnaContainer')[0]; + + // Embed the Q&A and display it within the div container. + powerbi.embed(qnaContainer, config); +} + // ---- Report Operations ---------------------------------------------------- function _Report_GetId() { diff --git a/demo/v2-demo/scripts/report.js b/demo/v2-demo/scripts/report.js index d1ca9071..5c4cd383 100644 --- a/demo/v2-demo/scripts/report.js +++ b/demo/v2-demo/scripts/report.js @@ -13,6 +13,7 @@ const interactTooltipTimeout = 2000; const defaultTokenType = 1; const defaultQnaQuestion = "2014 total units YTD var % by month, manufacturer as clustered column chart"; const defaultQnaMode = "Interactive"; +const interactiveNoQuestionMode = "InteractiveNoQuestion"; function OpenSamplesStep() { $('#steps-ul a').removeClass(active_class); @@ -230,7 +231,7 @@ function getEmbedCode(mode, entityType) } else if (entityType == EntityType.Qna) { - code = _Embed_QnaEmbed; + code = GetParameterByName(SessionKeys.TokenType) === '0' /* AAD Token */ ? _Embed_QnaEmbed_Aad : _Embed_QnaEmbed; } return code; } @@ -361,9 +362,10 @@ function OpenEmbedMode(mode, entityType, tokenType) setCodeAndShowEmbedSettings(mode, entityType, tokenType); let qnaMode = GetParameterByName(SessionKeys.QnaMode); if (qnaMode) { - SetSession(SessionKeys.QnaMode, qnaMode); let modesRadios = $('input:radio[name=qnaMode]'); - modesRadios.filter('[value=' + qnaMode + ']').prop('checked', true); + modesRadios.filter('[id=' + qnaMode + ']').prop('checked', true); + qnaMode = qnaMode !== interactiveNoQuestionMode ? qnaMode : defaultQnaMode; + SetSession(SessionKeys.QnaMode, qnaMode); } }; diff --git a/demo/v2-demo/settings_embed_qna.html b/demo/v2-demo/settings_embed_qna.html index f5abe6cb..ab926275 100644 --- a/demo/v2-demo/settings_embed_qna.html +++ b/demo/v2-demo/settings_embed_qna.html @@ -4,15 +4,15 @@