UNPKG

@nibo-ai/ngx-powerbi

Version:

TypeScript library for embedding Power BI assets (reports/dashboards/tiles) in your application. This TypeScript library is built on top of the official powerbi-client library provided by Microsoft.

2 lines 4.21 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("powerbi-client"),require("powerbi-models")):"function"==typeof define&&define.amd?define("@nibo-ai/ngx-powerbi",["exports","@angular/core","powerbi-client","powerbi-models"],t):t(((e=e||self)["nibo-ai"]=e["nibo-ai"]||{},e["nibo-ai"]["ngx-powerbi"]={}),e.ng.core,e.powerbiClient,e.powerbiModels)}(this,(function(e,t,r,o){"use strict";function i(){return new r.service.Service(r.factories.hpmFactory,r.factories.wpmpFactory,r.factories.routerFactory)}var n=function(){function e(e){this.service=e,this.powerBiCoreService=e||new r.service.Service(r.factories.hpmFactory,r.factories.wpmpFactory,r.factories.routerFactory)}return e.prototype.createReport=function(e,t){return this.powerBiCoreService.createReport(e,t)},e.prototype.embed=function(e,t){return this.powerBiCoreService.embed(e,t)},e.prototype.load=function(e,t){return this.powerBiCoreService.load(e,t)},e.prototype.enableAutoEmbed=function(){return this.powerBiCoreService.enableAutoEmbed()},e.prototype.get=function(e){return this.powerBiCoreService.get(e)},e.prototype.findById=function(e){return this.powerBiCoreService.find(e)},e.prototype.reset=function(e){return this.powerBiCoreService.reset(e)},e.prototype.handleTileEvents=function(e){return this.powerBiCoreService.handleTileEvents(e)},e.prototype.preload=function(e,t){return this.powerBiCoreService.preload(e,t)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root",useFactory:i}]}],e.ctorParameters=function(){return[{type:r.service.Service,decorators:[{type:t.Optional}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:i,token:e,providedIn:"root"}),e}();var p=function(){function e(e){this.ngxPowerBiService=e,this.embedded=new t.EventEmitter,this.powerBiService=e}return e.prototype.ngAfterViewInit=function(){this.ngxPowerBiIFrameRef.nativeElement&&this.validateRequiredAttributes()&&this.embed(this.ngxPowerBiIFrameRef.nativeElement,this.getConfig())},e.prototype.ngOnChanges=function(e){if(this.ngxPowerBiIFrameRef){var t=e.accessToken,r=e.tokenType,o=e.embedUrl,i=e.id,n=e.type,p=e.name,s=e.options;if(this.validateRequiredAttributes()){var c=this.getConfig(t&&t.currentValue,r&&r.currentValue,o&&o.currentValue,i&&i.currentValue,n&&n.currentValue,p&&p.currentValue,s&&s.currentValue);this.embed(this.ngxPowerBiIFrameRef.nativeElement,c)}else this.component&&this.reset(this.ngxPowerBiIFrameRef.nativeElement)}},e.prototype.ngOnDestroy=function(){this.component&&this.reset(this.ngxPowerBiIFrameRef.nativeElement)},e.prototype.validateRequiredAttributes=function(){return"string"==typeof this.embedUrl&&this.embedUrl.length>0&&"string"==typeof this.accessToken&&this.accessToken.length>0},e.prototype.getTokenType=function(e){if(!e)return o.TokenType.Aad;switch(e){case"Aad":return o.TokenType.Aad;case"Embed":return o.TokenType.Embed;default:return o.TokenType.Aad}},e.prototype.getConfig=function(e,t,r,o,i,n,p){return{type:i||(this.type?this.type:"Report"),embedUrl:r||this.embedUrl,accessToken:e||this.accessToken,tokenType:t?this.getTokenType(t):this.getTokenType(this.tokenType),id:o||this.id,uniqueId:n||this.name,settings:p||this.options}},e.prototype.embed=function(e,t){this.component=this.powerBiService.embed(e,t),this.embedded.emit(this.component)},e.prototype.reset=function(e){this.powerBiService.reset(e),this.component=null},e.decorators=[{type:t.Component,args:[{selector:"ngx-powerbi-component",template:'<div #ngxPowerBiIFrame style="height:100%; width: 100%;"></div>'}]}],e.ctorParameters=function(){return[{type:n}]},e.propDecorators={accessToken:[{type:t.Input}],tokenType:[{type:t.Input}],embedUrl:[{type:t.Input}],id:[{type:t.Input}],type:[{type:t.Input}],name:[{type:t.Input}],options:[{type:t.Input}],embedded:[{type:t.Output}],ngxPowerBiIFrameRef:[{type:t.ViewChild,args:["ngxPowerBiIFrame",{static:!0}]}]},e}();var s=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[],declarations:[p],exports:[p]}]}],e}();e.NgxPowerBiComponent=p,e.NgxPowerBiModule=s,e.NgxPowerBiService=n,e.powerBiServiceFactory=i,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=nibo-ai-ngx-powerbi.umd.min.js.map