Skip to content

Instantly share code, notes, and snippets.

View krishnaanaril's full-sized avatar
🎯
Focusing

Krishna Mohan krishnaanaril

🎯
Focusing
View GitHub Profile
@krishnaanaril
krishnaanaril / test.runsettings
Created July 4, 2019 09:13
Configuration for excluding dlls from unit test
<ModulePaths>
<Exclude>
<ModulePath>.*Moq.dll</ModulePath>
<ModulePath>.*GenFu.dll</ModulePath>
</Exclude>
</ModulePaths>
@krishnaanaril
krishnaanaril / DotnetCore.cmd
Created July 2, 2019 13:48
Dotnet core test command to generate the code coverage report.
dotnet test <Path to *.csproj file> --results-directory:<Test Result directory> --collect:"Code Coverage"
@krishnaanaril
krishnaanaril / user-data-embedPowerBITile.ts
Last active October 5, 2018 11:42
Embed Power BI tile for organization
getToken() {
this.adalSrv.context.acquireToken(environment.powerBIEndpoint, (error, token) => {
if (error || !token) {
// TODO: Handle error obtaining access token
console.error('ERROR:\n\n' + error);
return;
}
// Get available dashboards
this.adalSrv.getDashboardsInGroup(environment.groupId).pipe(mergeMap((res, ind) => {
// select the first among the available dashboards
@krishnaanaril
krishnaanaril / user-data-embedPowerBIReport.ts
Created October 5, 2018 11:40
Embed Power BI reports for organization
getToken() {
this.adalSrv.context.acquireToken(environment.powerBIEndpoint, (error, token) => {
if (error || !token) {
// TODO: Handle error obtaining access token
console.error('ERROR:\n\n' + error);
return;
}
//Get available reports in the group
this.adalSrv.getReportsInGroup(environment.groupId).subscribe(res=>{
// select the first report among it.
@krishnaanaril
krishnaanaril / user-data-embedPowerBIDashboard.ts
Last active October 5, 2018 11:41
Embed Power BI dashboard for organization
// get access token
getToken() {
this.adalSrv.context.acquireToken(environment.powerBIEndpoint, (error, token) => {
if (error || !token) {
// TODO: Handle error obtaining access token
console.error('ERROR:\n\n' + error);
return;
}
// Get available dashboards
this.adalSrv.getDashboardsInGroup(environment.groupId).subscribe(res=>{
@krishnaanaril
krishnaanaril / getTilesInGroup.ts
Created October 5, 2018 10:29
Calling Power BI API to get tiles in group
public getTilesInGroup(groupId: string, dashboardKey: string){
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._context.getCachedToken(environment.powerBIEndpoint)}`
});// this._context is the ADAL AuthenticationContext object
return this.http.get(`https://api.powerbi.com/v1.0/myorg/groups/${groupId}/dashboards/${dashboardKey}/tiles`, { headers: headers });
}
@krishnaanaril
krishnaanaril / getDashboardsInGroup.ts
Created October 5, 2018 10:27
Calling Power BI API to get dashboards in group
public getDashboardsInGroup(groupId: string){
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._context.getCachedToken(environment.powerBIEndpoint)}`
});// this._context is the ADAL AuthenticationContext object
return this.http.get(`https://api.powerbi.com/v1.0/myorg/groups/${groupId}/dashboards`, { headers: headers });
}
@krishnaanaril
krishnaanaril / environment.ts
Last active October 5, 2018 10:26
Angular environment settings for configuring Azure ADAL
export const environment = {
production: false,
apiEndPoint: "", // api endpoint for generationg embed tokens (for app-owns-data)
powerBIEndpoint: "https://analysis.windows.net/powerbi/api",
groupId: "", // similar to workspace id
adalConfig: {
tenant: '', //tenant id of your organization
clientId: '', // client id of your azure ad application
cacheLocation: 'localStorage', // Default is sessionStorage
redirectUri:`${window.location.origin}/` ,
@krishnaanaril
krishnaanaril / Web.config
Created October 5, 2018 10:21
Web.config settings for the API that generates embed tokens
<!--Id of the Azure AD application-->
<add key="applicationId" value="" />
<!--Id of the workspace where your reports reside-->
<add key="workspaceId" value="" />
<!-- The id of the report to embed. If empty, will use the first report in group -->
<add key="reportId" value="" />
<add key="authorityUrl" value="https://login.windows.net/common/oauth2/authorize/" />
<add key="resourceUrl" value="https://analysis.windows.net/powerbi/api" />
@krishnaanaril
krishnaanaril / getReportsInGroup.ts
Created October 5, 2018 10:17
Calling Power BI API to get reports in group
public getReportsInGroup(groupId: string){
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._context.getCachedToken(environment.powerBIEndpoint)}`
}); // this._context is the ADAL AuthenticationContext object
return this.http.get(`https://api.powerbi.com/v1.0/myorg/groups/${groupId}/reports`, { headers: headers });
}