@mwater/visualization 5.4.1 → 5.4.3
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.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +12 -20
- package/lib/dashboards/DashboardComponent.js +109 -69
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/languages.js +6 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/Quickfilter.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +5 -30
- package/lib/quickfilter/QuickfiltersDesignComponent.js +56 -63
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +189 -125
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/languages.ts +6 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/Quickfilter.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +127 -128
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +2 -2
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
|
@@ -11,27 +11,33 @@ export interface HoverContentProps {
|
|
|
11
11
|
/** Schema to use */
|
|
12
12
|
schema: Schema
|
|
13
13
|
dataSource: DataSource
|
|
14
|
-
/** Design of the marker layer */
|
|
15
|
-
design: any
|
|
16
14
|
filters?: JsonQLFilter[]
|
|
17
|
-
/** Table that
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
/** Table that hover over is for */
|
|
16
|
+
table: string
|
|
17
|
+
/** Hover over items */
|
|
18
|
+
items: HoverOverItem[]
|
|
19
|
+
/** Locale to use */
|
|
20
|
+
locale: string
|
|
21
|
+
/** Translate function to use */
|
|
22
|
+
translate: (input: string) => string
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
/** Component that displays hover over content */
|
|
26
|
+
const HoverContent = (props: HoverContentProps) => {
|
|
25
27
|
const [values, setValues] = useState<{ [key: string]: string }>({})
|
|
28
|
+
const [error, setError] = useState<string | null>(null)
|
|
26
29
|
const exprUtils = new ExprUtils(props.schema)
|
|
30
|
+
|
|
27
31
|
useEffect(() => {
|
|
28
|
-
|
|
32
|
+
let mounted = true
|
|
33
|
+
const items = props.items
|
|
34
|
+
|
|
29
35
|
if (items.length > 0) {
|
|
30
36
|
const exprCompiler = new ExprCompiler(props.schema)
|
|
31
37
|
const query: JsonQLSelectQuery = {
|
|
32
38
|
type: "query",
|
|
33
39
|
selects: [],
|
|
34
|
-
from: exprCompiler.compileTable(props.
|
|
40
|
+
from: exprCompiler.compileTable(props.table, "main"),
|
|
35
41
|
limit: 1
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -59,24 +65,42 @@ const HoverContent: React.FC<HoverContentProps> = props => {
|
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
props.dataSource.performQuery(query, (error: any, data: any) => {
|
|
68
|
+
if (!mounted) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (error) {
|
|
73
|
+
setError(props.translate("Error loading hover data"))
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
setValues(data?.[0] ?? {})
|
|
63
78
|
})
|
|
64
79
|
}
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
mounted = false
|
|
83
|
+
}
|
|
65
84
|
}, [])
|
|
85
|
+
|
|
86
|
+
if (error) {
|
|
87
|
+
return <div className="text-danger">{error}</div>
|
|
88
|
+
}
|
|
89
|
+
|
|
66
90
|
return (
|
|
67
91
|
<div className="_mviz-map-hover-content">
|
|
68
|
-
{props.
|
|
92
|
+
{props.items.map((item: HoverOverItem) => {
|
|
69
93
|
let value = values[item.id]
|
|
70
94
|
|
|
71
|
-
if (value
|
|
95
|
+
if (value != null && item.value) {
|
|
72
96
|
// Get expression type
|
|
73
97
|
const exprType = exprUtils.getExprType(item.value)
|
|
74
98
|
|
|
75
99
|
// Format if can format
|
|
76
100
|
if (exprType && canFormatType(exprType)) {
|
|
77
|
-
value = formatValue(exprType, value,
|
|
101
|
+
value = formatValue(exprType, value, item.format, props.locale)
|
|
78
102
|
} else {
|
|
79
|
-
value = exprUtils.stringifyExprLiteral(item.value, value)
|
|
103
|
+
value = exprUtils.stringifyExprLiteral(item.value, value, props.locale)
|
|
80
104
|
}
|
|
81
105
|
} else {
|
|
82
106
|
value = "■■■■"
|
|
@@ -84,8 +108,8 @@ const HoverContent: React.FC<HoverContentProps> = props => {
|
|
|
84
108
|
|
|
85
109
|
return (
|
|
86
110
|
<>
|
|
87
|
-
<span>{item.label}:</span>
|
|
88
|
-
<span className="text-muted">{values[item.id] === null ? "n/a" :
|
|
111
|
+
<span>{props.translate(item.label)}:</span>
|
|
112
|
+
<span className="text-muted">{values[item.id] === null ? "n/a" : value}</span>
|
|
89
113
|
</>
|
|
90
114
|
)
|
|
91
115
|
})}
|
package/src/maps/Layer.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { OnGridClickResults, OnGridHoverResults } from "./maps"
|
|
|
9
9
|
import { ReactNode } from "react"
|
|
10
10
|
import { JsonQLExpr, JsonQLQuery, JsonQLSelectQuery } from "@mwater/jsonql"
|
|
11
11
|
import { LayerSpecification } from "maplibre-gl"
|
|
12
|
+
import { MapLayerDataSource } from "./MapLayerDataSource"
|
|
12
13
|
|
|
13
14
|
export interface JsonQLCssLayerDefinition {
|
|
14
15
|
layers: Array<{
|
|
@@ -37,11 +38,15 @@ export interface OnGridClickOptions<LayerDesign> {
|
|
|
37
38
|
/** data source to use */
|
|
38
39
|
dataSource: DataSource
|
|
39
40
|
/** layer data source */
|
|
40
|
-
layerDataSource:
|
|
41
|
+
layerDataSource: MapLayerDataSource
|
|
41
42
|
/** current scope data if layer is scoping */
|
|
42
43
|
scopeData: any
|
|
43
44
|
/** compiled filters to apply to the popup */
|
|
44
45
|
filters: JsonQLFilter[]
|
|
46
|
+
/** Locale to use */
|
|
47
|
+
locale: string
|
|
48
|
+
/** Translate function to use */
|
|
49
|
+
translate: (input: string) => string
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
export interface OnGridHoverOptions<LayerDesign> {
|
|
@@ -52,11 +57,15 @@ export interface OnGridHoverOptions<LayerDesign> {
|
|
|
52
57
|
/** data source to use */
|
|
53
58
|
dataSource: DataSource
|
|
54
59
|
/** layer data source */
|
|
55
|
-
layerDataSource:
|
|
60
|
+
layerDataSource: MapLayerDataSource
|
|
56
61
|
/** current scope data if layer is scoping */
|
|
57
62
|
scopeData: any
|
|
58
63
|
/** compiled filters to apply to the popup */
|
|
59
64
|
filters: JsonQLFilter[]
|
|
65
|
+
/** Locale to use */
|
|
66
|
+
locale: string
|
|
67
|
+
/** Translate function to use */
|
|
68
|
+
translate: (input: string) => string
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
/** Definition of a vector tile layer */
|
|
@@ -186,14 +195,7 @@ export default class Layer<LayerDesign> {
|
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
/** Get the legend to be optionally displayed on the map. Returns a React element */
|
|
189
|
-
getLegend(
|
|
190
|
-
design: LayerDesign,
|
|
191
|
-
schema: Schema,
|
|
192
|
-
name: string,
|
|
193
|
-
dataSource: DataSource,
|
|
194
|
-
locale: string,
|
|
195
|
-
filters: JsonQLFilter[]
|
|
196
|
-
): ReactNode {
|
|
198
|
+
getLegend(options: LegendOptions<LayerDesign>): ReactNode {
|
|
197
199
|
return null
|
|
198
200
|
}
|
|
199
201
|
|
|
@@ -325,4 +327,20 @@ export default class Layer<LayerDesign> {
|
|
|
325
327
|
}
|
|
326
328
|
})
|
|
327
329
|
}
|
|
330
|
+
|
|
331
|
+
/** Get strings to be translated */
|
|
332
|
+
getTranslatableStrings(design: LayerDesign, schema: Schema): string[] {
|
|
333
|
+
return []
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface LegendOptions<LayerDesign> {
|
|
338
|
+
design: LayerDesign
|
|
339
|
+
schema: Schema
|
|
340
|
+
name: string
|
|
341
|
+
dataSource: DataSource
|
|
342
|
+
locale: string
|
|
343
|
+
filters: JsonQLFilter[]
|
|
344
|
+
/** Translate function to use */
|
|
345
|
+
translate: (input: string) => string
|
|
328
346
|
}
|
package/src/maps/LayerFactory.ts
CHANGED
|
@@ -14,36 +14,28 @@ export default class LayerFactory {
|
|
|
14
14
|
switch (type) {
|
|
15
15
|
case "MWaterServer":
|
|
16
16
|
return new MWaterServerLayer()
|
|
17
|
-
break
|
|
18
17
|
|
|
19
18
|
case "Markers":
|
|
20
19
|
return new MarkersLayer()
|
|
21
|
-
break
|
|
22
20
|
|
|
23
21
|
case "Buffer":
|
|
24
22
|
return new BufferLayer()
|
|
25
|
-
break
|
|
26
23
|
|
|
27
24
|
// Uses a legacy type name
|
|
28
25
|
case "AdminChoropleth":
|
|
29
26
|
return new ChoroplethLayer()
|
|
30
|
-
break
|
|
31
27
|
|
|
32
28
|
case "Cluster":
|
|
33
29
|
return new ClusterLayer()
|
|
34
|
-
break
|
|
35
30
|
|
|
36
31
|
case "TileUrl":
|
|
37
32
|
return new TileUrlLayer()
|
|
38
|
-
break
|
|
39
33
|
|
|
40
34
|
case "SwitchableTileUrl":
|
|
41
35
|
return new SwitchableTileUrlLayer()
|
|
42
|
-
break
|
|
43
36
|
|
|
44
37
|
case "Grid":
|
|
45
38
|
return new GridLayer()
|
|
46
|
-
break
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
throw new Error(`Unknown type ${type}`)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
1
|
import React from "react"
|
|
3
2
|
import _ from "lodash"
|
|
4
|
-
const R = React.createElement
|
|
5
3
|
import AxisBuilder from "../axes/AxisBuilder"
|
|
6
4
|
import LegendGroup from "./LegendGroup"
|
|
7
|
-
import {
|
|
5
|
+
import { Schema } from "@mwater/expressions"
|
|
8
6
|
import { Axis } from "../axes/Axis"
|
|
9
7
|
|
|
10
8
|
export interface LayerLegendComponentProps {
|
|
@@ -60,7 +58,7 @@ export default class LayerLegendComponent extends React.Component<LayerLegendCom
|
|
|
60
58
|
return null
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
const label = axisBuilder.formatCategory(this.props.axis
|
|
61
|
+
const label = axisBuilder.formatCategory(this.props.axis!, category)
|
|
64
62
|
const color = _.find(this.props.axis!.colorMap!, { value: category.value })
|
|
65
63
|
if (color) {
|
|
66
64
|
return { color: color.color, name: label }
|
|
@@ -3,7 +3,11 @@ import React, { CSSProperties, Ref, useEffect, useRef, useState } from "react"
|
|
|
3
3
|
import { MapDesign, MapLayerView } from "./MapDesign"
|
|
4
4
|
|
|
5
5
|
/** Component to switch layers on a map */
|
|
6
|
-
export function LayerSwitcherComponent(props: {
|
|
6
|
+
export function LayerSwitcherComponent(props: {
|
|
7
|
+
design: MapDesign
|
|
8
|
+
onDesignChange: (design: MapDesign) => void
|
|
9
|
+
translate: (input: string) => string
|
|
10
|
+
}) {
|
|
7
11
|
const [dropdownOpen, setDropdownOpen] = useState(false)
|
|
8
12
|
|
|
9
13
|
const iconStyle: CSSProperties = {
|
|
@@ -45,7 +49,7 @@ export function LayerSwitcherComponent(props: { design: MapDesign; onDesignChang
|
|
|
45
49
|
return (
|
|
46
50
|
<div key={index} style={{ fontSize: 12, whiteSpace: "nowrap", cursor: "pointer" }} onClick={handleClick}>
|
|
47
51
|
<i className={lv.visible ? "fa fa-fw fa-check-square text-primary" : "fa fa-fw fa-square text-muted"} />
|
|
48
|
-
{lv.name}
|
|
52
|
+
{props.translate(lv.name)}
|
|
49
53
|
</div>
|
|
50
54
|
)
|
|
51
55
|
}
|
|
@@ -221,7 +221,9 @@ export default class LeafletMapComponent extends Component<Props> {
|
|
|
221
221
|
lBounds = lBounds.pad(pad)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
if (lBounds.getEast() !== Infinity && lBounds.getWest() !== -Infinity && lBounds.getNorth() !== Infinity && lBounds.getSouth() !== -Infinity) {
|
|
225
|
+
this.map.fitBounds(lBounds, { animate: true })
|
|
226
|
+
}
|
|
225
227
|
} else {
|
|
226
228
|
// Fit world doesn't work sometimes. Make sure that entire left-right is included
|
|
227
229
|
this.map.fitBounds([
|
|
@@ -15,6 +15,7 @@ export default function LegendComponent(props: {
|
|
|
15
15
|
/** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
|
|
16
16
|
filters: JsonQLFilter[]
|
|
17
17
|
locale: string
|
|
18
|
+
translate: (input: string) => string
|
|
18
19
|
onHide: () => void
|
|
19
20
|
}) {
|
|
20
21
|
const legendItems = _.compact(
|
|
@@ -53,7 +54,15 @@ export default function LegendComponent(props: {
|
|
|
53
54
|
|
|
54
55
|
return {
|
|
55
56
|
key: layerView.id,
|
|
56
|
-
legend: layer.getLegend(
|
|
57
|
+
legend: layer.getLegend({
|
|
58
|
+
design,
|
|
59
|
+
schema: props.schema,
|
|
60
|
+
name: layerView.name,
|
|
61
|
+
dataSource: props.dataSource,
|
|
62
|
+
locale: props.locale,
|
|
63
|
+
filters: props.filters,
|
|
64
|
+
translate: props.translate
|
|
65
|
+
})
|
|
57
66
|
}
|
|
58
67
|
})
|
|
59
68
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import $ from "jquery"
|
|
2
|
-
import Layer from "./Layer"
|
|
2
|
+
import Layer, { LegendOptions } from "./Layer"
|
|
3
3
|
import React from "react"
|
|
4
4
|
import { Schema } from "@mwater/expressions"
|
|
5
5
|
const R = React.createElement
|
|
@@ -46,11 +46,11 @@ export default class MWaterServerLayer extends Layer<any> {
|
|
|
46
46
|
|
|
47
47
|
// Get the legend to be optionally displayed on the map. Returns
|
|
48
48
|
// a React element
|
|
49
|
-
getLegend(
|
|
49
|
+
getLegend(options: LegendOptions<any>) {
|
|
50
50
|
// Create loading legend component
|
|
51
51
|
// TODO hardcoded
|
|
52
52
|
const apiUrl = "https://api.mwater.co/v3/"
|
|
53
|
-
return React.createElement(LoadingLegend, { url: `${apiUrl}maps/legend?type=${design.type}` })
|
|
53
|
+
return React.createElement(LoadingLegend, { url: `${apiUrl}maps/legend?type=${options.design.type}` })
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Get a list of table ids that can be filtered on
|
package/src/maps/MapComponent.ts
CHANGED
|
@@ -133,7 +133,7 @@ export default class MapComponent extends React.Component<MapComponentProps, Map
|
|
|
133
133
|
onClick: this.handleUndo
|
|
134
134
|
},
|
|
135
135
|
R("span", { className: "fas fa-caret-left" }),
|
|
136
|
-
R("span", { className: "hide-600px" }, T`
|
|
136
|
+
R("span", { className: "hide-600px" }, " ", T`Undo`)
|
|
137
137
|
),
|
|
138
138
|
" ",
|
|
139
139
|
R(
|
|
@@ -144,7 +144,7 @@ export default class MapComponent extends React.Component<MapComponentProps, Map
|
|
|
144
144
|
onClick: this.handleRedo
|
|
145
145
|
},
|
|
146
146
|
R("span", { className: "fas fa-caret-right" }),
|
|
147
|
-
R("span", { className: "hide-600px" }, T`
|
|
147
|
+
R("span", { className: "hide-600px" }, " ", T`Redo`)
|
|
148
148
|
)
|
|
149
149
|
]
|
|
150
150
|
: undefined,
|
|
@@ -153,7 +153,7 @@ export default class MapComponent extends React.Component<MapComponentProps, Map
|
|
|
153
153
|
"a",
|
|
154
154
|
{ key: "showQuickfilters", className: "btn btn-link btn-sm", onClick: this.handleShowQuickfilters },
|
|
155
155
|
R("span", { className: "fa fa-filter" }),
|
|
156
|
-
R("span", { className: "hide-600px" }, T`
|
|
156
|
+
R("span", { className: "hide-600px" }, " ", T`Show Quickfilters`)
|
|
157
157
|
)
|
|
158
158
|
: undefined,
|
|
159
159
|
this.props.extraTitleButtonsElem,
|
package/src/maps/MapDesign.ts
CHANGED
|
@@ -25,6 +25,9 @@ export interface MapDesign {
|
|
|
25
25
|
/** true to automatically zoom to bounds of data */
|
|
26
26
|
autoBounds?: boolean
|
|
27
27
|
|
|
28
|
+
/** True to animate zoom to bounds of data. Default is true */
|
|
29
|
+
animateAutoBounds?: boolean
|
|
30
|
+
|
|
28
31
|
/** maximum allowed zoom level */
|
|
29
32
|
maxZoom?: number | null
|
|
30
33
|
|