-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerBI.razor
44 lines (38 loc) · 1.31 KB
/
PowerBI.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop;
@inject IJSRuntime JSRuntime
<div id="reportContainer" style="width:100%;height:600px;max-width: 2000px"></div>
<button @onclick="SayHello">Say Hello!</button>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
try
{
var reportContainer = "reportContainer";
var accessToken = "TOKEN";
var embedUrl = "https://app.powerbi.com/reportEmbed";
var embedReportId = "YOUR_REPORT_ID";
var jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./assets/powerbiInterop.js");
await JSRuntime.InvokeVoidAsync("showMyPowerBIReport", reportContainer, accessToken, embedUrl, embedReportId);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
private async Task SayHello()
{
try
{
var jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./assets/helloWorld.js");
await JSRuntime.InvokeVoidAsync("helloWorld");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}