From 5149e3b0891b204a89b17ccd191cab7beaf44de4 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Thu, 23 Sep 2021 18:34:48 +0300 Subject: [PATCH] [Feature #139317] Added facility type fiilter --- .../DiscodataOpenlayersMapBlock/View.jsx | 156 ++++++++++++++++++ .../manage/Blocks/FiltersBlock/View.jsx | 37 +++++ .../manage/Blocks/IndustryMap/View.jsx | 151 +++++++++++++++++ .../manage/Blocks/IndustryMap/index.js | 5 + 4 files changed, 349 insertions(+) diff --git a/src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx b/src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx index 5fcfc86..d9e06dd 100644 --- a/src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx +++ b/src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx @@ -72,6 +72,157 @@ let Map, olExtent; let OL_LOADED = false; +// const PopupDetails = ({ data }) => { +// const countFactypeEprtr = data.count_factype_EPRTR; +// const countFactypeNonEprtr = data.count_factype_NONEPRTR; +// const countInstypeIed = data.count_instype_IED; +// const countInstypeNonIed = data.count_instype_NONIED; +// const countPlantypeLcp = data.count_plantType_LCP; +// const countPlantypeCoWi = data.count_plantType_coWI; +// const countPlantypeWi = data.count_plantType_WI; + +// return ( +//
+// {/* SITE CONTENTS */} +// {data.nFacilities || data.nInstallations || data.nLCP ? ( +//
+//
+//
Site contents
+//
+// {countFactypeEprtr ? ( +//
+//

+// {`${countFactypeEprtr} ${ +// countFactypeEprtr === 1 +// ? 'EPRTR Facility' +// : 'EPRTR Facilities' +// }`} +//

+//
+// ) : ( +// '' +// )} +// {countFactypeNonEprtr ? ( +//
+//

+// {`${countFactypeNonEprtr} ${ +// countFactypeNonEprtr === 1 +// ? 'NON-EPRTR Facility' +// : 'NON-EPRTR Facilities' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countInstypeIed ? ( +//
+//

+// {`${countInstypeIed} ${ +// countInstypeIed === 1 +// ? 'IED Installation' +// : 'IED Installations' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countInstypeNonIed ? ( +//
+//

+// {`${countInstypeNonIed} ${ +// countInstypeNonIed === 1 +// ? 'NON-IED Installation' +// : 'NON-IED Installations' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeLcp ? ( +//
+//

+// {`${countPlantypeLcp} ${ +// countPlantypeLcp === 1 +// ? 'Large combustion plant' +// : 'Large combustion plants' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeCoWi ? ( +//
+//

+// {`${countPlantypeCoWi} ${ +// countPlantypeCoWi === 1 +// ? 'Co-waste incinerator' +// : 'Large combustion plants' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeWi ? ( +//
+//

+// {`${countPlantypeWi} ${ +// countPlantypeWi === 1 +// ? 'Co-waste incinerator' +// : 'Co-waste incinerator' +// }`} +//

+//
+// ) : ( +// '' +// )} +//
+// ) : ( +// '' +// )} + +// {/* SITE POLLUTANT EMISSIONS */} +//
+//
+//
Pollutant emissions
+//
+//
+// {data.pollutants ? ( +//

{data.pollutants}

+// ) : ( +//

There are no data regarding the pollutants

+// )} +//
+//
+// {/* REGULATORY INFORMATION */} +//
+//
+//
Regulatory information
+//
+//
+// {data.Site_reporting_year ? ( +//

+// Inspections in {data.Site_reporting_year}:{' '} +// {data.numInspections || 0} +//

+// ) : ( +// '' +// )} +//
+//
+//
+// ); +// }; + const OpenlayersMapView = (props) => { const stateRef = useRef({ map: { @@ -368,6 +519,11 @@ const OpenlayersMapView = (props) => { sql: `(Site_reporting_year = :options)`, type: 'multiple', }, + // Facility type + facilityTypes: { + sql: `(facilityTypes LIKE ':options')`, + type: 'multiple', + }, // Plant type plantTypes: { sql: `(plantTypes LIKE '%:options%')`, diff --git a/src/components/manage/Blocks/FiltersBlock/View.jsx b/src/components/manage/Blocks/FiltersBlock/View.jsx index e8ecfc8..8b4dfcb 100644 --- a/src/components/manage/Blocks/FiltersBlock/View.jsx +++ b/src/components/manage/Blocks/FiltersBlock/View.jsx @@ -48,6 +48,7 @@ const View = ({ content, ...props }) => { 'pollutant_groups', 'pollutants', 'reporting_years', + 'facility_types', 'plant_types', 'bat_conclusions', 'permit_types', @@ -451,6 +452,42 @@ const View = ({ content, ...props }) => { delete filtersMeta[key]; } }); + filtersMeta['facility_types'] = { + filteringInputs: [ + { + id: _uniqueId('select_'), + type: 'select', + position: 0, + }, + ], + placeholder: 'Select facility type', + queryToSet: 'facilityTypes', + title: 'Facility type', + static: true, + options: [ + { key: null, value: null, text: 'No value' }, + { + key: 'EPRTR', + value: 'EPRTR', + text: 'EPRTR', + }, + { + key: 'NONEPRTR', + value: 'NONEPRTR', + text: 'NONEPRTR', + }, + { + key: 'EPRTR, NONEPRTR', + value: 'EPRTR, NONEPRTR', + text: 'EPRTR, NONEPRTR', + }, + { + key: 'NONEPRTR, EPRTR', + value: 'NONEPRTR, EPRTR', + text: 'NONEPRTR, EPRTR', + }, + ], + }; response.forEach((res, index) => { const results = JSON.parse(res.request.response).results; let filteringInputs = []; diff --git a/src/components/manage/Blocks/IndustryMap/View.jsx b/src/components/manage/Blocks/IndustryMap/View.jsx index 8ccd2e6..6b4aeda 100644 --- a/src/components/manage/Blocks/IndustryMap/View.jsx +++ b/src/components/manage/Blocks/IndustryMap/View.jsx @@ -32,6 +32,157 @@ import './style.css'; let _REQS = 0; const zoomSwitch = 6; +// const PopupDetails = ({ data }) => { +// const countFactypeEprtr = data.count_factype_EPRTR; +// const countFactypeNonEprtr = data.count_factype_NONEPRTR; +// const countInstypeIed = data.count_instype_IED; +// const countInstypeNonIed = data.count_instype_NONIED; +// const countPlantypeLcp = data.count_plantType_LCP; +// const countPlantypeCoWi = data.count_plantType_coWI; +// const countPlantypeWi = data.count_plantType_WI; + +// return ( +//
+// {/* SITE CONTENTS */} +// {data.nFacilities || data.nInstallations || data.nLCP ? ( +//
+//
+//
Site contents
+//
+// {countFactypeEprtr ? ( +//
+//

+// {`${countFactypeEprtr} ${ +// countFactypeEprtr === 1 +// ? 'EPRTR Facility' +// : 'EPRTR Facilities' +// }`} +//

+//
+// ) : ( +// '' +// )} +// {countFactypeNonEprtr ? ( +//
+//

+// {`${countFactypeNonEprtr} ${ +// countFactypeNonEprtr === 1 +// ? 'NON-EPRTR Facility' +// : 'NON-EPRTR Facilities' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countInstypeIed ? ( +//
+//

+// {`${countInstypeIed} ${ +// countInstypeIed === 1 +// ? 'IED Installation' +// : 'IED Installations' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countInstypeNonIed ? ( +//
+//

+// {`${countInstypeNonIed} ${ +// countInstypeNonIed === 1 +// ? 'NON-IED Installation' +// : 'NON-IED Installations' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeLcp ? ( +//
+//

+// {`${countPlantypeLcp} ${ +// countPlantypeLcp === 1 +// ? 'Large combustion plant' +// : 'Large combustion plants' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeCoWi ? ( +//
+//

+// {`${countPlantypeCoWi} ${ +// countPlantypeCoWi === 1 +// ? 'Co-waste incinerator' +// : 'Large combustion plants' +// }`} +//

+//
+// ) : ( +// '' +// )} + +// {countPlantypeWi ? ( +//
+//

+// {`${countPlantypeWi} ${ +// countPlantypeWi === 1 +// ? 'Co-waste incinerator' +// : 'Co-waste incinerator' +// }`} +//

+//
+// ) : ( +// '' +// )} +//
+// ) : ( +// '' +// )} + +// {/* SITE POLLUTANT EMISSIONS */} +//
+//
+//
Pollutant emissions
+//
+//
+// {data.pollutants ? ( +//

{data.pollutants}

+// ) : ( +//

There are no data regarding the pollutants

+// )} +//
+//
+// {/* REGULATORY INFORMATION */} +//
+//
+//
Regulatory information
+//
+//
+// {data.Site_reporting_year ? ( +//

+// Inspections in {data.Site_reporting_year}:{' '} +// {data.numInspections || 0} +//

+// ) : ( +// '' +// )} +//
+//
+//
+// ); +// }; + const View = (props) => { const map = useRef(); const popup = useRef(); diff --git a/src/components/manage/Blocks/IndustryMap/index.js b/src/components/manage/Blocks/IndustryMap/index.js index e318741..07af32f 100644 --- a/src/components/manage/Blocks/IndustryMap/index.js +++ b/src/components/manage/Blocks/IndustryMap/index.js @@ -12,6 +12,7 @@ const filters = [ { queryKey: 'nuts_latest', featureKey: 'nuts_regions', op: 'like' }, { queryKey: 'permitType', featureKey: 'permit_types', op: 'like' }, { queryKey: 'permitYear', featureKey: 'permitYears', op: 'like' }, + { queryKey: 'facilityTypes', featureKey: 'facilityTypes', op: 'eqStr' }, { queryKey: 'plantTypes', featureKey: 'plantTypes', op: 'like' }, { queryKey: 'pollutant', featureKey: 'pollutants', op: 'like' }, { queryKey: 'pollutantGroup', featureKey: 'air_groups', op: 'like' }, @@ -86,6 +87,8 @@ export const getWhereStatement = (query = {}) => { where[filter].push(`${featureKey} LIKE '%${value}%'`); } else if (op === 'eq' && value) { where[filter].push(`${featureKey} = ${value}`); + } else if (op === 'eqStr' && value) { + where[filter].push(`${featureKey} = '${value}''`); } } } else if (query[queryKey]) { @@ -95,6 +98,8 @@ export const getWhereStatement = (query = {}) => { where[filter].push(`${featureKey} LIKE '%${value}%'`); } else if (op === 'eq' && value) { where[filter].push(`${featureKey} = ${value}`); + } else if (op === 'eqStr' && value) { + where[filter].push(`${featureKey} = '${value}''`); } } }