@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LegendItem = LegendItem;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("../../../styles/legends.css");
|
|
9
|
+
var _ui = require("@dhis2/ui");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _map = require("../../../../../../../utils/map");
|
|
12
|
+
var _LegendCardHeader = _interopRequireDefault(require("../../../../LegendArea/components/LegendCardHeader"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function LegendItem(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
legend,
|
|
19
|
+
value
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
22
|
+
className: "legend-item"
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
24
|
+
className: "legend-item-color",
|
|
25
|
+
style: {
|
|
26
|
+
backgroundColor: legend.color
|
|
27
|
+
}
|
|
28
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
29
|
+
className: "legend-item-label"
|
|
30
|
+
}, `${legend.startValue} - ${legend.endValue}`), /*#__PURE__*/_react.default.createElement("div", {
|
|
31
|
+
className: "legend-item-value"
|
|
32
|
+
}, `(${value})`));
|
|
33
|
+
}
|
|
34
|
+
function ChoroplethLegend(_ref2, ref) {
|
|
35
|
+
let {
|
|
36
|
+
dataItem,
|
|
37
|
+
data,
|
|
38
|
+
name,
|
|
39
|
+
collapsible,
|
|
40
|
+
onCollapse,
|
|
41
|
+
legends
|
|
42
|
+
} = _ref2;
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
className: "legend-card",
|
|
45
|
+
ref: ref
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_LegendCardHeader.default, {
|
|
47
|
+
title: dataItem.displayName,
|
|
48
|
+
collapsible: collapsible,
|
|
49
|
+
onCollapse: onCollapse
|
|
50
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.Divider, {
|
|
51
|
+
margin: "0"
|
|
52
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
53
|
+
className: "legend-list pt-8"
|
|
54
|
+
}, legends === null || legends === void 0 ? void 0 : legends.map(legend => /*#__PURE__*/_react.default.createElement(LegendItem, {
|
|
55
|
+
key: `${legend === null || legend === void 0 ? void 0 : legend.color}-legend-list`,
|
|
56
|
+
legend: legend,
|
|
57
|
+
value: (0, _map.getLegendCount)(legend, data)
|
|
58
|
+
}))));
|
|
59
|
+
}
|
|
60
|
+
var _default = /*#__PURE__*/(0, _react.forwardRef)(ChoroplethLegend);
|
|
61
|
+
exports.default = _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Choropleth;
|
|
7
|
+
var _ui = require("@dhis2/ui");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactLeaflet = require("react-leaflet");
|
|
10
|
+
var _map = require("../../../../../../utils/map");
|
|
11
|
+
var _CustomTooltip = _interopRequireDefault(require("../CustomTooltip"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const defaultStyle = {
|
|
14
|
+
weight: 1
|
|
15
|
+
};
|
|
16
|
+
const highlightStyle = {
|
|
17
|
+
weight: 2
|
|
18
|
+
};
|
|
19
|
+
function Choropleth(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
data,
|
|
22
|
+
legends
|
|
23
|
+
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
orgUnit
|
|
26
|
+
} = data;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactLeaflet.GeoJSON, {
|
|
28
|
+
data: orgUnit.geoJSON,
|
|
29
|
+
eventHandlers: {
|
|
30
|
+
mouseover: e => (0, _map.highlightFeature)(e, highlightStyle),
|
|
31
|
+
mouseout: e => (0, _map.resetHighlight)(e, defaultStyle)
|
|
32
|
+
},
|
|
33
|
+
pathOptions: {
|
|
34
|
+
fillColor: (0, _map.getColorFromLegendSet)(legends, data.data),
|
|
35
|
+
fillOpacity: 1,
|
|
36
|
+
color: _ui.colors.grey900,
|
|
37
|
+
weight: 1
|
|
38
|
+
},
|
|
39
|
+
key: `${data.dataItem.id}-layer`
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomTooltip.default, {
|
|
41
|
+
data: data
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = CustomTooltip;
|
|
7
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactLeaflet = require("react-leaflet");
|
|
10
|
+
var _hooks = require("../../../../../MapProvider/hooks");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function CustomTooltip(_ref) {
|
|
13
|
+
var _useMapPeriods;
|
|
14
|
+
let {
|
|
15
|
+
data: dataObject
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
dataItem,
|
|
19
|
+
orgUnit,
|
|
20
|
+
data
|
|
21
|
+
} = dataObject !== null && dataObject !== void 0 ? dataObject : {};
|
|
22
|
+
const {
|
|
23
|
+
periods
|
|
24
|
+
} = (_useMapPeriods = (0, _hooks.useMapPeriods)()) !== null && _useMapPeriods !== void 0 ? _useMapPeriods : {};
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_reactLeaflet.Pane, {
|
|
26
|
+
name: `${dataItem.displayName}-${orgUnit.id}-popup-pane`,
|
|
27
|
+
pane: "popupPane"
|
|
28
|
+
}, /*#__PURE__*/_react.default.createElement(_reactLeaflet.Tooltip, null, orgUnit === null || orgUnit === void 0 ? void 0 : orgUnit.name, " (", data, ")"), /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
|
|
29
|
+
minWidth: 80
|
|
30
|
+
}, /*#__PURE__*/_react.default.createElement("h3", {
|
|
31
|
+
style: {
|
|
32
|
+
margin: 0
|
|
33
|
+
}
|
|
34
|
+
}, orgUnit === null || orgUnit === void 0 ? void 0 : orgUnit.name), /*#__PURE__*/_react.default.createElement("div", null, dataItem === null || dataItem === void 0 ? void 0 : dataItem.displayName), /*#__PURE__*/_react.default.createElement("div", null, periods === null || periods === void 0 ? void 0 : periods.map(period => period.name).join(",")), /*#__PURE__*/_react.default.createElement("div", null, _d2I18n.default.t("Value"), ": ", data)));
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useThematicLayer;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _state = require("../../../../../state");
|
|
10
|
+
function useThematicLayer(layerId) {
|
|
11
|
+
const {
|
|
12
|
+
layers
|
|
13
|
+
} = (0, _react.useContext)(_state.MapLayersContext);
|
|
14
|
+
return (0, _lodash.find)(layers, ["id", layerId]);
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ThematicLayer;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactLeaflet = require("react-leaflet");
|
|
10
|
+
var _Bubble = _interopRequireDefault(require("./components/Bubble"));
|
|
11
|
+
var _Choropleth = _interopRequireDefault(require("./components/Choropleth"));
|
|
12
|
+
var _config = _interopRequireDefault(require("./hooks/config"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function ThematicLayer(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
layerId,
|
|
17
|
+
index
|
|
18
|
+
} = _ref;
|
|
19
|
+
const layer = (0, _config.default)(layerId);
|
|
20
|
+
if (!layer) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const {
|
|
24
|
+
type,
|
|
25
|
+
dataItem,
|
|
26
|
+
name,
|
|
27
|
+
data,
|
|
28
|
+
enabled,
|
|
29
|
+
legends
|
|
30
|
+
} = layer !== null && layer !== void 0 ? layer : {};
|
|
31
|
+
const uniqueName = name !== null && name !== void 0 ? name : dataItem.displayName;
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactLeaflet.LayersControl.Overlay, {
|
|
33
|
+
checked: enabled,
|
|
34
|
+
name: uniqueName
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_reactLeaflet.Pane, {
|
|
36
|
+
style: {
|
|
37
|
+
zIndex: type === "bubble" ? 500 : 500 - (index + 1)
|
|
38
|
+
},
|
|
39
|
+
name: uniqueName
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_reactLeaflet.LayerGroup, null, data === null || data === void 0 ? void 0 : data.map(datum => {
|
|
41
|
+
var _datum$dataItem, _datum$orgUnit;
|
|
42
|
+
return type === "choropleth" ? /*#__PURE__*/_react.default.createElement(_Choropleth.default, {
|
|
43
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
44
|
+
data: datum,
|
|
45
|
+
key: `${datum === null || datum === void 0 ? void 0 : (_datum$dataItem = datum.dataItem) === null || _datum$dataItem === void 0 ? void 0 : _datum$dataItem.id}-${datum === null || datum === void 0 ? void 0 : (_datum$orgUnit = datum.orgUnit) === null || _datum$orgUnit === void 0 ? void 0 : _datum$orgUnit.id}-layer`
|
|
46
|
+
}) : null;
|
|
47
|
+
}), data === null || data === void 0 ? void 0 : data.map(datum => {
|
|
48
|
+
var _last$data, _last, _datum$dataItem2, _datum$orgUnit2;
|
|
49
|
+
return type === "bubble" ? /*#__PURE__*/_react.default.createElement(_Bubble.default, {
|
|
50
|
+
radius: layer === null || layer === void 0 ? void 0 : layer.radius,
|
|
51
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
52
|
+
highestData: (_last$data = (_last = (0, _lodash.last)(data)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 1,
|
|
53
|
+
data: datum,
|
|
54
|
+
key: `${datum === null || datum === void 0 ? void 0 : (_datum$dataItem2 = datum.dataItem) === null || _datum$dataItem2 === void 0 ? void 0 : _datum$dataItem2.id}-${datum === null || datum === void 0 ? void 0 : (_datum$orgUnit2 = datum.orgUnit) === null || _datum$orgUnit2 === void 0 ? void 0 : _datum$orgUnit2.id}-layer`
|
|
55
|
+
}) : null;
|
|
56
|
+
})))));
|
|
57
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = MapLayer;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _BoundaryLayer = _interopRequireDefault(require("./components/BoundaryLayer"));
|
|
9
|
+
var _GoogleEngineLayer = _interopRequireDefault(require("./components/GoogleEngineLayer"));
|
|
10
|
+
var _PointLayer = require("./components/PointLayer");
|
|
11
|
+
var _ThematicLayer = _interopRequireDefault(require("./components/ThematicLayer"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function MapLayer(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
layer,
|
|
16
|
+
index
|
|
17
|
+
} = _ref;
|
|
18
|
+
switch (layer.type) {
|
|
19
|
+
case "overlay":
|
|
20
|
+
case "basemap":
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_BoundaryLayer.default, layer);
|
|
22
|
+
case "bubble":
|
|
23
|
+
case "choropleth":
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_ThematicLayer.default, {
|
|
25
|
+
layerId: layer.id,
|
|
26
|
+
index: index
|
|
27
|
+
});
|
|
28
|
+
case "point":
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_PointLayer.PointLayer, null);
|
|
30
|
+
case "population":
|
|
31
|
+
case "elevation":
|
|
32
|
+
case "footprints":
|
|
33
|
+
case "landCover":
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_GoogleEngineLayer.default, {
|
|
35
|
+
layerId: layer.id
|
|
36
|
+
});
|
|
37
|
+
default:
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SUPPORTED_EARTH_ENGINE_LAYERS = void 0;
|
|
7
|
+
const SUPPORTED_EARTH_ENGINE_LAYERS = ["population", "footprints", "elevation", "landCover"];
|
|
8
|
+
exports.SUPPORTED_EARTH_ENGINE_LAYERS = SUPPORTED_EARTH_ENGINE_LAYERS;
|
package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGoogleEngineLayers = useGoogleEngineLayers;
|
|
7
|
+
exports.usePointLayer = usePointLayer;
|
|
8
|
+
exports.useThematicLayers = useThematicLayers;
|
|
9
|
+
var _lodash = require("lodash");
|
|
10
|
+
var _hooks = require("../../../hooks");
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _map = require("../../../../../utils/map");
|
|
13
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
14
|
+
var _asyncEs = require("async-es");
|
|
15
|
+
var _colors = require("../../../../../utils/colors");
|
|
16
|
+
var _hooks2 = require("../../../../MapLayer/components/GoogleEngineLayer/hooks");
|
|
17
|
+
var _useBoundaryData = require("../../../../MapLayer/components/BoundaryLayer/hooks/useBoundaryData");
|
|
18
|
+
var _engine = require("../../../../MapLayer/components/GoogleEngineLayer/services/engine");
|
|
19
|
+
var _constants = require("../../../../MapLayer/components/GoogleEngineLayer/constants");
|
|
20
|
+
const analyticsQuery = {
|
|
21
|
+
analytics: {
|
|
22
|
+
resource: "analytics",
|
|
23
|
+
params: _ref => {
|
|
24
|
+
let {
|
|
25
|
+
ou,
|
|
26
|
+
pe,
|
|
27
|
+
dx,
|
|
28
|
+
startDate,
|
|
29
|
+
endDate
|
|
30
|
+
} = _ref;
|
|
31
|
+
const peDimension = !(0, _lodash.isEmpty)(pe) ? `pe:${pe === null || pe === void 0 ? void 0 : pe.join(";")}` : undefined;
|
|
32
|
+
const ouDimension = !(0, _lodash.isEmpty)(ou) ? `ou:${ou === null || ou === void 0 ? void 0 : ou.join(";")}` : undefined;
|
|
33
|
+
const dxDimension = !(0, _lodash.isEmpty)(dx) ? `dx:${dx === null || dx === void 0 ? void 0 : dx.join(";")}` : undefined;
|
|
34
|
+
return {
|
|
35
|
+
dimension: (0, _lodash.compact)([dxDimension, peDimension, ouDimension]),
|
|
36
|
+
startDate,
|
|
37
|
+
endDate,
|
|
38
|
+
displayProperty: "NAME"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const query = {
|
|
44
|
+
layer: {
|
|
45
|
+
resource: "geoFeatures",
|
|
46
|
+
params: _ref2 => {
|
|
47
|
+
let {
|
|
48
|
+
ous
|
|
49
|
+
} = _ref2;
|
|
50
|
+
return {
|
|
51
|
+
ou: `ou:${ous.join(";")}`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
analytics: {
|
|
56
|
+
resource: "analytics",
|
|
57
|
+
params: _ref3 => {
|
|
58
|
+
let {
|
|
59
|
+
ous
|
|
60
|
+
} = _ref3;
|
|
61
|
+
return {
|
|
62
|
+
dimension: [`ou:${ous.join(";")}`, `pe:${new Date().getFullYear()}`],
|
|
63
|
+
skipData: true,
|
|
64
|
+
hierarchyMeta: true
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const groupSetQuery = {
|
|
70
|
+
groupSet: {
|
|
71
|
+
resource: "organisationUnitGroupSets",
|
|
72
|
+
id: _ref4 => {
|
|
73
|
+
let {
|
|
74
|
+
groupSet
|
|
75
|
+
} = _ref4;
|
|
76
|
+
return groupSet;
|
|
77
|
+
},
|
|
78
|
+
params: {
|
|
79
|
+
fields: ["organisationUnitGroups[name,color,symbol,organisationUnits[id]]"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const legendSetsQuery = {
|
|
84
|
+
legendSets: {
|
|
85
|
+
resource: "legendSets",
|
|
86
|
+
id: _ref5 => {
|
|
87
|
+
let {
|
|
88
|
+
id
|
|
89
|
+
} = _ref5;
|
|
90
|
+
return id;
|
|
91
|
+
},
|
|
92
|
+
params: {
|
|
93
|
+
fields: ["id", "displayName", "legends[id,code,startValue,endValue,color]"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function useThematicLayers() {
|
|
98
|
+
var _useMapPeriods;
|
|
99
|
+
const engine = (0, _appRuntime.useDataEngine)();
|
|
100
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
101
|
+
const {
|
|
102
|
+
orgUnits,
|
|
103
|
+
orgUnitSelection
|
|
104
|
+
} = (0, _hooks.useMapOrganisationUnit)();
|
|
105
|
+
const {
|
|
106
|
+
periods,
|
|
107
|
+
range
|
|
108
|
+
} = (_useMapPeriods = (0, _hooks.useMapPeriods)()) !== null && _useMapPeriods !== void 0 ? _useMapPeriods : {};
|
|
109
|
+
const ou = (0, _react.useMemo)(() => (0, _map.getOrgUnitsSelection)(orgUnitSelection), [orgUnitSelection]);
|
|
110
|
+
const pe = (0, _react.useMemo)(() => periods === null || periods === void 0 ? void 0 : periods.map(pe => pe.id), [periods]);
|
|
111
|
+
const {
|
|
112
|
+
startDate,
|
|
113
|
+
endDate
|
|
114
|
+
} = (0, _react.useMemo)(() => {
|
|
115
|
+
if (!range) {
|
|
116
|
+
return {
|
|
117
|
+
startDate: undefined,
|
|
118
|
+
endDate: undefined
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
startDate: (0, _map.sanitizeDate)(range.start.toDateString()),
|
|
123
|
+
endDate: (0, _map.sanitizeDate)(range.end.toDateString())
|
|
124
|
+
};
|
|
125
|
+
}, [range]);
|
|
126
|
+
const sanitizeData = (data, layer) => {
|
|
127
|
+
if (data) {
|
|
128
|
+
const {
|
|
129
|
+
analytics
|
|
130
|
+
} = data;
|
|
131
|
+
const rows = analytics === null || analytics === void 0 ? void 0 : analytics.rows;
|
|
132
|
+
const ouIndex = analytics.headers.findIndex(header => header.name === "ou");
|
|
133
|
+
const dxIndex = analytics.headers.findIndex(header => header.name === "dx");
|
|
134
|
+
const valueIndex = analytics.headers.findIndex(header => header.name === "value");
|
|
135
|
+
if (!(0, _lodash.isEmpty)(rows)) {
|
|
136
|
+
return (0, _lodash.sortBy)(orgUnits === null || orgUnits === void 0 ? void 0 : orgUnits.map(ou => {
|
|
137
|
+
const row = rows.find(row => row[ouIndex] === ou.id && row[dxIndex] === layer.dataItem.id);
|
|
138
|
+
return {
|
|
139
|
+
orgUnit: ou,
|
|
140
|
+
data: row ? parseFloat(row[valueIndex]) : undefined,
|
|
141
|
+
dataItem: {
|
|
142
|
+
...layer.dataItem
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}), ["data"]);
|
|
146
|
+
}
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
return [];
|
|
150
|
+
};
|
|
151
|
+
const sanitizeLegends = async layers => {
|
|
152
|
+
return await (0, _asyncEs.map)(layers, (0, _asyncEs.asyncify)(async layer => {
|
|
153
|
+
try {
|
|
154
|
+
const legends = [];
|
|
155
|
+
if (layer.dataItem.legendSet) {
|
|
156
|
+
const legendSetData = await engine.query(legendSetsQuery, {
|
|
157
|
+
variables: {
|
|
158
|
+
id: layer.dataItem.legendSet
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const legendSet = legendSetData === null || legendSetData === void 0 ? void 0 : legendSetData.legendSets;
|
|
162
|
+
if (legendSet) {
|
|
163
|
+
legends.push(...legendSet.legends);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
var _layer$dataItem$legen, _last$data, _last, _head$data, _head;
|
|
167
|
+
const {
|
|
168
|
+
scale,
|
|
169
|
+
colorClass
|
|
170
|
+
} = (_layer$dataItem$legen = layer.dataItem.legendConfig) !== null && _layer$dataItem$legen !== void 0 ? _layer$dataItem$legen : {
|
|
171
|
+
scale: _colors.defaultClasses,
|
|
172
|
+
colorClass: _colors.defaultColorScaleName
|
|
173
|
+
};
|
|
174
|
+
const sortedData = (0, _lodash.sortBy)(layer.data, "data");
|
|
175
|
+
const autoLegends = (0, _map.generateLegends)((_last$data = (_last = (0, _lodash.last)(sortedData)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 0, (_head$data = (_head = (0, _lodash.head)(sortedData)) === null || _head === void 0 ? void 0 : _head.data) !== null && _head$data !== void 0 ? _head$data : 0, {
|
|
176
|
+
classesCount: scale,
|
|
177
|
+
colorClass
|
|
178
|
+
});
|
|
179
|
+
legends.push(...autoLegends);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
...layer,
|
|
183
|
+
legends
|
|
184
|
+
};
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return layer;
|
|
187
|
+
}
|
|
188
|
+
}));
|
|
189
|
+
};
|
|
190
|
+
const sanitizeLayers = async layers => {
|
|
191
|
+
try {
|
|
192
|
+
setLoading(true);
|
|
193
|
+
const layersWithoutData = layers === null || layers === void 0 ? void 0 : layers.filter(layer => !layer.data);
|
|
194
|
+
const layersWithData = (0, _lodash.differenceBy)(layers, layersWithoutData, "id");
|
|
195
|
+
const dx = layersWithoutData.map(layer => layer.dataItem.id);
|
|
196
|
+
let sanitizedLayersWithData = [];
|
|
197
|
+
if (!(0, _lodash.isEmpty)(dx)) {
|
|
198
|
+
const data = await engine.query(analyticsQuery, {
|
|
199
|
+
variables: {
|
|
200
|
+
dx,
|
|
201
|
+
ou,
|
|
202
|
+
pe,
|
|
203
|
+
startDate,
|
|
204
|
+
endDate
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
sanitizedLayersWithData = layersWithoutData.map(layer => {
|
|
208
|
+
var _ref6, _layer$name, _layer$dataItem;
|
|
209
|
+
return {
|
|
210
|
+
...layer,
|
|
211
|
+
name: (_ref6 = (_layer$name = layer === null || layer === void 0 ? void 0 : layer.name) !== null && _layer$name !== void 0 ? _layer$name : layer === null || layer === void 0 ? void 0 : (_layer$dataItem = layer.dataItem) === null || _layer$dataItem === void 0 ? void 0 : _layer$dataItem.displayName) !== null && _ref6 !== void 0 ? _ref6 : layer.id,
|
|
212
|
+
data: sanitizeData(data, layer)
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const sanitizedLayersWithOrgUnits = layersWithData.map(layer => {
|
|
217
|
+
var _layer$data;
|
|
218
|
+
return {
|
|
219
|
+
...layer,
|
|
220
|
+
data: (_layer$data = layer.data) === null || _layer$data === void 0 ? void 0 : _layer$data.map(datum => {
|
|
221
|
+
var _ref7, _layer$name2, _layer$dataItem2;
|
|
222
|
+
return {
|
|
223
|
+
...datum,
|
|
224
|
+
orgUnit: (0, _lodash.find)(orgUnits, ["id", datum.orgUnit]),
|
|
225
|
+
dataItem: layer.dataItem,
|
|
226
|
+
name: (_ref7 = (_layer$name2 = layer === null || layer === void 0 ? void 0 : layer.name) !== null && _layer$name2 !== void 0 ? _layer$name2 : layer === null || layer === void 0 ? void 0 : (_layer$dataItem2 = layer.dataItem) === null || _layer$dataItem2 === void 0 ? void 0 : _layer$dataItem2.displayName) !== null && _ref7 !== void 0 ? _ref7 : layer.id
|
|
227
|
+
};
|
|
228
|
+
})
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
setLoading(false);
|
|
232
|
+
return await sanitizeLegends([...sanitizedLayersWithData, ...sanitizedLayersWithOrgUnits]);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.error(`Error getting thematic layers`, e.details);
|
|
235
|
+
setLoading(false);
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
sanitizeLayers,
|
|
241
|
+
loading
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function usePointLayer() {
|
|
245
|
+
const engine = (0, _appRuntime.useDataEngine)();
|
|
246
|
+
const {
|
|
247
|
+
orgUnitSelection
|
|
248
|
+
} = (0, _hooks.useMapOrganisationUnit)();
|
|
249
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
250
|
+
const sanitizePointData = (0, _react.useCallback)((orgUnitData, groupSetData) => {
|
|
251
|
+
var _ref8;
|
|
252
|
+
const {
|
|
253
|
+
analytics,
|
|
254
|
+
layer
|
|
255
|
+
} = (_ref8 = orgUnitData) !== null && _ref8 !== void 0 ? _ref8 : {};
|
|
256
|
+
const rawOrgUnits = (0, _map.sanitizeOrgUnits)(analytics === null || analytics === void 0 ? void 0 : analytics.metaData);
|
|
257
|
+
const geoJSONObjects = (0, _map.toGeoJson)(layer === null || layer === void 0 ? void 0 : layer.filter(bound => bound.co));
|
|
258
|
+
return (0, _lodash.compact)(rawOrgUnits.map(orgUnit => {
|
|
259
|
+
var _organisationUnitGrou, _groupSetData$groupSe;
|
|
260
|
+
const geoJSONObject = geoJSONObjects === null || geoJSONObjects === void 0 ? void 0 : geoJSONObjects.find(geoJSON => geoJSON.properties.id === orgUnit.id);
|
|
261
|
+
const orgUnitGroups = (_organisationUnitGrou = groupSetData === null || groupSetData === void 0 ? void 0 : (_groupSetData$groupSe = groupSetData.groupSet) === null || _groupSetData$groupSe === void 0 ? void 0 : _groupSetData$groupSe.organisationUnitGroups) !== null && _organisationUnitGrou !== void 0 ? _organisationUnitGrou : [];
|
|
262
|
+
const ouGroup = (0, _lodash.find)(orgUnitGroups, ouGroup => {
|
|
263
|
+
var _ouGroup$organisation;
|
|
264
|
+
return !!(0, _lodash.find)((_ouGroup$organisation = ouGroup === null || ouGroup === void 0 ? void 0 : ouGroup.organisationUnits) !== null && _ouGroup$organisation !== void 0 ? _ouGroup$organisation : [], ["id", orgUnit.id]);
|
|
265
|
+
});
|
|
266
|
+
if (!geoJSONObject || geoJSONObject.properties.type !== "Point") {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
...orgUnit,
|
|
271
|
+
geoJSON: geoJSONObject,
|
|
272
|
+
level: geoJSONObject.properties.level,
|
|
273
|
+
icon: {
|
|
274
|
+
type: "groupIcon",
|
|
275
|
+
icon: ouGroup === null || ouGroup === void 0 ? void 0 : ouGroup.symbol
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}));
|
|
279
|
+
}, []);
|
|
280
|
+
const sanitizeLayer = (0, _react.useCallback)(async layer => {
|
|
281
|
+
try {
|
|
282
|
+
var _layer$style, _organisationUnitGrou2, _groupSetData$groupSe2;
|
|
283
|
+
if (!layer.level && !layer.group) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
setLoading(true);
|
|
287
|
+
const level = layer.level ? `LEVEL-${layer.level}` : undefined;
|
|
288
|
+
const group = layer.group ? `OU_GROUP-${layer.group}` : undefined;
|
|
289
|
+
const ous = [...(0, _map.getOrgUnitsSelection)(orgUnitSelection), level, group];
|
|
290
|
+
const pointData = await engine.query(query, {
|
|
291
|
+
variables: {
|
|
292
|
+
ous
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
const groupSetData = await engine.query(groupSetQuery, {
|
|
296
|
+
variables: {
|
|
297
|
+
groupSet: (_layer$style = layer.style) === null || _layer$style === void 0 ? void 0 : _layer$style.groupSet
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const sanitizedOrgUnitData = sanitizePointData(pointData, groupSetData);
|
|
301
|
+
const orgUnitGroups = (_organisationUnitGrou2 = groupSetData === null || groupSetData === void 0 ? void 0 : (_groupSetData$groupSe2 = groupSetData.groupSet) === null || _groupSetData$groupSe2 === void 0 ? void 0 : _groupSetData$groupSe2.organisationUnitGroups) !== null && _organisationUnitGrou2 !== void 0 ? _organisationUnitGrou2 : [];
|
|
302
|
+
const sanitizedOrgUnitGroups = orgUnitGroups.map(ouGroup => ({
|
|
303
|
+
...ouGroup,
|
|
304
|
+
organisationUnits: undefined
|
|
305
|
+
}));
|
|
306
|
+
setLoading(false);
|
|
307
|
+
return {
|
|
308
|
+
...layer,
|
|
309
|
+
points: sanitizedOrgUnitData,
|
|
310
|
+
style: {
|
|
311
|
+
...layer.style,
|
|
312
|
+
orgUnitGroups: sanitizedOrgUnitGroups
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
} catch (e) {
|
|
316
|
+
setLoading(false);
|
|
317
|
+
console.error(`Error getting point layer`, e.details);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
}, []);
|
|
321
|
+
return {
|
|
322
|
+
loading,
|
|
323
|
+
sanitizeLayer
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function useGoogleEngineLayers() {
|
|
327
|
+
const {
|
|
328
|
+
refresh
|
|
329
|
+
} = (0, _hooks2.useGoogleEngineToken)();
|
|
330
|
+
const orgUnits = (0, _useBoundaryData.useBoundaryData)();
|
|
331
|
+
async function getImageUrl(earthEngine, _ref9) {
|
|
332
|
+
let {
|
|
333
|
+
filters
|
|
334
|
+
} = _ref9;
|
|
335
|
+
if (earthEngine.initialized) {
|
|
336
|
+
try {
|
|
337
|
+
earthEngine.setOrgUnits(orgUnits !== null && orgUnits !== void 0 ? orgUnits : []);
|
|
338
|
+
const period = filters === null || filters === void 0 ? void 0 : filters.period;
|
|
339
|
+
if (period) {
|
|
340
|
+
earthEngine.setPeriod(period);
|
|
341
|
+
}
|
|
342
|
+
return earthEngine.url();
|
|
343
|
+
} catch (e) {
|
|
344
|
+
console.error(e);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const sanitizeLayers = (0, _react.useCallback)(async layers => {
|
|
349
|
+
try {
|
|
350
|
+
const {
|
|
351
|
+
token
|
|
352
|
+
} = await refresh();
|
|
353
|
+
await _engine.EarthEngine.setToken(token, refresh);
|
|
354
|
+
return (0, _asyncEs.map)(layers, (0, _asyncEs.asyncify)(async layer => {
|
|
355
|
+
try {
|
|
356
|
+
var _find, _layer$aggregations, _layer$params;
|
|
357
|
+
const defaultOptions = (_find = (0, _lodash.find)(_constants.EARTH_ENGINE_LAYERS, ["id", layer.type])) !== null && _find !== void 0 ? _find : {};
|
|
358
|
+
const options = {
|
|
359
|
+
...defaultOptions,
|
|
360
|
+
aggregations: (_layer$aggregations = layer.aggregations) !== null && _layer$aggregations !== void 0 ? _layer$aggregations : defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.aggregations,
|
|
361
|
+
params: (_layer$params = layer.params) !== null && _layer$params !== void 0 ? _layer$params : defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.params
|
|
362
|
+
};
|
|
363
|
+
const updatedLayer = {
|
|
364
|
+
...layer,
|
|
365
|
+
options
|
|
366
|
+
};
|
|
367
|
+
const earthEngine = new _engine.EarthEngine({
|
|
368
|
+
options
|
|
369
|
+
});
|
|
370
|
+
const url = await getImageUrl(earthEngine, updatedLayer);
|
|
371
|
+
return {
|
|
372
|
+
...updatedLayer,
|
|
373
|
+
engine: earthEngine,
|
|
374
|
+
url
|
|
375
|
+
};
|
|
376
|
+
} catch (e) {
|
|
377
|
+
console.error(e);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}));
|
|
381
|
+
} catch (e) {
|
|
382
|
+
console.error(`Error getting thematic layers`, e.details);
|
|
383
|
+
return [];
|
|
384
|
+
}
|
|
385
|
+
}, [refresh]);
|
|
386
|
+
return {
|
|
387
|
+
sanitizeLayers
|
|
388
|
+
};
|
|
389
|
+
}
|