forked from microsoft/PowerBI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqna.ts
57 lines (50 loc) · 1.55 KB
/
qna.ts
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
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as service from './service';
import * as models from 'powerbi-models';
import * as embed from './embed';
import * as utils from './util';
/**
* The Power BI Qna embed component
*
* @export
* @class Qna
* @extends {Embed}
*/
export class Qna extends embed.Embed {
static type = "Qna";
static allowedEvents = ["loaded", "visualRendered"];
constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean) {
super(service, element, config, /* iframe */ undefined, phasedRender);
this.loadPath = "/qna/load";
this.phasedLoadPath = "/qna/prepare";
Array.prototype.push.apply(this.allowedEvents, Qna.allowedEvents);
}
/**
* The ID of the Qna embed component
*
* @returns {string}
*/
getId(): string {
return null;
}
/**
* Change the question of the Q&A embed component
*
* @param question - question which will render Q&A data
* @returns {string}
*/
setQuestion(question: string): Promise<void> {
const qnaData: models.IQnaInterpretInputData = {
question: question
};
return this.service.hpm.post<models.IError[]>('/qna/interpret', qnaData, { uid: this.config.uniqueId }, this.iframe.contentWindow)
.catch(response => {
throw response.body;
});
}
/**
* Validate load configuration.
*/
validate(config: embed.IEmbedConfigurationBase): models.IError[] {
return models.validateLoadQnaConfiguration(config);
}
}