diff options
author | Struan Donald <struan@exo.org.uk> | 2012-05-10 15:55:01 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-05-10 15:55:01 +0100 |
commit | faf4ff882ff0ebd709f25ecb363d418c2f955b9a (patch) | |
tree | 026f71e3f835a8883caed897d69722274357559f /perllib/FixMyStreet/App/Controller/Dashboard.pm | |
parent | c46ef588de465a79f1475f4e1da5e756c9554853 (diff) |
put example dashboard data in json file
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Dashboard.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 1f2d003fe..1f723f52b 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -3,6 +3,7 @@ use Moose; use namespace::autoclean; use DateTime; +use File::Slurp; BEGIN { extends 'Catalyst::Controller'; } @@ -33,18 +34,25 @@ sub example : Local : Args(0) { # See if we've had anything from the dropdowns - perhaps vary results if so $c->stash->{ward} = $c->req->param('ward'); $c->stash->{category} = $c->req->param('category'); - #$c->stash->{q_state} = $c->req->param('state'); - - my %counts; - $counts{wtd} = { - total => 10, - 'planned' => 2, 'in progress' => 1, investigating => 1, - 'fixed - council' => 3, fixed_user => 2, - time_to_fix => 8, time_to_mark => 2, + $c->stash->{q_state} = $c->req->param('state'); + + eval { + my $data = File::Slurp::read_file( + FixMyStreet->path_to( 'data/dashboard.json' )->stringify + ); + my $j = JSON->new->utf8->decode($data); + $c->stash->{problems} = $j->{counts}; + if ( lc($c->stash->{q_state}) eq 'all' or !$c->stash->{q_state} ) { + $c->stash->{lists} = $j->{lists}->{all}; + } else { + $c->stash->{lists} = $j->{lists}->{filtered}; + } }; - # TODO Repeat for week/weeks/ytd? Or another way? - - $c->stash->{problems} = \%counts; + if ($@) { + $c->stash->{message} = _("There was a problem showing this page. Please try again later.") . ' ' . + sprintf(_('The error was: %s'), $@); + $c->stash->{template} = 'errors/generic.html'; + } } =head2 check_page_allowed |