diff --git a/app/backend/wells/urls.py b/app/backend/wells/urls.py index 06774b3f2..eeb9a3c48 100644 --- a/app/backend/wells/urls.py +++ b/app/backend/wells/urls.py @@ -114,5 +114,9 @@ # Well Licensing status endpoint from e-Licensing. url(api_path_prefix() + r'/wells/licensing$', - views.well_licensing, name='well-licensing') + views.well_licensing, name='well-licensing'), + + # get geocoder address + url(api_path_prefix() + r'/wells/geocoder$', + views.AddressGeocoder.as_view(), name='address-geocoder'), ] diff --git a/app/backend/wells/views.py b/app/backend/wells/views.py index 5bad3b0ab..b1ec3604c 100644 --- a/app/backend/wells/views.py +++ b/app/backend/wells/views.py @@ -893,3 +893,15 @@ def get_queryset(self): qs = qs.filter(well_tag_number__in=wells) return qs +class AddressGeocoder(APIView): + def get(self, request,**kwargs): + GEOCODER_ADDRESS_URL = get_env_variable('GEOCODER_ADDRESS_API_BASE') + self.request.query_params.get('searchTag') + response = requests.get(GEOCODER_ADDRESS_URL) + # Check if the request was successful (status code 200) + if response.status_code == 200: + data = response.json() + # Create a Django JsonResponse object and return it + return JsonResponse(data) + else: + # If the request was not successful, return an appropriate HTTP response + return JsonResponse({'error': f"Error: {response.status_code} - {response.text}"}, status=500) diff --git a/app/frontend/src/common/services/ApiService.js b/app/frontend/src/common/services/ApiService.js index 9527e6419..6bb22a866 100644 --- a/app/frontend/src/common/services/ApiService.js +++ b/app/frontend/src/common/services/ApiService.js @@ -94,6 +94,9 @@ const ApiService = { incrementFileCount(resource, documentType){ return axios.get(`${resource}/sum`, {params: { inc: true, documentType}}) }, + getAddresses(searchTag){ + return axios.get(`wells/geocoder`, {params: { searchTag: searchTag }}) + }, } export default ApiService diff --git a/app/frontend/src/submissions/components/SubmissionForm/Location.vue b/app/frontend/src/submissions/components/SubmissionForm/Location.vue index b07bb0b61..b80d127df 100644 --- a/app/frontend/src/submissions/components/SubmissionForm/Location.vue +++ b/app/frontend/src/submissions/components/SubmissionForm/Location.vue @@ -38,10 +38,23 @@ Licensed under the Apache License, Version 2.0 (the "License"); id="wellStreetAddress" type="text" label="Street address" + @input="fetchAddressSuggestions" + v-on:focus="showList(true)" + v-on:blur="showList(false)" :errors="errors['street_address']" :loaded="fieldsLoaded['street_address']" :disabled="sameAsOwnerAddress" > + +
+
+ +
+
+ +
+ Loading... +
@@ -202,10 +215,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); @@ -293,4 +392,9 @@ export default { .dropdown-error-border { border-radius: 5px; } +.address-suggestions { + list-style-type: none; + position: absolute; + z-index: 10; + } diff --git a/app/frontend/src/submissions/components/SubmissionForm/Owner.vue b/app/frontend/src/submissions/components/SubmissionForm/Owner.vue index 817fb3d06..52033d6f8 100644 --- a/app/frontend/src/submissions/components/SubmissionForm/Owner.vue +++ b/app/frontend/src/submissions/components/SubmissionForm/Owner.vue @@ -27,10 +27,35 @@ Licensed under the Apache License, Version 2.0 (the "License"); - + - + + + +
+
+ +
+
+ +
+ Loading... +
@@ -85,11 +110,10 @@ Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker-compose.yml b/docker-compose.yml index 0efc76cb7..90a1d1c67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -188,6 +188,7 @@ services: S3_WELL_EXPORT_BUCKET: gwells S3_USE_SECURE: 0 EMAIL_NOTIFICATION_RECIPIENT: sustainment.team@gov.bc.ca + GEOCODER_ADDRESS_API_BASE: https://geocoder.api.gov.bc.ca/addresses.json? command: /bin/bash -c " sleep 3 && set -x && diff --git a/openshift/backend.dc.json b/openshift/backend.dc.json index e9e6ada2f..dcd308873 100644 --- a/openshift/backend.dc.json +++ b/openshift/backend.dc.json @@ -733,6 +733,15 @@ { "name": "ENFORCE_ENV_VARIABLES", "value": "False" + }, + { + "name": "GEOCODER_ADDRESS_API_BASE", + "valueFrom": { + "configMapKeyRef": { + "key": "GEOCODER_ADDRESS_API_BASE", + "name": "gwells-global-config${NAME_SUFFIX}" + } + } } ], "resources": { diff --git a/openshift/ocp4/backend.dc.json b/openshift/ocp4/backend.dc.json index fca3bbb87..74a317bfa 100644 --- a/openshift/ocp4/backend.dc.json +++ b/openshift/ocp4/backend.dc.json @@ -742,6 +742,15 @@ "name": "gwells-global-config${NAME_SUFFIX}" } } + }, + { + "name": "GEOCODER_ADDRESS_API_BASE", + "valueFrom": { + "configMapKeyRef": { + "key": "GEOCODER_ADDRESS_API_BASE", + "name": "gwells-global-config${NAME_SUFFIX}" + } + } } ], "resources": {