Skip to content

Add pageView to loadDashboardConfiguration - #95

Merged
Noa (noanu) merged 1 commit into
devfrom
add_pageview_to_dashboard_embed_configuration
Nov 14, 2016
Merged

Noa (noanu) merged 1 commit into
devfrom
add_pageview_to_dashboard_embed_configuration

Conversation

@noanu

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/dashboard.ts
validate(config: models.IDashboardLoadConfiguration): models.IError[] {
return models.validateDashboardLoad(config);
let error = models.validateDashboardLoad(config);
return error ? error : this.ValidatePageView(config.pageView);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can do
error || this.validate....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will return false or true like this - won't it? I want to return the error itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "error" variable isn't boolean...

Comment thread src/dashboard.ts
validate(config: models.IDashboardLoadConfiguration): models.IError[] {
return models.validateDashboardLoad(config);
let error = models.validateDashboardLoad(config);
return error ? error : this.ValidatePageView(config.pageView);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't ValidatePageView part of validateDashboardLoad?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateDashboardLoad is auto generated in the powerbi-models project...

Comment thread src/dashboard.ts
/**
* Validate that pageView has a legal value: if page view is defined it must have one of the values defined in models.PageView
*/
private ValidatePageView(pageView: models.PageView): models.IError[] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there any utility class (in TS) existing or new one we can write for verifying whether a value is a valid among all the available values in an emun?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a short investigation - I am not familiar with such a class and don't know of a way to create one (this is a string enum, it is not a regular enum).
I will add this task to a "code improvements" task I have (that also include the reuse of loadConfiguration in embedConfiguration)

Comment thread test/test.spec.ts
pageView: pageView
};

powerbi.embed(component[0], <any>dashboardEmbedConfig);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems redundant as you embed within try{} catch{}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validate is called only on "load" (not on "embed"). In "reality" - the constructor of embed class assigns "onLoad" to the iframe that calls the "load" function when the iframe is ready. That doesn't happen on tests, so we need to call the embed again - when embeding the second time the code flow doesn't wait for the iframe to be ready and calls the load function.

@noanu
Noa (noanu) merged commit 57208e5 into dev Nov 14, 2016
@noanu
Noa (noanu) deleted the add_pageview_to_dashboard_embed_configuration branch November 27, 2016 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants