@hisptz/dhis2-analytics 1.0.5 → 1.0.6
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/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +253 -0
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.test.js +51 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +48 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +34 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +67 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/column-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/complex-multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/pie-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/stacked-chart-data.json +0 -0
- package/build/cjs/components/ChartAnalytics/hooks/useChart.js +38 -0
- package/build/cjs/components/ChartAnalytics/index.js +69 -0
- package/build/cjs/components/ChartAnalytics/models/column.js +53 -0
- package/build/cjs/components/ChartAnalytics/models/index.js +102 -0
- package/build/cjs/components/ChartAnalytics/models/line.js +35 -0
- package/build/cjs/components/ChartAnalytics/models/multi-series.js +111 -0
- package/build/cjs/components/ChartAnalytics/models/pie.js +53 -0
- package/build/cjs/components/ChartAnalytics/services/export.js +50 -0
- package/{src → build/cjs}/components/ChartAnalytics/styles/custom-highchart.css +0 -0
- package/build/cjs/components/ChartAnalytics/types/props.js +1 -0
- package/build/cjs/components/ChartAnalytics/utils/chart.js +133 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +45 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.test.js +13 -0
- package/build/cjs/components/CircularProgressDashboard/index.js +49 -0
- package/build/cjs/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/cjs/components/Map/Map.stories.js +352 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/index.js +458 -0
- package/build/cjs/components/Map/components/MapArea/index.js +101 -0
- package/build/cjs/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapControls/components/CustomControl/index.js +32 -0
- package/build/cjs/components/Map/components/MapControls/components/DownloadControl/index.js +25 -0
- package/build/cjs/components/Map/components/MapControls/components/FullscreenControl/index.js +13 -0
- package/build/cjs/components/Map/components/MapControls/index.js +42 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +13 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/index.js +51 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +106 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +379 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +36 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +200 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +10 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +412 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +124 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +26 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/index.js +181 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +86 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +14 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/index.js +46 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +57 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js +145 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +56 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +61 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +35 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +15 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/index.js +57 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/index.js +40 -0
- package/build/cjs/components/Map/components/MapLayer/interfaces/index.js +8 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +389 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/index.js +116 -0
- package/build/cjs/components/Map/components/MapProvider/hooks/index.js +19 -0
- package/build/cjs/components/Map/components/MapProvider/index.js +121 -0
- package/build/cjs/components/Map/components/MapUpdater/index.js +24 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js +428 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +63 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +72 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +71 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +47 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +79 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/index.js +265 -0
- package/build/cjs/components/Map/constants/colors.js +428 -0
- package/build/cjs/components/Map/constants/legendSet.js +22 -0
- package/build/cjs/components/Map/hooks/map.js +52 -0
- package/build/cjs/components/Map/index.js +108 -0
- package/build/cjs/components/Map/interfaces/index.js +1 -0
- package/build/cjs/components/Map/state/index.js +23 -0
- package/build/cjs/components/Map/utils/colors.js +78 -0
- package/build/cjs/components/Map/utils/helpers.js +25 -0
- package/build/cjs/components/Map/utils/map.js +161 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +127 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.test.js +23 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +54 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +24 -0
- package/build/cjs/components/SingleValueContainer/index.js +43 -0
- package/{src → build/cjs}/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -0
- package/build/cjs/components/SingleValueContainer/types/props.js +1 -0
- package/{src → build/cjs}/data/map.json +0 -0
- package/build/cjs/dataProviders/map.js +31 -0
- package/build/cjs/index.js +49 -0
- package/build/cjs/index.test.js +7 -0
- package/build/cjs/locales/en/translations.json +128 -0
- package/build/cjs/locales/index.js +22 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +235 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.test.js +46 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +41 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +26 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +58 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/build/es/components/ChartAnalytics/data/column-data.json +210 -0
- package/build/es/components/ChartAnalytics/data/complex-multi-series-data.json +124 -0
- package/build/es/components/ChartAnalytics/data/multi-series-data.json +536 -0
- package/build/es/components/ChartAnalytics/data/pie-data.json +115 -0
- package/build/es/components/ChartAnalytics/data/stacked-chart-data.json +415 -0
- package/build/es/components/ChartAnalytics/hooks/useChart.js +32 -0
- package/build/es/components/ChartAnalytics/index.js +40 -0
- package/build/es/components/ChartAnalytics/models/column.js +45 -0
- package/build/es/components/ChartAnalytics/models/index.js +95 -0
- package/build/es/components/ChartAnalytics/models/line.js +28 -0
- package/build/es/components/ChartAnalytics/models/multi-series.js +104 -0
- package/build/es/components/ChartAnalytics/models/pie.js +46 -0
- package/build/es/components/ChartAnalytics/services/export.js +36 -0
- package/build/es/components/ChartAnalytics/styles/custom-highchart.css +48 -0
- package/build/es/components/ChartAnalytics/types/props.js +1 -0
- package/build/es/components/ChartAnalytics/utils/chart.js +122 -0
- package/{src/components/CircularProgressDashboard/CircularProgressIndicator.stories.tsx → build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js} +9 -16
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.test.js +10 -0
- package/build/es/components/CircularProgressDashboard/index.js +41 -0
- package/build/es/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/es/components/Map/Map.stories.js +334 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/index.js +448 -0
- package/build/es/components/Map/components/MapArea/index.js +91 -0
- package/build/es/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapControls/components/CustomControl/index.js +25 -0
- package/build/es/components/Map/components/MapControls/components/DownloadControl/index.js +18 -0
- package/build/es/components/Map/components/MapControls/components/FullscreenControl/index.js +6 -0
- package/build/es/components/Map/components/MapControls/index.js +35 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +7 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/index.js +41 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +95 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +369 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +29 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +191 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +10 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +403 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +111 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +12 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +19 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/index.js +172 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +76 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +8 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/index.js +39 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +49 -0
- package/{src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx → build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js} +57 -74
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +47 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +36 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +28 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +9 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/index.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +62 -0
- package/build/es/components/Map/components/MapLayer/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +381 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/index.js +107 -0
- package/{src/components/Map/components/MapProvider/hooks/index.ts → build/es/components/Map/components/MapProvider/hooks/index.js} +3 -6
- package/build/es/components/Map/components/MapProvider/index.js +112 -0
- package/build/es/components/Map/components/MapUpdater/index.js +17 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +33 -0
- package/{src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts → build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js} +46 -59
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +53 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +15 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +12 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +56 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +64 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +38 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +70 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/index.js +254 -0
- package/{src/components/Map/constants/colors.ts → build/es/components/Map/constants/colors.js} +46 -59
- package/build/es/components/Map/constants/legendSet.js +15 -0
- package/build/es/components/Map/hooks/map.js +44 -0
- package/build/es/components/Map/index.js +51 -0
- package/build/es/components/Map/interfaces/index.js +1 -0
- package/build/es/components/Map/state/index.js +14 -0
- package/build/es/components/Map/utils/colors.js +61 -0
- package/build/es/components/Map/utils/helpers.js +14 -0
- package/build/es/components/Map/utils/map.js +147 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +115 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.test.js +20 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +47 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +17 -0
- package/build/es/components/SingleValueContainer/index.js +29 -0
- package/build/es/components/SingleValueContainer/styles/SingleValueContainer.module.css +39 -0
- package/build/es/components/SingleValueContainer/types/props.js +1 -0
- package/build/es/data/map.json +5984 -0
- package/build/es/dataProviders/map.js +24 -0
- package/{src/index.ts → build/es/index.js} +1 -0
- package/build/es/index.test.js +6 -0
- package/build/es/locales/en/translations.json +128 -0
- package/build/es/locales/index.js +13 -0
- package/package.json +21 -4
- package/d2.config.js +0 -8
- package/i18n/en.pot +0 -409
- package/src/components/ChartAnalytics/ChartAnalytics.stories.tsx +0 -250
- package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
- package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
- package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
- package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -67
- package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +0 -1
- package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
- package/src/components/ChartAnalytics/index.tsx +0 -23
- package/src/components/ChartAnalytics/models/column.ts +0 -50
- package/src/components/ChartAnalytics/models/index.ts +0 -78
- package/src/components/ChartAnalytics/models/line.ts +0 -31
- package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
- package/src/components/ChartAnalytics/models/pie.ts +0 -54
- package/src/components/ChartAnalytics/services/export.ts +0 -38
- package/src/components/ChartAnalytics/types/props.tsx +0 -48
- package/src/components/ChartAnalytics/utils/chart.ts +0 -123
- package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
- package/src/components/CircularProgressDashboard/index.tsx +0 -35
- package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
- package/src/components/Map/Map.stories.tsx +0 -339
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
- package/src/components/Map/components/MapArea/index.tsx +0 -83
- package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
- package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
- package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -10
- package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
- package/src/components/Map/components/MapControls/index.tsx +0 -24
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -76
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34233
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
- package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
- package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -168
- package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
- package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
- package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
- package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
- package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
- package/src/components/Map/components/MapLayer/index.tsx +0 -32
- package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -359
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
- package/src/components/Map/components/MapProvider/index.tsx +0 -93
- package/src/components/Map/components/MapUpdater/index.tsx +0 -8
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
- package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
- package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
- package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
- package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
- package/src/components/Map/constants/legendSet.ts +0 -19
- package/src/components/Map/hooks/map.ts +0 -47
- package/src/components/Map/index.tsx +0 -65
- package/src/components/Map/interfaces/index.ts +0 -57
- package/src/components/Map/state/index.tsx +0 -31
- package/src/components/Map/utils/colors.ts +0 -95
- package/src/components/Map/utils/helpers.ts +0 -15
- package/src/components/Map/utils/map.ts +0 -150
- package/src/components/SingleValueContainer/SingleValueContainer.stories.tsx +0 -146
- package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
- package/src/components/SingleValueContainer/index.tsx +0 -30
- package/src/components/SingleValueContainer/types/props.tsx +0 -16
- package/src/dataProviders/map.tsx +0 -24
- package/src/index.test.ts +0 -7
- package/tsconfig.json +0 -45
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type {Legend} from "@hisptz/dhis2-utils";
|
|
2
|
-
import {MapOrgUnit, PointOrgUnit} from "../../../interfaces";
|
|
3
|
-
import {LegendColorScale} from "../../../utils/colors";
|
|
4
|
-
import {EarthEngineOptions} from "../components/GoogleEngineLayer/interfaces";
|
|
5
|
-
import {EarthEngine} from "../components/GoogleEngineLayer/services/engine";
|
|
6
|
-
|
|
7
|
-
export type BoundaryLayerType = "basemap" | "overlay";
|
|
8
|
-
export type ThematicLayerType = "choropleth" | "bubble";
|
|
9
|
-
|
|
10
|
-
export const SUPPORTED_EARTH_ENGINE_LAYERS = ["population", "footprints", "elevation", "landCover"];
|
|
11
|
-
|
|
12
|
-
export type GoogleEngineLayerType = "population" | "footprints" | "elevation" | "landCover";
|
|
13
|
-
|
|
14
|
-
export interface CustomBoundaryLayer extends CustomMapLayer {
|
|
15
|
-
id: string;
|
|
16
|
-
type: BoundaryLayerType;
|
|
17
|
-
enabled: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface EarthEngineLayerConfig extends CustomMapLayer {
|
|
21
|
-
type: GoogleEngineLayerType;
|
|
22
|
-
aggregations?: string[];
|
|
23
|
-
name?: string;
|
|
24
|
-
filters?: {
|
|
25
|
-
period: string;
|
|
26
|
-
};
|
|
27
|
-
params?: {
|
|
28
|
-
min: number;
|
|
29
|
-
max: number;
|
|
30
|
-
palette?: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface CustomGoogleEngineLayer extends CustomMapLayer {
|
|
35
|
-
type: GoogleEngineLayerType;
|
|
36
|
-
options: EarthEngineOptions;
|
|
37
|
-
aggregations?: string[];
|
|
38
|
-
name: string;
|
|
39
|
-
url: string;
|
|
40
|
-
engine?: EarthEngine;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface CustomPointLayer extends CustomMapLayer {
|
|
44
|
-
id: string;
|
|
45
|
-
type: "point";
|
|
46
|
-
label?: string;
|
|
47
|
-
level?: string | number;
|
|
48
|
-
group?: string;
|
|
49
|
-
style?: {
|
|
50
|
-
icon?: string;
|
|
51
|
-
groupSet?: string;
|
|
52
|
-
orgUnitGroups?: Array<{ name: string; symbol: string }>;
|
|
53
|
-
};
|
|
54
|
-
points?: Array<PointOrgUnit>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type DataItemType = "dataElement" | "indicator" | "programIndicator";
|
|
58
|
-
|
|
59
|
-
export interface ThematicLayerDataItem {
|
|
60
|
-
id: string;
|
|
61
|
-
displayName: string;
|
|
62
|
-
type: DataItemType;
|
|
63
|
-
legendSet?: string;
|
|
64
|
-
legendConfig?: {
|
|
65
|
-
colorClass: LegendColorScale;
|
|
66
|
-
scale: number;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface ThematicLayerControl {
|
|
71
|
-
position: "topleft" | "topright" | "bottomleft" | "bottomright";
|
|
72
|
-
enabled: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface ThematicLayerData {
|
|
76
|
-
orgUnit: MapOrgUnit;
|
|
77
|
-
data?: number;
|
|
78
|
-
dataItem: ThematicLayerDataItem;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ThematicLayerRawData {
|
|
82
|
-
orgUnit: string;
|
|
83
|
-
data?: number;
|
|
84
|
-
dataItem: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface CustomChoroplethLayer extends CustomMapLayer {
|
|
88
|
-
enabled: boolean;
|
|
89
|
-
name?: string;
|
|
90
|
-
data: ThematicLayerData[];
|
|
91
|
-
dataItem: ThematicLayerDataItem;
|
|
92
|
-
type: "choropleth";
|
|
93
|
-
control?: ThematicLayerControl;
|
|
94
|
-
legends?: Legend[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface CustomBubbleLayer extends CustomMapLayer {
|
|
98
|
-
enabled: boolean;
|
|
99
|
-
name?: string;
|
|
100
|
-
data: ThematicLayerData[];
|
|
101
|
-
dataItem: ThematicLayerDataItem;
|
|
102
|
-
type: "bubble";
|
|
103
|
-
control?: ThematicLayerControl;
|
|
104
|
-
legends?: Legend[];
|
|
105
|
-
radius?: {
|
|
106
|
-
min: number;
|
|
107
|
-
max: number;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export type CustomThematicLayer = CustomBubbleLayer | CustomChoroplethLayer;
|
|
112
|
-
|
|
113
|
-
export interface ThematicLayerConfig {
|
|
114
|
-
id: string;
|
|
115
|
-
data?: ThematicLayerRawData[];
|
|
116
|
-
enabled: boolean;
|
|
117
|
-
name?: string;
|
|
118
|
-
dataItem: ThematicLayerDataItem;
|
|
119
|
-
type: ThematicLayerType;
|
|
120
|
-
control?: ThematicLayerControl;
|
|
121
|
-
radius?: {
|
|
122
|
-
min: number;
|
|
123
|
-
max: number;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface CustomMapLayer {
|
|
128
|
-
id: string;
|
|
129
|
-
type: string;
|
|
130
|
-
enabled: boolean;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export type MapLayer = CustomBoundaryLayer | ThematicLayerConfig | CustomPointLayer | CustomGoogleEngineLayer;
|
|
134
|
-
|
|
135
|
-
export interface MapLayerProps {
|
|
136
|
-
enabled: boolean;
|
|
137
|
-
type: "boundary" | "thematic" | "external" | "point" | "earthEngine";
|
|
138
|
-
layer: MapLayer;
|
|
139
|
-
}
|
package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import {compact, differenceBy, find, head, isEmpty, last, sortBy} from "lodash";
|
|
2
|
-
import {useMapOrganisationUnit, useMapPeriods} from "../../../hooks";
|
|
3
|
-
import {useCallback, useMemo, useState} from "react";
|
|
4
|
-
import {
|
|
5
|
-
generateLegends,
|
|
6
|
-
getOrgUnitsSelection,
|
|
7
|
-
sanitizeDate,
|
|
8
|
-
sanitizeOrgUnits,
|
|
9
|
-
toGeoJson
|
|
10
|
-
} from "../../../../../utils/map";
|
|
11
|
-
import {useDataEngine} from "@dhis2/app-runtime";
|
|
12
|
-
import {
|
|
13
|
-
CustomGoogleEngineLayer,
|
|
14
|
-
CustomPointLayer,
|
|
15
|
-
CustomThematicLayer,
|
|
16
|
-
EarthEngineLayerConfig,
|
|
17
|
-
ThematicLayerConfig
|
|
18
|
-
} from "../../../../MapLayer/interfaces";
|
|
19
|
-
import {MapOrgUnit, PointOrgUnit} from "../../../../../interfaces";
|
|
20
|
-
import {asyncify, map} from "async-es";
|
|
21
|
-
import {LegendSet} from "@hisptz/dhis2-utils";
|
|
22
|
-
import {defaultClasses, defaultColorScaleName} from "../../../../../utils/colors";
|
|
23
|
-
import {useGoogleEngineToken} from "../../../../MapLayer/components/GoogleEngineLayer/hooks";
|
|
24
|
-
import {useBoundaryData} from "../../../../MapLayer/components/BoundaryLayer/hooks/useBoundaryData";
|
|
25
|
-
import {EarthEngine} from "../../../../MapLayer/components/GoogleEngineLayer/services/engine";
|
|
26
|
-
import {EARTH_ENGINE_LAYERS} from "../../../../MapLayer/components/GoogleEngineLayer/constants";
|
|
27
|
-
import {EarthEngineOptions} from "../../../../MapLayer/components/GoogleEngineLayer/interfaces";
|
|
28
|
-
|
|
29
|
-
const analyticsQuery = {
|
|
30
|
-
analytics: {
|
|
31
|
-
resource: "analytics",
|
|
32
|
-
params: ({ ou, pe, dx, startDate, endDate }: any) => {
|
|
33
|
-
const peDimension = !isEmpty(pe) ? `pe:${pe?.join(";")}` : undefined;
|
|
34
|
-
const ouDimension = !isEmpty(ou) ? `ou:${ou?.join(";")}` : undefined;
|
|
35
|
-
const dxDimension = !isEmpty(dx) ? `dx:${dx?.join(";")}` : undefined;
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
dimension: compact([dxDimension, peDimension, ouDimension]),
|
|
39
|
-
startDate,
|
|
40
|
-
endDate,
|
|
41
|
-
displayProperty: "NAME",
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
const query = {
|
|
47
|
-
layer: {
|
|
48
|
-
resource: "geoFeatures",
|
|
49
|
-
params: ({ ous }: any) => ({
|
|
50
|
-
ou: `ou:${ous.join(";")}`,
|
|
51
|
-
}),
|
|
52
|
-
},
|
|
53
|
-
analytics: {
|
|
54
|
-
resource: "analytics",
|
|
55
|
-
params: ({ ous }: any) => ({
|
|
56
|
-
dimension: [`ou:${ous.join(";")}`, `pe:${new Date().getFullYear()}`],
|
|
57
|
-
skipData: true,
|
|
58
|
-
hierarchyMeta: true,
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
const groupSetQuery = {
|
|
63
|
-
groupSet: {
|
|
64
|
-
resource: "organisationUnitGroupSets",
|
|
65
|
-
id: ({ groupSet }: any) => groupSet,
|
|
66
|
-
params: {
|
|
67
|
-
fields: ["organisationUnitGroups[name,color,symbol,organisationUnits[id]]"],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
const legendSetsQuery = {
|
|
72
|
-
legendSets: {
|
|
73
|
-
resource: "legendSets",
|
|
74
|
-
id: ({ id }: any) => id,
|
|
75
|
-
params: {
|
|
76
|
-
fields: ["id", "displayName", "legends[id,code,startValue,endValue,color]"],
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export function useThematicLayers(): any {
|
|
82
|
-
const engine = useDataEngine();
|
|
83
|
-
const [loading, setLoading] = useState(false);
|
|
84
|
-
const { orgUnits, orgUnitSelection } = useMapOrganisationUnit();
|
|
85
|
-
const { periods, range } = useMapPeriods() ?? {};
|
|
86
|
-
const ou = useMemo(() => getOrgUnitsSelection(orgUnitSelection), [orgUnitSelection]);
|
|
87
|
-
const pe = useMemo(() => periods?.map((pe: any) => pe.id), [periods]);
|
|
88
|
-
|
|
89
|
-
const { startDate, endDate } = useMemo(() => {
|
|
90
|
-
if (!range) {
|
|
91
|
-
return {
|
|
92
|
-
startDate: undefined,
|
|
93
|
-
endDate: undefined,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
startDate: sanitizeDate(range.start.toDateString()),
|
|
98
|
-
endDate: sanitizeDate(range.end.toDateString()),
|
|
99
|
-
};
|
|
100
|
-
}, [range]);
|
|
101
|
-
const sanitizeData = (data: any, layer: ThematicLayerConfig) => {
|
|
102
|
-
if (data) {
|
|
103
|
-
const { analytics } = data as any;
|
|
104
|
-
const rows = analytics?.rows;
|
|
105
|
-
const ouIndex = analytics.headers.findIndex((header: any) => header.name === "ou");
|
|
106
|
-
const dxIndex = analytics.headers.findIndex((header: any) => header.name === "dx");
|
|
107
|
-
const valueIndex = analytics.headers.findIndex((header: any) => header.name === "value");
|
|
108
|
-
|
|
109
|
-
if (!isEmpty(rows)) {
|
|
110
|
-
return sortBy(
|
|
111
|
-
orgUnits?.map((ou: MapOrgUnit) => {
|
|
112
|
-
const row = rows.find((row: any) => row[ouIndex] === ou.id && row[dxIndex] === layer.dataItem.id);
|
|
113
|
-
return {
|
|
114
|
-
orgUnit: ou,
|
|
115
|
-
data: row ? parseFloat(row[valueIndex]) : undefined,
|
|
116
|
-
dataItem: {
|
|
117
|
-
...layer.dataItem,
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
}),
|
|
121
|
-
["data"]
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
return [];
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const sanitizeLegends = async (layers: CustomThematicLayer[]): Promise<CustomThematicLayer[]> => {
|
|
130
|
-
return (await map(
|
|
131
|
-
layers,
|
|
132
|
-
asyncify(async (layer: CustomThematicLayer) => {
|
|
133
|
-
try {
|
|
134
|
-
const legends = [];
|
|
135
|
-
if (layer.dataItem.legendSet) {
|
|
136
|
-
const legendSetData = await engine.query(legendSetsQuery, {
|
|
137
|
-
variables: {
|
|
138
|
-
id: layer.dataItem.legendSet,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
const legendSet: LegendSet = legendSetData?.legendSets as LegendSet;
|
|
142
|
-
if (legendSet) {
|
|
143
|
-
legends.push(...legendSet.legends);
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
const { scale, colorClass } = layer.dataItem.legendConfig ?? {
|
|
147
|
-
scale: defaultClasses,
|
|
148
|
-
colorClass: defaultColorScaleName,
|
|
149
|
-
};
|
|
150
|
-
const sortedData = sortBy(layer.data, "data");
|
|
151
|
-
const autoLegends = generateLegends(last(sortedData)?.data ?? 0, head(sortedData)?.data ?? 0, {
|
|
152
|
-
classesCount: scale,
|
|
153
|
-
colorClass,
|
|
154
|
-
});
|
|
155
|
-
legends.push(...autoLegends);
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
...layer,
|
|
159
|
-
legends,
|
|
160
|
-
};
|
|
161
|
-
} catch (e) {
|
|
162
|
-
return layer;
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
)) as CustomThematicLayer[];
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const sanitizeLayers = async (layers: ThematicLayerConfig[]): Promise<CustomThematicLayer[]> => {
|
|
169
|
-
try {
|
|
170
|
-
setLoading(true);
|
|
171
|
-
const layersWithoutData = layers?.filter((layer) => !layer.data);
|
|
172
|
-
const layersWithData = differenceBy(layers, layersWithoutData, "id");
|
|
173
|
-
const dx = layersWithoutData.map((layer) => layer.dataItem.id);
|
|
174
|
-
let sanitizedLayersWithData: any = [];
|
|
175
|
-
|
|
176
|
-
if (!isEmpty(dx)) {
|
|
177
|
-
const data = await engine.query(analyticsQuery, {
|
|
178
|
-
variables: {
|
|
179
|
-
dx,
|
|
180
|
-
ou,
|
|
181
|
-
pe,
|
|
182
|
-
startDate,
|
|
183
|
-
endDate,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
sanitizedLayersWithData = layersWithoutData.map((layer) => ({
|
|
187
|
-
...layer,
|
|
188
|
-
name: layer?.name ?? layer?.dataItem?.displayName ?? layer.id,
|
|
189
|
-
data: sanitizeData(data, layer),
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
192
|
-
const sanitizedLayersWithOrgUnits = layersWithData.map((layer) => ({
|
|
193
|
-
...layer,
|
|
194
|
-
data: layer.data?.map((datum) => ({
|
|
195
|
-
...datum,
|
|
196
|
-
orgUnit: find(orgUnits, ["id", datum.orgUnit]) as MapOrgUnit,
|
|
197
|
-
dataItem: layer.dataItem,
|
|
198
|
-
name: layer?.name ?? layer?.dataItem?.displayName ?? layer.id,
|
|
199
|
-
})),
|
|
200
|
-
}));
|
|
201
|
-
setLoading(false);
|
|
202
|
-
return await sanitizeLegends([...sanitizedLayersWithData, ...sanitizedLayersWithOrgUnits]);
|
|
203
|
-
} catch (e: any) {
|
|
204
|
-
console.error(`Error getting thematic layers`, e.details);
|
|
205
|
-
setLoading(false);
|
|
206
|
-
return [];
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
return {
|
|
211
|
-
sanitizeLayers,
|
|
212
|
-
loading,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function usePointLayer() {
|
|
217
|
-
const engine = useDataEngine();
|
|
218
|
-
const { orgUnitSelection } = useMapOrganisationUnit();
|
|
219
|
-
const [loading, setLoading] = useState(false);
|
|
220
|
-
|
|
221
|
-
const sanitizePointData = useCallback((orgUnitData: any, groupSetData: any): PointOrgUnit[] => {
|
|
222
|
-
const { analytics, layer } = (orgUnitData as any) ?? {};
|
|
223
|
-
const rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);
|
|
224
|
-
const geoJSONObjects = toGeoJson(layer?.filter((bound: any) => bound.co));
|
|
225
|
-
return compact(
|
|
226
|
-
rawOrgUnits.map((orgUnit: any) => {
|
|
227
|
-
const geoJSONObject: any = geoJSONObjects?.find((geoJSON: any) => geoJSON.properties.id === orgUnit.id);
|
|
228
|
-
const orgUnitGroups: any = (groupSetData?.groupSet as any)?.organisationUnitGroups ?? [];
|
|
229
|
-
const ouGroup = find(orgUnitGroups, (ouGroup) => !!find(ouGroup?.organisationUnits ?? [], ["id", orgUnit.id]));
|
|
230
|
-
|
|
231
|
-
if (!geoJSONObject || geoJSONObject.properties.type !== "Point") {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
...orgUnit,
|
|
236
|
-
geoJSON: geoJSONObject,
|
|
237
|
-
level: geoJSONObject.properties.level,
|
|
238
|
-
icon: {
|
|
239
|
-
type: "groupIcon",
|
|
240
|
-
icon: ouGroup?.symbol,
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
})
|
|
244
|
-
);
|
|
245
|
-
}, []);
|
|
246
|
-
|
|
247
|
-
const sanitizeLayer = useCallback(async (layer: CustomPointLayer): Promise<CustomPointLayer | undefined> => {
|
|
248
|
-
try {
|
|
249
|
-
if (!layer.level && !layer.group) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
setLoading(true);
|
|
253
|
-
const level = layer.level ? `LEVEL-${layer.level}` : undefined;
|
|
254
|
-
const group = layer.group ? `OU_GROUP-${layer.group}` : undefined;
|
|
255
|
-
const ous = [...getOrgUnitsSelection(orgUnitSelection), level, group];
|
|
256
|
-
|
|
257
|
-
const pointData = await engine.query(query, {
|
|
258
|
-
variables: {
|
|
259
|
-
ous,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
const groupSetData = await engine.query(groupSetQuery, {
|
|
263
|
-
variables: {
|
|
264
|
-
groupSet: layer.style?.groupSet,
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
const sanitizedOrgUnitData = sanitizePointData(pointData, groupSetData);
|
|
268
|
-
|
|
269
|
-
const orgUnitGroups = (groupSetData?.groupSet as any)?.organisationUnitGroups ?? [];
|
|
270
|
-
|
|
271
|
-
const sanitizedOrgUnitGroups = orgUnitGroups.map((ouGroup: any) => ({
|
|
272
|
-
...ouGroup,
|
|
273
|
-
organisationUnits: undefined,
|
|
274
|
-
}));
|
|
275
|
-
setLoading(false);
|
|
276
|
-
return {
|
|
277
|
-
...layer,
|
|
278
|
-
points: sanitizedOrgUnitData,
|
|
279
|
-
style: {
|
|
280
|
-
...layer.style,
|
|
281
|
-
orgUnitGroups: sanitizedOrgUnitGroups,
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
} catch (e: any) {
|
|
285
|
-
setLoading(false);
|
|
286
|
-
console.error(`Error getting point layer`, e.details);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
}, []);
|
|
290
|
-
|
|
291
|
-
return {
|
|
292
|
-
loading,
|
|
293
|
-
sanitizeLayer,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function useGoogleEngineLayers() {
|
|
298
|
-
const { refresh } = useGoogleEngineToken();
|
|
299
|
-
const orgUnits = useBoundaryData();
|
|
300
|
-
|
|
301
|
-
async function getImageUrl(earthEngine: EarthEngine, { filters }: EarthEngineLayerConfig): Promise<string | undefined> {
|
|
302
|
-
if (earthEngine.initialized) {
|
|
303
|
-
try {
|
|
304
|
-
earthEngine.setOrgUnits(orgUnits ?? []);
|
|
305
|
-
const period = filters?.period;
|
|
306
|
-
if (period) {
|
|
307
|
-
earthEngine.setPeriod(period);
|
|
308
|
-
}
|
|
309
|
-
return earthEngine.url();
|
|
310
|
-
} catch (e) {
|
|
311
|
-
console.error(e);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const sanitizeLayers = useCallback(
|
|
317
|
-
async (layers: EarthEngineLayerConfig[]): Promise<CustomGoogleEngineLayer[]> => {
|
|
318
|
-
try {
|
|
319
|
-
const { token } = await refresh();
|
|
320
|
-
await EarthEngine.setToken(token, refresh);
|
|
321
|
-
return map(
|
|
322
|
-
layers,
|
|
323
|
-
asyncify(async (layer: EarthEngineLayerConfig) => {
|
|
324
|
-
try {
|
|
325
|
-
const defaultOptions: any = find(EARTH_ENGINE_LAYERS, ["id", layer.type]) ?? {};
|
|
326
|
-
const options: EarthEngineOptions = {
|
|
327
|
-
...defaultOptions,
|
|
328
|
-
aggregations: layer.aggregations ?? defaultOptions?.aggregations,
|
|
329
|
-
params: layer.params ?? defaultOptions?.params,
|
|
330
|
-
};
|
|
331
|
-
const updatedLayer = {
|
|
332
|
-
...layer,
|
|
333
|
-
options,
|
|
334
|
-
};
|
|
335
|
-
const earthEngine = new EarthEngine({ options });
|
|
336
|
-
const url = await getImageUrl(earthEngine, updatedLayer);
|
|
337
|
-
return {
|
|
338
|
-
...updatedLayer,
|
|
339
|
-
engine: earthEngine,
|
|
340
|
-
url,
|
|
341
|
-
};
|
|
342
|
-
} catch (e) {
|
|
343
|
-
console.error(e);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
);
|
|
348
|
-
} catch (e: any) {
|
|
349
|
-
console.error(`Error getting thematic layers`, e.details);
|
|
350
|
-
return [];
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
[refresh]
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
return {
|
|
357
|
-
sanitizeLayers,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import i18n from "@dhis2/d2-i18n";
|
|
2
|
-
import {CenteredContent, CircularLoader} from "@dhis2/ui";
|
|
3
|
-
import {LayersControlEvent} from "leaflet";
|
|
4
|
-
import {compact, find, head, set} from "lodash";
|
|
5
|
-
import React, {useCallback, useEffect, useState} from "react";
|
|
6
|
-
import {useMapEvents} from "react-leaflet";
|
|
7
|
-
import {MapLayersContext} from "../../../../state";
|
|
8
|
-
import {MapLayerConfig} from "../../../MapArea/interfaces";
|
|
9
|
-
import {
|
|
10
|
-
CustomBoundaryLayer,
|
|
11
|
-
CustomGoogleEngineLayer,
|
|
12
|
-
CustomMapLayer,
|
|
13
|
-
CustomPointLayer,
|
|
14
|
-
CustomThematicLayer,
|
|
15
|
-
ThematicLayerConfig,
|
|
16
|
-
} from "../../../MapLayer/interfaces";
|
|
17
|
-
import {useMapOrganisationUnit, useMapPeriods} from "../../hooks";
|
|
18
|
-
import {useGoogleEngineLayers, usePointLayer, useThematicLayers} from "./hooks";
|
|
19
|
-
|
|
20
|
-
export function MapLayersProvider({ layers, children }: { layers: MapLayerConfig; children: React.ReactNode }) {
|
|
21
|
-
const period = useMapPeriods();
|
|
22
|
-
const orgUnit = useMapOrganisationUnit();
|
|
23
|
-
const [updatedLayers, setUpdatedLayers] = useState<Array<CustomThematicLayer | CustomBoundaryLayer | CustomPointLayer | CustomGoogleEngineLayer>>([]);
|
|
24
|
-
const { sanitizeLayers: sanitizeThematicLayers, error } = useThematicLayers();
|
|
25
|
-
const { sanitizeLayer: sanitizePointLayer } = usePointLayer();
|
|
26
|
-
const { sanitizeLayers: sanitizeEarthEngineLayers } = useGoogleEngineLayers();
|
|
27
|
-
const [loading, setLoading] = useState(false);
|
|
28
|
-
|
|
29
|
-
useMapEvents({
|
|
30
|
-
overlayremove: (event) => {
|
|
31
|
-
setupLayerListeners("remove", event);
|
|
32
|
-
},
|
|
33
|
-
overlayadd: (event) => {
|
|
34
|
-
setupLayerListeners("add", event);
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const sanitizeLayers = async () => {
|
|
39
|
-
setLoading(true);
|
|
40
|
-
try {
|
|
41
|
-
const { boundaryLayers, thematicLayers, pointLayers, earthEngineLayers } = layers;
|
|
42
|
-
const sanitizedThematicLayers = await sanitizeThematicLayers([...(thematicLayers ?? [])] as ThematicLayerConfig[]);
|
|
43
|
-
const sanitizedBoundaryLayers = (boundaryLayers ?? []) as CustomBoundaryLayer[];
|
|
44
|
-
const sanitizedPointLayer = head(pointLayers ?? []) ? await sanitizePointLayer(head(pointLayers) as CustomPointLayer) : undefined;
|
|
45
|
-
const sanitizedEarthEngineLayers = await sanitizeEarthEngineLayers([...(earthEngineLayers ?? [])] as unknown as CustomGoogleEngineLayer[]);
|
|
46
|
-
setUpdatedLayers(
|
|
47
|
-
compact([...(sanitizedBoundaryLayers ?? []), ...(sanitizedThematicLayers ?? []), sanitizedPointLayer, ...(sanitizedEarthEngineLayers ?? [])])
|
|
48
|
-
);
|
|
49
|
-
} catch (e: any) {
|
|
50
|
-
console.error(`Error sanitizing layers`, e.toString());
|
|
51
|
-
}
|
|
52
|
-
setLoading(false);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const updateLayer = useCallback((id: string, updatedLayer: CustomMapLayer) => {
|
|
56
|
-
setUpdatedLayers((prevLayers) => {
|
|
57
|
-
const updatedLayers = [...prevLayers];
|
|
58
|
-
const layerIndex = updatedLayers.findIndex((layer) => layer.id === updatedLayer.id);
|
|
59
|
-
if (layerIndex < 0) {
|
|
60
|
-
return prevLayers;
|
|
61
|
-
}
|
|
62
|
-
set(updatedLayers, layerIndex, updatedLayer);
|
|
63
|
-
return updatedLayers;
|
|
64
|
-
});
|
|
65
|
-
}, []);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
sanitizeLayers().catch(console.error);
|
|
69
|
-
}, [period, orgUnit]);
|
|
70
|
-
|
|
71
|
-
const setupLayerListeners = (type: "add" | "remove", event: LayersControlEvent) => {
|
|
72
|
-
const name = event.name;
|
|
73
|
-
|
|
74
|
-
const layerConfig = find(updatedLayers, (layer: any) => {
|
|
75
|
-
const nameFromConfig = layer?.name ?? layer?.dataItem?.displayname ?? layer?.label;
|
|
76
|
-
return nameFromConfig === name;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (layerConfig) {
|
|
80
|
-
updateLayer(layerConfig.id, { ...layerConfig, enabled: type === "add" });
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
if (loading) {
|
|
85
|
-
return (
|
|
86
|
-
<div style={{ height: "100%", width: "100%" }}>
|
|
87
|
-
<CenteredContent>
|
|
88
|
-
<CircularLoader small />
|
|
89
|
-
</CenteredContent>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
if (error) {
|
|
94
|
-
return (
|
|
95
|
-
<div style={{ height: "100%", width: "100%" }}>
|
|
96
|
-
<CenteredContent>
|
|
97
|
-
<h4>
|
|
98
|
-
{i18n.t("Error")}: {error.message}
|
|
99
|
-
</h4>
|
|
100
|
-
</CenteredContent>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
return <MapLayersContext.Provider value={{ layers: updatedLayers, updateLayer }}>{children}</MapLayersContext.Provider>;
|
|
105
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {useDataQuery} from "@dhis2/app-runtime";
|
|
2
|
-
import i18n from "@dhis2/d2-i18n";
|
|
3
|
-
import {CenteredContent, CircularLoader} from "@dhis2/ui";
|
|
4
|
-
import {compact, isEmpty} from "lodash";
|
|
5
|
-
import React, {useEffect, useState} from "react";
|
|
6
|
-
import {MapOrgUnit, MapProviderProps} from "../../interfaces";
|
|
7
|
-
import {MapOrgUnitContext, MapPeriodContext} from "../../state";
|
|
8
|
-
import {getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson} from "../../utils/map";
|
|
9
|
-
import {BasePeriod, PeriodUtility} from "@hisptz/dhis2-utils";
|
|
10
|
-
|
|
11
|
-
const boundaryQuery = {
|
|
12
|
-
boundaries: {
|
|
13
|
-
resource: "geoFeatures",
|
|
14
|
-
params: ({ orgUnitIds }: any) => ({
|
|
15
|
-
ou: `ou:${orgUnitIds?.join(";")}`,
|
|
16
|
-
}),
|
|
17
|
-
},
|
|
18
|
-
analytics: {
|
|
19
|
-
resource: "analytics",
|
|
20
|
-
params: ({ orgUnitIds }: any) => ({
|
|
21
|
-
dimension: [`ou:${orgUnitIds.join(";")}`, `pe:${new Date().getFullYear()}`],
|
|
22
|
-
skipData: true,
|
|
23
|
-
hierarchyMeta: true,
|
|
24
|
-
}),
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function MapProvider({ children, orgUnitSelection, periodSelection }: MapProviderProps) {
|
|
29
|
-
const [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);
|
|
30
|
-
const { refetch, loading, error } = useDataQuery(boundaryQuery, { lazy: true });
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
async function getOrgUnits() {
|
|
34
|
-
const rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);
|
|
35
|
-
const data = await refetch({ orgUnitIds: rawOrgUnitIds });
|
|
36
|
-
const { analytics, boundaries } = (data as any) ?? {};
|
|
37
|
-
const rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);
|
|
38
|
-
const geoJSONObjects = toGeoJson(boundaries.filter((bound: any) => bound.co));
|
|
39
|
-
const orgUnits: MapOrgUnit[] = compact(
|
|
40
|
-
rawOrgUnits.map((orgUnit: any) => {
|
|
41
|
-
const geoJSONObject: any = geoJSONObjects?.find((geoJSON: any) => geoJSON.properties.id === orgUnit.id);
|
|
42
|
-
|
|
43
|
-
if (!geoJSONObject) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
...orgUnit,
|
|
48
|
-
geoJSON: geoJSONObject,
|
|
49
|
-
bounds: [],
|
|
50
|
-
level: geoJSONObject.properties.level,
|
|
51
|
-
};
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
setOrgUnits(orgUnits);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
getOrgUnits().catch((error) => console.log(error));
|
|
58
|
-
}, [orgUnitSelection, refetch]);
|
|
59
|
-
|
|
60
|
-
if (loading) {
|
|
61
|
-
return (
|
|
62
|
-
<div style={{ height: "100%", width: "100%" }}>
|
|
63
|
-
<CenteredContent>
|
|
64
|
-
<CircularLoader small />
|
|
65
|
-
</CenteredContent>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (error) {
|
|
71
|
-
return (
|
|
72
|
-
<div style={{ height: "100%", width: "100%" }}>
|
|
73
|
-
<CenteredContent>
|
|
74
|
-
<h4>
|
|
75
|
-
{i18n.t("Error")}: {error.message}
|
|
76
|
-
</h4>
|
|
77
|
-
</CenteredContent>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const periods: BasePeriod[] = compact(periodSelection?.periods?.map((pe) => PeriodUtility.getPeriodById(pe)));
|
|
83
|
-
|
|
84
|
-
if (!isEmpty(orgUnits)) {
|
|
85
|
-
return (
|
|
86
|
-
<MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>
|
|
87
|
-
<MapPeriodContext.Provider value={{ ...periodSelection, periods }}>{children}</MapPeriodContext.Provider>
|
|
88
|
-
</MapOrgUnitContext.Provider>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {useCenterMap} from "../../hooks/map";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {LatLngTuple} from "leaflet";
|
|
4
|
-
|
|
5
|
-
export default function MapUpdater({ bounds }: { bounds: LatLngTuple[] }) {
|
|
6
|
-
const ref = useCenterMap({ bounds });
|
|
7
|
-
return <div style={{ width: "100%", height: "100%" }} ref={ref}></div>;
|
|
8
|
-
}
|