This file contains hidden or 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
canActivate() { | |
if ( this.authService.isLoggedIn() ) { | |
return true; | |
} | |
this.router.navigate(['/']); | |
return false; | |
} |
This file contains hidden or 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
public class EmbedConfig | |
{ | |
public string Id { get; set; } | |
public string EmbedUrl { get; set; } | |
public EmbedToken EmbedToken { get; set; } | |
public int MinutesToExpiration | |
{ |
This file contains hidden or 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
public class ValuesController : ApiController | |
{ | |
private static readonly string Username = ConfigurationManager.AppSettings["pbiUsername"]; | |
private static readonly string Password = ConfigurationManager.AppSettings["pbiPassword"]; | |
private static readonly string AuthorityUrl = ConfigurationManager.AppSettings["authorityUrl"]; | |
private static readonly string ResourceUrl = ConfigurationManager.AppSettings["resourceUrl"]; | |
private static readonly string ApplicationId = ConfigurationManager.AppSettings["ApplicationId"]; | |
private static readonly string ApiUrl = ConfigurationManager.AppSettings["apiUrl"]; | |
private static readonly string WorkspaceId = ConfigurationManager.AppSettings["workspaceId"]; | |
private static readonly string ReportId = ConfigurationManager.AppSettings["reportId"]; |
This file contains hidden or 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
public class TileEmbedConfig : EmbedConfig | |
{ | |
public string dashboardId { get; set; } | |
} |
This file contains hidden or 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
getReportEmbedToken(): Observable<any> { | |
let apiUrl = environment.apiEndPoint + "/api/values/getReportEmbedToken?username=&roles="; | |
return this.http.get(apiUrl) | |
.pipe( | |
catchError(this.handleError) | |
); | |
} |
This file contains hidden or 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
getDashboardEmbedToken(): Observable<any> { | |
let apiUrl = environment.apiEndPoint + "/api/values/getDashboardEmbedToken"; | |
return this.http.get(apiUrl) | |
.pipe( | |
catchError(this.handleError) | |
); | |
} |
This file contains hidden or 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
getTileEmbedToken(): Observable<any> { | |
let apiUrl = environment.apiEndPoint + "/api/values/getTileEmbedToken"; | |
return this.http.get(apiUrl) | |
.pipe( | |
catchError(this.handleError) | |
); | |
} |
This file contains hidden or 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, |
This file contains hidden or 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
setTokenExpirationListener(tokenExpiration, | |
minutesToRefresh = 2){ | |
// get current time | |
var currentTime = Date.now(); | |
var expiration = Date.parse(tokenExpiration); | |
var safetyInterval = minutesToRefresh * 60 * 1000; | |
// time until token refresh in milliseconds | |
var timeout = expiration - currentTime - safetyInterval; |
This file contains hidden or 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
updateToken() { | |
// Generate new EmbedToken | |
this.service.getDashboardEmbedToken() | |
.subscribe((res) => { | |
let Token = res.json(); | |
// Get a reference to the embedded report HTML element | |
var embedDashboard = <HTMLElement>document.getElementById( | |
'embedDashboard' | |
); |
OlderNewer