-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.6.js
43 lines (37 loc) · 1.33 KB
/
main.6.js
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
import { makeSwapData } from './textReplace.6'
import { dashboardConfigs } from './dashboards.6'
const replaceText = () => {
var supportedChartTypes = ["pivot"];
var activeDashboard = prism.activeDashboard.oid;
var widgetConfig = dashboardConfigs[activeDashboard];
function widgetNotSupported(type){
if (supportedChartTypes.indexOf(type)>=0){
return false;
} else{
return true;
}
}
function processWidgets(widgetList){
var widget;
for(widget of widgetList){
let curWidgetEle = prism.activeDashboard.widgets.get(widget.widget_id);
if(curWidgetEle === undefined){
console.error("TextReplace: Cannot find widget: ", widget.widget_id);
}
else if(widgetNotSupported(curWidgetEle.type)){
console.error("TextReplace: Widget type not supported for: ", curWidgetEle.type);
}
else{
curWidgetEle.on('ready',makeSwapData(widget.widget_id,widget.dictionary))
}
}
}
if (widgetConfig === undefined){
//console.error("TextReplace: Dashboard configuration not found")
} else {
processWidgets(widgetConfig);
}
}
prism.on('dashboardloaded',(event, args) =>{
prism.activeDashboard.on('initialized',replaceText)
});