Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP - do not merge] CBA Integration #18

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
fb4a8f6
add nav element
jamiecook Jul 18, 2021
f78981a
tidy up jsx
jamiecook Jul 18, 2021
8132120
refactor out site pages
jamiecook Jul 18, 2021
dd7f75a
refactors and start laying out the cba page
jamiecook Jul 18, 2021
ce5febe
bring funcationality from cba-webapp
jamiecook Jul 18, 2021
7b4b783
scripts for automating CBA-API
jamiecook Jul 25, 2021
a29f728
.
jamiecook Jul 25, 2021
9d9d62d
.
jamiecook Jul 25, 2021
9ccfd03
.
jamiecook Jul 25, 2021
4c9289c
.
jamiecook Jul 25, 2021
4829b7f
update README url links to point to vnopenroads organisation
jamiecook Jul 25, 2021
96934be
add tai pub key
jamiecook Jul 28, 2021
4fc6f80
get deployment of main react app working
jamiecook Jul 28, 2021
2e0a886
.
jamiecook Aug 1, 2021
1b389c8
update react to version 16
jamiecook Aug 8, 2021
65eda39
gradually ticking away at config architecture
jamiecook Aug 8, 2021
6cec0cf
getting ready for deploy
jamiecook Aug 15, 2021
dbef485
upgrade to node v10
jamiecook Aug 18, 2021
bec4eed
much ansible
jamiecook Aug 18, 2021
e603ae9
config and snapshots
jamiecook Aug 22, 2021
9ccda6c
loading spinnger
jamiecook Aug 22, 2021
eb4e0ac
lots of stuff
jamiecook Aug 23, 2021
cd8f2a8
take a snapshot
jamiecook Aug 23, 2021
1d59fc7
.
jamiecook Aug 25, 2021
191c804
.
jamiecook Aug 28, 2021
a55ecbb
ansible clean up
jamiecook Aug 28, 2021
2646ae7
tidy up
jamiecook Aug 28, 2021
99988d4
.
jamiecook Sep 9, 2021
7ed0d51
steel threaded
jamiecook Sep 11, 2021
297d7db
lots of missing files - more work on styling
jamiecook Sep 19, 2021
f890afd
.
jamiecook Sep 20, 2021
fad538b
.
jamiecook Sep 27, 2021
fd62b38
.
jamiecook Sep 30, 2021
f0294ef
clean up
jamiecook Oct 2, 2021
ce032d6
.
jamiecook Oct 3, 2021
c503973
.
jamiecook Oct 4, 2021
31a7001
.
jamiecook Oct 4, 2021
7c4074e
add csv download
jamiecook Oct 9, 2021
df7a210
add version, fix coupel of rendering bugs
jamiecook Oct 9, 2021
30e1b78
clean up results page
jamiecook Oct 10, 2021
12fb059
.
jamiecook Oct 11, 2021
14e04a6
.
jamiecook Oct 11, 2021
35f3ef3
.
jamiecook Oct 11, 2021
e020cae
.
jamiecook Oct 12, 2021
bdaa2b1
charts and stuff
jamiecook Oct 15, 2021
9e7682c
.
jamiecook Oct 17, 2021
585f88c
.
jamiecook Oct 17, 2021
9ec82bc
.
jamiecook Oct 17, 2021
060e57c
.
jamiecook Oct 19, 2021
b6f64c9
.
jamiecook Oct 19, 2021
d7d5f90
.
jamiecook Oct 19, 2021
3fe04a3
.
jamiecook Oct 21, 2021
375f355
.
jamiecook Oct 29, 2021
76ddbc4
.
jamiecook Oct 30, 2021
67f0d2f
.
jamiecook Oct 31, 2021
0ce63da
.
jamiecook Oct 31, 2021
3875c7d
.
jamiecook Oct 31, 2021
fe9af20
.
jamiecook Oct 31, 2021
770a713
.
jamiecook Nov 1, 2021
24db940
.
jamiecook Nov 2, 2021
f104c41
.
jamiecook Nov 3, 2021
ecd4414
.
jamiecook Dec 11, 2021
8bde388
.
jamiecook Dec 12, 2021
4b44f50
.
jamiecook Dec 13, 2021
d87518a
.
jamiecook Feb 27, 2022
d00e829
add nginx config from prod
jamiecook Feb 27, 2022
c93298a
.
jamiecook Feb 27, 2022
d79fcec
.
jamiecook Feb 27, 2022
a57f4ef
deployment stuff
jamiecook Mar 6, 2022
c33b243
bumping version numbers
jamiecook Mar 6, 2022
eef294c
oops
jamiecook Mar 6, 2022
a4e255a
fix FAQ
jamiecook Mar 7, 2022
167ad1d
fix asset details
jamiecook Mar 7, 2022
39aeceb
add temporary mapbox token
jamiecook Mar 13, 2022
be49f1d
.
jamiecook Mar 13, 2022
4e174be
bind methods before passing them
jamiecook Mar 13, 2022
75c6df9
bind methods before passing them
jamiecook Mar 13, 2022
75c498b
bind methods before passing them
jamiecook Mar 13, 2022
4b705e1
bind methods before passing them
jamiecook Mar 13, 2022
ba0a553
bind methods before passing them
jamiecook Mar 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ env
## pyenv
.python-version
yarn-error.log


