@mwater/visualization 5.4.4 → 5.5.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/.storybook/head.html +0 -1
- package/lib/MWaterContextComponent.js +1 -1
- package/lib/MWaterLoaderComponent.d.ts +2 -2
- package/lib/dashboards/DashboardComponent.js +2 -1
- package/lib/dashboards/LayoutOptionsComponent.js +18 -11
- package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
- package/lib/dashboards/ServerDashboardDataSource.js +29 -0
- package/lib/dashboards/layoutOptions.d.ts +5 -1
- package/lib/datagrids/DatagridComponent.js +1 -1
- package/lib/datagrids/ExprCellComponent.d.ts +1 -0
- package/lib/datagrids/ExprCellComponent.js +22 -20
- package/lib/maps/BufferLayer.d.ts +18 -0
- package/lib/maps/BufferLayer.js +24 -14
- package/lib/maps/ChoroplethLayer.d.ts +18 -0
- package/lib/maps/ChoroplethLayer.js +34 -25
- package/lib/maps/ChoroplethLayerDesign.d.ts +3 -2
- package/lib/maps/ChoroplethLayerDesigner.d.ts +11 -1
- package/lib/maps/DirectMapDataSource.js +17 -0
- package/lib/maps/EditHoverOver.d.ts +1 -1
- package/lib/maps/EditHoverOver.js +62 -33
- package/lib/maps/HoverContent.d.ts +10 -5
- package/lib/maps/HoverContent.js +6 -35
- package/lib/maps/Layer.d.ts +37 -0
- package/lib/maps/Layer.js +30 -4
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +6 -6
- package/lib/maps/MapLayerDataSource.d.ts +9 -0
- package/lib/maps/MapUtils.d.ts +19 -1
- package/lib/maps/MapUtils.js +71 -1
- package/lib/maps/MarkersLayer.d.ts +18 -0
- package/lib/maps/MarkersLayer.js +24 -24
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +14 -1
- package/lib/maps/RasterMapViewComponent.js +1 -1
- package/lib/maps/ServerMapDataSource.d.ts +9 -0
- package/lib/maps/ServerMapDataSource.js +29 -0
- package/lib/maps/VectorMapViewComponent.js +6 -6
- package/lib/maps/maps.d.ts +4 -2
- package/lib/mwater_table_selection/FormsListComponent.d.ts +33 -0
- package/lib/mwater_table_selection/FormsListComponent.js +141 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +47 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.js +182 -0
- package/lib/mwater_table_selection/IssuesListComponent.d.ts +29 -0
- package/lib/mwater_table_selection/IssuesListComponent.js +123 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.d.ts +20 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.js +157 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.js +79 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +37 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +275 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.js +94 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +32 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.js +158 -0
- package/lib/quickfilter/Quickfilter.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersDesignComponent.js +18 -10
- package/lib/widgets/charts/Chart.d.ts +11 -0
- package/lib/widgets/charts/Chart.js +15 -0
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +1 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +27 -1
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +5 -12
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +43 -57
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +113 -110
- package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +2 -1
- package/lib/widgets/charts/layered/LayeredChartUtils.js +0 -2
- package/lib/widgets/charts/pivot/PivotChart.d.ts +2 -0
- package/lib/widgets/charts/pivot/PivotChart.js +156 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -20
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +31 -61
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +4 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +4 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +5 -44
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +38 -63
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +7 -68
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +58 -106
- package/lib/widgets/charts/table/TableChart.d.ts +2 -0
- package/lib/widgets/charts/table/TableChart.js +172 -1
- package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +7 -17
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +79 -95
- package/lib/widgets/charts/table/TableChartViewComponent.d.ts +1 -7
- package/lib/widgets/charts/table/TableChartViewComponent.js +19 -27
- package/package.json +3 -8
- package/src/MWaterContextComponent.tsx +1 -1
- package/src/MWaterLoaderComponent.ts +1 -1
- package/src/dashboards/DashboardComponent.tsx +2 -1
- package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
- package/src/dashboards/ServerDashboardDataSource.ts +36 -1
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.tsx +1 -1
- package/src/datagrids/ExprCellComponent.tsx +23 -20
- package/src/maps/BufferLayer.ts +35 -20
- package/src/maps/ChoroplethLayer.ts +51 -33
- package/src/maps/ChoroplethLayerDesign.ts +3 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +2 -2
- package/src/maps/DirectMapDataSource.ts +21 -1
- package/src/maps/EditHoverOver.tsx +91 -51
- package/src/maps/HoverContent.tsx +16 -47
- package/src/maps/Layer.ts +42 -4
- package/src/maps/MWaterServerLayer.ts +6 -6
- package/src/maps/MapLayerDataSource.ts +8 -0
- package/src/maps/MapUtils.ts +70 -3
- package/src/maps/MarkersLayer.ts +34 -24
- package/src/maps/RasterMapViewComponent.ts +1 -1
- package/src/maps/ServerMapDataSource.ts +35 -0
- package/src/maps/VectorMapViewComponent.tsx +6 -6
- package/src/maps/maps.ts +4 -2
- package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +283 -0
- package/src/mwater_table_selection/IssuesListComponent.tsx +167 -0
- package/src/mwater_table_selection/MWaterAccountingSystemListComponent.tsx +225 -0
- package/src/{MWaterAssetSystemsListComponent.tsx → mwater_table_selection/MWaterAssetSystemsListComponent.tsx} +2 -2
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +377 -0
- package/src/{MWaterCustomTablesetListComponent.tsx → mwater_table_selection/MWaterCustomTablesetListComponent.tsx} +1 -1
- package/src/{MWaterMetricsTableListComponent.tsx → mwater_table_selection/MWaterMetricsTableListComponent.tsx} +1 -1
- package/src/{MWaterTableSelectComponent.tsx → mwater_table_selection/MWaterTableSelectComponent.tsx} +83 -86
- package/src/quickfilter/Quickfilter.ts +3 -0
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +19 -14
- package/src/widgets/charts/Chart.ts +17 -0
- package/src/widgets/charts/ChartWidgetComponent.tsx +36 -1
- package/src/widgets/charts/layered/LayeredChartDesign.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +23 -24
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +260 -211
- package/src/widgets/charts/layered/LayeredChartUtils.ts +7 -7
- package/src/widgets/charts/pivot/PivotChart.ts +191 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +124 -129
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +4 -2
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +120 -149
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +178 -198
- package/src/widgets/charts/table/TableChart.ts +177 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.tsx +422 -0
- package/src/widgets/charts/table/{TableChartViewComponent.ts → TableChartViewComponent.tsx} +65 -60
- package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { default as TabbedComponent, TabbedComponentTab } from "@mwater/react-library/lib/TabbedComponent"
|
|
4
|
+
import * as uiComponents from "../UIComponents"
|
|
5
|
+
import { ExprUtils, Schema } from "@mwater/expressions"
|
|
6
|
+
import { MWaterCustomTablesetListComponent } from "./MWaterCustomTablesetListComponent"
|
|
7
|
+
import { MWaterMetricsTableListComponent } from "./MWaterMetricsTableListComponent"
|
|
8
|
+
import { MWaterAssetSystemsListComponent } from "./MWaterAssetSystemsListComponent"
|
|
9
|
+
import { FormsListComponent } from "./FormsListComponent"
|
|
10
|
+
import { IndicatorsListComponent } from "./IndicatorsListComponent"
|
|
11
|
+
import { IssuesListComponent } from "./IssuesListComponent"
|
|
12
|
+
import { MWaterAccountingSystemListComponent } from "./MWaterAccountingSystemListComponent"
|
|
13
|
+
|
|
14
|
+
const sitesOrder: { [table: string]: number } = {
|
|
15
|
+
"entities.water_point": 1,
|
|
16
|
+
"entities.sanitation_facility": 2,
|
|
17
|
+
"entities.household": 3,
|
|
18
|
+
"entities.community": 4,
|
|
19
|
+
"entities.school": 5,
|
|
20
|
+
"entities.health_facility": 6,
|
|
21
|
+
"entities.place_of_worship": 7,
|
|
22
|
+
"entities.water_system": 8,
|
|
23
|
+
"entities.water_system_component": 9,
|
|
24
|
+
"entities.wastewater_treatment_system": 10,
|
|
25
|
+
"entities.waste_disposal_site": 11
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Entity types that are assets */
|
|
29
|
+
const assetEntities = [
|
|
30
|
+
"entities.water_asset"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
interface MWaterCompleteTableSelectComponentProps {
|
|
34
|
+
/** Url to hit api */
|
|
35
|
+
apiUrl: string
|
|
36
|
+
/** Optional client */
|
|
37
|
+
client?: string
|
|
38
|
+
schema: Schema
|
|
39
|
+
/** User id */
|
|
40
|
+
user?: string
|
|
41
|
+
table?: string
|
|
42
|
+
/** Called with table selected */
|
|
43
|
+
onChange: any
|
|
44
|
+
extraTables: any
|
|
45
|
+
onExtraTablesChange: any
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Allows selection of a table. Is the complete list mode of tables
|
|
49
|
+
export default class MWaterCompleteTableSelectComponent extends React.Component<MWaterCompleteTableSelectComponentProps, {
|
|
50
|
+
showLegacyAssets: boolean
|
|
51
|
+
}> {
|
|
52
|
+
constructor(props: MWaterCompleteTableSelectComponentProps) {
|
|
53
|
+
super(props)
|
|
54
|
+
|
|
55
|
+
this.state = {
|
|
56
|
+
showLegacyAssets: false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handleExtraTableAdd = (tableId: any) => {
|
|
61
|
+
return this.props.onExtraTablesChange(_.union(this.props.extraTables, [tableId]))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
handleExtraTableRemove = (tableId: any) => {
|
|
65
|
+
// Set to null if current table
|
|
66
|
+
if (this.props.table === tableId) {
|
|
67
|
+
this.props.onChange(null)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return this.props.onExtraTablesChange(_.without(this.props.extraTables, tableId))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
renderSites() {
|
|
74
|
+
let table
|
|
75
|
+
let types = []
|
|
76
|
+
|
|
77
|
+
for (table of this.props.schema.getTables()) {
|
|
78
|
+
if (table.deprecated) {
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!table.id.match(/^entities\./)) {
|
|
83
|
+
continue
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Skip assets
|
|
87
|
+
if (assetEntities.includes(table.id)) {
|
|
88
|
+
continue
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
types.push(table.id)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Sort by order if present
|
|
95
|
+
types = _.sortBy(types, (type) => sitesOrder[type] || 999)
|
|
96
|
+
|
|
97
|
+
return <uiComponents.OptionListComponent
|
|
98
|
+
items={_.compact(
|
|
99
|
+
_.map(types, (tableId) => {
|
|
100
|
+
table = this.props.schema.getTable(tableId)!
|
|
101
|
+
return {
|
|
102
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
103
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
104
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
)}
|
|
108
|
+
/>
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
renderForms() {
|
|
112
|
+
return <FormsListComponent
|
|
113
|
+
schema={this.props.schema}
|
|
114
|
+
client={this.props.client}
|
|
115
|
+
apiUrl={this.props.apiUrl}
|
|
116
|
+
user={this.props.user}
|
|
117
|
+
onChange={this.props.onChange}
|
|
118
|
+
extraTables={this.props.extraTables}
|
|
119
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
120
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
121
|
+
/>
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
renderIndicators() {
|
|
125
|
+
return <IndicatorsListComponent
|
|
126
|
+
schema={this.props.schema}
|
|
127
|
+
client={this.props.client}
|
|
128
|
+
apiUrl={this.props.apiUrl}
|
|
129
|
+
user={this.props.user}
|
|
130
|
+
onChange={this.props.onChange}
|
|
131
|
+
extraTables={this.props.extraTables}
|
|
132
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
133
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
134
|
+
/>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
renderIssues() {
|
|
138
|
+
return <IssuesListComponent
|
|
139
|
+
schema={this.props.schema}
|
|
140
|
+
client={this.props.client}
|
|
141
|
+
apiUrl={this.props.apiUrl}
|
|
142
|
+
user={this.props.user}
|
|
143
|
+
onChange={this.props.onChange}
|
|
144
|
+
extraTables={this.props.extraTables}
|
|
145
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
146
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
147
|
+
/>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
renderSweetSense() {
|
|
151
|
+
let sweetSenseTables = this.getSweetSenseTables()
|
|
152
|
+
|
|
153
|
+
sweetSenseTables = _.sortBy(sweetSenseTables, (table) => table.name.en)
|
|
154
|
+
return <uiComponents.OptionListComponent
|
|
155
|
+
items={_.map(sweetSenseTables, (table) => {
|
|
156
|
+
return {
|
|
157
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
158
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
159
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
160
|
+
}
|
|
161
|
+
})}
|
|
162
|
+
/>
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
renderTablesets() {
|
|
166
|
+
return <MWaterCustomTablesetListComponent
|
|
167
|
+
schema={this.props.schema}
|
|
168
|
+
client={this.props.client}
|
|
169
|
+
apiUrl={this.props.apiUrl}
|
|
170
|
+
user={this.props.user}
|
|
171
|
+
onChange={this.props.onChange}
|
|
172
|
+
extraTables={this.props.extraTables}
|
|
173
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
174
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
175
|
+
locale={T.locale}
|
|
176
|
+
/>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
renderMetrics() {
|
|
180
|
+
return <MWaterMetricsTableListComponent
|
|
181
|
+
schema={this.props.schema}
|
|
182
|
+
client={this.props.client}
|
|
183
|
+
apiUrl={this.props.apiUrl}
|
|
184
|
+
user={this.props.user}
|
|
185
|
+
onChange={this.props.onChange}
|
|
186
|
+
extraTables={this.props.extraTables}
|
|
187
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
188
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
189
|
+
locale={T.locale}
|
|
190
|
+
/>
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
renderAccountingSystems() {
|
|
194
|
+
return <MWaterAccountingSystemListComponent
|
|
195
|
+
schema={this.props.schema}
|
|
196
|
+
client={this.props.client}
|
|
197
|
+
apiUrl={this.props.apiUrl}
|
|
198
|
+
user={this.props.user}
|
|
199
|
+
onChange={this.props.onChange}
|
|
200
|
+
extraTables={this.props.extraTables}
|
|
201
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
202
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
203
|
+
locale={T.locale}
|
|
204
|
+
/>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
renderAssets() {
|
|
208
|
+
const items: {
|
|
209
|
+
name: string
|
|
210
|
+
desc?: string
|
|
211
|
+
onClick: () => void
|
|
212
|
+
onRemove?: () => void
|
|
213
|
+
}[] = []
|
|
214
|
+
|
|
215
|
+
for (const tableId of assetEntities) {
|
|
216
|
+
const table = this.props.schema.getTable(tableId)
|
|
217
|
+
if (!table) {
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
220
|
+
items.push({
|
|
221
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
222
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
223
|
+
onClick: this.props.onChange.bind(null, table.id),
|
|
224
|
+
onRemove: this.handleExtraTableRemove.bind(null, table.id)
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return <div>
|
|
229
|
+
<uiComponents.OptionListComponent
|
|
230
|
+
items={items}
|
|
231
|
+
/>
|
|
232
|
+
<div className="text-center mt-2 mb-2">
|
|
233
|
+
<button className="btn btn-link" onClick={() => this.setState({ showLegacyAssets: !this.state.showLegacyAssets })}>
|
|
234
|
+
{this.state.showLegacyAssets ? T`Hide` : T`Show`} {T`Legacy Assets`}
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
{this.state.showLegacyAssets && this.renderLegacyAssets()}
|
|
238
|
+
</div>
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
renderLegacyAssets() {
|
|
243
|
+
return <MWaterAssetSystemsListComponent
|
|
244
|
+
schema={this.props.schema}
|
|
245
|
+
client={this.props.client}
|
|
246
|
+
apiUrl={this.props.apiUrl}
|
|
247
|
+
user={this.props.user}
|
|
248
|
+
onChange={this.props.onChange}
|
|
249
|
+
extraTables={this.props.extraTables}
|
|
250
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
251
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
252
|
+
locale={T.locale}
|
|
253
|
+
/>
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
renderOther() {
|
|
257
|
+
let otherTables = _.filter(this.props.schema.getTables(), (table) => {
|
|
258
|
+
// Remove deprecated
|
|
259
|
+
if (table.deprecated) {
|
|
260
|
+
return false
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Remove sites
|
|
264
|
+
if (table.id.match(/^entities\./)) {
|
|
265
|
+
return false
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// sweetsense tables
|
|
269
|
+
if (table.id.match(/^sweetsense/)) {
|
|
270
|
+
return false
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Remove responses
|
|
274
|
+
if (table.id.match(/^responses:/)) {
|
|
275
|
+
return false
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Remove indicators
|
|
279
|
+
if (table.id.match(/^indicator_values:/)) {
|
|
280
|
+
return false
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Remove issues
|
|
284
|
+
if (table.id.match(/^(issues|issue_events):/)) {
|
|
285
|
+
return false
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Remove custom tablesets
|
|
289
|
+
if (table.id.match(/^custom\./)) {
|
|
290
|
+
return false
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Remove metrics
|
|
294
|
+
if (table.id.match(/^metrics:/)) {
|
|
295
|
+
return false
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Remove assets
|
|
299
|
+
if (table.id.match(/^assets:/)) {
|
|
300
|
+
return false
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return true
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
otherTables = _.sortBy(otherTables, (table) => table.name.en)
|
|
307
|
+
return <uiComponents.OptionListComponent
|
|
308
|
+
items={_.map(otherTables, (table) => {
|
|
309
|
+
return {
|
|
310
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
311
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
312
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
313
|
+
}
|
|
314
|
+
})}
|
|
315
|
+
/>
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
getSweetSenseTables() {
|
|
319
|
+
return _.filter(this.props.schema.getTables(), (table) => {
|
|
320
|
+
if (table.deprecated) {
|
|
321
|
+
return false
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (table.id.match(/^sweetsense/)) {
|
|
325
|
+
return true
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return false
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
render() {
|
|
333
|
+
const sweetSenseTables = this.getSweetSenseTables()
|
|
334
|
+
|
|
335
|
+
const tabs: TabbedComponentTab[] = [
|
|
336
|
+
{ id: "sites", label: <><i className="fa fa-map-marker" /> {T`Sites`}</>, elem: this.renderSites() },
|
|
337
|
+
{ id: "forms", label: <><i className="fa fa-th-list" /> {T`Surveys`}</>, elem: this.renderForms() },
|
|
338
|
+
{
|
|
339
|
+
id: "indicators",
|
|
340
|
+
label: <><i className="fa fa-check-circle" /> {T`Indicators`}</>,
|
|
341
|
+
elem: this.renderIndicators()
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: "issues",
|
|
345
|
+
label: <><i className="fa fa-exclamation-circle" /> {T`Issues`}</>,
|
|
346
|
+
elem: this.renderIssues()
|
|
347
|
+
},
|
|
348
|
+
{ id: "tablesets", label: <><i className="fa fa-table" /> {T`Tables`}</>, elem: this.renderTablesets() },
|
|
349
|
+
{ id: "metrics", label: <><i className="fa fa-line-chart" /> {T`Metrics`}</>, elem: this.renderMetrics() },
|
|
350
|
+
{
|
|
351
|
+
id: "accounting",
|
|
352
|
+
label: <><i className="fa fa-calculator" /> {T`Accounting`}</>,
|
|
353
|
+
elem: this.renderAccountingSystems()
|
|
354
|
+
},
|
|
355
|
+
{ id: "assets", label: <><i className="fas fa-map-pin" /> {T`Assets`}</>, elem: this.renderAssets() }
|
|
356
|
+
]
|
|
357
|
+
|
|
358
|
+
if (sweetSenseTables.length > 0) {
|
|
359
|
+
tabs.push({ id: "sensors", label: T`Sensors`, elem: this.renderSweetSense() })
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
tabs.push({ id: "other", label: T`Advanced`, elem: this.renderOther() })
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<div>
|
|
366
|
+
<div className="text-muted">
|
|
367
|
+
{T`Select data from sites, surveys or an advanced category below. Indicators can be found within their associated site types.`}
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<TabbedComponent
|
|
371
|
+
tabs={tabs}
|
|
372
|
+
initialTabId="sites"
|
|
373
|
+
/>
|
|
374
|
+
</div>
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
@@ -2,7 +2,7 @@ import _ from "lodash"
|
|
|
2
2
|
import { Schema, LocalizedString, Table, ExprUtils } from "@mwater/expressions"
|
|
3
3
|
import { useState, useEffect } from "react"
|
|
4
4
|
import React from "react"
|
|
5
|
-
import { OptionListComponent } from "
|
|
5
|
+
import { OptionListComponent } from "../UIComponents"
|
|
6
6
|
import { TextInput } from "@mwater/react-library/lib/bootstrap"
|
|
7
7
|
|
|
8
8
|
/** Searchable list of custom tables */
|
|
@@ -2,7 +2,7 @@ import _ from "lodash"
|
|
|
2
2
|
import { Schema, LocalizedString, Table, ExprUtils } from "@mwater/expressions"
|
|
3
3
|
import { useState, useEffect } from "react"
|
|
4
4
|
import React from "react"
|
|
5
|
-
import { OptionListComponent } from "
|
|
5
|
+
import { OptionListComponent } from "../UIComponents"
|
|
6
6
|
import { TextInput } from "@mwater/react-library/lib/bootstrap"
|
|
7
7
|
|
|
8
8
|
/** Searchable list of metric tables */
|