Skip to content

Commit b9caffc

Browse files
committed
Merged PR 3731: live sample small fixes.
live sample small fixes.
1 parent 43f023b commit b9caffc

12 files changed

+99
-23
lines changed

demo/v2-demo/report.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
entityType = EntityType.Dashboard;
3838
} else if (entityTypeUrlParam == "tile") {
3939
entityType = EntityType.Tile;
40+
}
41+
else if (entityTypeUrlParam == "visual") {
42+
entityType = EntityType.Visual;
4043
} else {
4144
entityType = EntityType.Report;
4245
}

demo/v2-demo/scripts/codesamples.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,4 +1289,28 @@ function _Qna_QuestionChanged() {
12891289
qna.on("visualRendered", function(event) {
12901290
Log.log(event.detail);
12911291
});
1292+
}
1293+
1294+
// ---- Visual Events Listener ----------------------------------------------------
1295+
1296+
function _Visual_DataSelected() {
1297+
// Get a reference to the embedded visual HTML element
1298+
var visualContainer = $('#visualContainer')[0];
1299+
1300+
// Get a reference to the embedded visual.
1301+
visual = powerbi.get(visualContainer);
1302+
1303+
// Visual.off removes a given event listener if it exists.
1304+
visual.off("dataSelected");
1305+
1306+
// Visual.on will add an event listener.
1307+
visual.on("dataSelected", function(event) {
1308+
var data = event.detail;
1309+
Log.log(data);
1310+
});
1311+
1312+
// Select Run and select an element of a visualization.
1313+
// For example, a bar in a bar chart. You should see an entry in the Log window.
1314+
1315+
Log.logText("Select data to see events in Log window.");
12921316
}

demo/v2-demo/scripts/function_mapping.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function IsNotSupported(funcName) {
4848
return false
4949
}
5050

51-
const dashboardOrTileOrQnaMatch = funcName.match(/Dashboard|Tile|Qna/);
52-
if (dashboardOrTileOrQnaMatch) {
51+
const notReportMatch = funcName.match(/Dashboard|Tile|Qna|Visual/);
52+
if (notReportMatch) {
5353
return false;
5454
}
5555

@@ -60,12 +60,12 @@ function IsNotSupported(funcName) {
6060
return false;
6161
}
6262

63-
var runFunc = mockDict[funcName];
63+
var runFunc = mockDict[funcName];
6464
return (runFunc && runFunc === datasetNotSupported) ? true : false;
6565
}
6666

6767
function IsMock(funcName) {
68-
return (IsBasicMock(funcName) || IsSaveMock(funcName) || IsCreateMock(funcName) || IsNotSupported(funcName));
68+
return (IsBasicMock(funcName) || IsSaveMock(funcName) || IsCreateMock(funcName) || IsNotSupported(funcName));
6969
}
7070

