-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(demo): visualize enrichment results - EUBFR-267 (#227)
* Add documentation working with demo dashboard locally without deployments * Basic display * Mark enriched projects * Add pager * Move to projects * Add file-level stats regarding enriched project locations * Add file-level stats regarding enriched budget items * Add pie charts * Add loading message * Increase size charts * Listing improvements * Per field * Split code * Correction * Correction * Consolidate reports * Refactoring * Refactoring
- Loading branch information
1 parent
d453138
commit ed99d2f
Showing
15 changed files
with
962 additions
and
315 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint camelcase: "off" */ | ||
|
||
/** | ||
* Adds a new property to {Project} accumulating results of the enrichment loop. | ||
* @param {Array<Project>} projects | ||
* @returns {Array<Object>} The original {Array<Project>} with a new property "enrichmentResults". | ||
*/ | ||
const enrichmentDecorator = projects => | ||
projects.map(project => { | ||
// Focus on potentially enriched fields. | ||
const { budget, project_locations } = project._source; | ||
const { eu_contrib, total_cost } = budget; | ||
|
||
// Different fields have different means of marking information as enriched. | ||
const hasEnrichedLocation = project_locations.find(l => l.enriched); | ||
const hasEnrichedEuContrib = eu_contrib._original; | ||
const hasEnrichedTotalCost = total_cost._original; | ||
|
||
if (hasEnrichedLocation || hasEnrichedEuContrib || hasEnrichedTotalCost) { | ||
return { | ||
enrichmentResults: { | ||
project_locations, | ||
budget, | ||
}, | ||
...project, | ||
}; | ||
} | ||
|
||
return project; | ||
}); | ||
|
||
export default enrichmentDecorator; |
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 was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
demo/dashboard/client/src/pages/files/file/Projects/Listing.js
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,71 @@ | ||
import React, { Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Collapsible from 'react-collapsible'; | ||
import Pager from 'react-pager-component'; | ||
import JsonView from 'react-json-view'; | ||
|
||
const Listing = ({ | ||
current, | ||
enrichmentResults, | ||
onHandlePageChange, | ||
pagerLength, | ||
projectsEnriched, | ||
}) => ( | ||
<Fragment> | ||
<p>Enriched on this page: {projectsEnriched}</p> | ||
<ul className="ecl-listing"> | ||
{enrichmentResults.map((project, key) => { | ||
const { _source: doc } = project; | ||
const { title, description } = doc; | ||
|
||
return ( | ||
<li className="ecl-list-item" key={key} tabIndex={key}> | ||
<Collapsible trigger={title}> | ||
<Fragment> | ||
<p | ||
className="ecl-paragraph" | ||
dangerouslySetInnerHTML={{ | ||
__html: description, | ||
}} | ||
/> | ||
{project.enrichmentResults | ||
? Object.keys(project.enrichmentResults).map( | ||
(enrichedProperty, i) => ( | ||
<Fragment key={i}> | ||
<h3> | ||
Enrichment in <code>{enrichedProperty}</code> | ||
</h3> | ||
<JsonView | ||
collapsed={true} | ||
displayObjectSize={false} | ||
name={enrichedProperty} | ||
src={project.enrichmentResults[enrichedProperty]} | ||
/> | ||
</Fragment> | ||
) | ||
) | ||
: ''} | ||
</Fragment> | ||
</Collapsible> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
<Pager | ||
length={pagerLength} | ||
current={current} | ||
onChange={onHandlePageChange} | ||
/> | ||
</Fragment> | ||
); | ||
|
||
Listing.propTypes = { | ||
current: PropTypes.number, | ||
enrichmentResults: PropTypes.array, | ||
onHandlePageChange: PropTypes.func, | ||
pagerLength: PropTypes.number, | ||
projects: PropTypes.array, | ||
projectsEnriched: PropTypes.number, | ||
}; | ||
|
||
export default Listing; |
Oops, something went wrong.