Skip to content

Commit

Permalink
chore: geojsonloader and thematicloader
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Oct 30, 2024
1 parent 4cfb808 commit 52315bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/hooks/useLayersLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import useLoaderAlerts from '../components/loaders/useLoaderAlerts.js'
// import eventLoader from '../loaders/eventLoader.js'
import externalLoader from '../loaders/externalLoader.js'
import facilityLoader from '../loaders/facilityLoader.js'
import geoJsonUrlLoader from '../loaders/geoJsonUrlLoader.js'
import orgUnitLoader from '../loaders/orgUnitLoader.js'
import thematicLoader from '../loaders/thematicLoader.js'
// import trackedEntityLoader from '../loaders/trackedEntityLoader.js'
Expand All @@ -20,6 +21,8 @@ const loaders = {
facility: facilityLoader,
orgUnit: orgUnitLoader,
thematic: thematicLoader,
geoJsonUrl: geoJsonUrlLoader,

// trackedEntity: trackedEntityLoader,
}

Expand All @@ -31,7 +34,7 @@ export const useLayersLoader = () => {
({ layer }) => `Could not load layer ${layer}`,
{ critical: true }
)
const { nameProperty } = useCachedDataQuery()
const { nameProperty, currentUser } = useCachedDataQuery()
const { showAlerts } = useLoaderAlerts()

const allLayers = useSelector((state) => state.map.mapViews)
Expand All @@ -45,6 +48,8 @@ export const useLayersLoader = () => {
engine,
analyticsEngine,
baseUrl,
keyAnalysisDisplayProperty:
currentUser.keyAnalysisDisplayProperty,
})
if (result.alerts) {
showAlerts(result.alerts)
Expand Down Expand Up @@ -72,6 +77,7 @@ export const useLayersLoader = () => {
allLayers,
dispatch,
nameProperty,
currentUser.keyAnalysisDisplayProperty,
engine,
analyticsEngine,
showAlerts,
Expand Down
6 changes: 5 additions & 1 deletion src/loaders/geoJsonUrlLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const fetchData = async (url, engine, instanceBaseUrl) => {
}

const EMPTY_FEATURE_STYLE = {}
const geoJsonUrlLoader = async (layer, engine, instanceBaseUrl) => {
const geoJsonUrlLoader = async ({
config: layer,
engine,
baseUrl: instanceBaseUrl,
}) => {
const { config } = layer

let newConfig
Expand Down
12 changes: 6 additions & 6 deletions src/loaders/thematicLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const GEOFEATURES_QUERY = {

const thematicLoader = async ({
config,
displayProperty,
engine,
analyticsEngine,
keyAnalysisDisplayProperty,
}) => {
const {
columns,
Expand All @@ -82,7 +82,7 @@ const thematicLoader = async ({

const response = await loadData({
config,
displayProperty,
keyAnalysisDisplayProperty,
engine,
analyticsEngine,
alerts,
Expand Down Expand Up @@ -362,7 +362,7 @@ const getOrderedValues = (data) => {
// Load features and data values from api
const loadData = async ({
config,
displayProperty,
keyAnalysisDisplayProperty,
engine,
analyticsEngine,
alerts,
Expand Down Expand Up @@ -399,7 +399,7 @@ const loadData = async ({
let analyticsRequest = new analyticsEngine.request()
.addOrgUnitDimension(orgUnits.map((ou) => ou.id))
.addDataDimension(dataDimension)
.withDisplayProperty(displayProperty.toUpperCase())
.withDisplayProperty(keyAnalysisDisplayProperty)

if (!isSingleMap) {
analyticsRequest = analyticsRequest.addPeriodDimension(period.id)
Expand Down Expand Up @@ -451,7 +451,7 @@ const loadData = async ({
{
variables: {
ou: ouParam,
displayProperty,
displayProperty: keyAnalysisDisplayProperty,
userOrgUnit: geoFeaturesParams.userOrgUnit, // TODO
},
},
Expand Down Expand Up @@ -482,7 +482,7 @@ const loadData = async ({
{
variables: {
ou: ouParam,
displayProperty,
displayProperty: keyAnalysisDisplayProperty,
userOrgUnit: geoFeaturesParams.userOrgUnit,
coordinateField: coordinateField.id,
},
Expand Down

0 comments on commit 52315bb

Please sign in to comment.