7171
function mapFunc(func) {
@@ -75,7 +75,7 @@ function mapFunc(func) {
7575

7676
function getFuncName(func) {
7777
var funcName = func.name;
78-
78+
7979
if (!funcName)
8080
{
8181
// in IE, func.name is invalid method. so, function name should be extracted manually.

demo/v2-demo/scripts/report.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ function OpenInteractStep() {
134134
AddImgToNewOperations();
135135
});
136136
}
137+
else if (entityType == EntityType.Visual)
138+
{
139+
$("#settings").load("settings_interact_visual.html", function() {
140+
SetToggleHandler("visual-operations-div");
141+
LoadCodeArea("#embedCodeDiv", _Visual_DataSelected);
142+
AddImgToNewOperations();
143+
});
144+
}
137145
else
138146
{
139147
$("#settings").load("settings_interact.html", function() {
@@ -265,7 +273,7 @@ function OpenEmbedMode(mode, entityType, tokenType)
265273

266274
if (IsEmbeddingSampleReport())
267275
{
268-
LoadSampleReportIntoSession().then(function (response) {
276+
LoadSampleVisualIntoSession().then(function (response) {
269277
LoadSettings();
270278
});
271279
}

demo/v2-demo/scripts/step_authorize.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ function LoadSampleReportIntoSession() {
130130
return FetchUrlIntoSession(reportUrl, false /* updateCurrentToken */);
131131
}
132132

133+
function LoadSampleVisualIntoSession() {
134+
SetSession(SessionKeys.EntityType, EntityType.Visual);
135+
return FetchUrlIntoSession(reportUrl, false /* updateCurrentToken */);
136+
}
137+
133138
function LoadSampleDatasetIntoSession() {
134139
SetSession(SessionKeys.EntityType, EntityType.Report);
135140
return FetchUrlIntoSession(datasetUrl, false /* updateCurrentToken */);

demo/v2-demo/scripts/step_embed.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ function Qna_SetQuestion() {
144144
function Qna_QuestionChanged() {
145145
SetCode(_Qna_QuestionChanged);
146146
}
147+
148+
// ---- Visual Events Listener ----------------------------------------------------
149+
150+
function Visual_DataSelected() {
151+
SetCode(_Visual_DataSelected);
152+
}

demo/v2-demo/scripts/step_interact.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ function OpenReportOperations() {
88
$('#page-operations-li').removeClass('active');
99
$('#events-operations-li').removeClass('active');
1010
$('#editandsave-operations-li').removeClass('active');
11-
11+
1212
$("#report-operations-div .function-ul li.active").click()
13-
$("#selected-catogory-button").html("Report operations");
13+
$("#selected-catogory-button").text("Report operations");
1414
}
1515

1616
function OpenPageOperations() {
@@ -26,7 +26,7 @@ function OpenPageOperations() {
2626

2727
$("#page-operations-div .function-ul li.active").click();
2828

29-
$("#selected-catogory-button").html("Page operations");
29+
$("#selected-catogory-button").text("Page operations");
3030
}
3131

3232
function OpenEventOperations() {
@@ -42,7 +42,7 @@ function OpenEventOperations() {
4242

4343
$("#events-operations-div .function-ul li.active").click();
4444

45-
$("#selected-catogory-button").html("Events Listener");
45+
$("#selected-catogory-button").text("Events Listener");
4646
}
4747

4848
function OpenEditAndSaveOperations() {
@@ -55,26 +55,34 @@ function OpenEditAndSaveOperations() {
5555
$('#report-operations-li').removeClass('active');
5656
$('#events-operations-li').removeClass('active');
5757
$('#editandsave-operations-li').addClass('active');
58-
58+
5959
$("#editandsave-operations-div .function-ul li.active").click();
6060

61-
$("#selected-catogory-button").html("Edit and save operations");
61+
$("#selected-catogory-button").text("Edit and save operations");
6262
}
6363

6464
function OpenTileOperations() {
6565
$("#tile-operations-div").show();
6666
$("#tile-operations-li").addClass('active');
67-
67+
6868
$("#tile-operations-div .function-ul li.active").click()
69-
$("#selected-catogory-button").html("Tile operations");
69+
$("#selected-catogory-button").text("Tile operations");
7070
}
7171

7272
function OpenQnaOperations() {
7373
$("#qna-operations-div").show();
7474
$("#qna-operations-li").addClass('active');
75-
75+
7676
$("#qna-operations-div .function-ul li.active").click()
77-
$("#selected-catogory-button").html("QNA operations");
77+
$("#selected-catogory-button").text("QNA operations");
78+
}
79+
80+
function OpenVisualOperations() {
81+
$("#visual-operations-div").show();
82+
$("#visual-operations-li").addClass('active');
83+
84+
$("#visual-operations-div .function-ul li.active").click()
85+
$("#selected-catogory-button").text("Visual operations");
7886
}
7987

8088
function OpenDashboardOperations() {
@@ -83,9 +91,9 @@ function OpenDashboardOperations() {
8391

8492
$("#dashboard-operations-li").addClass('active');
8593
$('#dashboard-events-operations-li').removeClass('active');
86-
94+
8795
$("#dashboard-operations-div .function-ul li.active").click()
88-
$("#selected-catogory-button").html("Dashboard operations");
96+
$("#selected-catogory-button").text("Dashboard operations");
8997
}
9098

9199
function OpenDashboardEventOperations() {
@@ -96,7 +104,7 @@ function OpenDashboardEventOperations() {
96104
$('#dashboard-events-operations-li').addClass('active');
97105

98106
$("#dashboard-events-operations-div .function-ul li.active").click();
99-
$("#selected-catogory-button").html("Events Listener");
107+
$("#selected-catogory-button").text("Events Listener");
100108
}
101109

102110
function SetToggleHandler(devId) {

demo/v2-demo/settings_embed.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h4>Embed Report</h4>
1414

1515
<div id="typeSelector">
1616
<div onclick="SetEmbedTypeToEmbedToken(1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input></div>
17-
<div onclick="SetEmbedTypeToEmbedToken(0);"><input type="radio" name="tokenType" value="0"> Aad token</input></div>
17+
<div onclick="SetEmbedTypeToEmbedToken(0);"><input type="radio" name="tokenType" value="0"> AAD token</input></div>
1818
</div>
1919

2020
<div class="spacer" />

demo/v2-demo/settings_embed_dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h4>Embed Dashboard</h4>
66

77
<div id="typeSelector">
88
<div onclick="SetSession(SessionKeys.TokenType, 1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input></div>
9-
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0">Aad token</input></div>
9+
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0">AAD token</input></div>
1010
</div>
1111
<div id="embedModeInput">
1212
<h8>Fill in the fields below to get the code to embed your dashboard.</h8>

demo/v2-demo/settings_embed_tile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h4>Embed Tile</h4>
66

77
<div id="typeSelector">
88
<div onclick="SetSession(SessionKeys.TokenType, 1);"><input type="radio" name="tokenType" value="1" checked="checked"> Embed token </input></div>
9-
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0"> Aad token </input></div>
9+
<div onclick="SetSession(SessionKeys.TokenType, 0);"><input type="radio" name="tokenType" value="0"> AAD token </input></div>
1010
</div>
1111
<div id="embedModeInput">
1212
<h8>Fill in the fields below to get the code to embed your tile.</h8>

0 commit comments

Comments
 (0)