@@ -415,6 +415,102 @@ function _Mock_Embed_BasicEmbed_ViewMode() {
415415 _Mock_Embed_BasicEmbed ( false ) ;
416416}
417417
418+ function _Mock_Embed_BasicEmbed_ViewMode_With_Filters ( ) {
419+ var filters = [
420+ {
421+ "$schema" : "http://powerbi.com/product/schema#basic" ,
422+ "target" : {
423+ "table" : "Date" ,
424+ "column" : "Year"
425+ } ,
426+ "filterType" : 1 ,
427+ "operator" : "In" ,
428+ "values" : [
429+ 2014
430+ ]
431+ }
432+ ] ;
433+
434+ // Read embed application token from textbox
435+ var txtAccessToken = $ ( '#txtAccessToken' ) . val ( ) ;
436+
437+ // Read embed URL from textbox
438+ var txtEmbedUrl = $ ( '#txtReportEmbed' ) . val ( ) ;
439+
440+ // Read report Id from textbox
441+ var txtEmbedReportId = $ ( '#txtEmbedReportId' ) . val ( ) ;
442+
443+ // Read embed type from radio
444+ var tokenType = $ ( 'input:radio[name=tokenType]:checked' ) . val ( ) ;
445+
446+ // Get models. models contains enums that can be used.
447+ var models = window [ 'powerbi-client' ] . models ;
448+ var permissions = models . Permissions . All ;
449+ var viewMode = models . ViewMode . View ;
450+
451+ // Embed configuration used to describe the what and how to embed.
452+ // This object is used when calling powerbi.embed.
453+ // This also includes settings and options such as filters.
454+ // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
455+ var config = {
456+ type : 'report' ,
457+ tokenType : tokenType == '0' ? models . TokenType . Aad : models . TokenType . Embed ,
458+ accessToken : txtAccessToken ,
459+ embedUrl : txtEmbedUrl ,
460+ id : txtEmbedReportId ,
461+ permissions : permissions ,
462+ viewMode : viewMode ,
463+ settings : {
464+ filterPaneEnabled : true ,
465+ navContentPaneEnabled : true ,
466+ useCustomSaveAsDialog : true
467+ } ,
468+ filters : filters
469+ } ;
470+
471+ // Get a reference to the embedded report HTML element
472+ var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
473+
474+ powerbi . reset ( embedContainer ) ;
475+
476+ // Embed the report and display it within the div container.
477+ var report = powerbi . embed ( embedContainer , config ) ;
478+
479+ // Report.off removes a given event handler if it exists.
480+ report . off ( "loaded" ) ;
481+
482+ // Report.on will add an event handler which prints to Log window.
483+ report . on ( "loaded" , function ( ) {
484+ Log . logText ( "Loaded" ) ;
485+ } ) ;
486+
487+ // Report.off removes a given event handler if it exists.
488+ report . off ( "rendered" ) ;
489+
490+ // Report.on will add an event handler which prints to Log window.
491+ report . on ( "rendered" , function ( ) {
492+ Log . logText ( "Rendered" ) ;
493+ } ) ;
494+
495+ report . off ( "saveAsTriggered" ) ;
496+ report . on ( "saveAsTriggered" , function ( ) {
497+ Log . logText ( "Cannot save sample report" ) ;
498+ } ) ;
499+
500+ report . off ( "error" ) ;
501+ report . on ( "error" , function ( event ) {
502+ Log . log ( event . detail ) ;
503+ } ) ;
504+
505+ report . off ( "saved" ) ;
506+ report . on ( "saved" , function ( event ) {
507+ Log . log ( event . detail ) ;
508+ if ( event . detail . saveAs ) {
509+ Log . logText ( 'In order to interact with the new report, create a new token and load the new report' ) ;
510+ }
511+ } ) ;
512+ }
513+
418514function _Embed_BasicEmbed_EditMode ( ) {
419515 // Read embed application token from textbox
420516 var txtAccessToken = $ ( '#txtAccessToken' ) . val ( ) ;
0 commit comments