@@ -58,7 +58,7 @@ function _Embed_BasicEmbed() {
58
58
59
59
report . on ( "error" , function ( event ) {
60
60
Log . log ( event . detail ) ;
61
-
61
+
62
62
report . off ( "error" ) ;
63
63
} ) ;
64
64
@@ -71,6 +71,63 @@ function _Embed_BasicEmbed() {
71
71
} ) ;
72
72
}
73
73
74
+ function _Embed_VisualEmbed ( ) {
75
+ // Read embed application token from textbox
76
+ var txtAccessToken = $ ( '#txtAccessToken' ) . val ( ) ;
77
+
78
+ // Read embed URL from textbox
79
+ var txtEmbedUrl = $ ( '#txtReportEmbed' ) . val ( ) ;
80
+
81
+ // Read report Id from textbox
82
+ var txtReportId = $ ( '#txtEmbedReportId' ) . val ( ) ;
83
+
84
+ // Read page name from textbox
85
+ var txtPageName = $ ( '#txtPageName' ) . val ( ) ;
86
+
87
+ // Read visual name from textbox
88
+ var txtVisualName = $ ( '#txtVisualName' ) . val ( ) ;
89
+
90
+ // Read embed type from radio
91
+ var tokenType = $ ( 'input:radio[name=tokenType]:checked' ) . val ( ) ;
92
+
93
+ // Get models. models contains enums that can be used.
94
+ var models = window [ 'powerbi-client' ] . models ;
95
+
96
+ // Embed configuration used to describe the what and how to embed.
97
+ // This object is used when calling powerbi.embed.
98
+ // This also includes settings and options such as filters.
99
+ // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
100
+ var config = {
101
+ type : 'visual' ,
102
+ tokenType : tokenType == '0' ? models . TokenType . Aad : models . TokenType . Embed ,
103
+ accessToken : txtAccessToken ,
104
+ embedUrl : txtEmbedUrl ,
105
+ id : txtReportId ,
106
+ pageName : txtPageName ,
107
+ visualName : txtVisualName
108
+ } ;
109
+
110
+ // Get a reference to the embedded report HTML element
111
+ var embedContainer = $ ( '#visualContainer' ) [ 0 ] ;
112
+
113
+ // Embed the report and display it within the div container.
114
+ var report = powerbi . embed ( embedContainer , config ) ;
115
+
116
+ // Report.off removes a given event handler if it exists.
117
+ report . off ( "loaded" ) ;
118
+
119
+ // Report.on will add an event handler which prints to Log window.
120
+ report . on ( "loaded" , function ( ) {
121
+ Log . logText ( "Loaded" ) ;
122
+ } ) ;
123
+
124
+ report . on ( "error" , function ( event ) {
125
+ Log . log ( event . detail ) ;
126
+
127
+ report . off ( "error" ) ;
128
+ } ) ;
129
+ }
130
+
74
131
function _Embed_DashboardEmbed ( ) {
75
132
// Read embed application token from textbox
76
133
var txtAccessToken = $ ( '#txtAccessToken' ) . val ( ) ;
@@ -115,7 +172,7 @@ function _Embed_DashboardEmbed() {
115
172
116
173
dashboard . on ( "error" , function ( event ) {
117
174
Log . log ( event . detail ) ;
118
-
175
+
119
176
dashboard . off ( "error" ) ;
120
177
} ) ;
121
178
@@ -269,7 +326,7 @@ function _Embed_EmbedWithDefaultFilter() {
269
326
var txtAccessToken = $ ( '#txtAccessToken' ) . val ( ) ;
270
327
var txtEmbedUrl = $ ( '#txtReportEmbed' ) . val ( ) ;
271
328
var txtEmbedReportId = $ ( '#txtEmbedReportId' ) . val ( ) ;
272
-
329
+
273
330
// Get models. models contains enums that can be used.
274
331
var models = window [ 'powerbi-client' ] . models ;
275
332
@@ -282,7 +339,7 @@ function _Embed_EmbedWithDefaultFilter() {
282
339
operator : "In" ,
283
340
values : [ "Lindseys" ]
284
341
} ;
285
-
342
+
286
343
var embedConfiguration = {
287
344
type : 'report' ,
288
345
tokenType : models . TokenType . Embed ,
@@ -295,7 +352,7 @@ function _Embed_EmbedWithDefaultFilter() {
295
352
} ,
296
353
filters : [ filter ]
297
354
} ;
298
-
355
+
299
356
var embedContainer = document . getElementById ( 'embedContainer' ) ;
300
357
powerbi . embed ( embedContainer , embedConfiguration ) ;
301
358
}
@@ -368,7 +425,7 @@ function _Embed_Create() {
368
425
369
426
// Read embed type from radio
370
427
var tokenType = $ ( 'input:radio[name=tokenType]:checked' ) . val ( ) ;
371
-
428
+
372
429
// Get models. models contains enums that can be used.
373
430
var models = window [ 'powerbi-client' ] . models ;
374
431
@@ -380,7 +437,7 @@ function _Embed_Create() {
380
437
embedUrl : txtEmbedUrl ,
381
438
datasetId : txtEmbedDatasetId ,
382
439
} ;
383
-
440
+
384
441
// Grab the reference to the div HTML element that will host the report
385
442
var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
386
443
@@ -420,7 +477,7 @@ function _Mock_Embed_Create() {
420
477
421
478
// Read embed type from radio
422
479
var tokenType = $ ( 'input:radio[name=tokenType]:checked' ) . val ( ) ;
423
-
480
+
424
481
// Get models. models contains enums that can be used.
425
482
var models = window [ 'powerbi-client' ] . models ;
426
483
@@ -435,7 +492,7 @@ function _Mock_Embed_Create() {
435
492
useCustomSaveAsDialog : true
436
493
}
437
494
} ;
438
-
495
+
439
496
// Grab the reference to the div HTML element that will host the report
440
497
var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
441
498
@@ -554,7 +611,7 @@ function _Report_GetPages() {
554
611
// Get a reference to the embedded report.
555
612
report = powerbi . get ( embedContainer ) ;
556
613
557
- // Retrieve the page collection and loop through to collect the
614
+ // Retrieve the page collection and loop through to collect the
558
615
// page name and display name of each page and display the value.
559
616
report . getPages ( )
560
617
. then ( function ( pages ) {
@@ -588,7 +645,7 @@ function _Report_SetPage() {
588
645
// Report.off removes a given event handler if it exists.
589
646
report . off ( "pageChanged" ) ;
590
647
591
- // Report.on will add an event handler which prints page
648
+ // Report.on will add an event handler which prints page
592
649
// name and display name to Log window.
593
650
report . on ( "pageChanged" , function ( event ) {
594
651
var page = event . detail . newPage ;
@@ -602,7 +659,7 @@ function _Report_GetFilters() {
602
659
603
660
// Get a reference to the embedded report.
604
661
report = powerbi . get ( embedContainer ) ;
605
-
662
+
606
663
// Get the filters applied to the report.
607
664
report . getFilters ( )
608
665
. then ( function ( filters ) {
@@ -631,7 +688,7 @@ function _Report_SetFilters() {
631
688
632
689
// Get a reference to the embedded report.
633
690
report = powerbi . get ( embedContainer ) ;
634
-
691
+
635
692
// Set the filter for the report.
636
693
// Pay attention that setFilters receives an array.
637
694
report . setFilters ( [ filter ] )
@@ -776,7 +833,7 @@ function _Report_saveAs() {
776
833
777
834
// Get a reference to the embedded report.
778
835
report = powerbi . get ( embedContainer ) ;
779
-
836
+
780
837
var saveAsParameters = {
781
838
name : "newReport"
782
839
} ;
@@ -892,7 +949,7 @@ function _Page_SetActive() {
892
949
893
950
// Get a reference to the embedded report.
894
951
report = powerbi . get ( embedContainer ) ;
895
-
952
+
896
953
// Retrieve the page collection, and then set the second page to be active.
897
954
report . getPages ( )
898
955
. then ( function ( pages ) {
@@ -911,7 +968,7 @@ function _Page_GetFilters() {
911
968
912
969
// Get a reference to the embedded report.
913
970
report = powerbi . get ( embedContainer ) ;
914
-
971
+
915
972
// Retrieve the page collection and get the filters for the first page.
916
973
report . getPages ( )
917
974
. then ( function ( pages ) {
@@ -976,7 +1033,7 @@ function _Page_SetFilters() {
976
1033
// Get a reference to the embedded report.
977
1034
report = powerbi . get ( embedContainer ) ;
978
1035
979
- // Build the filter you want to use. For more information, see Constructing
1036
+ // Build the filter you want to use. For more information, see Constructing
980
1037
// Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters.
981
1038
const filter = {
982
1039
$schema : "http://powerbi.com/product/schema#basic" ,
@@ -1016,7 +1073,7 @@ function _Page_RemoveFilters() {
1016
1073
1017
1074
// Get a reference to the embedded report.
1018
1075
report = powerbi . get ( embedContainer ) ;
1019
-
1076
+
1020
1077
// Retrieve the page collection and remove the filters for the first page.
1021
1078
report . getPages ( )
1022
1079
. then ( function ( pages ) {
@@ -1165,7 +1222,7 @@ function _DashboardEvents_TileClicked() {
1165
1222
function _Qna_SetQuestion ( ) {
1166
1223
// Get a reference to the embedded Q&A HTML element
1167
1224
var qnaContainer = $ ( '#qnaContainer' ) [ 0 ] ;
1168
-
1225
+
1169
1226
// Get a reference to the embedded Q&A.
1170
1227
qna = powerbi . get ( qnaContainer ) ;
1171
1228
@@ -1181,7 +1238,7 @@ function _Qna_SetQuestion() {
1181
1238
function _Qna_QuestionChanged ( ) {
1182
1239
// Get a reference to the embedded Q&A HTML element
1183
1240
var qnaContainer = $ ( '#qnaContainer' ) [ 0 ] ;
1184
-
1241
+
1185
1242
// Get a reference to the embedded Q&A.
1186
1243
qna = powerbi . get ( qnaContainer ) ;
1187
1244
0 commit comments