-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpart.ts
104 lines (93 loc) · 2.91 KB
/
webpart.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { Version } from '@microsoft/sp-core-library';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';
import styles from './HyperSdkWebPart.module.scss';
import * as strings from 'HyperSdkWebPartStrings';
export interface IHyperSdkWebPartProps {
sdk_url: string;
library_url: string;
authmode: string;
login: string;
password: string;
}
export default class HyperSdkWebPart extends BaseClientSideWebPart<IHyperSdkWebPartProps> {
public render(): void {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = this.properties.sdk_url;
document.body.appendChild(script);
var script_start = document.createElement('script');
script.onload = () => {
script_start.innerText = `
mstrHyper.start({
server: "${this.properties.library_url}",
authMode: ${this.properties.authmode},
});`;
if (this.properties.authmode === "16" || this.properties.authmode === "1") {
script_start.innerText += `
mstrHyper.login({
authMode: ${this.properties.authmode},
credential: {
username: "${this.properties.login}",
password: "${this.properties.password}"
}
});`;
} else {
script_start.innerText += `
mstrHyper.login({
authMode: ${this.properties.authmode},
});
`;
}
document.body.appendChild(script_start);
};
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected get disableReactivePropertyChanges(): boolean {
return true;
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('sdk_url', {
label: strings.HyperSDKURL,
value: "https://tutorial.microstrategy.com/hypersdk/js/mstr_hyper.bundle.js"
}),
PropertyPaneTextField('library_url', {
label: strings.LibraryURL,
value: "https://demo.microstrategy.com/MicroStrategyLibrary"
}),
PropertyPaneTextField('authmode', {
label: strings.AuthMode,
value: "8"
}),
PropertyPaneTextField('login', {
label: strings.Login,
value: ""
}),
PropertyPaneTextField('password', {
label: strings.Password,
value: ""
})
]
}
]
}
]
};
}
}