Created
October 5, 2018 09:54
-
-
Save krishnaanaril/1020ba7e54dfef79bfbdb4fdec266d4d to your computer and use it in GitHub Desktop.
Embedding Power BI Dashboard for customers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
embedPowerBIDashboard() { | |
this.service.getDashboardEmbedToken().subscribe((res) => { | |
let response = res.json(); | |
let Token = response.EmbedToken; | |
const config = { | |
type: 'dashboard', | |
tokenType: pbi.models.TokenType.Embed, | |
id: response.Id, | |
embedUrl: response.EmbedUrl, | |
accessToken: Token.token, | |
}; | |
// Grab the reference to the div HTML element that will host the report. | |
const dashboardContainer = <HTMLElement>document.getElementById( | |
'embedDashboard' | |
); | |
const report = this.powerbi.embed( | |
dashboardContainer, | |
config | |
); | |
// Report.off removes a given event handler if it exists. | |
report.off('loaded'); | |
// Report.on will add an event handler which prints to Log window. | |
report.on('loaded', (event)=>{ | |
console.log('loaded: '+event); | |
this.setTokenExpirationListener(Token.expiration, | |
2 /*minutes before expiration*/); | |
}) | |
report.on('error', function (event) { | |
console.log(event.detail); | |
report.off('error'); | |
}); | |
}, | |
(error) => { | |
console.log(error); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment