aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm40
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm12
-rw-r--r--perllib/FixMyStreet/Map/Bromley.pm23
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm13
-rw-r--r--templates/web/default/dashboard/index.html31
-rw-r--r--web/js/map-bing-ol.js13
6 files changed, 106 insertions, 26 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index 6c327d479..0273e0eda 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -46,31 +46,57 @@ sub index : Path : Args(0) {
my $council = $c->forward('check_page_allowed');
+ # Set up the data for the dropdowns
+
my $children = mySociety::MaPit::call('area/children', $council,
type => $mySociety::VotingArea::council_child_types,
);
$c->stash->{children} = $children;
+ # XXX Hmm, this is probably the best way to go
+ $c->stash->{all_councils} = { $council => { id => $council } };
+ $c->forward( '/report/new/setup_categories_and_councils' );
+
+ # See if we've had anything from the dropdowns
+
+ $c->stash->{ward} = $c->req->param('ward');
+ $c->stash->{category} = $c->req->param('category');
+ $c->stash->{q_state} = $c->req->param('state');
+
+ my %where = (
+ council => $council, # XXX This will break in a two tier council. Restriction needs looking at...
+ 'problem.state' => [ FixMyStreet::DB::Result::Problem->visible_states() ],
+ );
+ $where{areas} = { 'like', '%,' . $c->stash->{ward} . ',%' }
+ if $c->stash->{ward};
+ $where{category} = $c->stash->{category}
+ if $c->stash->{category};
+ if ( $c->stash->{q_state} eq 'fixed' ) {
+ $where{'problem.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ];
+ } elsif ( $c->stash->{q_state} ) {
+ $where{'problem.state'} = $c->stash->{q_state}
+ }
+
my %counts;
my $t = DateTime->today;
$counts{wtd} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', $t->subtract( days => $t->dow - 1 )
} } ] );
$counts{week} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 1 )
} } ] );
$counts{weeks} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 4 )
} } ] );
$counts{ytd} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->today->set( day => 1, month => 1 )
} } ] );
@@ -102,9 +128,9 @@ sub updates_search : Private {
{ %$params, mark_fixed => 1 }, { join => 'problem' }
)->count;
- $counts{total} = $c->cobrand->problems->search(
- { %$params, state => [ FixMyStreet::DB::Result::Problem::visible_states() ] }
- )->count;
+ $params->{state} = $params->{'problem.state'};
+ delete $params->{'problem.state'};
+ $counts{total} = $c->cobrand->problems->search( $params )->count;
return \%counts;
}
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 4ba00dbfe..0a7fc38dc 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -44,8 +44,6 @@ sub string {
if (!$js) {
return { error => _('Sorry, we could not parse that location. Please try again.') };
- } elsif ($js =~ /BT\d/ && $params->{bing_country} eq 'United Kingdom') {
- return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
}
$js = JSON->new->utf8->allow_nonref->decode($js);
@@ -54,11 +52,15 @@ sub string {
}
my $results = $js->{resourceSets}->[0]->{resources};
- my ( $error, @valid_locations, $latitude, $longitude );
+ my ( $error, @valid_locations, $latitude, $longitude, $ni );
foreach (@$results) {
my $address = $_->{name};
next unless $_->{address}->{countryRegion} eq $params->{bing_country};
+ if ($params->{bing_country} eq 'United Kingdom' && $_->{address}{adminDistrict} eq 'Northern Ireland') {
+ $ni = 1;
+ next;
+ }
# Getting duplicate, yet different, results from Bing sometimes
next if @valid_locations
@@ -73,6 +75,10 @@ sub string {
push (@valid_locations, $_);
}
+ if ($ni && !scalar @valid_locations) {
+ return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
+ }
+
return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
return { error => $error };
}
diff --git a/perllib/FixMyStreet/Map/Bromley.pm b/perllib/FixMyStreet/Map/Bromley.pm
new file mode 100644
index 000000000..6d9dfa742
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Bromley.pm
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::Bromley
+# Bromley have slightly different tiles, with trees etc.
+#
+# Copyright (c) 2012 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map::Bromley;
+use base 'FixMyStreet::Map::FMS';
+
+use strict;
+
+sub map_type {
+ my $self = shift;
+ return '"' . $self->map_tile_base . '"';
+}
+
+sub map_tile_base {
+ return "tilma.mysociety.org/bromley";
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index 24842c861..0ea4af4c1 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -37,14 +37,19 @@ sub get_quadkey {
return $key;
}
+sub map_tile_base {
+ "tilma.mysociety.org/sv";
+}
+
sub map_tiles {
my ($self, $x, $y, $z) = @_;
if ($z >= 16) {
+ my $tile_base = $self->map_tile_base;
return [
- "http://a.tilma.mysociety.org/sv/$z/" . ($x-1) . "/" . ($y-1) . ".png",
- "http://b.tilma.mysociety.org/sv/$z/$x/" . ($y-1) . ".png",
- "http://c.tilma.mysociety.org/sv/$z/" . ($x-1) . "/$y.png",
- "http://tilma.mysociety.org/sv/$z/$x/$y.png",
+ "http://a.$tile_base/$z/" . ($x-1) . "/" . ($y-1) . ".png",
+ "http://b.$tile_base/$z/$x/" . ($y-1) . ".png",
+ "http://c.$tile_base/$z/" . ($x-1) . "/$y.png",
+ "http://$tile_base/$z/$x/$y.png",
];
} else {
my $url = "g=701";
diff --git a/templates/web/default/dashboard/index.html b/templates/web/default/dashboard/index.html
index c54635b2a..a0ef7b911 100644
--- a/templates/web/default/dashboard/index.html
+++ b/templates/web/default/dashboard/index.html
@@ -11,19 +11,23 @@
#overview tr:nth-child(2) { background-color: #fee; }
</style>
-<p>Ward: <select name="ward"><option>All</option>
- [% FOR ward IN children.values.sort('name') %]
- <option value="[% ward.id %]">[% ward.name %]</option>
+<form>
+
+<p>Ward: <select name="ward"><option value=''>All</option>
+ [% FOR w IN children.values.sort('name') %]
+ <option value="[% w.id %]"[% ' selected' IF w.id == ward %]>[% w.name %]</option>
[% END %]
</select>
+<input type="submit" value="Look up">
<h2>Performance Overview</h2>
-<p>Report category: <select name="category"><option>All</option>
- [% FOR category IN categories %]
- <option></option>
+<p>Report category: <select name="category"><option value=''>All</option>
+ [% FOR cat_op IN category_options %]
+ <option value='[% cat_op | html %]'[% ' selected' IF category == cat_op %]>[% cat_op | html %]</option>
[% END %]
-</select>
+ </select>
+<input type="submit" value="Look up">
<table width="100%" id="overview">
<tr>
@@ -111,7 +115,16 @@
<h2>Reports</h2>
-<p>Report state: <select name="state"><option>All</option></select>
+ </select>
+<p>Report state: <select name="state">
+<option value=''>All</option>
+ [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating',
+ loc('Investigating')], ['planned', loc('Planned')], ['in progress',
+ loc('In Progress')], ['closed', loc('Closed')], ['fixed', loc('Fixed')] ] %]
+ <option [% 'selected ' IF state.0 == q_state %] value="[% state.0 %]">[% state.1 %]</option>
+ [% END %]
+</select>
+<input type="submit" value="Look up">
<table width="100%">
<tr>
@@ -128,4 +141,6 @@
</tr>
</table>
+</form>
+
[% INCLUDE 'footer.html' %]
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index 89b274b18..488dec58a 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -1,3 +1,5 @@
+var tile_base = 'tilma.mysociety.org/sv';
+
function set_map_config(perm) {
var permalink_id;
if ($('#map_permalink').length) {
@@ -17,6 +19,9 @@ function set_map_config(perm) {
new OpenLayers.Control.Permalink(permalink_id),
new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' })
];
+ if (fixmystreet.map_type) {
+ tile_base = fixmystreet.map_type;
+ }
fixmystreet.map_type = OpenLayers.Layer.Bing;
}
@@ -95,10 +100,10 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
var url;
if (z >= 16) {
url = [
- "http://tilma.mysociety.org/sv/${z}/${x}/${y}.png",
- "http://a.tilma.mysociety.org/sv/${z}/${x}/${y}.png",
- "http://b.tilma.mysociety.org/sv/${z}/${x}/${y}.png",
- "http://c.tilma.mysociety.org/sv/${z}/${x}/${y}.png"
+ "http://" + tile_base + "/${z}/${x}/${y}.png",
+ "http://a." + tile_base + "/${z}/${x}/${y}.png",
+ "http://b." + tile_base + "/${z}/${x}/${y}.png",
+ "http://c." + tile_base + "/${z}/${x}/${y}.png"
];
} else {
var type = '';