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
import { Injectable } from '@angular/core'; | |
import { HttpClient, HttpHeaders } from '@angular/common/http'; | |
import { Observable, Subscriber, of } from 'rxjs'; | |
import { switchMap, map } from 'rxjs/operators'; | |
import { RequestOptions } from '@angular/http'; | |
import { adal } from 'adal-angular'; | |
import * as AuthenticationContext from 'adal-angular/lib/adal' | |
import { environment } from '../../environments/environment'; |
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
embedPowerBITile() { | |
this.service.getTileEmbedToken().subscribe((res) => { | |
let response = res.json(); | |
let Token = response.EmbedToken; | |
const config = { | |
type: 'tile', | |
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
embedPowerBIReport() { | |
this.service.getReportEmbedToken().subscribe((res) => { | |
let response = res.json(); | |
let Token = response.EmbedToken; | |
const config = { | |
type: 'report', | |
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
import { Component, OnInit } from '@angular/core'; | |
import * as pbi from 'powerbi-client'; | |
@Component({ | |
selector: 'app-dashboard', | |
templateUrl: './dashboard.component.html', | |
styleUrls: ['./dashboard.component.less'] | |
}) | |
export class DashboardComponent implements OnInit { | |
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' | |
); |
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
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
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
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
getReportEmbedToken(): Observable<any> { | |
let apiUrl = environment.apiEndPoint + "/api/values/getReportEmbedToken?username=&roles="; | |
return this.http.get(apiUrl) | |
.pipe( | |
catchError(this.handleError) | |
); | |
} |