@hpcc-js/ddl-shim 3.3.1 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +43 -43
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/__package__.ts +3 -3
- package/src/cli.ts +60 -60
- package/src/ddl/v0_0_22.ts +344 -344
- package/src/ddl/v1.ts +313 -313
- package/src/ddl/v2.ts +426 -426
- package/src/ddl/v2_0_23.ts +395 -395
- package/src/ddl/v2_1_0.ts +406 -406
- package/src/dermatology.ts +229 -229
- package/src/index.ts +11 -11
- package/src/upgrade.ts +734 -734
- package/src/validate.ts +38 -38
package/src/dermatology.ts
CHANGED
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
import * as DDL2 from "./ddl/v2.ts";
|
|
2
|
-
|
|
3
|
-
const classMappings: any = {
|
|
4
|
-
c3chart_Bar: "chart_Bar",
|
|
5
|
-
c3chart_Column: "chart_Column",
|
|
6
|
-
c3chart_Pie: "chart_Pie",
|
|
7
|
-
c3chart_Area: "chart_Area",
|
|
8
|
-
c3chart_Line: "chart_Line",
|
|
9
|
-
amchart_Bar: "chart_Bar",
|
|
10
|
-
amchart_Column: "chart_Column",
|
|
11
|
-
amchart_Pie: "chart_Pie",
|
|
12
|
-
amchart_Area: "chart_Area",
|
|
13
|
-
amchart_Line: "chart_Line",
|
|
14
|
-
google_Bar: "chart_Bar",
|
|
15
|
-
google_Column: "chart_Column",
|
|
16
|
-
google_Pie: "chart_Pie",
|
|
17
|
-
google_Area: "chart_Area",
|
|
18
|
-
google_Line: "chart_Line",
|
|
19
|
-
other_Table: "dgrid_Table"
|
|
20
|
-
};
|
|
21
|
-
const propertyMappings: any = {
|
|
22
|
-
xAxisLabelRotation: [
|
|
23
|
-
{ name: "xAxisOverlapMode", transform: (n: any) => "rotate" },
|
|
24
|
-
{ name: "xAxisLabelRotation", transform: (n: any) => n }
|
|
25
|
-
],
|
|
26
|
-
tooltipLabelColor: {
|
|
27
|
-
name: "tooltipLabelColor"
|
|
28
|
-
},
|
|
29
|
-
tooltipSeriesColor: {
|
|
30
|
-
name: "tooltipSeriesColor"
|
|
31
|
-
},
|
|
32
|
-
tooltipValueColor: {
|
|
33
|
-
name: "tooltipValueColor"
|
|
34
|
-
},
|
|
35
|
-
tooltipValueFormat: {
|
|
36
|
-
name: "tooltipValueFormat"
|
|
37
|
-
},
|
|
38
|
-
timePattern: {
|
|
39
|
-
name: "xAxisTypeTimePattern"
|
|
40
|
-
},
|
|
41
|
-
smoothLines: {
|
|
42
|
-
name: "interpolate",
|
|
43
|
-
transform: (n: any) => {
|
|
44
|
-
if (n === false) return "linear";
|
|
45
|
-
return "catmullRom";
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
holePercent: {
|
|
49
|
-
name: "innerRadius"
|
|
50
|
-
},
|
|
51
|
-
flip: {
|
|
52
|
-
name: "orientation",
|
|
53
|
-
transform: (n: any) => n ? "vertical" : "horizontal"
|
|
54
|
-
},
|
|
55
|
-
bottomText: {
|
|
56
|
-
name: "xAxisTitle"
|
|
57
|
-
},
|
|
58
|
-
xAxisTypeTimePattern: {
|
|
59
|
-
name: "xAxisTypeTimePattern"
|
|
60
|
-
},
|
|
61
|
-
yAxisTypeTimePattern: {
|
|
62
|
-
name: "yAxisTypeTimePattern"
|
|
63
|
-
},
|
|
64
|
-
valueFormat: {
|
|
65
|
-
name: "tooltipValueFormat"
|
|
66
|
-
},
|
|
67
|
-
stacked: {
|
|
68
|
-
name: "yAxisStacked"
|
|
69
|
-
},
|
|
70
|
-
showYGrid: {
|
|
71
|
-
name: "yAxisGuideLines"
|
|
72
|
-
},
|
|
73
|
-
showXGrid: {
|
|
74
|
-
name: "xAxisGuideLines"
|
|
75
|
-
},
|
|
76
|
-
showValueLabel: {
|
|
77
|
-
name: "showValue"
|
|
78
|
-
},
|
|
79
|
-
low: {
|
|
80
|
-
name: "yAxisDomainLow"
|
|
81
|
-
},
|
|
82
|
-
high: {
|
|
83
|
-
name: "yAxisDomainHigh"
|
|
84
|
-
},
|
|
85
|
-
fillOpacity: {
|
|
86
|
-
name: "interpolateFillOpacity"
|
|
87
|
-
},
|
|
88
|
-
areaFillOpacity: {
|
|
89
|
-
name: "interpolateFillOpacity"
|
|
90
|
-
},
|
|
91
|
-
showToolbar: {
|
|
92
|
-
name: "titleVisible"
|
|
93
|
-
},
|
|
94
|
-
showCSV: {
|
|
95
|
-
name: "downloadButtonVisible"
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
function findKeyVal(object: any, key: any, val: any): any {
|
|
100
|
-
let value;
|
|
101
|
-
|
|
102
|
-
for (const k in object) {
|
|
103
|
-
if (k === key && object[k] === val) {
|
|
104
|
-
value = object;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
if (object[k] && typeof object[k] === "object") {
|
|
108
|
-
value = findKeyVal(object[k], key, val);
|
|
109
|
-
if (value !== undefined) {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function apply_to_dataviews(ddl2: DDL2.Schema, dermObj: any) {
|
|
118
|
-
|
|
119
|
-
ddl2.dataviews.forEach(apply_to_dataview);
|
|
120
|
-
|
|
121
|
-
function apply_to_dataview(dv: any) {
|
|
122
|
-
const widgetId = dv.id;
|
|
123
|
-
const dermPanelObj: any = findKeyVal(dermObj, "__id", widgetId);
|
|
124
|
-
if (dermPanelObj) {
|
|
125
|
-
const dermPanelProps: any = dermPanelObj.__properties;
|
|
126
|
-
const dermWidgetObj: any = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
|
|
127
|
-
const dermWidgetProps: any = dermWidgetObj.__properties;
|
|
128
|
-
apply_class_mapping(dermWidgetObj);
|
|
129
|
-
apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
|
|
130
|
-
apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
|
|
131
|
-
if (dv.visualization.properties.chartType) {
|
|
132
|
-
dv.visualization.properties.charttype = dv.visualization.properties.chartType;
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
console.warn(widgetId + " not found in dermObj");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function apply_class_mapping(dermWidgetObj: any) {
|
|
139
|
-
dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
|
|
140
|
-
dv.visualization.properties.__class = "marshaller_VizChartPanel";
|
|
141
|
-
if (!dv.visualization.properties.widget) dv.visualization.properties.widget = {};
|
|
142
|
-
dv.visualization.properties.widget.__class = dv.visualization.__class;
|
|
143
|
-
|
|
144
|
-
function swap_with_supported_class(_class: string): string {
|
|
145
|
-
return classMappings[_class] ? classMappings[_class] : _class;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function apply_panel_property_mapping(dermPanelProps: any, dermWidgetProps: any) {
|
|
149
|
-
dv.visualization.title = dermPanelProps.title || "";
|
|
150
|
-
dv.visualization.description = "";
|
|
151
|
-
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
152
|
-
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
153
|
-
for (const propName in dermPanelProps) {
|
|
154
|
-
if (typeof propertyMappings[propName] !== "undefined") {
|
|
155
|
-
const newPropName = propertyMappings[propName].name;
|
|
156
|
-
|
|
157
|
-
if (typeof propertyMappings[propName].transform === "function") {
|
|
158
|
-
dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
|
|
159
|
-
} else {
|
|
160
|
-
dv.visualization.properties[newPropName] = dermPanelProps[propName];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
|
|
166
|
-
dv.visualization.properties.legendVisible = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function apply_widget_property_mapping(dermPanelProps: any, dermWidgetProps: any) {
|
|
170
|
-
dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
|
|
171
|
-
dv.visualization.description = ""; // TODO - should this map to anything?
|
|
172
|
-
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
173
|
-
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
174
|
-
for (const propName in dermWidgetProps) {
|
|
175
|
-
if (typeof propertyMappings[propName] !== "undefined") {
|
|
176
|
-
if (propertyMappings[propName] instanceof Array) {
|
|
177
|
-
propertyMappings[propName].forEach((p: any) => {
|
|
178
|
-
const newPropName = p.name;
|
|
179
|
-
dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
|
|
180
|
-
if (typeof propertyMappings[propName].transform === "function") {
|
|
181
|
-
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
182
|
-
} else {
|
|
183
|
-
dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
const newPropName = propertyMappings[propName].name;
|
|
188
|
-
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
type CellPosition = {
|
|
197
|
-
id: string;
|
|
198
|
-
position: [number, number, number, number];
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
type DDLProperties = {
|
|
202
|
-
layout: CellPosition[]
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
function apply_to_properties_layout(ddl2: DDL2.Schema, dermObj: any) {
|
|
206
|
-
const retVal: DDLProperties = {
|
|
207
|
-
layout: []
|
|
208
|
-
};
|
|
209
|
-
if (!dermObj || !dermObj.__properties) return;
|
|
210
|
-
dermObj.__properties.content.forEach((cell: any) => {
|
|
211
|
-
const cellPosition: CellPosition = {
|
|
212
|
-
// TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
|
|
213
|
-
id: cell.__properties.widget.__id,
|
|
214
|
-
position: [
|
|
215
|
-
cell.__properties.gridCol,
|
|
216
|
-
cell.__properties.gridRow,
|
|
217
|
-
cell.__properties.gridColSpan,
|
|
218
|
-
cell.__properties.gridRowSpan
|
|
219
|
-
]
|
|
220
|
-
};
|
|
221
|
-
retVal.layout.push(cellPosition);
|
|
222
|
-
});
|
|
223
|
-
return retVal;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export function upgrade(ddl2: DDL2.Schema, dermObj: any) {
|
|
227
|
-
apply_to_dataviews(ddl2, dermObj);
|
|
228
|
-
return apply_to_properties_layout(ddl2, dermObj);
|
|
229
|
-
}
|
|
1
|
+
import * as DDL2 from "./ddl/v2.ts";
|
|
2
|
+
|
|
3
|
+
const classMappings: any = {
|
|
4
|
+
c3chart_Bar: "chart_Bar",
|
|
5
|
+
c3chart_Column: "chart_Column",
|
|
6
|
+
c3chart_Pie: "chart_Pie",
|
|
7
|
+
c3chart_Area: "chart_Area",
|
|
8
|
+
c3chart_Line: "chart_Line",
|
|
9
|
+
amchart_Bar: "chart_Bar",
|
|
10
|
+
amchart_Column: "chart_Column",
|
|
11
|
+
amchart_Pie: "chart_Pie",
|
|
12
|
+
amchart_Area: "chart_Area",
|
|
13
|
+
amchart_Line: "chart_Line",
|
|
14
|
+
google_Bar: "chart_Bar",
|
|
15
|
+
google_Column: "chart_Column",
|
|
16
|
+
google_Pie: "chart_Pie",
|
|
17
|
+
google_Area: "chart_Area",
|
|
18
|
+
google_Line: "chart_Line",
|
|
19
|
+
other_Table: "dgrid_Table"
|
|
20
|
+
};
|
|
21
|
+
const propertyMappings: any = {
|
|
22
|
+
xAxisLabelRotation: [
|
|
23
|
+
{ name: "xAxisOverlapMode", transform: (n: any) => "rotate" },
|
|
24
|
+
{ name: "xAxisLabelRotation", transform: (n: any) => n }
|
|
25
|
+
],
|
|
26
|
+
tooltipLabelColor: {
|
|
27
|
+
name: "tooltipLabelColor"
|
|
28
|
+
},
|
|
29
|
+
tooltipSeriesColor: {
|
|
30
|
+
name: "tooltipSeriesColor"
|
|
31
|
+
},
|
|
32
|
+
tooltipValueColor: {
|
|
33
|
+
name: "tooltipValueColor"
|
|
34
|
+
},
|
|
35
|
+
tooltipValueFormat: {
|
|
36
|
+
name: "tooltipValueFormat"
|
|
37
|
+
},
|
|
38
|
+
timePattern: {
|
|
39
|
+
name: "xAxisTypeTimePattern"
|
|
40
|
+
},
|
|
41
|
+
smoothLines: {
|
|
42
|
+
name: "interpolate",
|
|
43
|
+
transform: (n: any) => {
|
|
44
|
+
if (n === false) return "linear";
|
|
45
|
+
return "catmullRom";
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
holePercent: {
|
|
49
|
+
name: "innerRadius"
|
|
50
|
+
},
|
|
51
|
+
flip: {
|
|
52
|
+
name: "orientation",
|
|
53
|
+
transform: (n: any) => n ? "vertical" : "horizontal"
|
|
54
|
+
},
|
|
55
|
+
bottomText: {
|
|
56
|
+
name: "xAxisTitle"
|
|
57
|
+
},
|
|
58
|
+
xAxisTypeTimePattern: {
|
|
59
|
+
name: "xAxisTypeTimePattern"
|
|
60
|
+
},
|
|
61
|
+
yAxisTypeTimePattern: {
|
|
62
|
+
name: "yAxisTypeTimePattern"
|
|
63
|
+
},
|
|
64
|
+
valueFormat: {
|
|
65
|
+
name: "tooltipValueFormat"
|
|
66
|
+
},
|
|
67
|
+
stacked: {
|
|
68
|
+
name: "yAxisStacked"
|
|
69
|
+
},
|
|
70
|
+
showYGrid: {
|
|
71
|
+
name: "yAxisGuideLines"
|
|
72
|
+
},
|
|
73
|
+
showXGrid: {
|
|
74
|
+
name: "xAxisGuideLines"
|
|
75
|
+
},
|
|
76
|
+
showValueLabel: {
|
|
77
|
+
name: "showValue"
|
|
78
|
+
},
|
|
79
|
+
low: {
|
|
80
|
+
name: "yAxisDomainLow"
|
|
81
|
+
},
|
|
82
|
+
high: {
|
|
83
|
+
name: "yAxisDomainHigh"
|
|
84
|
+
},
|
|
85
|
+
fillOpacity: {
|
|
86
|
+
name: "interpolateFillOpacity"
|
|
87
|
+
},
|
|
88
|
+
areaFillOpacity: {
|
|
89
|
+
name: "interpolateFillOpacity"
|
|
90
|
+
},
|
|
91
|
+
showToolbar: {
|
|
92
|
+
name: "titleVisible"
|
|
93
|
+
},
|
|
94
|
+
showCSV: {
|
|
95
|
+
name: "downloadButtonVisible"
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function findKeyVal(object: any, key: any, val: any): any {
|
|
100
|
+
let value;
|
|
101
|
+
|
|
102
|
+
for (const k in object) {
|
|
103
|
+
if (k === key && object[k] === val) {
|
|
104
|
+
value = object;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (object[k] && typeof object[k] === "object") {
|
|
108
|
+
value = findKeyVal(object[k], key, val);
|
|
109
|
+
if (value !== undefined) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function apply_to_dataviews(ddl2: DDL2.Schema, dermObj: any) {
|
|
118
|
+
|
|
119
|
+
ddl2.dataviews.forEach(apply_to_dataview);
|
|
120
|
+
|
|
121
|
+
function apply_to_dataview(dv: any) {
|
|
122
|
+
const widgetId = dv.id;
|
|
123
|
+
const dermPanelObj: any = findKeyVal(dermObj, "__id", widgetId);
|
|
124
|
+
if (dermPanelObj) {
|
|
125
|
+
const dermPanelProps: any = dermPanelObj.__properties;
|
|
126
|
+
const dermWidgetObj: any = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
|
|
127
|
+
const dermWidgetProps: any = dermWidgetObj.__properties;
|
|
128
|
+
apply_class_mapping(dermWidgetObj);
|
|
129
|
+
apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
|
|
130
|
+
apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
|
|
131
|
+
if (dv.visualization.properties.chartType) {
|
|
132
|
+
dv.visualization.properties.charttype = dv.visualization.properties.chartType;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
console.warn(widgetId + " not found in dermObj");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function apply_class_mapping(dermWidgetObj: any) {
|
|
139
|
+
dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
|
|
140
|
+
dv.visualization.properties.__class = "marshaller_VizChartPanel";
|
|
141
|
+
if (!dv.visualization.properties.widget) dv.visualization.properties.widget = {};
|
|
142
|
+
dv.visualization.properties.widget.__class = dv.visualization.__class;
|
|
143
|
+
|
|
144
|
+
function swap_with_supported_class(_class: string): string {
|
|
145
|
+
return classMappings[_class] ? classMappings[_class] : _class;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function apply_panel_property_mapping(dermPanelProps: any, dermWidgetProps: any) {
|
|
149
|
+
dv.visualization.title = dermPanelProps.title || "";
|
|
150
|
+
dv.visualization.description = "";
|
|
151
|
+
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
152
|
+
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
153
|
+
for (const propName in dermPanelProps) {
|
|
154
|
+
if (typeof propertyMappings[propName] !== "undefined") {
|
|
155
|
+
const newPropName = propertyMappings[propName].name;
|
|
156
|
+
|
|
157
|
+
if (typeof propertyMappings[propName].transform === "function") {
|
|
158
|
+
dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
|
|
159
|
+
} else {
|
|
160
|
+
dv.visualization.properties[newPropName] = dermPanelProps[propName];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
|
|
166
|
+
dv.visualization.properties.legendVisible = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function apply_widget_property_mapping(dermPanelProps: any, dermWidgetProps: any) {
|
|
170
|
+
dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
|
|
171
|
+
dv.visualization.description = ""; // TODO - should this map to anything?
|
|
172
|
+
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
173
|
+
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
174
|
+
for (const propName in dermWidgetProps) {
|
|
175
|
+
if (typeof propertyMappings[propName] !== "undefined") {
|
|
176
|
+
if (propertyMappings[propName] instanceof Array) {
|
|
177
|
+
propertyMappings[propName].forEach((p: any) => {
|
|
178
|
+
const newPropName = p.name;
|
|
179
|
+
dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
|
|
180
|
+
if (typeof propertyMappings[propName].transform === "function") {
|
|
181
|
+
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
182
|
+
} else {
|
|
183
|
+
dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
const newPropName = propertyMappings[propName].name;
|
|
188
|
+
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
type CellPosition = {
|
|
197
|
+
id: string;
|
|
198
|
+
position: [number, number, number, number];
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
type DDLProperties = {
|
|
202
|
+
layout: CellPosition[]
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
function apply_to_properties_layout(ddl2: DDL2.Schema, dermObj: any) {
|
|
206
|
+
const retVal: DDLProperties = {
|
|
207
|
+
layout: []
|
|
208
|
+
};
|
|
209
|
+
if (!dermObj || !dermObj.__properties) return;
|
|
210
|
+
dermObj.__properties.content.forEach((cell: any) => {
|
|
211
|
+
const cellPosition: CellPosition = {
|
|
212
|
+
// TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
|
|
213
|
+
id: cell.__properties.widget.__id,
|
|
214
|
+
position: [
|
|
215
|
+
cell.__properties.gridCol,
|
|
216
|
+
cell.__properties.gridRow,
|
|
217
|
+
cell.__properties.gridColSpan,
|
|
218
|
+
cell.__properties.gridRowSpan
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
retVal.layout.push(cellPosition);
|
|
222
|
+
});
|
|
223
|
+
return retVal;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function upgrade(ddl2: DDL2.Schema, dermObj: any) {
|
|
227
|
+
apply_to_dataviews(ddl2, dermObj);
|
|
228
|
+
return apply_to_properties_layout(ddl2, dermObj);
|
|
229
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./__package__.ts";
|
|
2
|
-
import * as DDL1 from "./ddl/v1.ts";
|
|
3
|
-
import * as DDL2 from "./ddl/v2.ts";
|
|
4
|
-
export * from "./upgrade.ts";
|
|
5
|
-
export * from "./validate.ts";
|
|
6
|
-
|
|
7
|
-
export { DDL1, DDL2 };
|
|
8
|
-
|
|
9
|
-
export function isDDL2Schema(ref: DDL1.DDLSchema | DDL2.Schema): ref is DDL2.Schema {
|
|
10
|
-
return (ref as DDL2.Schema).version !== undefined && (ref as DDL2.Schema).datasources !== undefined && (ref as DDL2.Schema).dataviews !== undefined;
|
|
11
|
-
}
|
|
1
|
+
export * from "./__package__.ts";
|
|
2
|
+
import * as DDL1 from "./ddl/v1.ts";
|
|
3
|
+
import * as DDL2 from "./ddl/v2.ts";
|
|
4
|
+
export * from "./upgrade.ts";
|
|
5
|
+
export * from "./validate.ts";
|
|
6
|
+
|
|
7
|
+
export { DDL1, DDL2 };
|
|
8
|
+
|
|
9
|
+
export function isDDL2Schema(ref: DDL1.DDLSchema | DDL2.Schema): ref is DDL2.Schema {
|
|
10
|
+
return (ref as DDL2.Schema).version !== undefined && (ref as DDL2.Schema).datasources !== undefined && (ref as DDL2.Schema).dataviews !== undefined;
|
|
11
|
+
}
|