Skip to content

Commit

Permalink
FCRM-5389 map component hard coded urls replaced with configured ones
Browse files Browse the repository at this point in the history
  • Loading branch information
markfee committed Nov 28, 2024
1 parent 4e41458 commit 8c81ce1
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 385 deletions.
740 changes: 371 additions & 369 deletions client/js/defra-map/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ placeApiUrl=http://dummyuri
#AGOL
agolClientId=TEST_AGOL_CLIENT_ID
agolClientSecret=TEST_AGOL_CLIENT_SECRET
agolServiceUrl=http://dummyAgolUrl
agolServiceId=DUMMY_SERVICE_ID
agolCustomerTeamEndPoint=/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/0
agolLocalAuthorityEndPoint=/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/1
agolIsEnglandEndPoint=/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/2
Expand Down
4 changes: 3 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const config = {
agol: {
clientId: process.env.agolClientId,
clientSecret: process.env.agolClientSecret,
serviceUrl: process.env.agolServiceUrl,
serviceId: process.env.agolServiceId,
serviceUrl: `https://services1.arcgis.com/${process.env.agolServiceId}/arcgis/rest/services`,
vectorTileUrl: `https://tiles.arcgis.com/tiles/${process.env.agolServiceId}/arcgis/rest/services`,
customerTeamEndPoint: process.env.agolCustomerTeamEndPoint,
localAuthorityEndPoint: process.env.agolLocalAuthorityEndPoint,
isEnglandEndPoint: process.env.agolIsEnglandEndPoint,
Expand Down
2 changes: 2 additions & 0 deletions config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const schema = Joi.object({
agol: {
clientId: Joi.string().required(),
clientSecret: Joi.string().required(),
serviceId: Joi.string().required(),
serviceUrl: Joi.string().uri().required(),
vectorTileUrl: Joi.string().uri().required(),
customerTeamEndPoint: Joi.string().required(),
localAuthorityEndPoint: Joi.string().required(),
isEnglandEndPoint: Joi.string().required(),
Expand Down
1 change: 1 addition & 0 deletions server/plugins/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const routes = [].concat(
require('../routes/defra-map'),
require('../routes/defra-map/map-config'),
require('../routes/defra-map/styles'),
require('../routes/home'),
require('../routes/flood-zone-results'),
Expand Down
11 changes: 0 additions & 11 deletions server/routes/defra-map/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { config } = require('../../../config')
const { getEsriToken } = require('../../services/agol/getEsriToken')
const { getOsToken } = require('../../services/os/getOsToken')

Expand All @@ -12,16 +11,6 @@ module.exports = [
return h.view('map')
}
}
}, {
method: 'GET',
path: '/defra-map/config',
options: {
description: 'config values for the defra-map component',
handler: async (request, h) => {
const { defraMap } = config
return defraMap
}
}
}, {
method: 'GET',
path: '/os-token',
Expand Down
18 changes: 18 additions & 0 deletions server/routes/defra-map/map-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { config } = require('../../../config')
const { defraMap: mapConfig } = config

Object.assign(mapConfig, {
agolServiceUrl: config.agol.serviceUrl,
agolVectorTileUrl: config.agol.vectorTileUrl
})

module.exports = {
method: 'GET',
path: '/defra-map/config',
options: {
description: 'config values for the defra-map component',
handler: async (request, h) => {
return mapConfig
}
}
}
4 changes: 3 additions & 1 deletion test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ lab.experiment('Ensure config is correct', () => {
agol: {
clientId: 'TEST_AGOL_CLIENT_ID',
clientSecret: 'TEST_AGOL_CLIENT_SECRET',
serviceUrl: 'http://dummyAgolUrl',
serviceId: 'DUMMY_SERVICE_ID',
serviceUrl: 'https://services1.arcgis.com/DUMMY_SERVICE_ID/arcgis/rest/services',
vectorTileUrl: 'https://tiles.arcgis.com/tiles/DUMMY_SERVICE_ID/arcgis/rest/services',
customerTeamEndPoint: '/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/0',
localAuthorityEndPoint: '/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/1',
isEnglandEndPoint: '/Flood_Map_for_Planning_Query_Service_NON_PRODUCTION/FeatureServer/2',
Expand Down
4 changes: 2 additions & 2 deletions test/services/agol.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lab.experiment('agol.js', () => {

// Test that the expected params get passed to queryFeatures
const expectedParameters = {
url: 'http://dummyAgolUrl/endPoint1',
url: 'https://services1.arcgis.com/DUMMY_SERVICE_ID/arcgis/rest/services/endPoint1',
geometry: undefined,
geometryType: undefined,
spatialRel: 'esriSpatialRelIntersects',
Expand All @@ -77,7 +77,7 @@ lab.experiment('agol.js', () => {

// Test that the modified expected params get passed to queryFeatures
Object.assign(expectedParameters, {
url: 'http://dummyAgolUrl/endPoint2',
url: 'https://services1.arcgis.com/DUMMY_SERVICE_ID/arcgis/rest/services/endPoint2',
authentication: 'dummy_token_refreshed'
})

Expand Down

0 comments on commit 8c81ce1

Please sign in to comment.