@mwater/visualization 5.4.5 → 5.6.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/MWaterContextComponent.d.ts +1 -1
- package/lib/MWaterContextComponent.js +1 -1
- package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
- package/lib/MWaterGlobalFiltersComponent.js +11 -20
- package/lib/MWaterLoaderComponent.d.ts +5 -14
- package/lib/MWaterLoaderComponent.js +2 -11
- package/lib/UndoStack.d.ts +2 -1
- package/lib/UndoStack.js +12 -6
- package/lib/dashboards/DashboardComponent.js +7 -5
- package/lib/dashboards/DashboardDesign.d.ts +1 -1
- package/lib/dashboards/LayoutOptionsComponent.js +18 -11
- package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
- package/lib/dashboards/ServerDashboardDataSource.js +29 -10
- package/lib/dashboards/SettingsModalComponent.js +1 -1
- package/lib/dashboards/layoutOptions.d.ts +5 -1
- package/lib/datagrids/DatagridComponent.js +23 -3
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
- package/lib/datagrids/DatagridDesignerComponent.js +108 -120
- package/lib/datagrids/DatagridViewComponent.js +3 -2
- package/lib/datagrids/ExprCellComponent.d.ts +1 -0
- package/lib/datagrids/ExprCellComponent.js +22 -20
- package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
- package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
- package/lib/index.css +45 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +2 -3
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
- package/lib/maps/BufferLayer.d.ts +18 -0
- package/lib/maps/BufferLayer.js +36 -14
- package/lib/maps/BufferLayerDesign.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayer.d.ts +18 -0
- package/lib/maps/ChoroplethLayer.js +46 -25
- package/lib/maps/ChoroplethLayerDesign.d.ts +7 -3
- package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -22
- package/lib/maps/ChoroplethLayerDesigner.js +58 -89
- package/lib/maps/DirectMapDataSource.js +17 -10
- package/lib/maps/EditHoverOver.d.ts +4 -3
- package/lib/maps/EditHoverOver.js +64 -35
- package/lib/maps/HoverContent.d.ts +10 -5
- package/lib/maps/HoverContent.js +7 -36
- package/lib/maps/Layer.d.ts +37 -0
- package/lib/maps/Layer.js +30 -4
- package/lib/maps/LeafletMapComponent.js +10 -19
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +6 -6
- package/lib/maps/MapComponent.js +0 -1
- package/lib/maps/MapLayerDataSource.d.ts +9 -0
- package/lib/maps/MapUtils.d.ts +19 -1
- package/lib/maps/MapUtils.js +80 -1
- package/lib/maps/MarkersLayer.d.ts +18 -0
- package/lib/maps/MarkersLayer.js +42 -26
- package/lib/maps/MarkersLayerDesign.d.ts +1 -1
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +12 -28
- package/lib/maps/MarkersLayerDesignerComponent.js +81 -111
- package/lib/maps/RasterMapViewComponent.js +1 -1
- package/lib/maps/ServerMapDataSource.d.ts +9 -0
- package/lib/maps/ServerMapDataSource.js +29 -10
- package/lib/maps/VectorMapViewComponent.js +7 -15
- package/lib/maps/maps.d.ts +4 -2
- package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
- package/lib/maps/symbols/font-awesome/ban.png +0 -0
- package/lib/maps/symbols/font-awesome/beer.png +0 -0
- package/lib/maps/symbols/font-awesome/bell.png +0 -0
- package/lib/maps/symbols/font-awesome/bolt.png +0 -0
- package/lib/maps/symbols/font-awesome/building.png +0 -0
- package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
- package/lib/maps/symbols/font-awesome/bus.png +0 -0
- package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
- package/lib/maps/symbols/font-awesome/certificate.png +0 -0
- package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/check.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud.png +0 -0
- package/lib/maps/symbols/font-awesome/comment.png +0 -0
- package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/lib/maps/symbols/font-awesome/female.png +0 -0
- package/lib/maps/symbols/font-awesome/file.png +0 -0
- package/lib/maps/symbols/font-awesome/flag.png +0 -0
- package/lib/maps/symbols/font-awesome/flask.png +0 -0
- package/lib/maps/symbols/font-awesome/h-square.png +0 -0
- package/lib/maps/symbols/font-awesome/home.png +0 -0
- package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/male.png +0 -0
- package/lib/maps/symbols/font-awesome/medkit.png +0 -0
- package/lib/maps/symbols/font-awesome/mobile.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
- package/lib/maps/symbols/font-awesome/plus.png +0 -0
- package/lib/maps/symbols/font-awesome/square.png +0 -0
- package/lib/maps/symbols/font-awesome/star.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/lib/maps/symbols/font-awesome/ticket.png +0 -0
- package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/times.png +0 -0
- package/lib/maps/symbols/font-awesome/tint.png +0 -0
- package/lib/maps/symbols/font-awesome/tree.png +0 -0
- package/lib/maps/symbols/font-awesome/university.png +0 -0
- package/lib/maps/symbols/font-awesome/usd.png +0 -0
- package/lib/maps/symbols/font-awesome/user.png +0 -0
- package/lib/maps/symbols/font-awesome/users.png +0 -0
- package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/lib/maps/symbols/sdf-ize.sh +93 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +20 -36
- 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 +49 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.js +251 -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/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +63 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +461 -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 +163 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
- package/lib/quickfilter/QuickfiltersComponent.js +53 -110
- package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
- package/lib/quickfilter/TextLiteralComponent.js +85 -82
- package/lib/widgets/MapWidget.js +4 -2
- 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/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
- package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
- package/package.json +4 -10
- package/src/MWaterContextComponent.tsx +2 -2
- package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
- package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +18 -19
- package/src/UndoStack.ts +14 -6
- package/src/dashboards/DashboardComponent.tsx +7 -5
- package/src/dashboards/DashboardDesign.ts +1 -1
- package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
- package/src/dashboards/ServerDashboardDataSource.ts +36 -13
- package/src/dashboards/SettingsModalComponent.tsx +1 -1
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.tsx +31 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
- package/src/datagrids/DatagridViewComponent.tsx +3 -2
- package/src/datagrids/ExprCellComponent.tsx +23 -20
- package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
- package/src/index.css +45 -2
- package/src/index.ts +5 -11
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
- package/src/maps/BufferLayer.ts +48 -20
- package/src/maps/BufferLayerDesign.ts +1 -1
- package/src/maps/BufferLayerDesignerComponent.tsx +2 -1
- package/src/maps/ChoroplethLayer.ts +70 -39
- package/src/maps/ChoroplethLayerDesign.ts +6 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +171 -167
- package/src/maps/DirectMapDataSource.ts +21 -13
- package/src/maps/EditHoverOver.tsx +98 -54
- package/src/maps/HoverContent.tsx +17 -48
- package/src/maps/Layer.ts +42 -4
- package/src/maps/LeafletMapComponent.tsx +10 -19
- package/src/maps/MWaterServerLayer.ts +6 -6
- package/src/maps/MapComponent.ts +0 -1
- package/src/maps/MapLayerDataSource.ts +8 -0
- package/src/maps/MapUtils.ts +82 -3
- package/src/maps/MarkersLayer.ts +54 -27
- package/src/maps/MarkersLayerDesign.ts +1 -1
- package/src/maps/MarkersLayerDesignerComponent.tsx +360 -0
- package/src/maps/RasterMapViewComponent.ts +1 -1
- package/src/maps/ServerMapDataSource.ts +35 -12
- package/src/maps/VectorMapViewComponent.tsx +8 -19
- package/src/maps/maps.ts +4 -2
- package/src/maps/symbols/font-awesome/asterisk.png +0 -0
- package/src/maps/symbols/font-awesome/ban.png +0 -0
- package/src/maps/symbols/font-awesome/beer.png +0 -0
- package/src/maps/symbols/font-awesome/bell.png +0 -0
- package/src/maps/symbols/font-awesome/bolt.png +0 -0
- package/src/maps/symbols/font-awesome/building.png +0 -0
- package/src/maps/symbols/font-awesome/bullseye.png +0 -0
- package/src/maps/symbols/font-awesome/bus.png +0 -0
- package/src/maps/symbols/font-awesome/caret-up.png +0 -0
- package/src/maps/symbols/font-awesome/certificate.png +0 -0
- package/src/maps/symbols/font-awesome/check-circle.png +0 -0
- package/src/maps/symbols/font-awesome/check.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/symbols/font-awesome/cloud.png +0 -0
- package/src/maps/symbols/font-awesome/comment.png +0 -0
- package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/src/maps/symbols/font-awesome/female.png +0 -0
- package/src/maps/symbols/font-awesome/file.png +0 -0
- package/src/maps/symbols/font-awesome/flag.png +0 -0
- package/src/maps/symbols/font-awesome/flask.png +0 -0
- package/src/maps/symbols/font-awesome/h-square.png +0 -0
- package/src/maps/symbols/font-awesome/home.png +0 -0
- package/src/maps/symbols/font-awesome/info-circle.png +0 -0
- package/src/maps/symbols/font-awesome/male.png +0 -0
- package/src/maps/symbols/font-awesome/medkit.png +0 -0
- package/src/maps/symbols/font-awesome/mobile.png +0 -0
- package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/src/maps/symbols/font-awesome/plus-square.png +0 -0
- package/src/maps/symbols/font-awesome/plus.png +0 -0
- package/src/maps/symbols/font-awesome/square.png +0 -0
- package/src/maps/symbols/font-awesome/star.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/src/maps/symbols/font-awesome/ticket.png +0 -0
- package/src/maps/symbols/font-awesome/times-circle.png +0 -0
- package/src/maps/symbols/font-awesome/times.png +0 -0
- package/src/maps/symbols/font-awesome/tint.png +0 -0
- package/src/maps/symbols/font-awesome/tree.png +0 -0
- package/src/maps/symbols/font-awesome/university.png +0 -0
- package/src/maps/symbols/font-awesome/usd.png +0 -0
- package/src/maps/symbols/font-awesome/user.png +0 -0
- package/src/maps/symbols/font-awesome/users.png +0 -0
- package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/src/maps/symbols/sdf-ize.sh +93 -0
- package/src/maps/vectorMaps.tsx +20 -44
- package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +411 -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/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +713 -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} +91 -90
- package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
- package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
- package/src/quickfilter/TextLiteralComponent.tsx +197 -0
- package/src/widgets/MapWidget.tsx +9 -1
- 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/widgets/text/ExprItemEditorComponent.tsx +83 -77
- package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
- package/test/UndoStackTests.ts +52 -1
- package/.storybook/config.js +0 -7
- package/.storybook/head.html +0 -4
- package/.storybook/webpack.config.js +0 -15
- package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
- package/src/maps/BingLayer.ts +0 -146
- package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
- package/src/quickfilter/TextLiteralComponent.ts +0 -165
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
- package/stories/UpdateableComponent.js +0 -29
- package/stories/consoles.js +0 -202
- package/stories/dashboards.js +0 -217
- package/stories/datagridDesign.js +0 -114
- package/stories/datagrids.js +0 -69
- package/stories/dates.js +0 -80
- package/stories/exprcomponent.js +0 -43
- package/stories/index.js +0 -18
- package/stories/leaflet.js +0 -59
- package/stories/maps.js +0 -24
- package/stories/pivotChart.js +0 -235
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import * as uiComponents from "../UIComponents"
|
|
4
|
+
import { ExprUtils, Schema } from "@mwater/expressions"
|
|
5
|
+
import { MWaterCustomTablesetListComponent } from "./MWaterCustomTablesetListComponent"
|
|
6
|
+
import { MWaterMetricsTableListComponent } from "./MWaterMetricsTableListComponent"
|
|
7
|
+
import { MWaterAssetSystemsListComponent } from "./MWaterAssetSystemsListComponent"
|
|
8
|
+
import { FormsListComponent } from "./FormsListComponent"
|
|
9
|
+
import { IndicatorsListComponent } from "./IndicatorsListComponent"
|
|
10
|
+
import { IssuesListComponent } from "./IssuesListComponent"
|
|
11
|
+
import { MWaterAccountingSystemListComponent } from "./MWaterAccountingSystemListComponent"
|
|
12
|
+
import { MWaterCalculatedDataSourcesListComponent } from "./MWaterCalculatedDataSourcesListComponent"
|
|
13
|
+
import { MWaterWorkflowsSelectComponent } from "./MWaterWorkflowsSelectComponent"
|
|
14
|
+
|
|
15
|
+
const sitesOrder: { [table: string]: number } = {
|
|
16
|
+
"entities.water_point": 1,
|
|
17
|
+
"entities.sanitation_facility": 2,
|
|
18
|
+
"entities.household": 3,
|
|
19
|
+
"entities.community": 4,
|
|
20
|
+
"entities.school": 5,
|
|
21
|
+
"entities.health_facility": 6,
|
|
22
|
+
"entities.place_of_worship": 7,
|
|
23
|
+
"entities.water_system": 8,
|
|
24
|
+
"entities.water_system_component": 9,
|
|
25
|
+
"entities.wastewater_treatment_system": 10,
|
|
26
|
+
"entities.waste_disposal_site": 11
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Entity types that are assets */
|
|
30
|
+
const assetEntities = [
|
|
31
|
+
"entities.water_asset"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
interface MWaterCompleteTableSelectComponentProps {
|
|
35
|
+
/** Url to hit api */
|
|
36
|
+
apiUrl: string
|
|
37
|
+
/** Optional client */
|
|
38
|
+
client?: string
|
|
39
|
+
schema: Schema
|
|
40
|
+
/** User id */
|
|
41
|
+
user?: string
|
|
42
|
+
table?: string
|
|
43
|
+
/** Called with table selected */
|
|
44
|
+
onChange: any
|
|
45
|
+
extraTables: any
|
|
46
|
+
onExtraTablesChange: any
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface Category {
|
|
50
|
+
id: string
|
|
51
|
+
name: string
|
|
52
|
+
description: string
|
|
53
|
+
icon: string
|
|
54
|
+
render: () => JSX.Element
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Allows selection of a table. Card-based layout with categories */
|
|
58
|
+
export default class MWaterCompleteTableSelectComponent extends React.Component<
|
|
59
|
+
MWaterCompleteTableSelectComponentProps,
|
|
60
|
+
{
|
|
61
|
+
selectedCategory: string | null
|
|
62
|
+
showLegacyAssets: boolean
|
|
63
|
+
searchText: string
|
|
64
|
+
}
|
|
65
|
+
> {
|
|
66
|
+
constructor(props: MWaterCompleteTableSelectComponentProps) {
|
|
67
|
+
super(props)
|
|
68
|
+
|
|
69
|
+
this.state = {
|
|
70
|
+
selectedCategory: null,
|
|
71
|
+
showLegacyAssets: false,
|
|
72
|
+
searchText: ""
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
handleExtraTableAdd = (tableId: any) => {
|
|
77
|
+
return this.props.onExtraTablesChange(_.union(this.props.extraTables, [tableId]))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
handleExtraTableRemove = (tableId: any) => {
|
|
81
|
+
const displayName = this.getExtraTableDisplayName(tableId)
|
|
82
|
+
if (!displayName) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
confirm(
|
|
88
|
+
T`Remove ${displayName}? Any widgets that depend on it will no longer work properly.`
|
|
89
|
+
)
|
|
90
|
+
) {
|
|
91
|
+
// Set to null if current table matches (for wildcards, check if current table starts with prefix)
|
|
92
|
+
if (tableId.endsWith(".*")) {
|
|
93
|
+
const prefix = tableId.slice(0, -2)
|
|
94
|
+
if (this.props.table && this.props.table.startsWith(prefix + ".")) {
|
|
95
|
+
this.props.onChange(null)
|
|
96
|
+
}
|
|
97
|
+
} else if (this.props.table === tableId) {
|
|
98
|
+
this.props.onChange(null)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.props.onExtraTablesChange(_.without(this.props.extraTables, tableId))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
handleCategorySelect = (categoryId: string) => {
|
|
106
|
+
this.setState({ selectedCategory: categoryId })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
handleBackToCategories = () => {
|
|
110
|
+
this.setState({ selectedCategory: null, showLegacyAssets: false })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
renderSites() {
|
|
114
|
+
let table
|
|
115
|
+
let types = []
|
|
116
|
+
|
|
117
|
+
for (table of this.props.schema.getTables()) {
|
|
118
|
+
if (table.deprecated) {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!table.id.match(/^entities\./)) {
|
|
123
|
+
continue
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Skip assets
|
|
127
|
+
if (assetEntities.includes(table.id)) {
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
types.push(table.id)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Sort by order if present
|
|
135
|
+
types = _.sortBy(types, (type) => sitesOrder[type] || 999)
|
|
136
|
+
|
|
137
|
+
return <uiComponents.OptionListComponent
|
|
138
|
+
items={_.compact(
|
|
139
|
+
_.map(types, (tableId) => {
|
|
140
|
+
table = this.props.schema.getTable(tableId)!
|
|
141
|
+
return {
|
|
142
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
143
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
144
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
)}
|
|
148
|
+
/>
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
renderForms() {
|
|
152
|
+
return <FormsListComponent
|
|
153
|
+
schema={this.props.schema}
|
|
154
|
+
client={this.props.client}
|
|
155
|
+
apiUrl={this.props.apiUrl}
|
|
156
|
+
user={this.props.user}
|
|
157
|
+
onChange={this.props.onChange}
|
|
158
|
+
extraTables={this.props.extraTables}
|
|
159
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
160
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
161
|
+
/>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
renderIndicators() {
|
|
165
|
+
return <IndicatorsListComponent
|
|
166
|
+
schema={this.props.schema}
|
|
167
|
+
client={this.props.client}
|
|
168
|
+
apiUrl={this.props.apiUrl}
|
|
169
|
+
user={this.props.user}
|
|
170
|
+
onChange={this.props.onChange}
|
|
171
|
+
extraTables={this.props.extraTables}
|
|
172
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
173
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
174
|
+
/>
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
renderIssues() {
|
|
178
|
+
return <IssuesListComponent
|
|
179
|
+
schema={this.props.schema}
|
|
180
|
+
client={this.props.client}
|
|
181
|
+
apiUrl={this.props.apiUrl}
|
|
182
|
+
user={this.props.user}
|
|
183
|
+
onChange={this.props.onChange}
|
|
184
|
+
extraTables={this.props.extraTables}
|
|
185
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
186
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
187
|
+
/>
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
renderWorkflows() {
|
|
191
|
+
return <MWaterWorkflowsSelectComponent
|
|
192
|
+
schema={this.props.schema}
|
|
193
|
+
client={this.props.client}
|
|
194
|
+
apiUrl={this.props.apiUrl}
|
|
195
|
+
user={this.props.user}
|
|
196
|
+
onChange={this.props.onChange}
|
|
197
|
+
extraTables={this.props.extraTables}
|
|
198
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
199
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
200
|
+
/>
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
renderSweetSense() {
|
|
204
|
+
let sweetSenseTables = this.getSweetSenseTables()
|
|
205
|
+
|
|
206
|
+
sweetSenseTables = _.sortBy(sweetSenseTables, (table) => table.name.en)
|
|
207
|
+
return <uiComponents.OptionListComponent
|
|
208
|
+
items={_.map(sweetSenseTables, (table) => {
|
|
209
|
+
return {
|
|
210
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
211
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
212
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
213
|
+
}
|
|
214
|
+
})}
|
|
215
|
+
/>
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
renderTablesets() {
|
|
219
|
+
return <MWaterCustomTablesetListComponent
|
|
220
|
+
schema={this.props.schema}
|
|
221
|
+
client={this.props.client}
|
|
222
|
+
apiUrl={this.props.apiUrl}
|
|
223
|
+
user={this.props.user}
|
|
224
|
+
onChange={this.props.onChange}
|
|
225
|
+
extraTables={this.props.extraTables}
|
|
226
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
227
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
228
|
+
locale={T.locale}
|
|
229
|
+
/>
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
renderMetrics() {
|
|
233
|
+
return <MWaterMetricsTableListComponent
|
|
234
|
+
schema={this.props.schema}
|
|
235
|
+
client={this.props.client}
|
|
236
|
+
apiUrl={this.props.apiUrl}
|
|
237
|
+
user={this.props.user}
|
|
238
|
+
onChange={this.props.onChange}
|
|
239
|
+
extraTables={this.props.extraTables}
|
|
240
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
241
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
242
|
+
locale={T.locale}
|
|
243
|
+
/>
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
renderAccountingSystems() {
|
|
247
|
+
return <MWaterAccountingSystemListComponent
|
|
248
|
+
schema={this.props.schema}
|
|
249
|
+
client={this.props.client}
|
|
250
|
+
apiUrl={this.props.apiUrl}
|
|
251
|
+
user={this.props.user}
|
|
252
|
+
onChange={this.props.onChange}
|
|
253
|
+
extraTables={this.props.extraTables}
|
|
254
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
255
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
256
|
+
locale={T.locale}
|
|
257
|
+
/>
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
renderAssets() {
|
|
261
|
+
const items: {
|
|
262
|
+
name: string
|
|
263
|
+
desc?: string
|
|
264
|
+
onClick: () => void
|
|
265
|
+
onRemove?: () => void
|
|
266
|
+
}[] = []
|
|
267
|
+
|
|
268
|
+
for (const tableId of assetEntities) {
|
|
269
|
+
const table = this.props.schema.getTable(tableId)
|
|
270
|
+
if (!table) {
|
|
271
|
+
continue
|
|
272
|
+
}
|
|
273
|
+
items.push({
|
|
274
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
275
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
276
|
+
onClick: this.props.onChange.bind(null, table.id),
|
|
277
|
+
onRemove: this.handleExtraTableRemove.bind(null, table.id)
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return <div>
|
|
282
|
+
<uiComponents.OptionListComponent
|
|
283
|
+
items={items}
|
|
284
|
+
/>
|
|
285
|
+
<div className="text-center mt-2 mb-2">
|
|
286
|
+
<button className="btn btn-link" onClick={() => this.setState({ showLegacyAssets: !this.state.showLegacyAssets })}>
|
|
287
|
+
{this.state.showLegacyAssets ? T`Hide` : T`Show`} {T`Legacy Assets`}
|
|
288
|
+
</button>
|
|
289
|
+
</div>
|
|
290
|
+
{this.state.showLegacyAssets && this.renderLegacyAssets()}
|
|
291
|
+
</div>
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
renderLegacyAssets() {
|
|
295
|
+
return <MWaterAssetSystemsListComponent
|
|
296
|
+
schema={this.props.schema}
|
|
297
|
+
client={this.props.client}
|
|
298
|
+
apiUrl={this.props.apiUrl}
|
|
299
|
+
user={this.props.user}
|
|
300
|
+
onChange={this.props.onChange}
|
|
301
|
+
extraTables={this.props.extraTables}
|
|
302
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
303
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
304
|
+
locale={T.locale}
|
|
305
|
+
/>
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
renderCalculated() {
|
|
309
|
+
return <MWaterCalculatedDataSourcesListComponent
|
|
310
|
+
schema={this.props.schema}
|
|
311
|
+
client={this.props.client}
|
|
312
|
+
apiUrl={this.props.apiUrl}
|
|
313
|
+
user={this.props.user}
|
|
314
|
+
onChange={this.props.onChange}
|
|
315
|
+
extraTables={this.props.extraTables}
|
|
316
|
+
onExtraTableAdd={this.handleExtraTableAdd}
|
|
317
|
+
onExtraTableRemove={this.handleExtraTableRemove}
|
|
318
|
+
locale={T.locale}
|
|
319
|
+
/>
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
renderOther() {
|
|
323
|
+
let otherTables = _.filter(this.props.schema.getTables(), (table) => {
|
|
324
|
+
// Remove deprecated
|
|
325
|
+
if (table.deprecated) {
|
|
326
|
+
return false
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Remove sites
|
|
330
|
+
if (table.id.match(/^entities\./)) {
|
|
331
|
+
return false
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// sweetsense tables
|
|
335
|
+
if (table.id.match(/^sweetsense/)) {
|
|
336
|
+
return false
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Remove responses
|
|
340
|
+
if (table.id.match(/^responses:/)) {
|
|
341
|
+
return false
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Remove indicators
|
|
345
|
+
if (table.id.match(/^indicator_values:/)) {
|
|
346
|
+
return false
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Remove issues
|
|
350
|
+
if (table.id.match(/^(issues|issue_events):/)) {
|
|
351
|
+
return false
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Remove custom tablesets
|
|
355
|
+
if (table.id.match(/^custom\./)) {
|
|
356
|
+
return false
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Remove metrics
|
|
360
|
+
if (table.id.match(/^metrics:/)) {
|
|
361
|
+
return false
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Remove assets
|
|
365
|
+
if (table.id.match(/^assets:/)) {
|
|
366
|
+
return false
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Remove calculated data sources
|
|
370
|
+
if (table.id.match(/^calculated:/)) {
|
|
371
|
+
return false
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Remove workflows
|
|
375
|
+
if (table.id.match(/^(workflows|workflow_events):/)) {
|
|
376
|
+
return false
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return true
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
otherTables = _.sortBy(otherTables, (table) => table.name.en)
|
|
383
|
+
return <uiComponents.OptionListComponent
|
|
384
|
+
items={_.map(otherTables, (table) => {
|
|
385
|
+
return {
|
|
386
|
+
name: ExprUtils.localizeString(table.name, T.locale),
|
|
387
|
+
desc: ExprUtils.localizeString(table.desc, T.locale),
|
|
388
|
+
onClick: this.props.onChange.bind(null, table.id)
|
|
389
|
+
}
|
|
390
|
+
})}
|
|
391
|
+
/>
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
getSweetSenseTables() {
|
|
395
|
+
return _.filter(this.props.schema.getTables(), (table) => {
|
|
396
|
+
if (table.deprecated) {
|
|
397
|
+
return false
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (table.id.match(/^sweetsense/)) {
|
|
401
|
+
return true
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return false
|
|
405
|
+
})
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Get all available categories */
|
|
409
|
+
getCategories(): Category[] {
|
|
410
|
+
const categories: Category[] = [
|
|
411
|
+
{
|
|
412
|
+
id: "sites",
|
|
413
|
+
name: T("Sites").toString(),
|
|
414
|
+
description: T("Water points, sanitation facilities, households, and other sites").toString(),
|
|
415
|
+
icon: "fa fa-map-marker",
|
|
416
|
+
render: () => this.renderSites()
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: "forms",
|
|
420
|
+
name: T("Surveys").toString(),
|
|
421
|
+
description: T("Data collected from survey forms").toString(),
|
|
422
|
+
icon: "fa fa-th-list",
|
|
423
|
+
render: () => this.renderForms()
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: "assets",
|
|
427
|
+
name: T("Assets").toString(),
|
|
428
|
+
description: T("Asset tracking and management").toString(),
|
|
429
|
+
icon: "fas fa-map-pin",
|
|
430
|
+
render: () => this.renderAssets()
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
id: "indicators",
|
|
434
|
+
name: T("Indicators").toString(),
|
|
435
|
+
description: T("Calculated indicators and metrics").toString(),
|
|
436
|
+
icon: "fa fa-check-circle",
|
|
437
|
+
render: () => this.renderIndicators()
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: "tablesets",
|
|
441
|
+
name: T("Tables").toString(),
|
|
442
|
+
description: T("Custom tables and datasets").toString(),
|
|
443
|
+
icon: "fa fa-table",
|
|
444
|
+
render: () => this.renderTablesets()
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
id: "calculated",
|
|
448
|
+
name: T("Calculated").toString(),
|
|
449
|
+
description: T("Calculated and derived data sources").toString(),
|
|
450
|
+
icon: "fa fa-cogs",
|
|
451
|
+
render: () => this.renderCalculated()
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
id: "accounting",
|
|
455
|
+
name: T("Accounting").toString(),
|
|
456
|
+
description: T("Financial and accounting data").toString(),
|
|
457
|
+
icon: "fa fa-calculator",
|
|
458
|
+
render: () => this.renderAccountingSystems()
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
id: "workflows",
|
|
462
|
+
name: T("Workflows").toString(),
|
|
463
|
+
description: T("Multi-step processes and workflows").toString(),
|
|
464
|
+
icon: "fa fa-project-diagram",
|
|
465
|
+
render: () => this.renderWorkflows()
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "issues",
|
|
469
|
+
name: T("Issues").toString(),
|
|
470
|
+
description: T("Reported problems and issues").toString(),
|
|
471
|
+
icon: "fa fa-exclamation-circle",
|
|
472
|
+
render: () => this.renderIssues()
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
id: "metrics",
|
|
476
|
+
name: T("Metrics").toString(),
|
|
477
|
+
description: T("Performance metrics and KPIs").toString(),
|
|
478
|
+
icon: "fa fa-line-chart",
|
|
479
|
+
render: () => this.renderMetrics()
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
id: "other",
|
|
483
|
+
name: T("Advanced").toString(),
|
|
484
|
+
description: T("Other advanced data sources").toString(),
|
|
485
|
+
icon: "fa fa-ellipsis-h",
|
|
486
|
+
render: () => this.renderOther()
|
|
487
|
+
}
|
|
488
|
+
]
|
|
489
|
+
|
|
490
|
+
// // Add sensors if applicable
|
|
491
|
+
// const sweetSenseTables = this.getSweetSenseTables()
|
|
492
|
+
// if (sweetSenseTables.length > 0) {
|
|
493
|
+
// categories.splice(9, 0, {
|
|
494
|
+
// id: "sensors",
|
|
495
|
+
// name: T("Sensors").toString(),
|
|
496
|
+
// description: T("Sensor data and monitoring").toString(),
|
|
497
|
+
// icon: "fa fa-wifi",
|
|
498
|
+
// render: () => this.renderSweetSense()
|
|
499
|
+
// })
|
|
500
|
+
// }
|
|
501
|
+
|
|
502
|
+
return categories
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Render a single category card */
|
|
506
|
+
renderCategoryCard(category: Category) {
|
|
507
|
+
return (
|
|
508
|
+
<div
|
|
509
|
+
key={category.id}
|
|
510
|
+
className="card mb-2"
|
|
511
|
+
style={{
|
|
512
|
+
cursor: "pointer",
|
|
513
|
+
transition: "background-color 0.15s, border-color 0.15s"
|
|
514
|
+
}}
|
|
515
|
+
onMouseEnter={(e) => {
|
|
516
|
+
e.currentTarget.style.backgroundColor = "#f8f9fa"
|
|
517
|
+
e.currentTarget.style.borderColor = "#adb5bd"
|
|
518
|
+
}}
|
|
519
|
+
onMouseLeave={(e) => {
|
|
520
|
+
e.currentTarget.style.backgroundColor = ""
|
|
521
|
+
e.currentTarget.style.borderColor = ""
|
|
522
|
+
}}
|
|
523
|
+
onClick={() => this.handleCategorySelect(category.id)}
|
|
524
|
+
>
|
|
525
|
+
<div className="card-body d-flex align-items-center" style={{ padding: "0.75rem" }}>
|
|
526
|
+
<div style={{ fontSize: "1.75rem", width: "2.5rem", textAlign: "center", color: "#6c757d" }}>
|
|
527
|
+
<i className={category.icon} />
|
|
528
|
+
</div>
|
|
529
|
+
<div style={{ flex: 1, marginLeft: "0.75rem" }}>
|
|
530
|
+
<div style={{ fontWeight: 600, fontSize: "1rem", marginBottom: "0.15rem" }}>
|
|
531
|
+
{category.name}
|
|
532
|
+
</div>
|
|
533
|
+
<div className="text-muted" style={{ fontSize: "0.85rem" }}>
|
|
534
|
+
{category.description}
|
|
535
|
+
</div>
|
|
536
|
+
</div>
|
|
537
|
+
<div style={{ color: "#adb5bd", fontSize: "1.1rem" }}>
|
|
538
|
+
<i className="fa fa-chevron-right" />
|
|
539
|
+
</div>
|
|
540
|
+
</div>
|
|
541
|
+
</div>
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** Get display name for an extra table (handles wildcards) */
|
|
546
|
+
getExtraTableDisplayName(tableId: string): string | null {
|
|
547
|
+
// Check if it's a wildcard pattern
|
|
548
|
+
if (tableId.endsWith(".*")) {
|
|
549
|
+
// Find first matching table
|
|
550
|
+
const prefix = tableId.slice(0, -2) // Remove .*
|
|
551
|
+
const matchingTable = this.props.schema.getTables().find(t => t.id.startsWith(prefix + "."))
|
|
552
|
+
|
|
553
|
+
if (matchingTable) {
|
|
554
|
+
const fullName = ExprUtils.localizeString(matchingTable.name, T.locale)
|
|
555
|
+
// Split by " > " and take first part
|
|
556
|
+
const parts = fullName.split(" > ")
|
|
557
|
+
return parts[0]
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Fallback to showing the pattern
|
|
561
|
+
return tableId
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// Regular table
|
|
565
|
+
const table = this.props.schema.getTable(tableId)
|
|
566
|
+
if (!table) {
|
|
567
|
+
return null
|
|
568
|
+
}
|
|
569
|
+
return ExprUtils.localizeString(table.name, T.locale)
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** Render the currently included extra tables section */
|
|
573
|
+
renderExtraTables() {
|
|
574
|
+
if (!this.props.extraTables || this.props.extraTables.length === 0) {
|
|
575
|
+
return null
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return (
|
|
579
|
+
<div className="mb-3 pb-2" style={{ borderBottom: "1px solid #dee2e6" }}>
|
|
580
|
+
<span className="text-muted me-2" style={{ fontSize: "0.9rem" }}>
|
|
581
|
+
{T`Currently Included`}:
|
|
582
|
+
</span>
|
|
583
|
+
{this.props.extraTables.map((tableId: string) => {
|
|
584
|
+
const displayName = this.getExtraTableDisplayName(tableId)
|
|
585
|
+
if (!displayName) {
|
|
586
|
+
return null
|
|
587
|
+
}
|
|
588
|
+
return (
|
|
589
|
+
<span
|
|
590
|
+
key={tableId}
|
|
591
|
+
className="d-inline-flex align-items-center me-2 px-2 py-1 bg-light border rounded"
|
|
592
|
+
style={{ fontSize: "0.85rem" }}
|
|
593
|
+
>
|
|
594
|
+
<span>{displayName}</span>
|
|
595
|
+
<button
|
|
596
|
+
className="btn btn-link btn-sm p-0 ms-1"
|
|
597
|
+
style={{ fontSize: "0.9rem", color: "#6c757d" }}
|
|
598
|
+
onClick={(e) => {
|
|
599
|
+
e.stopPropagation()
|
|
600
|
+
this.handleExtraTableRemove(tableId)
|
|
601
|
+
}}
|
|
602
|
+
>
|
|
603
|
+
<i className="fa fa-times" />
|
|
604
|
+
</button>
|
|
605
|
+
</span>
|
|
606
|
+
)
|
|
607
|
+
})}
|
|
608
|
+
</div>
|
|
609
|
+
)
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** Render the landing page with all categories */
|
|
613
|
+
renderLandingPage() {
|
|
614
|
+
const categories = this.getCategories()
|
|
615
|
+
|
|
616
|
+
// Filter by search text
|
|
617
|
+
const filteredCategories = this.state.searchText
|
|
618
|
+
? categories.filter((cat) => {
|
|
619
|
+
const searchLower = this.state.searchText.toLowerCase()
|
|
620
|
+
return (
|
|
621
|
+
cat.name.toLowerCase().includes(searchLower) ||
|
|
622
|
+
cat.description.toLowerCase().includes(searchLower)
|
|
623
|
+
)
|
|
624
|
+
})
|
|
625
|
+
: categories
|
|
626
|
+
|
|
627
|
+
return (
|
|
628
|
+
<div>
|
|
629
|
+
<div className="text-muted mb-3">
|
|
630
|
+
{T`Select a data source category to browse available tables and datasets.`}
|
|
631
|
+
</div>
|
|
632
|
+
|
|
633
|
+
{/* Search box */}
|
|
634
|
+
<div className="mb-3 position-relative">
|
|
635
|
+
<i className="fa fa-search position-absolute" style={{ left: "0.75rem", top: "50%", transform: "translateY(-50%)", color: "#6c757d" }} />
|
|
636
|
+
<input
|
|
637
|
+
type="text"
|
|
638
|
+
className="form-control"
|
|
639
|
+
style={{ paddingLeft: "2.5rem" }}
|
|
640
|
+
placeholder={T("Search categories...").toString()}
|
|
641
|
+
value={this.state.searchText}
|
|
642
|
+
onChange={(e) => this.setState({ searchText: e.target.value })}
|
|
643
|
+
ref={(c: HTMLInputElement | null) => {
|
|
644
|
+
if (c) {
|
|
645
|
+
c.focus()
|
|
646
|
+
}
|
|
647
|
+
}}
|
|
648
|
+
/>
|
|
649
|
+
</div>
|
|
650
|
+
|
|
651
|
+
{/* Extra tables section */}
|
|
652
|
+
{this.renderExtraTables()}
|
|
653
|
+
|
|
654
|
+
{/* Category cards grid */}
|
|
655
|
+
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "0.5rem" }}>
|
|
656
|
+
{filteredCategories.map((category) => this.renderCategoryCard(category))}
|
|
657
|
+
</div>
|
|
658
|
+
|
|
659
|
+
{filteredCategories.length === 0 && this.state.searchText && (
|
|
660
|
+
<div className="text-center text-muted mt-4">
|
|
661
|
+
{T`No categories match your search.`}
|
|
662
|
+
</div>
|
|
663
|
+
)}
|
|
664
|
+
</div>
|
|
665
|
+
)
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** Render a specific category view */
|
|
669
|
+
renderCategoryView() {
|
|
670
|
+
const categories = this.getCategories()
|
|
671
|
+
const category = categories.find((c) => c.id === this.state.selectedCategory)
|
|
672
|
+
|
|
673
|
+
if (!category) {
|
|
674
|
+
return null
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return (
|
|
678
|
+
<div>
|
|
679
|
+
{/* Back button */}
|
|
680
|
+
<div className="mb-3">
|
|
681
|
+
<button
|
|
682
|
+
className="btn btn-link p-0"
|
|
683
|
+
style={{ textDecoration: "none" }}
|
|
684
|
+
onClick={this.handleBackToCategories}
|
|
685
|
+
>
|
|
686
|
+
<i className="fa fa-arrow-left me-2" />
|
|
687
|
+
{T`Back to All Data Sources`}
|
|
688
|
+
</button>
|
|
689
|
+
</div>
|
|
690
|
+
|
|
691
|
+
{/* Category title */}
|
|
692
|
+
<h5 className="mb-3">
|
|
693
|
+
<i className={`${category.icon} me-2 text-muted`} />
|
|
694
|
+
{category.name}
|
|
695
|
+
</h5>
|
|
696
|
+
|
|
697
|
+
{/* Category content */}
|
|
698
|
+
{category.render()}
|
|
699
|
+
</div>
|
|
700
|
+
)
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
render() {
|
|
704
|
+
return (
|
|
705
|
+
<div style={{ height: "65vh", overflowY: "auto" }}>
|
|
706
|
+
{this.state.selectedCategory === null
|
|
707
|
+
? this.renderLandingPage()
|
|
708
|
+
: this.renderCategoryView()}
|
|
709
|
+
</div>
|
|
710
|
+
)
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|