From 87b8e34298c94c9cbcb14211676796f8f5e9dee3 Mon Sep 17 00:00:00 2001 From: wenwa Date: Mon, 15 Aug 2016 11:11:46 -0700 Subject: [PATCH 1/2] Initial commit for dashboard embed SDK support --- src/core.ts | 10 ++++++---- src/dashboard.ts | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/dashboard.ts diff --git a/src/core.ts b/src/core.ts index 46040e78..30808481 100644 --- a/src/core.ts +++ b/src/core.ts @@ -18,7 +18,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. @@ -30,7 +31,8 @@ export class PowerBi { private static eventMap = { 'tileClicked': 'tile-click', 'tileLoaded': 'tile-load', - 'reportPageLoaded': 'report-load' + 'reportPageLoaded': 'report-load', + 'dashboardPageLoaded': 'dashboard-load' }; /** @@ -47,7 +49,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 = {}) { @@ -112,7 +114,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; diff --git a/src/dashboard.ts b/src/dashboard.ts new file mode 100644 index 00000000..d38d59a2 --- /dev/null +++ b/src/dashboard.ts @@ -0,0 +1,23 @@ +import { Embed, IEmbedOptions, ILoadMessage } from './embed'; + +export interface IDashboardLoadMessage extends ILoadMessage { + reportId: 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); + } +} \ No newline at end of file From 60c77b1f347c7fa7d2885c19e2cea4666c4548eb Mon Sep 17 00:00:00 2001 From: wenwa Date: Mon, 15 Aug 2016 11:35:00 -0700 Subject: [PATCH 2/2] Fixed Sdks --- src/core.ts | 1 + src/dashboard.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index 30808481..40080a1d 100644 --- a/src/core.ts +++ b/src/core.ts @@ -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'; diff --git a/src/dashboard.ts b/src/dashboard.ts index d38d59a2..7c437e7d 100644 --- a/src/dashboard.ts +++ b/src/dashboard.ts @@ -1,7 +1,7 @@ import { Embed, IEmbedOptions, ILoadMessage } from './embed'; export interface IDashboardLoadMessage extends ILoadMessage { - reportId: string + dashboardId: string } export class Dashboard extends Embed {