Skip to content

Commit 966e280

Browse files
author
Amit Shuster
committed
Merged PR 13354: Add Q&A url params support and fix token url param bug
Add Q&A url params support and fix token url param bug
1 parent f7da5cf commit 966e280

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

demo/v2-demo/report.html

+2-12
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/report.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,27 @@ function OpenEmbedMode(mode, entityType, tokenType)
355355
}
356356
else if (entityType == EntityType.Qna)
357357
{
358+
LoadSettings = function() {
359+
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
360+
SetTextboxFromSessionOrUrlParam(SessionKeys.QnaQuestion, "#txtQuestion");
361+
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
362+
let qnaMode = GetParameterByName(SessionKeys.QnaMode);
363+
if (qnaMode) {
364+
SetSession(SessionKeys.QnaMode, qnaMode);
365+
let modesRadios = $('input:radio[name=qnaMode]');
366+
modesRadios.filter('[value=' + qnaMode + ']').prop('checked', true);
367+
}
368+
};
369+
358370
if (IsEmbeddingSampleQna())
359371
{
360372
LoadSampleQnaIntoSession().then(function (response) {
361-
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
362-
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
373+
LoadSettings();
363374
});
364375
}
365376
else
366377
{
367-
SetTextBoxesFromSessionOrUrlParam("#txtAccessToken", "#txtQnaEmbed", "#txtDatasetId");
368-
setCodeAndShowEmbedSettings(mode, entityType, tokenType);
378+
LoadSettings();
369379
}
370380
}
371381
}
@@ -411,7 +421,7 @@ function ToggleQuestionBox(enabled) {
411421
let txtQuestion = $("#txtQuestion");
412422
if (enabled === true) {
413423
let question = GetSession(SessionKeys.QnaQuestion);
414-
question = question? question : defaultQnaQuestion;
424+
question = question ? question : defaultQnaQuestion;
415425
txtQuestion.val(question);
416426
txtQuestion.prop('disabled', false);
417427
}

demo/v2-demo/scripts/utils.js

+16-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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="InteractiveNoQuestion"> Show Q&A </input>
88
<span class="checkmark"></span></div>
99
</label>
1010
<label class="radioContainer">

0 commit comments

Comments
 (0)