Skip to content

Commit

Permalink
Added total DFID country budget amount on the aid by location page.
Browse files Browse the repository at this point in the history
  • Loading branch information
aunindadf committed Jun 2, 2016
1 parent 806fe5a commit c535b95
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion devtracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@
:layout => :'layouts/layout',
:locals => {
:dfid_country_map_data => dfid_country_map_data,
:dfid_complete_country_list => dfid_complete_country_list
:dfid_complete_country_list => dfid_complete_country_list,
:dfid_total_country_budget => total_country_budget_location
}
end

Expand Down
12 changes: 12 additions & 0 deletions helpers/country_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,16 @@ def get_country_all_projects_rss(countryCode)
rssResults = rssData['results']
end

def total_country_budget_location
firstDayOfFinYear = first_day_of_financial_year(DateTime.now)
lastDayOfFinYear = last_day_of_financial_year(DateTime.now)
totalCountryBudgetLocation = RestClient.get settings.oipa_api_url + "activities/aggregations/?reporting_organisation=GB-GOV-1&group_by=recipient_country&aggregations=budget&budget_period_start=#{firstDayOfFinYear}&budget_period_end=#{lastDayOfFinYear}&order_by=-budget&format=json"
totalCountryBudgetLocation = JSON.parse(totalCountryBudgetLocation)
totalAmount = 0.0
totalCountryBudgetLocation['results'].each do |countryBudgets|
totalAmount = totalAmount + countryBudgets['budget'].to_f
end
totalAmount = (format_million_stg totalAmount.to_f).to_s.gsub("£","")
totalAmount
end
end
16 changes: 16 additions & 0 deletions public/javascripts/leaflet/indexmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@
minZoom: 2,
maxZoom: 4
}).addTo(map);

// control that shows state info on hover
var info = L.control();

info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};

info.update = function (props) {
this._div.innerHTML = '<h6>Total DFID Country Project Budget for ' + finYear + ': ' + TotalCountryBudget + '</h6>';
};

info.addTo(map);

//L.tileLayer('http://a{s}.acetate.geoiq.com/tiles/acetate-base/{z}/{x}/{y}.png', {
// attribution: '&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
// subdomains: '0123',
Expand Down
15 changes: 14 additions & 1 deletion public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,17 @@ g.c3-axis-y > g:last-child {

.filter-header {
margin-bottom: 10px;
}
}


.info {
background: rgba(255, 255, 255, 0.8) none repeat scroll 0 0;
border-radius: 5px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
font: 14px/16px Arial,Helvetica,sans-serif;
padding: 6px 8px;
}
.info h6 {
color: #777;
margin: 0 0 5px;
}
2 changes: 2 additions & 0 deletions views/location/country/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<div class="twelve columns map">
<script type="text/javascript">
var countriesData = <%= dfid_country_map_data %>;
var TotalCountryBudget = '<%= total_country_budget_location%>';
var finYear = '<%=current_financial_year%>';
</script>
<!-- <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> -->
<script src="/javascripts/leaflet/leaflet.js" type="text/javascript"></script>
Expand Down

0 comments on commit c535b95

Please sign in to comment.