-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PollutantIndex Block; Flags feature
- Loading branch information
Showing
14 changed files
with
948 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { compose } from 'redux'; | ||
import _uniqueId from 'lodash/uniqueId'; | ||
import View from './View'; | ||
import './style.css'; | ||
|
||
const Edit = (props) => { | ||
const [state, setState] = useState({ | ||
id: _uniqueId('block_'), | ||
}); | ||
return ( | ||
<div> | ||
<View {...props} id={state.id} mode="edit" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default compose( | ||
connect((state, props) => ({ | ||
pathname: state.router.location.pathname, | ||
})), | ||
)(Edit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* REACT */ | ||
import React, { useState, useEffect } from 'react'; | ||
import { compose } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import { setFlags } from '~/actions'; | ||
import './style.css'; | ||
|
||
const View = (props) => { | ||
const flags = props.flags; | ||
const siteInspireId = props.discodata_query.search.siteInspireId; | ||
const site = props.discodata_resources.data.sites_6?.[siteInspireId]; | ||
const facilities = site?.results; | ||
useEffect(() => { | ||
if (site && siteInspireId && !flags.items.sites?.[siteInspireId]) { | ||
const facilitiesFlags = {}; | ||
props.setFlags('sites', siteInspireId, { | ||
has_facilities: site.has_facilities, | ||
has_fuel_data: site.has_fuel_data, | ||
has_installations: site.has_installations, | ||
has_lcps: site.has_lcps, | ||
has_ophours_data: site.has_ophours_data, | ||
has_release_data: site.has_release_data, | ||
has_transfer_data: site.has_transfer_data, | ||
has_waste_data: site.has_waste_data, | ||
}); | ||
facilities.forEach((facility) => { | ||
if ( | ||
facility && | ||
!flags.items.facilities?.[facility.facilityInspireId] && | ||
!facilitiesFlags[facility.facilityInspireId] | ||
) { | ||
facilitiesFlags[facility.facilityInspireId] = { | ||
has_fuel_data: facility.facility_has_fuel_data, | ||
has_installations: facility.facility_has_installations, | ||
has_lcps: facility.facility_has_lcps, | ||
has_ophours_data: facility.facility_has_ophours_data, | ||
has_release_data: facility.facility_has_release_data, | ||
has_transfer_data: facility.facility_has_transfer_data, | ||
has_waste_data: facility.facility_has_waste_data, | ||
}; | ||
} | ||
}); | ||
props.setFlags('facilities', null, facilitiesFlags); | ||
} | ||
}, [siteInspireId, JSON.stringify(site)]); | ||
|
||
return <div>{props.mode === 'edit' ? <p>Flags</p> : ''}</div>; | ||
}; | ||
|
||
export default compose( | ||
connect( | ||
(state, props) => ({ | ||
query: state.router.location.search, | ||
flags: state.flags, | ||
discodata_query: state.discodata_query, | ||
discodata_resources: state.discodata_resources, | ||
}), | ||
{ setFlags }, | ||
), | ||
)(View); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.embeded-iframe { | ||
border: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.