Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Embed, IEmbedConstructor, IEmbedOptions } from './embed';
import { Report } from './report';
import { Dashboard } from './dashboard';
import { Tile } from './tile';
import { Utils } from './util';

Expand All @@ -18,7 +19,8 @@ export class PowerBi {
*/
private static components: IEmbedConstructor[] = [
Tile,
Report
Report,
Dashboard
];
/**
* Mapping of event names from iframe postMessage to their name percieved by parent DOM.
Expand All @@ -30,7 +32,8 @@ export class PowerBi {
private static eventMap = {
'tileClicked': 'tile-click',
'tileLoaded': 'tile-load',
'reportPageLoaded': 'report-load'
'reportPageLoaded': 'report-load',
'dashboardPageLoaded': 'dashboard-load'
};

/**
Expand All @@ -47,7 +50,7 @@ export class PowerBi {
/** Configuration object */
private config: IPowerBiConfiguration;

/** List of components (Reports/Tiles) that have been embedded using this service instance. */
/** List of components (Dashboards/Reports/Tiles) that have been embedded using this service instance. */
private embeds: Embed[];

constructor(config: IPowerBiConfiguration = {}) {
Expand Down Expand Up @@ -112,7 +115,7 @@ export class PowerBi {
}

// TODO: Consider removing in favor of passing reference to `this` in constructor
// The getGlobalAccessToken function is only here so that the components (Tile | Report) can get the global access token without needing reference
// The getGlobalAccessToken function is only here so that the components (Dashboard | Tile | Report) can get the global access token without needing reference
// to the service that they are registered within becaues it creates circular dependencies
config.getGlobalAccessToken = () => this.accessToken;

Expand Down
23 changes: 23 additions & 0 deletions src/dashboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Embed, IEmbedOptions, ILoadMessage } from './embed';

export interface IDashboardLoadMessage extends ILoadMessage {
dashboardId: string
}

export class Dashboard extends Embed {
static name = "Dashboard";

load(options: IEmbedOptions, requireId: boolean = false) {
if(requireId && typeof options.id !== 'string') {
throw new Error(`id must be specified when loading reports on existing elements.`);
}

const message: IDashboardLoadMessage = {
action: 'loadDashboard',
dashboardId: options.id,
accessToken: null
};

super.load(options, requireId, message);
}
}