# Pycharm/IntelliJ based IDE
.idea
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8
10
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

#### [v3.5.0](https://github.com/vnopenroads/openroads-vn-analytics/compare/v3.4.0...v3.5.0)

> 6 March 2022

- Adds new Cost Benefit Analysis functionality as a major tab in the main interface [`#18`](https://github.com/vnopenroads/openroads-vn-analytics/pull/18)


#### [v3.4.0](https://github.com/orma/openroads-vn-analytics/compare/v3.3.1...v3.4.0)

> 27 March 2019
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

This repo contains the static assets that constitute the OpenRoads Vietnam website. This repository is also where Development Seed stores all GitHub tickets and planning for the ORMA–VN project. The other repos in this project include:

- [API](https://github.com/orma/openroads-vn-api/)
- [various workers](https://github.com/orma/openroads-vn-tiler)
- [iD editor](https://github.com/orma/openroads-vn-iD)
- [admin boundary generation](https://github.com/orma/openroads-vn-boundaries)
- [raster tile generation](https://github.com/orma/openroads-tilemap)
- [API](https://github.com/vnopenroads/openroads-vn-api/)
- [various workers](https://github.com/vnopenroads/openroads-vn-tiler)
- [iD editor](https://github.com/vnopenroads/openroads-vn-iD)
- [admin boundary generation](https://github.com/vnopenroads/openroads-vn-boundaries)
- [raster tile generation](https://github.com/vnopenroads/openroads-vn-tilemap)

ORMA–VN is a deployment of the ORMA platform, originally built by Development Seed and the World Bank for use in the Philippines; several more repos may be found in the `orma` GitHub organization, pertaining to that or other deployments.
ORMA–VN is a deployment of the ORMA platform, originally built by Development Seed and the World Bank for use in the Philippines; several more repos may be found in the `vnopenroads` GitHub organization, pertaining to that or other deployments.

## Platform functionality

Expand Down Expand Up @@ -92,7 +92,7 @@ To add new words to translate:
$ tx pull && tx push -s
```

the reason to pull then push is so that translations on transifex aren't overwritten (the behavior of tx push)
the reason to pull then push is so that translations on transifex aren't overwritten (the behavior of tx push)

3. pull the new changes using tx pull once translations are complete on transifex

Expand Down
10 changes: 8 additions & 2 deletions app/assets/locales/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"Done": "Done",
"Status": "Status",
"Total": "Total",
"Valid": "Valid",
"Invalid": "Invalid",
"Complete": "Complete",
"% Complete": "% Complete",
"Progress": "Progress",
Expand Down Expand Up @@ -228,5 +230,9 @@
"CVTS": "CVTS",
"Stats": "Stats",
"Add new asset": "Add new asset",
"Meta": "Meta"
}
"Meta": "Meta",
"CBA": "CBA",
"Config": "Config",
"Results": "Results",
"Analysis": "Analysis"
}
20 changes: 9 additions & 11 deletions app/assets/scripts/components/aa-field-map-legend.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import lineColors from '../utils/line-colors';
import T from './t';

const AAFieldMapLegend = React.createClass({
displayName: 'AAFieldMapLegend',
export default class AAFieldMapLegend extends React.Component {

propTypes: {
sources: React.PropTypes.array
},

renderLegendElements: function () {
renderLegendElements() {
// for each source as the source name
// as well as a small svg path with the color
// matching source in the lineColors config
Expand All @@ -25,9 +21,9 @@ const AAFieldMapLegend = React.createClass({
</li>
);
});
},
}

render: function () {
render() {
return (
<div className='aa-map-legend'>
<h3 className='aa-map-legend-title'><T>Field Data Sources</T></h3>
Expand All @@ -37,6 +33,8 @@ const AAFieldMapLegend = React.createClass({
</div>
);
}
});
};

module.exports = AAFieldMapLegend;
AAFieldMapLegend.propTypes = {
sources: PropTypes.array
};
50 changes: 26 additions & 24 deletions app/assets/scripts/components/aa-field-map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import mapboxgl from 'mapbox-gl';
import {
toPairs,
Expand Down Expand Up @@ -31,22 +32,14 @@ import {
} from '../constants';


var AAFieldMap = React.createClass({
displayName: 'AAFieldMap',
propTypes: {
status: React.PropTypes.string,
geoJSON: React.PropTypes.object,
vpromm: React.PropTypes.string,
provinceName: React.PropTypes.string,
navigateBack: React.PropTypes.func,
setMapPosition: React.PropTypes.func
},
class AAFieldMap extends React.Component {

getInitialState: function () {
return { layerRendered: false };
},
constructor(props) {
super(props);
this.state = { layerRendered: false };
}

componentDidMount: function () {
componentDidMount() {
mapboxgl.accessToken = config.mbToken;

this.map = new mapboxgl.Map({
Expand All @@ -63,23 +56,23 @@ var AAFieldMap = React.createClass({
if (this.props.geoJSON && !this.state.layerRendered) {
this.renderLayer();
}
},
}


componentWillReceiveProps: function ({ geoJSON, lng, lat, zoom }) {
UNSAFE_componentWillReceiveProps({ geoJSON, lng, lat, zoom }) {
// TODO - rendering map could be less of a kludge w/ proper react/mapbox-gl bindings
if (geoJSON && !this.state.layerRendered) {
this.renderLayer();
}
},
}

componentWillUnmount: function () {
componentWillUnmount() {
const { lng, lat } = this.map.getCenter();
const zoom = this.map.getZoom();
this.props.setMapPosition(lng, lat, zoom);
},
}

renderLayer: function () {
renderLayer() {
this.setState({ layerRendered: true });

this.map.on('load', () => {
Expand All @@ -100,10 +93,10 @@ var AAFieldMap = React.createClass({
}
});
});
},
}


render: function () {
render() {
const { vpromm, provinceName, navigateBack } = this.props;

return (
Expand Down Expand Up @@ -146,10 +139,19 @@ const reducer = (
return state;
};

AAFieldMap.propTypes = {
status: PropTypes.string,
geoJSON: PropTypes.object,
vpromm: PropTypes.string,
provinceName: PropTypes.string,
navigateBack: PropTypes.func,
setMapPosition: PropTypes.func
}

module.exports = compose(
withRouter,
getContext({
language: React.PropTypes.string
language: PropTypes.string
}),
withProps(({ language, params: { vpromm } }) => {
const [aaId, { name }] = find(
Expand Down Expand Up @@ -186,7 +188,7 @@ module.exports = compose(
)
}),
lifecycle({
componentWillMount: function () {
UNSAFE_componentWillMount: function () {
const { vpromm, geoJSON, status, fetchRoadGeometry } = this.props;
if (!geoJSON && status !== 'pending' && status !== 'error') {
fetchRoadGeometry(vpromm);
Expand Down
36 changes: 20 additions & 16 deletions app/assets/scripts/components/admin-stats-tables.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
import c from 'classnames';
import _ from 'lodash';

import T, {translate} from '../components/t';
import T, { translate } from '../components/t';

import { environment } from '../config';

Expand Down Expand Up @@ -35,14 +36,14 @@ export const statsColumns = [
}
];

export const StatsTableHeader = ({type}) => (
export const StatsTableHeader = ({ type }) => (
<thead>
<tr>
{type === 'province' && <th><T>Provinces</T></th>}
{type === 'province-district' && <th><T>Province</T></th>}
{type === 'province' && <th><T>Districts</T></th>}
{(type === 'province-district' || type === 'district') && <th><T>District</T></th>}
{statsColumns.map(({key, label}) => <th key={key}><T>{label}</T></th>)}
{statsColumns.map(({ key, label }) => <th key={key}><T>{label}</T></th>)}
</tr>
</thead>
);
Expand All @@ -55,11 +56,11 @@ if (environment !== 'production') {

const getPrintValue = (v) => (v === 0 || v) && v !== ' ' ? v : 'n/a';

export const StatsTableRow = ({type, data, lang, provinceId, provinceName, districtId, districtName}) => (
export const StatsTableRow = ({ type, data, lang, provinceId, provinceName, districtId, districtName }) => (
<tr>
{type === 'province-district' && <th><Link to={`/${lang}/assets/${provinceId}`} title={translate(lang, 'View province page')}>{provinceName}</Link></th>}
<th><Link to={`/${lang}/assets/${provinceId}/${districtId}`} title={translate(lang, 'View district page')}>{districtName}</Link></th>
{statsColumns.map(({key, accessor}) => <td key={key}>{getPrintValue(accessor(data))}</td>)}
{statsColumns.map(({ key, accessor }) => <td key={key}>{getPrintValue(accessor(data))}</td>)}
</tr>
);

Expand All @@ -75,12 +76,12 @@ if (environment !== 'production') {
};
}

export const StatsTableExpandableTbody = ({lang, provinceId, provName, disctrictCount, isExpanded, onExpandToggle, data, children}) => (
<tbody className={c({'table-details--expanded': isExpanded, 'table-details--collapsed': !isExpanded})}>
export const StatsTableExpandableTbody = ({ lang, provinceId, provName, disctrictCount, isExpanded, onExpandToggle, data, children }) => (
<tbody className={c({ 'table-details--expanded': isExpanded, 'table-details--collapsed': !isExpanded })}>
<tr>
<th><Link to={`/${lang}/assets/${provinceId}`} title={translate(lang, 'View province page')}>{provName}</Link></th>
<td><a href='#' className='button-expand-collapse' title={translate(lang, 'Expand districts')} onClick={onExpandToggle}>{disctrictCount}</a></td>
{statsColumns.map(({key, accessor}) => <td key={key}>{getPrintValue(accessor(data))}</td>)}
{statsColumns.map(({ key, accessor }) => <td key={key}>{getPrintValue(accessor(data))}</td>)}
</tr>
<tr className={c('table-details')}>
<td colSpan={6}>
Expand All @@ -103,11 +104,14 @@ if (environment !== 'production') {
};
}

export const StatsBar = ({total, completed}) => (
<div className='stats-bar'>
<span className='stats-bar__complete' style={{width: Math.min((completed / total) || 0, 100) * 100 + '%'}}></span>
</div>
);
export const StatsBar = ({ total, completed }) => {
var perc = (total == 0) ? 0 : Math.min((completed / total) || 0, 1.0) * 100
return (
<div className='stats-bar'>
<span className='stats-bar__complete' style={{ width: perc + '%' }}></span>
</div>
)
};

if (environment !== 'production') {
StatsBar.propTypes = {
Expand All @@ -116,14 +120,14 @@ if (environment !== 'production') {
};
}

export const StatsBlock = ({title, total, completed, list}) => (
export const StatsBlock = ({ title, total, completed, list }) => (
<div className='stats-block'>
<h3>{title}</h3>
<figure>
<StatsBar total={total} completed={completed} />
<figcaption>
<ul className='stats-list'>
{list.map(({label, value}) => (
{list.map(({ label, value }) => (
<li key={label} className='stats-list__item'><span className='value'>{value}</span><small>{label}</small></li>
))}
</ul>
Expand Down
Loading