@mwater/visualization 5.2.0 → 5.3.1
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/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +5 -16
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +4 -6
- package/lib/MWaterContextComponent.js +4 -13
- package/lib/MWaterLoaderComponent.d.ts +5 -3
- package/lib/MWaterLoaderComponent.js +2 -1
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +3 -1
- package/lib/axes/AxisComponent.d.ts +2 -5
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -12
- package/lib/dashboards/DashboardComponent.js +18 -38
- package/lib/dashboards/DashboardDesign.d.ts +3 -3
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +109 -132
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +211 -42
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.js +87 -33
- package/lib/demo.js +3 -3
- package/lib/index.css +5 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -57
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +2 -1
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/MapComponent.d.ts +1 -4
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +1 -4
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/ServerMapDataSource.d.ts +2 -3
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.js +61 -55
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +1 -2
- package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
- package/lib/widgets/MapWidget.d.ts +2 -0
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -62
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +3 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -112
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -1
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -28
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +11 -11
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +13 -1
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +9 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +8 -17
- package/src/MWaterLoaderComponent.ts +6 -3
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/AxisBuilder.ts +7 -5
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +71 -107
- package/src/dashboards/DashboardDesign.ts +3 -3
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +380 -75
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/ServerDatagridDataSource.ts +106 -43
- package/src/demo.ts +3 -3
- package/src/index.css +5 -0
- package/src/index.ts +1 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +2 -1
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/VectorMapViewComponent.tsx +2 -1
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +79 -74
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +13 -14
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +22 -1
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -303
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
package/src/wellknown.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
https://github.com/mapbox/wellknown
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2016, Mapbox
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
9
|
+
copyright notice and this permission notice appear in all copies.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
12
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
13
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
14
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
15
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
16
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
17
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const numberRegexp: RegExp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
|
|
23
|
+
// Matches sequences like '100 100' or '100 100 100'.
|
|
24
|
+
const tuples: RegExp = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}');
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Parse WKT and return GeoJSON.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} _ A WKT geometry
|
|
30
|
+
* @return {?Object} A GeoJSON geometry object
|
|
31
|
+
*/
|
|
32
|
+
export function parse(input: string): any {
|
|
33
|
+
let parts: string[] = input.split(';');
|
|
34
|
+
let _: string | undefined = parts.pop();
|
|
35
|
+
let srid: string = (parts.shift() || '').split('=').pop() || '';
|
|
36
|
+
|
|
37
|
+
let i: number = 0;
|
|
38
|
+
|
|
39
|
+
function $(re: RegExp): string | null {
|
|
40
|
+
let match: RegExpMatchArray | null = _!.substring(i).match(re);
|
|
41
|
+
if (!match) return null;
|
|
42
|
+
else {
|
|
43
|
+
i += match[0].length;
|
|
44
|
+
return match[0];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function crs(obj: any): any {
|
|
49
|
+
if (obj && srid.match(/\d+/)) {
|
|
50
|
+
obj.crs = {
|
|
51
|
+
type: 'name',
|
|
52
|
+
properties: {
|
|
53
|
+
name: 'urn:ogc:def:crs:EPSG::' + srid
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function white(): void { $(/^\s*/); }
|
|
62
|
+
|
|
63
|
+
function multicoords(): any[] | null {
|
|
64
|
+
white();
|
|
65
|
+
let depth: number = 0;
|
|
66
|
+
let rings: any[] = [];
|
|
67
|
+
let stack: any[][] = [rings];
|
|
68
|
+
let pointer: any[] = rings;
|
|
69
|
+
let elem: string | null;
|
|
70
|
+
|
|
71
|
+
while (elem =
|
|
72
|
+
$(/^(\()/) ||
|
|
73
|
+
$(/^(\))/) ||
|
|
74
|
+
$(/^(,)/) ||
|
|
75
|
+
$(tuples)) {
|
|
76
|
+
if (elem === '(') {
|
|
77
|
+
stack.push(pointer);
|
|
78
|
+
pointer = [];
|
|
79
|
+
stack[stack.length - 1].push(pointer);
|
|
80
|
+
depth++;
|
|
81
|
+
} else if (elem === ')') {
|
|
82
|
+
// For the case: Polygon(), ...
|
|
83
|
+
if (pointer.length === 0) return null;
|
|
84
|
+
|
|
85
|
+
pointer = stack.pop() || [];
|
|
86
|
+
// the stack was empty, input was malformed
|
|
87
|
+
if (!pointer) return null;
|
|
88
|
+
depth--;
|
|
89
|
+
if (depth === 0) break;
|
|
90
|
+
} else if (elem === ',') {
|
|
91
|
+
pointer = [];
|
|
92
|
+
stack[stack.length - 1].push(pointer);
|
|
93
|
+
} else if (!elem.split(/\s/g).some(s => isNaN(s as any))) {
|
|
94
|
+
Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
|
|
95
|
+
} else {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
white();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (depth !== 0) return null;
|
|
102
|
+
|
|
103
|
+
return rings;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function coords(): any[] | null {
|
|
107
|
+
let list: any[] = [];
|
|
108
|
+
let item: any[] | undefined;
|
|
109
|
+
let pt: string | null;
|
|
110
|
+
while (pt =
|
|
111
|
+
$(tuples) ||
|
|
112
|
+
$(/^(,)/)) {
|
|
113
|
+
if (pt === ',') {
|
|
114
|
+
list.push(item);
|
|
115
|
+
item = [];
|
|
116
|
+
} else if (!pt.split(/\s/g).some(s => isNaN(s as any))) {
|
|
117
|
+
if (!item) item = [];
|
|
118
|
+
Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
|
|
119
|
+
}
|
|
120
|
+
white();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (item) list.push(item);
|
|
124
|
+
else return null;
|
|
125
|
+
|
|
126
|
+
return list.length ? list : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function point(): any | null {
|
|
130
|
+
if (!$(/^(point(\sz)?)/i)) return null;
|
|
131
|
+
white();
|
|
132
|
+
if (!$(/^(\()/)) return null;
|
|
133
|
+
let c: any[] | null = coords();
|
|
134
|
+
if (!c) return null;
|
|
135
|
+
white();
|
|
136
|
+
if (!$(/^(\))/)) return null;
|
|
137
|
+
return {
|
|
138
|
+
type: 'Point',
|
|
139
|
+
coordinates: c[0]
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function multipoint(): any | null {
|
|
144
|
+
if (!$(/^(multipoint(\sz)?)/i)) return null;
|
|
145
|
+
white();
|
|
146
|
+
let newCoordsFormat: string = _!
|
|
147
|
+
.substring(_!.indexOf('(') + 1, _!.length - 1)
|
|
148
|
+
.replace(/\(/g, '')
|
|
149
|
+
.replace(/\)/g, '');
|
|
150
|
+
_ = 'MULTIPOINT (' + newCoordsFormat + ')';
|
|
151
|
+
let c: any[] | null = multicoords();
|
|
152
|
+
if (!c) return null;
|
|
153
|
+
white();
|
|
154
|
+
return {
|
|
155
|
+
type: 'MultiPoint',
|
|
156
|
+
coordinates: c
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function multilinestring(): any | null {
|
|
161
|
+
if (!$(/^(multilinestring(\sz)?)/i)) return null;
|
|
162
|
+
white();
|
|
163
|
+
let c: any[] | null = multicoords();
|
|
164
|
+
if (!c) return null;
|
|
165
|
+
white();
|
|
166
|
+
return {
|
|
167
|
+
type: 'MultiLineString',
|
|
168
|
+
coordinates: c
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function linestring(): any | null {
|
|
173
|
+
if (!$(/^(linestring(\sz)?)/i)) return null;
|
|
174
|
+
white();
|
|
175
|
+
if (!$(/^(\()/)) return null;
|
|
176
|
+
let c: any[] | null = coords();
|
|
177
|
+
if (!c) return null;
|
|
178
|
+
if (!$(/^(\))/)) return null;
|
|
179
|
+
return {
|
|
180
|
+
type: 'LineString',
|
|
181
|
+
coordinates: c
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function polygon(): any | null {
|
|
186
|
+
if (!$(/^(polygon(\sz)?)/i)) return null;
|
|
187
|
+
white();
|
|
188
|
+
let c: any[] | null = multicoords();
|
|
189
|
+
if (!c) return null;
|
|
190
|
+
return {
|
|
191
|
+
type: 'Polygon',
|
|
192
|
+
coordinates: c
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function multipolygon(): any | null {
|
|
197
|
+
if (!$(/^(multipolygon(\sz)?)/i)) return null;
|
|
198
|
+
white();
|
|
199
|
+
let c: any[] | null = multicoords();
|
|
200
|
+
if (!c) return null;
|
|
201
|
+
return {
|
|
202
|
+
type: 'MultiPolygon',
|
|
203
|
+
coordinates: c
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function geometrycollection(): any | null {
|
|
208
|
+
let geometries: any[] = [];
|
|
209
|
+
let geometry: any | null;
|
|
210
|
+
|
|
211
|
+
if (!$(/^(geometrycollection)/i)) return null;
|
|
212
|
+
white();
|
|
213
|
+
|
|
214
|
+
if (!$(/^(\()/)) return null;
|
|
215
|
+
while (geometry = root()) {
|
|
216
|
+
geometries.push(geometry);
|
|
217
|
+
white();
|
|
218
|
+
$(/^(,)/);
|
|
219
|
+
white();
|
|
220
|
+
}
|
|
221
|
+
if (!$(/^(\))/)) return null;
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
type: 'GeometryCollection',
|
|
225
|
+
geometries: geometries
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function root(): any | null {
|
|
230
|
+
return point() ||
|
|
231
|
+
linestring() ||
|
|
232
|
+
polygon() ||
|
|
233
|
+
multipoint() ||
|
|
234
|
+
multilinestring() ||
|
|
235
|
+
multipolygon() ||
|
|
236
|
+
geometrycollection();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return crs(root());
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Stringifies a GeoJSON object into WKT
|
|
244
|
+
*/
|
|
245
|
+
export function stringify(gj: any): string {
|
|
246
|
+
if (gj.type === 'Feature') {
|
|
247
|
+
gj = gj.geometry;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function pairWKT(c: any[]): string {
|
|
251
|
+
return c.join(' ');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function ringWKT(r: any[]): string {
|
|
255
|
+
return r.map(pairWKT).join(', ');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function ringsWKT(r: any[]): string {
|
|
259
|
+
return r.map(ringWKT).map(wrapParens).join(', ');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function multiRingsWKT(r: any[]): string {
|
|
263
|
+
return r.map(ringsWKT).map(wrapParens).join(', ');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function wrapParens(s: string): string { return '(' + s + ')'; }
|
|
267
|
+
|
|
268
|
+
switch (gj.type) {
|
|
269
|
+
case 'Point':
|
|
270
|
+
return 'POINT (' + pairWKT(gj.coordinates) + ')';
|
|
271
|
+
case 'LineString':
|
|
272
|
+
return 'LINESTRING (' + ringWKT(gj.coordinates) + ')';
|
|
273
|
+
case 'Polygon':
|
|
274
|
+
return 'POLYGON (' + ringsWKT(gj.coordinates) + ')';
|
|
275
|
+
case 'MultiPoint':
|
|
276
|
+
return 'MULTIPOINT (' + ringWKT(gj.coordinates) + ')';
|
|
277
|
+
case 'MultiPolygon':
|
|
278
|
+
return 'MULTIPOLYGON (' + multiRingsWKT(gj.coordinates) + ')';
|
|
279
|
+
case 'MultiLineString':
|
|
280
|
+
return 'MULTILINESTRING (' + ringsWKT(gj.coordinates) + ')';
|
|
281
|
+
case 'GeometryCollection':
|
|
282
|
+
return 'GEOMETRYCOLLECTION (' + gj.geometries.map(stringify).join(', ') + ')';
|
|
283
|
+
default:
|
|
284
|
+
throw new Error('stringify requires a valid GeoJSON Feature or geometry object as input');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { ReactNode, useRef, useCallback } from "react"
|
|
2
|
+
|
|
3
|
+
export interface DropdownWidgetComponentProps {
|
|
4
|
+
/** Width specification */
|
|
5
|
+
width?: any
|
|
6
|
+
/** Height specification */
|
|
7
|
+
height?: any
|
|
8
|
+
dropdownItems: { label: ReactNode; onClick: () => void }[]
|
|
9
|
+
children?: ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Widget wrapper that adds a dropdown menu in a gear floating
|
|
13
|
+
const DropdownWidgetComponent = (props: DropdownWidgetComponentProps) => {
|
|
14
|
+
const { width, height, dropdownItems, children } = props
|
|
15
|
+
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
16
|
+
|
|
17
|
+
const renderDropdownItem = (item: { label: ReactNode; onClick: () => void }, i: number) => {
|
|
18
|
+
return (
|
|
19
|
+
<li key={`${i}`}>
|
|
20
|
+
<a className="dropdown-item" onClick={item.onClick}>
|
|
21
|
+
{item.label}
|
|
22
|
+
</a>
|
|
23
|
+
</li>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const renderDropdown = () => {
|
|
28
|
+
if (dropdownItems.length === 0) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const dropdownStyle: React.CSSProperties = {
|
|
33
|
+
position: "absolute",
|
|
34
|
+
right: 3,
|
|
35
|
+
top: 3,
|
|
36
|
+
cursor: "pointer",
|
|
37
|
+
zIndex: 1029
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div style={dropdownStyle} ref={dropdownRef}>
|
|
42
|
+
<div style={dropdownStyle} data-bs-toggle="dropdown">
|
|
43
|
+
<div className="mwater-visualization-simple-widget-gear-button">
|
|
44
|
+
<span className="fas fa-cog" />
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<ul className="dropdown-menu dropdown-menu-end" style={{ top: 25 }}>
|
|
48
|
+
{dropdownItems.map(renderDropdownItem)}
|
|
49
|
+
</ul>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const closeMenu = useCallback(() => {
|
|
55
|
+
if (dropdownRef.current) {
|
|
56
|
+
const dropdownToggle = dropdownRef.current.querySelector('[data-bs-toggle="dropdown"]')
|
|
57
|
+
if (dropdownToggle) {
|
|
58
|
+
dropdownToggle.parentElement?.classList.remove('open')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [])
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
className="mwater-visualization-simple-widget"
|
|
66
|
+
onMouseLeave={closeMenu}
|
|
67
|
+
style={{ width, height }}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
{renderDropdown()}
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default DropdownWidgetComponent
|
package/src/widgets/MapWidget.ts
CHANGED
|
@@ -36,7 +36,8 @@ export default class MapWidget extends Widget {
|
|
|
36
36
|
onScopeChange: options.onScopeChange,
|
|
37
37
|
width: options.width,
|
|
38
38
|
height: options.height,
|
|
39
|
-
onRowClick: options.onRowClick
|
|
39
|
+
onRowClick: options.onRowClick,
|
|
40
|
+
refreshKey: options.refreshKey
|
|
40
41
|
})
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -66,6 +67,8 @@ interface MapWidgetComponentProps {
|
|
|
66
67
|
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
67
68
|
onScopeChange?: any
|
|
68
69
|
onRowClick?: any
|
|
70
|
+
/** TODO: implement refreshing */
|
|
71
|
+
refreshKey?: any
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
interface MapWidgetComponentState {
|
|
@@ -178,7 +181,7 @@ class MapWidgetComponent extends React.Component<MapWidgetComponentProps, MapWid
|
|
|
178
181
|
schema: this.props.schema,
|
|
179
182
|
design,
|
|
180
183
|
dataSource: this.props.dataSource,
|
|
181
|
-
mapDataSource: this.props.widgetDataSource.getMapDataSource(design),
|
|
184
|
+
mapDataSource: this.props.widgetDataSource.getMapDataSource!(design),
|
|
182
185
|
onDesignChange,
|
|
183
186
|
scope: this.props.scope,
|
|
184
187
|
onScopeChange: this.props.onScopeChange,
|
package/src/widgets/TOCWidget.ts
CHANGED
|
@@ -155,6 +155,7 @@ class TOCWidgetViewComponent extends React.Component {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
handleEntryClick = (tocEntry: any) => {
|
|
158
|
+
debugger
|
|
158
159
|
return this.props.onScrollToTOCEntry?.(tocEntry.widgetId, tocEntry.id)
|
|
159
160
|
}
|
|
160
161
|
|
|
@@ -228,7 +229,7 @@ class TOCWidgetViewComponent extends React.Component {
|
|
|
228
229
|
}),
|
|
229
230
|
|
|
230
231
|
// Add placeholder if none and editable
|
|
231
|
-
this.props.onDesignChange && this.props.tocEntries.length === 0
|
|
232
|
+
this.props.onDesignChange && (this.props.tocEntries || []).length === 0
|
|
232
233
|
? R(
|
|
233
234
|
"div",
|
|
234
235
|
{ className: "text-muted" },
|
package/src/widgets/Widget.ts
CHANGED
|
@@ -39,6 +39,9 @@ export interface CreateViewElementOptions {
|
|
|
39
39
|
|
|
40
40
|
/** called with (widgetId, tocEntryId) to scroll to TOC entry */
|
|
41
41
|
onScrollToTOCEntry?: (widgetId: string, tocEntryId: string) => void
|
|
42
|
+
|
|
43
|
+
/** A key that changes when the widget should be refreshed */
|
|
44
|
+
refreshKey?: any
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
export default class Widget {
|
|
@@ -11,8 +11,10 @@ export interface WidgetDataSource {
|
|
|
11
11
|
* design: design of the widget. Ignored in the case of server-side rendering
|
|
12
12
|
* filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
|
|
13
13
|
* callback: (error, data)
|
|
14
|
+
*
|
|
15
|
+
* Can be aborted by cancelling the AbortController
|
|
14
16
|
*/
|
|
15
|
-
getData(design: any, filters: JsonQLFilter[], callback: (error: any, data?: any) => void): void
|
|
17
|
+
getData(design: any, filters: JsonQLFilter[], callback: (error: any, data?: any) => void): AbortController | void | undefined
|
|
16
18
|
|
|
17
19
|
/** For map widgets, the following is required */
|
|
18
20
|
getMapDataSource?(design: MapDesign): MapDataSource
|
|
@@ -119,7 +119,7 @@ export default class Chart {
|
|
|
119
119
|
// widgetDataSource: widget data source to use
|
|
120
120
|
// filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
|
|
121
121
|
// Returns an empty list by default
|
|
122
|
-
createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): { label: ReactNode,
|
|
122
|
+
createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): { label: ReactNode, onClick: () => void }[] {
|
|
123
123
|
return []
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -35,6 +35,9 @@ export interface ChartViewComponentProps {
|
|
|
35
35
|
onScopeChange?: (scope: WidgetScope | null) => void
|
|
36
36
|
|
|
37
37
|
onRowClick?: (tableId: string, rowId: any) => void
|
|
38
|
+
|
|
39
|
+
/** A key that changes when the widget should be refreshed */
|
|
40
|
+
refreshKey?: any
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
interface ChartViewComponentState {
|
|
@@ -54,6 +57,9 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
|
|
|
54
57
|
/** Ordinal of update (0, 1, 2...) to ensure using latest */
|
|
55
58
|
updateSeq: number
|
|
56
59
|
|
|
60
|
+
/** Abort controller for the current data load */
|
|
61
|
+
abortController: AbortController | undefined
|
|
62
|
+
|
|
57
63
|
constructor(props: ChartViewComponentProps) {
|
|
58
64
|
super(props)
|
|
59
65
|
|
|
@@ -77,7 +83,8 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
|
|
|
77
83
|
if (
|
|
78
84
|
!_.isEqual(prevProps.design, this.props.design) ||
|
|
79
85
|
!_.isEqual(prevProps.filters, this.props.filters) ||
|
|
80
|
-
this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry
|
|
86
|
+
this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry ||
|
|
87
|
+
prevProps.refreshKey !== this.props.refreshKey
|
|
81
88
|
) {
|
|
82
89
|
// Save new cache expiry
|
|
83
90
|
this.setState({ cacheExpiry: this.props.dataSource.getCacheExpiry() })
|
|
@@ -97,6 +104,9 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
this.updateSeq += 1
|
|
107
|
+
if (this.abortController) {
|
|
108
|
+
this.abortController.abort("Aborting previous data load")
|
|
109
|
+
}
|
|
100
110
|
|
|
101
111
|
// Set loading data after interval to prevent unnecessary refresh
|
|
102
112
|
const dataLoadingTimeout = setTimeout(() => {
|
|
@@ -106,15 +116,18 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
|
|
|
106
116
|
// Store updateSeq to check if latest
|
|
107
117
|
const loadingUpdateSeq = this.updateSeq
|
|
108
118
|
|
|
109
|
-
this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
|
|
119
|
+
this.abortController = this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
|
|
110
120
|
// Prevent setting data loading if ready
|
|
111
121
|
clearTimeout(dataLoadingTimeout)
|
|
112
122
|
|
|
113
123
|
// Only update if latest
|
|
114
124
|
if (loadingUpdateSeq == this.updateSeq) {
|
|
125
|
+
// Clear the abort controller
|
|
126
|
+
this.abortController = undefined
|
|
127
|
+
|
|
115
128
|
this.setState({ dataLoading: false, dataError: error, data, validDesign: design })
|
|
116
129
|
}
|
|
117
|
-
})
|
|
130
|
+
}) ?? undefined
|
|
118
131
|
}
|
|
119
132
|
|
|
120
133
|
renderSpinner() {
|