in src/visual.ts [163:187]
async getVisualDescriptor(): Promise<VisualDescriptor> {
const config = this.config as IVisualEmbedConfiguration;
try {
const response = await this.service.hpm.get<IVisual[]>(`/report/pages/${config.pageName}/visuals`, { uid: this.config.uniqueId }, this.iframe.contentWindow);
// Find the embedded visual from visuals of this page
// TODO: Use the Array.find method when ES6 is available
const embeddedVisuals = response.body.filter((pageVisual) => pageVisual.name === config.visualName);
if (embeddedVisuals.length === 0) {
const visualNotFoundError: IError = {
message: "visualNotFound",
detailedMessage: "Visual not found"
};
throw visualNotFoundError;
}
const embeddedVisual = embeddedVisuals[0];
const currentPage = this.page(config.pageName);
return new VisualDescriptor(currentPage, embeddedVisual.name, embeddedVisual.title, embeddedVisual.type, embeddedVisual.layout);
} catch (response) {
throw response.body;
}
}