@mwater/visualization 5.0.1 → 5.2.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/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/MWaterAddRelatedFormComponent.d.ts +1 -1
- package/lib/MWaterAddRelatedFormComponent.js +10 -17
- package/lib/MWaterCompleteTableSelectComponent.d.ts +2 -9
- package/lib/MWaterContextComponent.d.ts +31 -9
- package/lib/MWaterContextComponent.js +85 -76
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +14 -4
- package/lib/MWaterLoaderComponent.js +10 -2
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +20 -41
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.js +9 -7
- package/lib/axes/AxisComponent.d.ts +4 -4
- package/lib/axes/RangesComponent.d.ts +12 -6
- package/lib/axes/RangesComponent.js +21 -10
- package/lib/dashboards/DashboardComponent.d.ts +1 -14
- package/lib/dashboards/DashboardComponent.js +18 -56
- package/lib/dashboards/DashboardDesign.d.ts +2 -17
- package/lib/dashboards/DashboardViewComponent.js +3 -4
- package/lib/dashboards/LayoutOptionsComponent.js +4 -3
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -0
- package/lib/dashboards/ServerDashboardDataSource.js +3 -0
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/datagrids/DatagridComponent.d.ts +10 -13
- package/lib/datagrids/DatagridComponent.js +27 -5
- package/lib/datagrids/DatagridDataSource.d.ts +3 -2
- package/lib/datagrids/DatagridDataSource.js +0 -11
- package/lib/datagrids/DatagridDesign.d.ts +2 -0
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +11 -8
- package/lib/datagrids/DatagridViewComponent.js +2 -2
- package/lib/datagrids/DirectDatagridDataSource.d.ts +1 -0
- package/lib/datagrids/DirectDatagridDataSource.js +26 -0
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +2 -1
- package/lib/datagrids/ServerDatagridDataSource.js +16 -3
- package/lib/demo.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +2 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +2 -2
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/layouts/grid/LegoLayoutEngine.d.ts +1 -1
- package/lib/maps/BufferLayer.js +3 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayerDesigner.js +2 -2
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/ClusterLayerDesignerComponent.js +2 -2
- package/lib/maps/DirectMapDataSource.js +1 -2
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +2 -3
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +2 -7
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapDesignerComponent.d.ts +1 -12
- package/lib/maps/MapDesignerComponent.js +5 -12
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- 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/RasterMapViewComponent.d.ts +2 -9
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +1 -1
- package/lib/maps/UtfGridLayer.js +1 -1
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +10 -2
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/widgets/IFrameWidgetComponent.d.ts +2 -9
- package/lib/widgets/ImageWidgetComponent.d.ts +6 -24
- package/lib/widgets/ImageWidgetComponent.js +2 -2
- package/lib/widgets/MapWidget.d.ts +2 -7
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/charts/ChartWidget.d.ts +3 -15
- 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/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +2 -31
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +73 -66
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +10 -6
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +3 -22
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/table/TableChartViewComponent.js +21 -7
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprItemEditorComponent.js +2 -2
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextWidgetDesign.d.ts +3 -1
- package/package.json +1 -1
- package/src/GlobalFilter.ts +17 -0
- package/src/MWaterAddRelatedFormComponent.ts +15 -20
- package/src/MWaterContextComponent.tsx +158 -0
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +10 -3
- package/src/{MWaterTableSelectComponent.ts → MWaterTableSelectComponent.tsx} +61 -66
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +10 -9
- package/src/axes/RangesComponent.ts +27 -16
- package/src/dashboards/{DashboardComponent.ts → DashboardComponent.tsx} +39 -80
- package/src/dashboards/DashboardDesign.ts +2 -22
- package/src/dashboards/DashboardViewComponent.ts +4 -5
- package/src/dashboards/LayoutOptionsComponent.tsx +6 -4
- package/src/dashboards/ServerDashboardDataSource.ts +16 -12
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/datagrids/DatagridComponent.ts +45 -14
- package/src/datagrids/DatagridDataSource.ts +10 -8
- package/src/datagrids/DatagridDesign.ts +3 -0
- package/src/datagrids/DatagridDesignerComponent.tsx +31 -19
- package/src/datagrids/DatagridViewComponent.ts +4 -4
- package/src/datagrids/DirectDatagridDataSource.ts +35 -0
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +23 -6
- package/src/demo.ts +1 -1
- package/src/index.ts +1 -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/BufferLayer.ts +3 -1
- package/src/maps/BufferLayerDesignerComponent.ts +1 -1
- package/src/maps/ChoroplethLayerDesigner.tsx +1 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/ClusterLayerDesignerComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +1 -2
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +1 -2
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/LegendGroup.ts +1 -1
- package/src/maps/MWaterServerLayer.ts +2 -2
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapDesignerComponent.ts → MapDesignerComponent.tsx} +8 -16
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayerDesignerComponent.ts +1 -1
- package/src/maps/PopupFilterJoinsUtils.ts +4 -4
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/SwitchableTileUrlLayerDesigner.tsx +1 -13
- package/src/maps/UtfGridLayer.ts +4 -4
- package/src/maps/VectorMapViewComponent.tsx +0 -1
- package/src/maps/mapboxUtils.ts +2 -2
- package/src/maps/vectorMaps.tsx +10 -1
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- 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/charts/table/TableChartViewComponent.ts +21 -7
- package/src/widgets/text/ExprItemEditorComponent.tsx +1 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -1
- package/src/MWaterContextComponent.ts +0 -141
- package/src/TableSelectComponent.ts +0 -60
- package/src/dashboards/SettingsModalComponent.ts +0 -169
|
@@ -24,7 +24,7 @@ export interface FindReplaceModalComponentProps {
|
|
|
24
24
|
|
|
25
25
|
/** Update cell values by updating set of expressions and values */
|
|
26
26
|
updateExprValues: (tableId: string, rowUpdates: RowUpdate[]) => Promise<void>
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
onUpdate: () => void
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -73,6 +73,18 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
73
73
|
// Get expr of replace column
|
|
74
74
|
const replaceExpr = _.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr
|
|
75
75
|
|
|
76
|
+
const exprType = exprUtils.getExprType(this.state.withExpr)
|
|
77
|
+
let compiledWithExpr = exprCompiler.compileExpr({ expr: this.state.withExpr, tableAlias: "main" })
|
|
78
|
+
if (exprType === "geometry") {
|
|
79
|
+
compiledWithExpr = {
|
|
80
|
+
type: "op",
|
|
81
|
+
op: "ST_AsGeoJSON",
|
|
82
|
+
exprs: [
|
|
83
|
+
{ type: "op", op: "ST_Transform", exprs: [{ type: "op", op: "::geometry", exprs: [compiledWithExpr] }, 4326] }
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
76
88
|
// Get ids and with value, filtered by filters, design.filter and conditionExpr (if present)
|
|
77
89
|
const query: JsonQLSelectQuery = {
|
|
78
90
|
type: "query",
|
|
@@ -88,7 +100,7 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
88
100
|
},
|
|
89
101
|
{
|
|
90
102
|
type: "select",
|
|
91
|
-
expr:
|
|
103
|
+
expr: compiledWithExpr,
|
|
92
104
|
alias: "withValue"
|
|
93
105
|
}
|
|
94
106
|
],
|
|
@@ -120,7 +132,12 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
120
132
|
}
|
|
121
133
|
|
|
122
134
|
// Create expr
|
|
123
|
-
let expr: Expr = {
|
|
135
|
+
let expr: Expr = {
|
|
136
|
+
type: "op",
|
|
137
|
+
op: filter.op,
|
|
138
|
+
table: design.table!,
|
|
139
|
+
exprs: [columnExpr as Expr].concat(filter.exprs)
|
|
140
|
+
}
|
|
124
141
|
|
|
125
142
|
// Clean expr
|
|
126
143
|
expr = exprCleaner.cleanExpr(expr, { table: design.table! })
|
|
@@ -147,16 +164,19 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
147
164
|
}
|
|
148
165
|
|
|
149
166
|
// Perform updates
|
|
150
|
-
await this.props.updateExprValues(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
await this.props.updateExprValues(
|
|
168
|
+
this.props.design.table!,
|
|
169
|
+
rows.map(row => ({
|
|
170
|
+
primaryKey: row.id,
|
|
171
|
+
expr: replaceExpr,
|
|
172
|
+
value: exprType === "geometry" ? JSON.parse(row.withValue) : row.withValue
|
|
173
|
+
}))
|
|
174
|
+
)
|
|
175
|
+
|
|
156
176
|
alert(T("Successfully replaced {0} values", rows.length))
|
|
157
177
|
this.setState({ open: false })
|
|
158
178
|
this.props.onUpdate()
|
|
159
|
-
} catch(error) {
|
|
179
|
+
} catch (error) {
|
|
160
180
|
alert(`Error: ${error.message}`)
|
|
161
181
|
} finally {
|
|
162
182
|
this.setState({ busy: false })
|
|
@@ -183,7 +203,8 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
183
203
|
else: replaceColumn.expr
|
|
184
204
|
}
|
|
185
205
|
|
|
186
|
-
replaceColumn.label =
|
|
206
|
+
replaceColumn.label =
|
|
207
|
+
replaceColumn.label || exprUtils.summarizeExpr(replaceColumn.expr, this.props.design.locale)
|
|
187
208
|
}
|
|
188
209
|
|
|
189
210
|
// Add filter
|
|
@@ -193,13 +214,9 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
193
214
|
type: "op",
|
|
194
215
|
op: "and",
|
|
195
216
|
table: this.props.design.table!,
|
|
196
|
-
exprs: [
|
|
197
|
-
draft.filter,
|
|
198
|
-
this.state.conditionExpr
|
|
199
|
-
]
|
|
217
|
+
exprs: [draft.filter, this.state.conditionExpr]
|
|
200
218
|
}
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
219
|
+
} else {
|
|
203
220
|
draft.filter = this.state.conditionExpr
|
|
204
221
|
}
|
|
205
222
|
}
|
|
@@ -228,9 +245,9 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
228
245
|
// Determine which columns are replace-able. Excludes subtables and aggregates
|
|
229
246
|
const replaceColumns = _.filter(
|
|
230
247
|
this.props.design.columns,
|
|
231
|
-
|
|
248
|
+
column => !column.subtable && exprUtils.getExprAggrStatus(column.expr) === "individual"
|
|
232
249
|
)
|
|
233
|
-
const replaceColumnOptions = _.map(replaceColumns,
|
|
250
|
+
const replaceColumnOptions = _.map(replaceColumns, column => ({
|
|
234
251
|
value: column.id,
|
|
235
252
|
label: column.label || exprUtils.summarizeExpr(column.expr, this.props.design.locale)
|
|
236
253
|
}))
|
|
@@ -263,7 +280,7 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
263
280
|
placeholder: T("Select Column..."),
|
|
264
281
|
styles: {
|
|
265
282
|
// Keep menu above fixed data table headers
|
|
266
|
-
menu:
|
|
283
|
+
menu: style => _.extend({}, style, { zIndex: 2 })
|
|
267
284
|
}
|
|
268
285
|
})
|
|
269
286
|
),
|
|
@@ -282,7 +299,7 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
282
299
|
dataSource: this.props.dataSource,
|
|
283
300
|
table: this.props.design.table!,
|
|
284
301
|
value: this.state.withExpr,
|
|
285
|
-
onChange:
|
|
302
|
+
onChange: value => this.setState({ withExpr: value }),
|
|
286
303
|
types: [exprUtils.getExprType(replaceExpr)!],
|
|
287
304
|
enumValues: exprUtils.getExprEnumValues(replaceExpr) || undefined,
|
|
288
305
|
idTable: exprUtils.getExprIdTable(replaceExpr) || undefined,
|
|
@@ -304,7 +321,7 @@ export default class FindReplaceModalComponent extends React.Component<
|
|
|
304
321
|
dataSource: this.props.dataSource,
|
|
305
322
|
table: this.props.design.table!,
|
|
306
323
|
value: this.state.conditionExpr,
|
|
307
|
-
onChange:
|
|
324
|
+
onChange: value => this.setState({ conditionExpr: value }),
|
|
308
325
|
types: ["boolean"],
|
|
309
326
|
placeholder: T("All Rows")
|
|
310
327
|
})
|
|
@@ -22,7 +22,7 @@ export interface ServerDatagridDataSourceOptions {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** Uses mWater server to get datagrid data to allow sharing with unprivileged users */
|
|
25
|
-
export default class ServerDatagridDataSource
|
|
25
|
+
export default class ServerDatagridDataSource implements DatagridDataSource {
|
|
26
26
|
options: ServerDatagridDataSourceOptions
|
|
27
27
|
|
|
28
28
|
// options:
|
|
@@ -32,7 +32,6 @@ export default class ServerDatagridDataSource extends DatagridDataSource {
|
|
|
32
32
|
// datagridId: datagrid id to use on server
|
|
33
33
|
// rev: revision to use to allow caching
|
|
34
34
|
constructor(options: ServerDatagridDataSourceOptions) {
|
|
35
|
-
super()
|
|
36
35
|
this.options = options
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -51,9 +50,27 @@ export default class ServerDatagridDataSource extends DatagridDataSource {
|
|
|
51
50
|
|
|
52
51
|
const url = this.options.apiUrl + `datagrids/${this.options.datagridId}/data?` + querystring.stringify(query)
|
|
53
52
|
|
|
54
|
-
return $.getJSON(url, (data) => {
|
|
53
|
+
return $.getJSON(url, (data: any) => {
|
|
55
54
|
return callback(null, data)
|
|
56
|
-
}).fail((xhr) => {
|
|
55
|
+
}).fail((xhr: any) => {
|
|
56
|
+
console.log(xhr.responseText)
|
|
57
|
+
return callback(new Error(xhr.responseText))
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
countRows(design: DatagridDesign, filters: any, callback: any) {
|
|
62
|
+
const query = {
|
|
63
|
+
client: this.options.client,
|
|
64
|
+
share: this.options.share,
|
|
65
|
+
filters: compressJson(filters),
|
|
66
|
+
rev: this.options.rev,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const url = this.options.apiUrl + `datagrids/${this.options.datagridId}/summary?` + querystring.stringify(query)
|
|
70
|
+
|
|
71
|
+
return $.getJSON(url, (data: any) => {
|
|
72
|
+
return callback(null, data?.[0]?.cnt)
|
|
73
|
+
}).fail((xhr: any) => {
|
|
57
74
|
console.log(xhr.responseText)
|
|
58
75
|
return callback(new Error(xhr.responseText))
|
|
59
76
|
})
|
|
@@ -109,9 +126,9 @@ class ServerQuickfilterDataSource {
|
|
|
109
126
|
`datagrids/${this.options.datagridId}/quickfilters/${index}/values?` +
|
|
110
127
|
querystring.stringify(query)
|
|
111
128
|
|
|
112
|
-
return $.getJSON(url, (data) => {
|
|
129
|
+
return $.getJSON(url, (data: any) => {
|
|
113
130
|
return callback(null, data)
|
|
114
|
-
}).fail((xhr) => {
|
|
131
|
+
}).fail((xhr: any) => {
|
|
115
132
|
console.log(xhr.responseText)
|
|
116
133
|
return callback(new Error(xhr.responseText))
|
|
117
134
|
})
|
package/src/demo.ts
CHANGED
|
@@ -471,7 +471,7 @@ class WaterOrgDashboardPane extends React.Component {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
componentWillMount() {
|
|
474
|
-
const url = this.props.apiUrl + "
|
|
474
|
+
const url = this.props.apiUrl + "schema"
|
|
475
475
|
return $.getJSON(url, (schemaJson) => {
|
|
476
476
|
const schema = new Schema(schemaJson)
|
|
477
477
|
const dataSource = new MWaterDataSource(this.props.apiUrl, null, { serverCaching: false, localCaching: true })
|
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"
|
|
@@ -77,6 +75,7 @@ export { default as AxisBuilder } from "./axes/AxisBuilder"
|
|
|
77
75
|
export { default as ColorSchemeFactory } from "./ColorSchemeFactory"
|
|
78
76
|
export { default as DatagridComponent } from "./datagrids/DatagridComponent"
|
|
79
77
|
export { default as DatagridViewComponent } from "./datagrids/DatagridViewComponent"
|
|
78
|
+
export { default as DatagridDataSource } from "./datagrids/DatagridDataSource"
|
|
80
79
|
export { default as ServerDashboardDataSource } from "./dashboards/ServerDashboardDataSource"
|
|
81
80
|
export { default as ServerMapDataSource } from "./maps/ServerMapDataSource"
|
|
82
81
|
export { default as DirectMapDataSource } from "./maps/DirectMapDataSource"
|
|
@@ -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) {
|
package/src/maps/BufferLayer.ts
CHANGED
|
@@ -88,7 +88,9 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
|
|
|
88
88
|
sourceLayers: [{ id: "circles", jsonql: jsonql }],
|
|
89
89
|
ctes: [],
|
|
90
90
|
mapLayers: mapLayers,
|
|
91
|
-
mapLayersHandleClicks: [`${sourceId}:fill`]
|
|
91
|
+
mapLayersHandleClicks: [`${sourceId}:fill`],
|
|
92
|
+
minZoom: this.getMinZoom(design),
|
|
93
|
+
maxZoom: this.getMaxZoom(design)
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -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"
|
package/src/maps/ClusterLayer.ts
CHANGED
|
@@ -79,7 +79,9 @@ export default class ClusterLayer extends Layer<ClusterLayerDesign> {
|
|
|
79
79
|
sourceLayers: [{ id: "clusters", jsonql: jsonql }],
|
|
80
80
|
ctes: [],
|
|
81
81
|
mapLayers: mapLayers,
|
|
82
|
-
mapLayersHandleClicks: [`${sourceId}:circles-single`, `${sourceId}:circles-multiple`]
|
|
82
|
+
mapLayersHandleClicks: [`${sourceId}:circles-single`, `${sourceId}:circles-multiple`],
|
|
83
|
+
minZoom: this.getMinZoom(design),
|
|
84
|
+
maxZoom: this.getMaxZoom(design)
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -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 }
|
package/src/maps/GridLayer.ts
CHANGED
|
@@ -75,7 +75,9 @@ export default class GridLayer extends Layer<GridLayerDesign> {
|
|
|
75
75
|
sourceLayers: [{ id: "grid", jsonql: jsonql }],
|
|
76
76
|
ctes: [],
|
|
77
77
|
mapLayers: mapLayers,
|
|
78
|
-
mapLayersHandleClicks: [`${sourceId}:fill`]
|
|
78
|
+
mapLayersHandleClicks: [`${sourceId}:fill`],
|
|
79
|
+
minZoom: this.getMinZoom(design),
|
|
80
|
+
maxZoom: this.getMaxZoom(design)
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -606,9 +608,9 @@ export default class GridLayer extends Layer<GridLayerDesign> {
|
|
|
606
608
|
|
|
607
609
|
// Get min and max zoom levels
|
|
608
610
|
getMinZoom(design: GridLayerDesign) {
|
|
609
|
-
// Determine if too zoomed out to safely display (
|
|
611
|
+
// Determine if too zoomed out to safely display (200x200, so size = 4e7/(2^zoom) < 200)
|
|
610
612
|
if (design.sizeUnits === "meters") {
|
|
611
|
-
const minSafeZoom = Math.log2(
|
|
613
|
+
const minSafeZoom = Math.log2(200000.0 / (design.size || 20000))
|
|
612
614
|
if (design.minZoom) {
|
|
613
615
|
return Math.max(design.minZoom, minSafeZoom)
|
|
614
616
|
} else {
|
|
@@ -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"
|
|
@@ -69,7 +69,6 @@ export default class GridLayerDesigner extends React.Component<{
|
|
|
69
69
|
this.update((d) => {
|
|
70
70
|
d.sizeUnits = sizeUnits
|
|
71
71
|
d.size = 20000
|
|
72
|
-
d.minZoom = 6
|
|
73
72
|
})
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -60,7 +60,7 @@ export function LayerSwitcherComponent(props: { design: MapDesign; onDesignChang
|
|
|
60
60
|
<i className="fas fa-layer-group fa-fw" />
|
|
61
61
|
</div>
|
|
62
62
|
{dropdownOpen ? (
|
|
63
|
-
<div style={{ backgroundColor: "white", padding: 5 }}>{props.design.layerViews.map(renderLayerView)}</div>
|
|
63
|
+
<div style={{ backgroundColor: "white", padding: 5, textAlign: "left" }}>{props.design.layerViews.map(renderLayerView)}</div>
|
|
64
64
|
) : null}
|
|
65
65
|
</div>
|
|
66
66
|
)
|
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
|
}
|
package/src/maps/MapDesign.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Expr
|
|
1
|
+
import { Expr } from "@mwater/expressions"
|
|
2
2
|
import { Quickfilter } from "../quickfilter/Quickfilter"
|
|
3
|
+
import { GlobalFilter } from "../GlobalFilter"
|
|
3
4
|
|
|
4
5
|
/** Maps are stored as a base layer, a series of layers and filters. */
|
|
5
6
|
export interface MapDesign {
|
|
@@ -85,19 +86,3 @@ export interface MapLayerView {
|
|
|
85
86
|
/** true to hide legend */
|
|
86
87
|
hideLegend?: boolean
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
/** Global filters apply to multiple tables at once if a certain column is present. User-interface to set them is application-specific
|
|
90
|
-
and the default (non-mWater) dashboard applies them but does not allow editing. */
|
|
91
|
-
export interface GlobalFilter {
|
|
92
|
-
/** id of column to filter */
|
|
93
|
-
columnId: string
|
|
94
|
-
|
|
95
|
-
/** type of column to filter (to ensure that consistent) */
|
|
96
|
-
columnType: LiteralType
|
|
97
|
-
|
|
98
|
-
/** op of expression for filtering */
|
|
99
|
-
op: string
|
|
100
|
-
|
|
101
|
-
/** array of expressions to use for filtering. field expression for column will be injected as expression 0 in the resulting filter expression */
|
|
102
|
-
exprs: Expr[]
|
|
103
|
-
}
|
|
@@ -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
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
|
-
import {
|
|
6
|
-
import { DataSource, ExprCleaner, Schema } from "@mwater/expressions"
|
|
7
|
-
import { ExprUtils } from "@mwater/expressions"
|
|
4
|
+
import { DataSource, Schema } from "@mwater/expressions"
|
|
8
5
|
import PopoverHelpComponent from "@mwater/react-library/lib/PopoverHelpComponent"
|
|
9
6
|
import FiltersDesignerComponent from "../FiltersDesignerComponent"
|
|
10
7
|
import * as MapUtils from "./MapUtils"
|
|
8
|
+
import { GlobalFiltersElementFactoryContext } from "../MWaterContextComponent"
|
|
11
9
|
|
|
12
10
|
export interface MapFiltersDesignerComponentProps {
|
|
13
11
|
/** Schema to use */
|
|
@@ -22,8 +20,6 @@ export interface MapFiltersDesignerComponentProps {
|
|
|
22
20
|
|
|
23
21
|
// Designer for filters for a map
|
|
24
22
|
export default class MapFiltersDesignerComponent extends React.Component<MapFiltersDesignerComponentProps> {
|
|
25
|
-
static contextTypes = { globalFiltersElementFactory: PropTypes.func }
|
|
26
|
-
|
|
27
23
|
handleFiltersChange = (filters: any) => {
|
|
28
24
|
const design = _.extend({}, this.props.design, { filters })
|
|
29
25
|
return this.props.onDesignChange(design)
|
|
@@ -70,26 +66,30 @@ export default class MapFiltersDesignerComponent extends React.Component<MapFilt
|
|
|
70
66
|
})
|
|
71
67
|
)
|
|
72
68
|
),
|
|
69
|
+
|
|
70
|
+
<GlobalFiltersElementFactoryContext.Consumer>
|
|
71
|
+
{globalFiltersElementFactory =>
|
|
72
|
+
globalFiltersElementFactory
|
|
73
|
+
? R(
|
|
74
|
+
"div",
|
|
75
|
+
{ className: "mb-3" },
|
|
76
|
+
R("label", { className: "text-muted" }, "Global Filters "),
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
)
|
|
91
|
-
)
|
|
92
|
-
: undefined
|
|
78
|
+
R(
|
|
79
|
+
"div",
|
|
80
|
+
{ style: { margin: 5 } },
|
|
81
|
+
globalFiltersElementFactory({
|
|
82
|
+
schema: this.props.schema,
|
|
83
|
+
dataSource: this.props.dataSource,
|
|
84
|
+
filterableTables,
|
|
85
|
+
globalFilters: this.props.design.globalFilters || [],
|
|
86
|
+
onChange: this.handleGlobalFiltersChange
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
: undefined
|
|
91
|
+
}
|
|
92
|
+
</GlobalFiltersElementFactoryContext.Consumer>
|
|
93
93
|
)
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -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
|
}
|