aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-10 15:55:01 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-10 15:55:01 +0100
commitfaf4ff882ff0ebd709f25ecb363d418c2f955b9a (patch)
tree026f71e3f835a8883caed897d69722274357559f
parentc46ef588de465a79f1475f4e1da5e756c9554853 (diff)
put example dashboard data in json file
-rw-r--r--data/dashboard.json175
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm30
2 files changed, 194 insertions, 11 deletions
diff --git a/data/dashboard.json b/data/dashboard.json
new file mode 100644
index 000000000..008c92388
--- /dev/null
+++ b/data/dashboard.json
@@ -0,0 +1,175 @@
+{
+ "counts": {
+ "wtd": {
+ "total": 10,
+ "planned": 2,
+ "in progress": 1,
+ "investigating": 1,
+ "fixed - council": 3,
+ "fixed_user": 2,
+ "time_to_fix": 2,
+ "time_to_mark": 2,
+ "not_marked": 1
+ },
+ "week": {
+ "total": 21,
+ "planned": 5,
+ "in progress": 3,
+ "investigating": 4,
+ "fixed - council": 6,
+ "fixed_user": 3,
+ "time_to_fix": 3,
+ "time_to_mark": 2,
+ "not_marked": 1
+ },
+ "weeks": {
+ "total": 57,
+ "planned": 5,
+ "in progress": 16,
+ "investigating": 4,
+ "fixed - council": 23,
+ "fixed_user": 9,
+ "time_to_fix": 2,
+ "time_to_mark": 2,
+ "not_marked": 1
+ },
+ "ytd": {
+ "total": 171,
+ "planned": 23,
+ "in progress": 34,
+ "investigating": 9,
+ "fixed - council": 72,
+ "fixed_user": 33,
+ "time_to_fix": 2,
+ "time_to_mark": 2,
+ "not_marked": 1
+ }
+ },
+ "lists": {
+ "all": {
+ "1": [
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Uneven paving" }
+ ],
+ "2": [
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" }
+ ],
+ "3": [
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" }
+ ]
+ },
+ "filtered": {
+ "1": [
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Uneven paving" }
+ ],
+ "2": [
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" }
+ ],
+ "3": [
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Loose kerb" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Fallen Tree" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Fly tipping" },
+ { "id": 0, "title": "Burst pipe" },
+ { "id": 0, "title": "Abandoned car" },
+ { "id": 0, "title": "Pothole" },
+ { "id": 0, "title": "Uneven paving" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Blocked drain" },
+ { "id": 0, "title": "Pothole" }
+ ]
+ }
+ }
+}
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