@mwater/visualization 5.0.1 → 5.1.0
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/MWaterAddRelatedFormComponent.d.ts +1 -1
- package/lib/MWaterAddRelatedFormComponent.js +10 -17
- package/lib/MWaterContextComponent.d.ts +17 -7
- package/lib/MWaterContextComponent.js +51 -67
- package/lib/MWaterLoaderComponent.d.ts +2 -2
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +20 -41
- package/lib/axes/RangesComponent.d.ts +12 -6
- package/lib/axes/RangesComponent.js +21 -10
- package/lib/dashboards/DashboardComponent.d.ts +1 -9
- package/lib/dashboards/DashboardComponent.js +16 -27
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -0
- package/lib/dashboards/ServerDashboardDataSource.js +3 -0
- package/lib/datagrids/DatagridComponent.d.ts +8 -4
- package/lib/datagrids/DatagridComponent.js +27 -5
- package/lib/datagrids/DatagridDataSource.d.ts +1 -0
- package/lib/datagrids/DatagridDataSource.js +3 -0
- package/lib/datagrids/DatagridDesign.d.ts +2 -0
- package/lib/datagrids/DatagridDesignerComponent.js +3 -2
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/DirectDatagridDataSource.d.ts +1 -0
- package/lib/datagrids/DirectDatagridDataSource.js +26 -0
- package/lib/datagrids/ServerDatagridDataSource.d.ts +1 -0
- package/lib/datagrids/ServerDatagridDataSource.js +15 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +2 -4
- package/lib/layouts/blocks/BlocksDisplayComponent.js +2 -2
- package/lib/layouts/grid/LegoLayoutEngine.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayerDesigner.js +2 -2
- package/lib/maps/ClusterLayerDesignerComponent.js +2 -2
- package/lib/maps/DirectMapDataSource.js +1 -2
- package/lib/maps/GridLayerDesigner.js +2 -2
- package/lib/maps/MapDesignerComponent.d.ts +1 -12
- package/lib/maps/MapDesignerComponent.js +5 -12
- package/lib/maps/MarkersLayerDesignerComponent.js +2 -2
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -1
- package/lib/maps/PopupFilterJoinsUtils.js +4 -3
- package/lib/maps/UtfGridLayer.js +1 -1
- package/lib/widgets/ImageWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +2 -2
- package/lib/widgets/text/ExprItemEditorComponent.js +2 -2
- package/package.json +1 -1
- package/src/MWaterAddRelatedFormComponent.ts +15 -20
- package/src/MWaterContextComponent.tsx +140 -0
- package/src/MWaterLoaderComponent.ts +2 -2
- package/src/{MWaterTableSelectComponent.ts → MWaterTableSelectComponent.tsx} +61 -66
- package/src/axes/AxisBuilder.ts +1 -1
- package/src/axes/RangesComponent.ts +27 -16
- package/src/dashboards/{DashboardComponent.ts → DashboardComponent.tsx} +37 -40
- package/src/dashboards/ServerDashboardDataSource.ts +16 -12
- package/src/datagrids/DatagridComponent.ts +45 -14
- package/src/datagrids/DatagridDataSource.ts +8 -0
- package/src/datagrids/DatagridDesign.ts +3 -0
- package/src/datagrids/DatagridDesignerComponent.tsx +9 -1
- package/src/datagrids/DatagridViewComponent.ts +1 -1
- package/src/datagrids/DirectDatagridDataSource.ts +35 -0
- package/src/datagrids/ServerDatagridDataSource.ts +22 -4
- package/src/index.ts +0 -2
- package/src/layouts/blocks/BlocksDisplayComponent.ts +2 -2
- package/src/layouts/grid/LegoLayoutEngine.ts +2 -2
- package/src/layouts/grid/WidgetContainerComponent.ts +2 -2
- package/src/maps/BingLayer.ts +2 -2
- package/src/maps/BufferLayerDesignerComponent.ts +1 -1
- package/src/maps/ChoroplethLayerDesigner.tsx +1 -1
- package/src/maps/ClusterLayerDesignerComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +1 -2
- package/src/maps/GridLayerDesigner.tsx +1 -1
- package/src/maps/LegendGroup.ts +1 -1
- package/src/maps/MWaterServerLayer.ts +2 -2
- package/src/maps/{MapDesignerComponent.ts → MapDesignerComponent.tsx} +8 -16
- package/src/maps/MarkersLayerDesignerComponent.ts +1 -1
- package/src/maps/PopupFilterJoinsUtils.ts +4 -4
- package/src/maps/ServerMapDataSource.ts +6 -6
- package/src/maps/SwitchableTileUrlLayerDesigner.tsx +1 -13
- package/src/maps/UtfGridLayer.ts +4 -4
- package/src/maps/mapboxUtils.ts +2 -2
- package/src/richtext/ExprItemsHtmlConverter.ts +1 -1
- package/src/richtext/FontColorPaletteItem.ts +1 -1
- package/src/richtext/FontSizePaletteItem.ts +1 -1
- package/src/richtext/ItemsHtmlConverter.ts +2 -2
- package/src/widgets/ImageWidgetComponent.ts +1 -1
- package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +1 -1
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +1 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +1 -1
- package/src/widgets/text/ExprItemEditorComponent.tsx +1 -1
- package/src/MWaterContextComponent.ts +0 -141
- package/src/TableSelectComponent.ts +0 -60
|
@@ -97,7 +97,7 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
97
97
|
`dashboards/${this.options.dashboardId}/quickfilters/${index}/values?` +
|
|
98
98
|
querystring.stringify(query)
|
|
99
99
|
|
|
100
|
-
const headers = {}
|
|
100
|
+
const headers: any = {}
|
|
101
101
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
102
102
|
if (cacheExpiry) {
|
|
103
103
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -110,10 +110,10 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
110
110
|
url,
|
|
111
111
|
headers
|
|
112
112
|
})
|
|
113
|
-
.done((data) => {
|
|
113
|
+
.done((data: any) => {
|
|
114
114
|
return callback(null, data)
|
|
115
115
|
})
|
|
116
|
-
.fail((xhr) => {
|
|
116
|
+
.fail((xhr: any) => {
|
|
117
117
|
console.log(xhr.responseText)
|
|
118
118
|
return callback(new Error(xhr.responseText))
|
|
119
119
|
})
|
|
@@ -151,7 +151,7 @@ class ServerWidgetDataSource {
|
|
|
151
151
|
`dashboards/${this.options.dashboardId}/widgets/${this.options.widgetId}/data?` +
|
|
152
152
|
querystring.stringify(query)
|
|
153
153
|
|
|
154
|
-
const headers = {}
|
|
154
|
+
const headers: any = {}
|
|
155
155
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
156
156
|
if (cacheExpiry) {
|
|
157
157
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -164,10 +164,10 @@ class ServerWidgetDataSource {
|
|
|
164
164
|
url,
|
|
165
165
|
headers
|
|
166
166
|
})
|
|
167
|
-
.done((data) => {
|
|
167
|
+
.done((data: any) => {
|
|
168
168
|
return callback(null, data)
|
|
169
169
|
})
|
|
170
|
-
.fail((xhr) => {
|
|
170
|
+
.fail((xhr: any) => {
|
|
171
171
|
console.log(xhr.responseText)
|
|
172
172
|
return callback(new Error(xhr.responseText))
|
|
173
173
|
})
|
|
@@ -235,7 +235,7 @@ class ServerWidgetMapDataSource implements MapDataSource {
|
|
|
235
235
|
`dashboards/${this.options.dashboardId}/widgets/${this.options.widgetId}/bounds?` +
|
|
236
236
|
querystring.stringify(query)
|
|
237
237
|
|
|
238
|
-
const headers = {}
|
|
238
|
+
const headers: any = {}
|
|
239
239
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
240
240
|
if (cacheExpiry) {
|
|
241
241
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -248,14 +248,18 @@ class ServerWidgetMapDataSource implements MapDataSource {
|
|
|
248
248
|
url,
|
|
249
249
|
headers
|
|
250
250
|
})
|
|
251
|
-
.done((data) => {
|
|
251
|
+
.done((data: any) => {
|
|
252
252
|
return callback(null, data)
|
|
253
253
|
})
|
|
254
|
-
.fail((xhr) => {
|
|
254
|
+
.fail((xhr: any) => {
|
|
255
255
|
console.log(xhr.responseText)
|
|
256
256
|
return callback(new Error(xhr.responseText))
|
|
257
257
|
})
|
|
258
258
|
}
|
|
259
|
+
|
|
260
|
+
getQuickfiltersDataSource(): QuickfiltersDataSource {
|
|
261
|
+
return new ServerQuickfilterDataSource(this.options)
|
|
262
|
+
}
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
interface ServerWidgetLayerDataSourceOptions extends ServerDashboardDataSourceOptions {
|
|
@@ -480,7 +484,7 @@ class ServerWidgetLayerPopupWidgetDataSource implements WidgetDataSource {
|
|
|
480
484
|
`dashboards/${this.options.dashboardId}/widgets/${this.options.widgetId}/layers/${this.options.layerView.id}/widgets/${this.options.popupWidgetId}/data?` +
|
|
481
485
|
querystring.stringify(query)
|
|
482
486
|
|
|
483
|
-
const headers = {}
|
|
487
|
+
const headers: any = {}
|
|
484
488
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
485
489
|
if (cacheExpiry) {
|
|
486
490
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -493,10 +497,10 @@ class ServerWidgetLayerPopupWidgetDataSource implements WidgetDataSource {
|
|
|
493
497
|
url,
|
|
494
498
|
headers
|
|
495
499
|
})
|
|
496
|
-
.done((data) => {
|
|
500
|
+
.done((data: any) => {
|
|
497
501
|
return callback(null, data)
|
|
498
502
|
})
|
|
499
|
-
.fail((xhr) => {
|
|
503
|
+
.fail((xhr: any) => {
|
|
500
504
|
console.log(xhr.responseText)
|
|
501
505
|
return callback(new Error(xhr.responseText))
|
|
502
506
|
})
|
|
@@ -16,6 +16,7 @@ import QuickfilterCompiler from "../quickfilter/QuickfilterCompiler"
|
|
|
16
16
|
import FindReplaceModalComponent from "./FindReplaceModalComponent"
|
|
17
17
|
import DatagridDataSource from "./DatagridDataSource"
|
|
18
18
|
import { DatagridDesign, JsonQLFilter } from ".."
|
|
19
|
+
import { format as d3Format } from "d3-format"
|
|
19
20
|
|
|
20
21
|
export interface DatagridComponentProps {
|
|
21
22
|
/** schema to use */
|
|
@@ -55,21 +56,25 @@ export interface DatagridComponentProps {
|
|
|
55
56
|
filters?: JsonQLFilter[]
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
interface DatagridComponentState {
|
|
60
|
+
/** is design being edited */
|
|
61
|
+
editingDesign: boolean
|
|
62
|
+
/** True if cells can be edited directly */
|
|
63
|
+
cellEditingEnabled: boolean
|
|
64
|
+
/** Height of quickfilters */
|
|
65
|
+
quickfiltersHeight: number | null
|
|
66
|
+
quickfiltersValues: null | any[]
|
|
67
|
+
refreshKey: number
|
|
68
|
+
/** Number of rows */
|
|
69
|
+
numRows?: number
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
// Datagrid with decorations
|
|
59
73
|
// See README.md for description of datagrid format
|
|
60
74
|
// Design should be cleaned already before being passed in (see DatagridUtils)
|
|
61
75
|
export default class DatagridComponent extends React.Component<
|
|
62
76
|
DatagridComponentProps,
|
|
63
|
-
|
|
64
|
-
/** is design being edited */
|
|
65
|
-
editingDesign: boolean
|
|
66
|
-
/** True if cells can be edited directly */
|
|
67
|
-
cellEditingEnabled: boolean
|
|
68
|
-
/** Height of quickfilters */
|
|
69
|
-
quickfiltersHeight: number | null
|
|
70
|
-
quickfiltersValues: null | any[]
|
|
71
|
-
refreshKey: number
|
|
72
|
-
}
|
|
77
|
+
DatagridComponentState
|
|
73
78
|
> {
|
|
74
79
|
datagridView?: DatagridViewComponent | null
|
|
75
80
|
quickfilters?: HTMLElement | null
|
|
@@ -88,15 +93,40 @@ export default class DatagridComponent extends React.Component<
|
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
reload() {
|
|
91
|
-
|
|
96
|
+
this.datagridView?.reload()
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
componentDidMount() {
|
|
95
|
-
|
|
100
|
+
this.loadRowCount()
|
|
101
|
+
this.updateHeight()
|
|
96
102
|
}
|
|
97
103
|
|
|
98
|
-
componentDidUpdate() {
|
|
99
|
-
|
|
104
|
+
componentDidUpdate(prevProps: DatagridComponentProps, prevState: DatagridComponentState) {
|
|
105
|
+
if (!_.isEqual(prevProps.design, this.props.design) || !_.isEqual(prevState.quickfiltersValues, this.state.quickfiltersValues) || prevState.refreshKey !== this.state.refreshKey) {
|
|
106
|
+
this.loadRowCount()
|
|
107
|
+
}
|
|
108
|
+
this.updateHeight()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
loadRowCount() {
|
|
112
|
+
if(!this.props.design.showNumRows) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
let filters = this.props.filters || []
|
|
116
|
+
|
|
117
|
+
// Compile quickfilters
|
|
118
|
+
filters = filters.concat(this.getQuickfilterFilters())
|
|
119
|
+
this.props.datagridDataSource.countRows(this.props.design,
|
|
120
|
+
filters,
|
|
121
|
+
(error: any, numRows: any) => {
|
|
122
|
+
if (error) {
|
|
123
|
+
console.error(error)
|
|
124
|
+
alert(T("Error loading data"))
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
console.log(numRows)
|
|
128
|
+
this.setState({numRows})
|
|
129
|
+
})
|
|
100
130
|
}
|
|
101
131
|
|
|
102
132
|
handleRefreshData = () => {
|
|
@@ -265,6 +295,7 @@ export default class DatagridComponent extends React.Component<
|
|
|
265
295
|
R(
|
|
266
296
|
"div",
|
|
267
297
|
{ style: { float: "right" } },
|
|
298
|
+
this.props.design.showNumRows && this.state.numRows ? R("small", {className: 'text-muted text-sm'}, `${d3Format(',')(this.state.numRows)} rows`): undefined,
|
|
268
299
|
this.renderFindReplace(),
|
|
269
300
|
this.renderCellEdit(),
|
|
270
301
|
this.renderEditButton(),
|
|
@@ -14,6 +14,14 @@ export default class DatagridDataSource {
|
|
|
14
14
|
throw new Error("Not implemented")
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
countRows(
|
|
18
|
+
design: DatagridDesign,
|
|
19
|
+
filters: JsonQLFilter[] | undefined,
|
|
20
|
+
callback: (error: any, numRows: number) => void
|
|
21
|
+
): void {
|
|
22
|
+
throw new Error("Not implemented")
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
/** Gets the quickfilters data source */
|
|
18
26
|
getQuickfiltersDataSource(): QuickfiltersDataSource {
|
|
19
27
|
throw new Error("Not implemented")
|
|
@@ -14,7 +14,7 @@ import OrderBysDesignerComponent from "./OrderBysDesignerComponent"
|
|
|
14
14
|
import ReorderableListComponent from "@mwater/react-library/lib/reorderable/ReorderableListComponent"
|
|
15
15
|
import QuickfiltersDesignComponent from "../quickfilter/QuickfiltersDesignComponent"
|
|
16
16
|
import LabeledExprGenerator from "./LabeledExprGenerator"
|
|
17
|
-
import TableSelectComponent from "
|
|
17
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
18
18
|
import uuid from "uuid"
|
|
19
19
|
import update from "update-object"
|
|
20
20
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
@@ -196,6 +196,14 @@ function DatagridOptionsComponent(props: DatagridOptionsComponentProps) {
|
|
|
196
196
|
>
|
|
197
197
|
{T("Show row numbers")}
|
|
198
198
|
</ui.Checkbox>
|
|
199
|
+
<ui.Checkbox
|
|
200
|
+
value={props.design.showNumRows}
|
|
201
|
+
onChange={(showNumRows) =>
|
|
202
|
+
props.onDesignChange({ ...props.design, showNumRows })
|
|
203
|
+
}
|
|
204
|
+
>
|
|
205
|
+
{T("Show number of rows")}
|
|
206
|
+
</ui.Checkbox>
|
|
199
207
|
<ui.FormGroup label={T("Language")} hint={T("Preferred language of the datagrid")}>
|
|
200
208
|
<ReactSelect
|
|
201
209
|
value={localeOptions.find(opt => opt.value == (props.design.locale || "en")) || null}
|
|
@@ -95,7 +95,7 @@ export default class DatagridViewComponent extends React.Component<
|
|
|
95
95
|
// If design or filters changed, delete all rows
|
|
96
96
|
// TODO won't this reload on column resize?
|
|
97
97
|
if (!_.isEqual(nextProps.design, this.props.design) || !_.isEqual(nextProps.filters, this.props.filters) || nextProps.refreshKey !== this.props.refreshKey) {
|
|
98
|
-
|
|
98
|
+
this.setState({ rows: [], entirelyLoaded: false })
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -4,6 +4,8 @@ import * as QuickfilterUtils from "../quickfilter/QuickfilterUtils"
|
|
|
4
4
|
import { DataSource, Row, Schema } from "@mwater/expressions"
|
|
5
5
|
import { DatagridDesign } from "./DatagridDesign"
|
|
6
6
|
import { JsonQLFilter } from "../JsonQLFilter"
|
|
7
|
+
import _ from "lodash"
|
|
8
|
+
import { JsonQLSelectQuery } from "@mwater/jsonql"
|
|
7
9
|
|
|
8
10
|
/** Uses direct DataSource queries */
|
|
9
11
|
export default class DirectDatagridDataSource implements DatagridDataSource {
|
|
@@ -37,6 +39,39 @@ export default class DirectDatagridDataSource implements DatagridDataSource {
|
|
|
37
39
|
return this.options.dataSource.performQuery(query, callback)
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
countRows(
|
|
43
|
+
design: DatagridDesign,
|
|
44
|
+
filters: JsonQLFilter[] | undefined,
|
|
45
|
+
callback: (error: any, numRows: number) => void
|
|
46
|
+
): void {
|
|
47
|
+
const queryBuilder = new DatagridQueryBuilder(this.options.schema)
|
|
48
|
+
|
|
49
|
+
// Create query to get the page of rows at the specific offset
|
|
50
|
+
const query = queryBuilder.createQuery(design, {
|
|
51
|
+
extraFilters: filters
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const countQuery: JsonQLSelectQuery = {
|
|
55
|
+
..._.omit(query, 'orderBy'),
|
|
56
|
+
selects: [
|
|
57
|
+
{
|
|
58
|
+
type: 'select',
|
|
59
|
+
expr: {
|
|
60
|
+
type: 'op',
|
|
61
|
+
op: 'count',
|
|
62
|
+
exprs: []
|
|
63
|
+
},
|
|
64
|
+
alias: 'cnt'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
console.log(countQuery)
|
|
70
|
+
return this.options.dataSource.performQuery(countQuery, (error, rows) => {
|
|
71
|
+
callback(error, rows?.[0]?.cnt)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
40
75
|
// Gets the quickfilters data source
|
|
41
76
|
getQuickfiltersDataSource() {
|
|
42
77
|
return {
|
|
@@ -51,9 +51,27 @@ export default class ServerDatagridDataSource extends DatagridDataSource {
|
|
|
51
51
|
|
|
52
52
|
const url = this.options.apiUrl + `datagrids/${this.options.datagridId}/data?` + querystring.stringify(query)
|
|
53
53
|
|
|
54
|
-
return $.getJSON(url, (data) => {
|
|
54
|
+
return $.getJSON(url, (data: any) => {
|
|
55
55
|
return callback(null, data)
|
|
56
|
-
}).fail((xhr) => {
|
|
56
|
+
}).fail((xhr: any) => {
|
|
57
|
+
console.log(xhr.responseText)
|
|
58
|
+
return callback(new Error(xhr.responseText))
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
countRows(design: DatagridDesign, filters: any, callback: any) {
|
|
63
|
+
const query = {
|
|
64
|
+
client: this.options.client,
|
|
65
|
+
share: this.options.share,
|
|
66
|
+
filters: compressJson(filters),
|
|
67
|
+
rev: this.options.rev,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const url = this.options.apiUrl + `datagrids/${this.options.datagridId}/summary?` + querystring.stringify(query)
|
|
71
|
+
|
|
72
|
+
return $.getJSON(url, (data: any) => {
|
|
73
|
+
return callback(null, data?.[0]?.cnt)
|
|
74
|
+
}).fail((xhr: any) => {
|
|
57
75
|
console.log(xhr.responseText)
|
|
58
76
|
return callback(new Error(xhr.responseText))
|
|
59
77
|
})
|
|
@@ -109,9 +127,9 @@ class ServerQuickfilterDataSource {
|
|
|
109
127
|
`datagrids/${this.options.datagridId}/quickfilters/${index}/values?` +
|
|
110
128
|
querystring.stringify(query)
|
|
111
129
|
|
|
112
|
-
return $.getJSON(url, (data) => {
|
|
130
|
+
return $.getJSON(url, (data: any) => {
|
|
113
131
|
return callback(null, data)
|
|
114
|
-
}).fail((xhr) => {
|
|
132
|
+
}).fail((xhr: any) => {
|
|
115
133
|
console.log(xhr.responseText)
|
|
116
134
|
return callback(new Error(xhr.responseText))
|
|
117
135
|
})
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,6 @@ export { default as RegionSelectComponent } from "./maps/RegionSelectComponent"
|
|
|
12
12
|
|
|
13
13
|
export * from "./datagrids/DatagridDesign"
|
|
14
14
|
|
|
15
|
-
export { default as TableSelectComponent } from "./TableSelectComponent"
|
|
16
|
-
|
|
17
15
|
export * from "./JsonQLFilter"
|
|
18
16
|
|
|
19
17
|
export { default as DashboardComponent } from "./dashboards/DashboardComponent"
|
|
@@ -331,7 +331,7 @@ class BlocksDisplayComponent extends React.Component<BlocksDisplayComponentProps
|
|
|
331
331
|
R(
|
|
332
332
|
"div",
|
|
333
333
|
{
|
|
334
|
-
style: { position: "absolute", left: 141, top: 0, bottom: 0, right: 0,
|
|
334
|
+
style: { position: "absolute", left: 141, top: 0, bottom: 0, right: 0, overflowX: "auto", overflowY: "scroll" },
|
|
335
335
|
className: `mwater-visualization-block-parent-outer mwater-visualization-block-parent-outer-${
|
|
336
336
|
this.props.style || "default"
|
|
337
337
|
} mwater-visualization-block-editing`
|
|
@@ -351,7 +351,7 @@ class BlocksDisplayComponent extends React.Component<BlocksDisplayComponentProps
|
|
|
351
351
|
)
|
|
352
352
|
} else {
|
|
353
353
|
return R(AutoSizeComponent, { injectWidth: true, injectHeight: true } as any, (size: any) => {
|
|
354
|
-
const outerParentStyle: CSSProperties = { width: "100%", height: "100%", overflowX: "auto" }
|
|
354
|
+
const outerParentStyle: CSSProperties = { width: "100%", height: "100%", overflowX: "auto", overflowY: "scroll" }
|
|
355
355
|
innerParentStyle = {}
|
|
356
356
|
|
|
357
357
|
// Remove padding if small
|
|
@@ -68,8 +68,8 @@ export default class LegoLayoutEngine {
|
|
|
68
68
|
// Returns layout lookup of id -> layout
|
|
69
69
|
performLayout(layouts: any, priority: any) {
|
|
70
70
|
// Create list of placed layouts to avoid as placing new ones
|
|
71
|
-
const placedLayouts = []
|
|
72
|
-
const results = {}
|
|
71
|
+
const placedLayouts: any[] = []
|
|
72
|
+
const results: any = {}
|
|
73
73
|
|
|
74
74
|
// Add priority first to displace others
|
|
75
75
|
if (priority) {
|
|
@@ -106,7 +106,7 @@ class Container extends React.Component<ContainerProps, ContainerState> {
|
|
|
106
106
|
let items = _.clone(this.props.items)
|
|
107
107
|
items[id] = { layout: droppedLayout, widget }
|
|
108
108
|
|
|
109
|
-
let layouts = {}
|
|
109
|
+
let layouts: any = {}
|
|
110
110
|
for (id in items) {
|
|
111
111
|
const item = items[id]
|
|
112
112
|
layouts[id] = item.layout
|
|
@@ -279,7 +279,7 @@ class Container extends React.Component<ContainerProps, ContainerState> {
|
|
|
279
279
|
hoveredLayout = props.layoutEngine.rectToLayout(hoveredRect)
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
let layouts = {}
|
|
282
|
+
let layouts: any = {}
|
|
283
283
|
for (id in props.items) {
|
|
284
284
|
const item = props.items[id]
|
|
285
285
|
layouts[id] = item.layout
|
package/src/maps/BingLayer.ts
CHANGED
|
@@ -69,9 +69,9 @@ module.exports = L.TileLayer.extend({
|
|
|
69
69
|
loadMetadata: function () {
|
|
70
70
|
var _this = this
|
|
71
71
|
var cbid = "_bing_metadata_" + L.Util.stamp(this)
|
|
72
|
-
window[cbid] = function (meta: any) {
|
|
72
|
+
;(window as any)[cbid] = function (meta: any) {
|
|
73
73
|
_this.meta = meta
|
|
74
|
-
window[cbid] = undefined
|
|
74
|
+
;(window as any)[cbid] = undefined
|
|
75
75
|
var e = document.getElementById(cbid)
|
|
76
76
|
e!.parentNode!.removeChild(e!)
|
|
77
77
|
if (meta.errorDetails) {
|
|
@@ -9,7 +9,7 @@ import { ExprCompiler } from "@mwater/expressions"
|
|
|
9
9
|
import NumberInputComponent from "@mwater/react-library/lib/NumberInputComponent"
|
|
10
10
|
import AxisComponent from "./../axes/AxisComponent"
|
|
11
11
|
import ColorComponent from "../ColorComponent"
|
|
12
|
-
import TableSelectComponent from "
|
|
12
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
13
13
|
import { default as Rcslider } from "rc-slider"
|
|
14
14
|
import EditPopupComponent from "./EditPopupComponent"
|
|
15
15
|
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
@@ -6,7 +6,7 @@ import { produce } from "immer"
|
|
|
6
6
|
import { ExprComponent, FilterExprComponent } from "@mwater/expressions-ui"
|
|
7
7
|
import { ExprCompiler, Schema, DataSource, Expr, OpExpr } from "@mwater/expressions"
|
|
8
8
|
import AxisComponent from "./../axes/AxisComponent"
|
|
9
|
-
import TableSelectComponent from "
|
|
9
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
10
10
|
import ColorComponent from "../ColorComponent"
|
|
11
11
|
import Rcslider from "rc-slider"
|
|
12
12
|
import ChoroplethLayerDesign from "./ChoroplethLayerDesign"
|
|
@@ -8,7 +8,7 @@ import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
|
8
8
|
import { ExprCompiler } from "@mwater/expressions"
|
|
9
9
|
import AxisComponent from "./../axes/AxisComponent"
|
|
10
10
|
import ColorComponent from "../ColorComponent"
|
|
11
|
-
import TableSelectComponent from "
|
|
11
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
12
12
|
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
13
13
|
|
|
14
14
|
export interface ClusterLayerDesignerComponentProps {
|
|
@@ -249,8 +249,7 @@ class DirectLayerDataSource implements MapLayerDataSource {
|
|
|
249
249
|
const { url, expires } = await getVectorTileFromDirectRequest({
|
|
250
250
|
apiUrl: this.options.apiUrl,
|
|
251
251
|
client: this.options.client,
|
|
252
|
-
directTokenRequest
|
|
253
|
-
createdAfter
|
|
252
|
+
directTokenRequest
|
|
254
253
|
})
|
|
255
254
|
|
|
256
255
|
return { url, expires }
|
|
@@ -6,7 +6,7 @@ import { produce } from "immer"
|
|
|
6
6
|
import { ExprComponent, FilterExprComponent } from "@mwater/expressions-ui"
|
|
7
7
|
import { ExprCompiler, Schema, DataSource, Expr, OpExpr } from "@mwater/expressions"
|
|
8
8
|
import AxisComponent from "../axes/AxisComponent"
|
|
9
|
-
import TableSelectComponent from "
|
|
9
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
10
10
|
import Rcslider from "rc-slider"
|
|
11
11
|
import GridLayerDesign from "./GridLayerDesign"
|
|
12
12
|
import { JsonQLFilter } from "../index"
|
package/src/maps/LegendGroup.ts
CHANGED
|
@@ -94,14 +94,14 @@ class LoadingLegend extends React.Component<LoadingLegendProps, LoadingLegendSta
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
componentDidMount() {
|
|
97
|
-
return $.get(this.props.url).done((data) => {
|
|
97
|
+
return $.get(this.props.url).done((data: any) => {
|
|
98
98
|
return this.setState({ html: data })
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
componentWillReceiveProps(nextProps: any) {
|
|
103
103
|
if (nextProps.url !== this.props.url) {
|
|
104
|
-
return $.get(nextProps.url).done((data) => {
|
|
104
|
+
return $.get(nextProps.url).done((data: any) => {
|
|
105
105
|
return this.setState({ html: data })
|
|
106
106
|
})
|
|
107
107
|
}
|
|
@@ -18,6 +18,7 @@ import { MapDesign } from "./MapDesign"
|
|
|
18
18
|
import { JsonQLFilter } from "../JsonQLFilter"
|
|
19
19
|
import QuickfiltersDesignComponent from "../quickfilter/QuickfiltersDesignComponent"
|
|
20
20
|
import produce from "immer"
|
|
21
|
+
import { ActiveTablesContext } from "@mwater/expressions-ui"
|
|
21
22
|
|
|
22
23
|
export interface MapDesignerComponentProps {
|
|
23
24
|
/** Schema to use */
|
|
@@ -36,15 +37,6 @@ export interface MapDesignerComponentProps {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export default class MapDesignerComponent extends React.Component<MapDesignerComponentProps> {
|
|
39
|
-
static childContextTypes = { activeTables: PropTypes.arrayOf(PropTypes.string.isRequired) }
|
|
40
|
-
|
|
41
|
-
getChildContext() {
|
|
42
|
-
return {
|
|
43
|
-
// Pass active tables down to table select components so they can present a shorter list
|
|
44
|
-
activeTables: MapUtils.getFilterableTables(this.props.design, this.props.schema)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
40
|
handleAttributionChange = (text: any) => {
|
|
49
41
|
const design = { ...this.props.design, attribution: text }
|
|
50
42
|
return this.props.onDesignChange(design)
|
|
@@ -229,14 +221,14 @@ export default class MapDesignerComponent extends React.Component<MapDesignerCom
|
|
|
229
221
|
})
|
|
230
222
|
}
|
|
231
223
|
|
|
224
|
+
const activeTables = MapUtils.getFilterableTables(this.props.design, this.props.schema)
|
|
232
225
|
|
|
233
|
-
return
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
})
|
|
226
|
+
return (
|
|
227
|
+
<ActiveTablesContext.Provider value={activeTables}>
|
|
228
|
+
<div style={{ padding: 5 }}>
|
|
229
|
+
<TabbedComponent initialTabId="layers" tabs={tabs} />
|
|
230
|
+
</div>
|
|
231
|
+
</ActiveTablesContext.Provider>
|
|
240
232
|
)
|
|
241
233
|
}
|
|
242
234
|
}
|
|
@@ -6,7 +6,7 @@ import { DataSource, ExprUtils, OpExpr, Schema } from "@mwater/expressions"
|
|
|
6
6
|
import { ExprCompiler } from "@mwater/expressions"
|
|
7
7
|
import AxisComponent from "./../axes/AxisComponent"
|
|
8
8
|
import ColorComponent from "../ColorComponent"
|
|
9
|
-
import TableSelectComponent from "
|
|
9
|
+
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
10
10
|
import EditPopupComponent from "./EditPopupComponent"
|
|
11
11
|
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
12
12
|
import MarkerSymbolSelectComponent from "./MarkerSymbolSelectComponent"
|
|
@@ -38,7 +38,7 @@ export function createPopupFilters(
|
|
|
38
38
|
type: "op",
|
|
39
39
|
op: "within",
|
|
40
40
|
table,
|
|
41
|
-
exprs: [expr, { type: "literal", idTable: exprUtils.getExprIdTable(expr), valueType: "id", value: rowId }]
|
|
41
|
+
exprs: [expr, { type: "literal", idTable: exprUtils.getExprIdTable(expr) ?? undefined, valueType: "id", value: rowId }]
|
|
42
42
|
}
|
|
43
43
|
filters.push({ table, jsonql: exprCompiler.compileExpr({ expr: filterExpr, tableAlias: "{alias}" }) })
|
|
44
44
|
}
|
|
@@ -90,10 +90,10 @@ export function createPopupFilters(
|
|
|
90
90
|
|
|
91
91
|
// Create default popup filter joins where the join is just the id (not used for choropleth since that needs to join to admin_regions)
|
|
92
92
|
export function createDefaultPopupFilterJoins(table: any) {
|
|
93
|
-
const popupFilterJoins = {}
|
|
94
|
-
|
|
95
93
|
// Return id of row for a simple match
|
|
96
|
-
popupFilterJoins
|
|
94
|
+
const popupFilterJoins = {
|
|
95
|
+
[table]: { table, type: "id" }
|
|
96
|
+
}
|
|
97
97
|
|
|
98
98
|
return popupFilterJoins
|
|
99
99
|
}
|
|
@@ -79,7 +79,7 @@ export default class ServerMapDataSource implements MapDataSource {
|
|
|
79
79
|
|
|
80
80
|
$.getJSON(url, (data: any) => {
|
|
81
81
|
return callback(null, data)
|
|
82
|
-
}).fail((xhr) => {
|
|
82
|
+
}).fail((xhr: any) => {
|
|
83
83
|
console.log(xhr.responseText)
|
|
84
84
|
return callback(new Error(xhr.responseText))
|
|
85
85
|
})
|
|
@@ -317,9 +317,9 @@ class ServerMapLayerPopupWidgetDataSource implements WidgetDataSource {
|
|
|
317
317
|
`maps/${this.options.mapId}/layers/${this.options.layerId}/widgets/${this.options.popupWidgetId}/data?` +
|
|
318
318
|
querystring.stringify(query)
|
|
319
319
|
|
|
320
|
-
return $.getJSON(url, (data) => {
|
|
320
|
+
return $.getJSON(url, (data: any) => {
|
|
321
321
|
return callback(null, data)
|
|
322
|
-
}).fail((xhr) => {
|
|
322
|
+
}).fail((xhr: any) => {
|
|
323
323
|
console.log(xhr.responseText)
|
|
324
324
|
return callback(new Error(xhr.responseText))
|
|
325
325
|
})
|
|
@@ -374,7 +374,7 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
374
374
|
`maps/${this.options.mapId}/quickfilters/${index}/values?` +
|
|
375
375
|
querystring.stringify(query)
|
|
376
376
|
|
|
377
|
-
const headers = {}
|
|
377
|
+
const headers: any = {}
|
|
378
378
|
const cacheExpiry = this.options.dataSource.getCacheExpiry()
|
|
379
379
|
if (cacheExpiry) {
|
|
380
380
|
const seconds = Math.floor((new Date().getTime() - cacheExpiry) / 1000)
|
|
@@ -387,10 +387,10 @@ class ServerQuickfilterDataSource implements QuickfiltersDataSource {
|
|
|
387
387
|
url,
|
|
388
388
|
headers
|
|
389
389
|
})
|
|
390
|
-
.done((data) => {
|
|
390
|
+
.done((data: any) => {
|
|
391
391
|
return callback(null, data)
|
|
392
392
|
})
|
|
393
|
-
.fail((xhr) => {
|
|
393
|
+
.fail((xhr: any) => {
|
|
394
394
|
console.log(xhr.responseText)
|
|
395
395
|
return callback(new Error(xhr.responseText))
|
|
396
396
|
})
|
|
@@ -3,22 +3,10 @@ import React from "react"
|
|
|
3
3
|
const R = React.createElement
|
|
4
4
|
import { produce } from "immer"
|
|
5
5
|
|
|
6
|
-
import { ExprComponent, FilterExprComponent } from "@mwater/expressions-ui"
|
|
7
|
-
import { ExprCompiler, Schema, DataSource, Expr, OpExpr } from "@mwater/expressions"
|
|
8
|
-
import AxisComponent from "./../axes/AxisComponent"
|
|
9
|
-
import TableSelectComponent from "../TableSelectComponent"
|
|
10
|
-
import ColorComponent from "../ColorComponent"
|
|
11
|
-
import Rcslider from "rc-slider"
|
|
12
|
-
import ChoroplethLayerDesign from "./ChoroplethLayerDesign"
|
|
13
6
|
import { JsonQLFilter } from "../index"
|
|
14
|
-
import
|
|
15
|
-
import ZoomLevelsComponent from "./ZoomLevelsComponent"
|
|
16
|
-
import ui, { Radio } from "@mwater/react-library/lib/bootstrap"
|
|
17
|
-
import { Axis } from "../axes/Axis"
|
|
7
|
+
import { Radio } from "@mwater/react-library/lib/bootstrap"
|
|
18
8
|
import { SwitchableTileUrlLayerDesign } from "./SwitchableTileUrlLayer"
|
|
19
9
|
|
|
20
|
-
import AdminScopeAndDetailLevelComponent from "./AdminScopeAndDetailLevelComponent"
|
|
21
|
-
import ScopeAndDetailLevelComponent from "./ScopeAndDetailLevelComponent"
|
|
22
10
|
|
|
23
11
|
/** Designer for a switchable tile url layer */
|
|
24
12
|
export default class SwitchableTileUrlLayerDesigner extends React.Component<{
|