diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2017-05-17 17:35:43 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-06 18:39:14 +0100 |
commit | 8a6a4ccb789f5f638a5c969ffeecc0ca047095a1 (patch) | |
tree | ff55d6875d552236ff7b2383adf8423b33c4b470 /perllib/FixMyStreet/App/Controller | |
parent | c0176254c3716e9e9915f3fd0f875f43e5e1e4ed (diff) |
[fixmystreet.com] New version of /reports page.
This is a much broader summary page, plus a body name autocomplete.
This uses a cut down version of chart.js. [1]
[1] The full version was 149Kb (41Kb gzipped) plus you needed moment
(50Kb/17Kb), for a total of 199Kb/58Kb. By stripping out unused graphs
and code and config options, and switching to category axis rather than
time, it is now a total of 39Kb/13Kb.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index ed851f71f..024a23872 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -54,6 +54,15 @@ sub index : Path : Args(0) { $c->detach( 'redirect_body' ); } + if (my $body = $c->get_param('body')) { + $body = $c->model('DB::Body')->find( { id => $body } ); + if ($body) { + $body = $c->cobrand->short_name($body); + $c->res->redirect("/reports/$body"); + $c->detach; + } + } + # Fetch all bodies my @bodies = $c->model('DB::Body')->search({ deleted => 0, @@ -67,15 +76,21 @@ sub index : Path : Args(0) { $c->stash->{bodies} = \@bodies; $c->stash->{any_empty_bodies} = any { $_->get_column('area_count') == 0 } @bodies; - eval { + my $dashboard = eval { + my $data = File::Slurp::read_file( + FixMyStreet->path_to( '../data/all-reports-dashboard.json' )->stringify + ); + $c->stash(decode_json($data)); + return 1; + }; + my $table = eval { my $data = File::Slurp::read_file( FixMyStreet->path_to( '../data/all-reports.json' )->stringify ); - my $j = decode_json($data); - $c->stash->{fixed} = $j->{fixed}; - $c->stash->{open} = $j->{open}; + $c->stash(decode_json($data)); + return 1; }; - if ($@) { + if (!$dashboard && !$table) { my $message = _("There was a problem showing the All Reports page. Please try again later."); if ($c->config->{STAGING_SITE}) { $message .= '</p><p>Perhaps the bin/update-all-reports script needs running. Use: bin/update-all-reports</p><p>' @@ -88,7 +103,7 @@ sub index : Path : Args(0) { $c->response->header('Cache-Control' => 'max-age=3600'); } -=head2 index +=head2 body Show the summary page for a particular body. @@ -99,7 +114,7 @@ sub body : Path : Args(1) { $c->detach( 'ward', [ $body ] ); } -=head2 index +=head2 ward Show the summary page for a particular ward. |