Skip to content

Commit

Permalink
Merge pull request #539 from onaio/gisida-timeout
Browse files Browse the repository at this point in the history
Add Gisida timeout
  • Loading branch information
moshthepitt authored Oct 17, 2019
2 parents 576f079 + b88c5fe commit fcf2b2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ REACT_APP_SUPERSET_IRS_REPORTING_INDICATOR_ROWS=zambia2019
REACT_APP_SUPERSET_STRUCTURES_SLICE=0
REACT_APP_SUPERSET_TASKS_SLICE=0
REACT_APP_SUPERSET_PLAN_STRUCTURE_PIVOT_SLICE=0
REACT_APP_GISIDA_TIMEOUT=3000
REACT_APP_GISIDA_MAPBOX_TOKEN=hunter2
REACT_APP_GISIDA_ONADATA_API_TOKEN=hunter2
REACT_APP_DIGITAL_GLOBE_CONNECT_ID=mylifeforaiur
Expand Down
12 changes: 4 additions & 8 deletions src/components/GisidaWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { FillPaint, LinePaint, Map as mbMap, Style, SymbolPaint } from 'mapbox-g
import * as React from 'react';
import { GREY } from '../../colors';
import Loading from '../../components/page/Loading/index';
import {
GISIDA_MAPBOX_TOKEN,
GISIDA_ONADATA_API_TOKEN,
SUPERSET_MAX_RECORDS,
} from '../../configs/env';
import { GISIDA_MAPBOX_TOKEN, GISIDA_ONADATA_API_TOKEN, GISIDA_TIMEOUT } from '../../configs/env';
import {
circleLayerConfig,
fillLayerConfig,
Expand Down Expand Up @@ -184,7 +180,7 @@ class GisidaWrapper extends React.Component<GisidaProps, GisidaState> {
// Dirty work around! Arbitrary delay to allow style load before adding layers
setTimeout(() => {
this.initMap(null, null);
}, SUPERSET_MAX_RECORDS);
}, GISIDA_TIMEOUT);
}
);
} else if (!this.state.locations) {
Expand Down Expand Up @@ -212,7 +208,7 @@ class GisidaWrapper extends React.Component<GisidaProps, GisidaState> {
// Dirty work around! Arbitrary delay to allow style load before adding layers
setTimeout(() => {
this.initMap(null, null);
}, SUPERSET_MAX_RECORDS);
}, GISIDA_TIMEOUT);
}
);
}
Expand Down Expand Up @@ -261,7 +257,7 @@ class GisidaWrapper extends React.Component<GisidaProps, GisidaState> {
// Dirty work around! Arbitrary delay to allow style load before adding layers
setTimeout(() => {
this.initMap(null, null);
}, SUPERSET_MAX_RECORDS);
}, GISIDA_TIMEOUT);
}
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/configs/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export type SUPERSET_PLANS_SLICE = typeof SUPERSET_PLANS_SLICE;
export const SUPERSET_MAX_RECORDS = 3000;
export type SUPERSET_MAX_RECORDS = typeof SUPERSET_MAX_RECORDS;

export const GISIDA_TIMEOUT = 3000;
export type GISIDA_TIMEOUT = typeof GISIDA_TIMEOUT;

export const GISIDA_MAPBOX_TOKEN = 'hunter2';
export type GISIDA_MAPBOX_TOKEN = typeof GISIDA_MAPBOX_TOKEN;

Expand Down
4 changes: 4 additions & 0 deletions src/configs/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export type ONADATA_USER_URL = typeof ONADATA_USER_URL;
export const ONADATA_OAUTH_STATE = process.env.REACT_APP_ONADATA_OAUTH_STATE || 'onadata';
export type ONADATA_OAUTH_STATE = typeof ONADATA_OAUTH_STATE;

/** The max number of records to get from Superset API endpoint */
export const GISIDA_TIMEOUT = Number(process.env.REACT_APP_GISIDA_TIMEOUT) || 3000;
export type GISIDA_TIMEOUT = typeof GISIDA_TIMEOUT;

export const GISIDA_MAPBOX_TOKEN = process.env.REACT_APP_GISIDA_MAPBOX_TOKEN || '';
export type GISIDA_MAPBOX_TOKEN = typeof GISIDA_MAPBOX_TOKEN;

Expand Down

0 comments on commit fcf2b2d

Please sign in to comment.