diff options
20 files changed, 243 insertions, 272 deletions
diff --git a/bin/update-all-reports b/bin/update-all-reports index 02f9fda78..250901312 100755 --- a/bin/update-all-reports +++ b/bin/update-all-reports @@ -21,13 +21,13 @@ use Getopt::Long::Descriptive; my ($opt, $usage) = describe_options( '%c %o', - [ 'dashboard', "Output JSON for new dashboard-style page." ], + [ 'table', "Output JSON for old table-style page." ], [ 'help', "print usage message and exit", { shortcircuit => 1 } ], ); print($usage->text), exit if $opt->help; -if ($opt->dashboard) { - FixMyStreet::Script::UpdateAllReports::generate_dashboard(); -} else { +if ($opt->table) { FixMyStreet::Script::UpdateAllReports::generate(); +} else { + FixMyStreet::Script::UpdateAllReports::generate_dashboard(); } @@ -69,6 +69,7 @@ requires 'Locale::gettext'; requires 'LWP::Simple'; requires 'LWP::UserAgent'; requires 'Math::Trig'; +requires 'MIME::Parser'; # HandleMail requires 'Module::Pluggable'; requires 'Moose'; requires 'MooX::Types::MooseLike'; @@ -110,7 +111,7 @@ requires 'Algorithm::Diff'; # Modules used by CSS & watcher requires 'CSS::Sass'; requires 'File::ChangeNotify'; -requires 'Path::Tiny'; +requires 'Path::Tiny', '0.104'; requires 'File::Find::Rule'; # Modules used by the test suite diff --git a/cpanfile.snapshot b/cpanfile.snapshot index db00f48a7..51d284789 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -3495,6 +3495,53 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 Test::More 0.47 + MIME-tools-5.504 + pathname: D/DS/DSKOLL/MIME-tools-5.504.tar.gz + provides: + MIME::Body 5.504 + MIME::Body::File 5.504 + MIME::Body::InCore 5.504 + MIME::Body::Scalar 5.504 + MIME::Decoder 5.504 + MIME::Decoder::Base64 5.504 + MIME::Decoder::BinHex 5.504 + MIME::Decoder::Binary 5.504 + MIME::Decoder::Gzip64 5.504 + MIME::Decoder::NBit 5.504 + MIME::Decoder::QuotedPrint 5.504 + MIME::Decoder::UU 5.504 + MIME::Entity 5.504 + MIME::Field::ConTraEnc 5.504 + MIME::Field::ContDisp 5.504 + MIME::Field::ContType 5.504 + MIME::Field::ParamVal 5.504 + MIME::Head 5.504 + MIME::Parser 5.504 + MIME::Parser::FileInto undef + MIME::Parser::FileUnder undef + MIME::Parser::Filer undef + MIME::Parser::Reader undef + MIME::Parser::Results undef + MIME::Tools 5.504 + MIME::WordDecoder undef + MIME::WordDecoder::ISO_8859 undef + MIME::WordDecoder::US_ASCII undef + MIME::WordDecoder::UTF_8 undef + MIME::Words 5.504 + requirements: + ExtUtils::MakeMaker 6.42 + File::Path 1 + File::Spec 0.6 + File::Temp 0.18 + IO::File 1.13 + IO::Handle 0 + MIME::Base64 2.2 + Mail::Field 1.05 + Mail::Header 1.01 + Mail::Internet 1.0203 + Test::Deep 0 + Test::More 0 + perl 5.008 MRO-Compat-0.12 pathname: B/BO/BOBTFISH/MRO-Compat-0.12.tar.gz provides: @@ -4581,28 +4628,30 @@ DISTRIBUTIONS overload 0 strict 0 warnings 0 - Path-Tiny-0.028 - pathname: D/DA/DAGOLDEN/Path-Tiny-0.028.tar.gz + Path-Tiny-0.104 + pathname: D/DA/DAGOLDEN/Path-Tiny-0.104.tar.gz provides: - Path::Tiny 0.028 + Path::Tiny 0.104 + Path::Tiny::Error 0.104 requirements: Carp 0 Cwd 0 Digest 1.03 Digest::SHA 5.45 Exporter 5.57 - ExtUtils::MakeMaker 6.30 + ExtUtils::MakeMaker 6.17 Fcntl 0 File::Copy 0 + File::Glob 0 File::Path 2.07 - File::Spec 3.40 - File::Temp 0.18 + File::Spec 0.86 + File::Temp 0.19 File::stat 0 - autodie::exception 2.14 constant 0 + if 0 overload 0 + perl 5.008001 strict 0 - threads 0 warnings 0 PathTools-3.40 pathname: S/SM/SMUELLER/PathTools-3.40.tar.gz diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 35e8c2537..5575d915e 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -200,6 +200,10 @@ sub setup_request { $c->stash->{site_name} = Utils::trim_text($c->render_fragment('site-name.html')); + if (my $template = $c->forward('/about/find_template', [ 'homepage' ])) { + $c->stash->{homepage_template} = $template; + } + $c->model('DB::Problem')->set_restriction( $cobrand->site_key() ); Memcached::set_namespace( FixMyStreet->config('FMS_DB_NAME') . ":" ); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 81abba3ac..040579e9f 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -28,14 +28,11 @@ Redirect to homepage unless C<id> parameter in query, in which case redirect to sub index : Path('') : Args(0) { my ( $self, $c ) = @_; - my $id = $c->get_param('id'); - - my $uri = - $id - ? $c->uri_for( '/report', $id ) - : $c->uri_for('/'); - - $c->res->redirect($uri); + if ($c->stash->{homepage_template}) { + $c->stash->{template} = 'index.html'; + } else { + $c->res->redirect('/'); + } } =head2 report_display diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 024a23872..8f068f0ec 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -384,8 +384,6 @@ sub load_and_group_problems : Private { $c->forward('stash_report_sort', [ $c->cobrand->reports_ordering ]); my $page = $c->get_param('p') || 1; - # NB: If 't' is specified, it will override 'status'. - my $type = $c->get_param('t') || 'all'; my $category = [ $c->get_param_list('filter_category', 1) ]; my $states = $c->stash->{filter_problem_states}; @@ -413,25 +411,6 @@ sub load_and_group_problems : Private { $where->{'me.id'} = { -not_in => $shortlisted_ids }; } - my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ]; - if ( $type eq 'new' ) { - $where->{confirmed} = { '>', \"current_timestamp - INTERVAL '4 week'" }; - $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; - } elsif ( $type eq 'older' ) { - $where->{confirmed} = { '<', \"current_timestamp - INTERVAL '4 week'" }; - $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; - $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; - } elsif ( $type eq 'unknown' ) { - $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; - $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; - } elsif ( $type eq 'fixed' ) { - $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; - $where->{state} = $not_open; - } elsif ( $type eq 'older_fixed' ) { - $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; - $where->{state} = $not_open; - } - if (@$category) { $where->{category} = $category; } diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index 4f098dfc3..64d7fa6ae 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -58,6 +58,11 @@ sub index : Path : Args(0) { return; } + if ($c->stash->{homepage_template}) { + $c->stash->{template} = $c->stash->{homepage_template}; + $c->detach; + } + $c->forward('/auth/get_csrf_token'); } diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index eef767ce6..188e99a5c 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -485,31 +485,6 @@ sub extract_problem_list { return $result->{ problems } || []; } -=head2 extract_report_stats - - $stats = $mech->extract_report_stats - -Returns a hash ref keyed by council name of all the council stats from the all reports -page. Each value is an array ref with the first element being the council name and the -rest being the stats in the order the appear in each row. - -=cut - -sub extract_report_stats { - my $mech = shift; - - my $result = scraper { - process 'tr[align=center]', 'councils[]' => scraper { - process 'td.title a', 'council', 'TEXT', - process 'td', 'stats[]', 'TEXT' - } - }->scrape( $mech->response ); - - my %councils = map { $_->{council} => $_->{stats} } @{ $result->{councils} }; - - return \%councils; -} - =head2 visible_form_values $hashref = $mech->visible_form_values( ); diff --git a/t/app/controller/about.t b/t/app/controller/about.t index 8f3f25e27..04d902bc5 100644 --- a/t/app/controller/about.t +++ b/t/app/controller/about.t @@ -1,3 +1,9 @@ +package FixMyStreet::Cobrand::Tester; +use parent 'FixMyStreet::Cobrand::Default'; +sub path_to_web_templates { [ FixMyStreet->path_to( 't', 'app', 'controller', 'templates') ] } + +package main; + use FixMyStreet::TestMech; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); @@ -25,4 +31,22 @@ FixMyStreet::override_config { $mech->content_contains('html class="no-js" lang="nb"'); }; +$mech->get_ok('/'); +$mech->content_contains('Report a problem'); +$mech->content_lacks('STATIC FRONT PAGE'); +$mech->get('/report'); +is $mech->res->code, 200, "got 200"; +is $mech->res->previous->code, 302, "got 302 for redirect"; +is $mech->uri->path, '/', 'redirected to front page'; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'tester' ], +}, sub { + $mech->get_ok('/'); + $mech->content_contains('STATIC FRONT PAGE'); + $mech->get_ok('/report'); + is $mech->res->previous, undef, 'No redirect'; + $mech->content_contains('Report a problem'); +}; + done_testing(); diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index bcdf612be..093ea9cf8 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -35,11 +35,6 @@ subtest "check that no id redirects to homepage" => sub { is $mech->uri->path, '/', "at home page"; }; -subtest "test id=NNN redirects to /NNN" => sub { - $mech->get_ok("/report?id=$report_id"); - is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; -}; - subtest "test bad council email clients web links" => sub { $mech->get_ok("/report/3D$report_id"); is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 159095853..15e7e3718 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -1,8 +1,14 @@ +use Test::MockTime qw(:all); use FixMyStreet::TestMech; use mySociety::MaPit; use FixMyStreet::App; use DateTime; +set_absolute_time('2017-07-07T16:00:00'); +END { + restore_time; +} + ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); $mech->create_body_ok(2514, 'Birmingham City Council'); @@ -11,9 +17,9 @@ my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id; my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id; my $body_slash_id = $mech->create_body_ok(10000, 'Electricity/Gas Council')->id; -my @edinburgh_problems = $mech->create_problems_for_body(3, $body_edin_id, 'All reports'); -my @westminster_problems = $mech->create_problems_for_body(5, $body_west_id, 'All reports'); -my @fife_problems = $mech->create_problems_for_body(15, $body_fife_id, 'All reports'); +my @edinburgh_problems = $mech->create_problems_for_body(3, $body_edin_id, 'All reports', { category => 'Potholes' }); +my @westminster_problems = $mech->create_problems_for_body(5, $body_west_id, 'All reports', { category => 'Graffiti' }); +my @fife_problems = $mech->create_problems_for_body(15, $body_fife_id, 'All reports', { category => 'Flytipping' }); is scalar @westminster_problems, 5, 'correct number of westminster problems created'; is scalar @edinburgh_problems, 3, 'correct number of edinburgh problems created'; @@ -80,30 +86,21 @@ $fife_problems[10]->update( { # Run the cron script that makes the data for /reports so we don't get an error. use FixMyStreet::Script::UpdateAllReports; -FixMyStreet::Script::UpdateAllReports::generate(); +FixMyStreet::Script::UpdateAllReports::generate_dashboard(); # check that we can get the page $mech->get_ok('/reports'); -$mech->title_like(qr{Summary reports}); +$mech->title_like(qr{Dashboard}); $mech->content_contains('Birmingham'); -my $stats = $mech->extract_report_stats; - -is $stats->{'City of Edinburgh Council'}->[1], 2, 'correct number of new reports for Edinburgh'; -is $stats->{'City of Edinburgh Council'}->[2], 1, 'correct number of older reports for Edinburgh'; - -is $stats->{'Westminster City Council'}->[1], 5, 'correct number of reports for Westminster'; - -is $stats->{'Fife Council'}->[1], 5, 'correct number of new reports for Fife'; -is $stats->{'Fife Council'}->[2], 4, 'correct number of old reports for Fife'; -is $stats->{'Fife Council'}->[3], 1, 'correct number of unknown reports for Fife'; -is $stats->{'Fife Council'}->[4], 3, 'correct number of fixed reports for Fife'; -is $stats->{'Fife Council'}->[5], 1, 'correct number of older fixed reports for Fife'; +$mech->content_contains('"Apr","May","Jun","Jul"'); +$mech->content_contains('5,9,10,22'); +$mech->content_contains('2,3,4,4'); FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->follow_link_ok( { text_regex => qr/Birmingham/ } ); + $mech->submit_form_ok( { with_fields => { body => $body_edin_id } }, 'Submitted dropdown okay' ); $mech->get_ok('/reports/Westminster'); }; @@ -118,54 +115,44 @@ FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/reports'); - $mech->follow_link_ok({ url_regex => qr{/reports/Electricity_Gas\+Council} }); + $mech->submit_form_ok({ with_fields => { body => $body_slash_id } }, 'Submitted dropdown okay'); is $mech->uri->path, '/reports/Electricity_Gas+Council', 'Path is correct'; - $mech->get_ok('/reports/City+of+Edinburgh?t=new'); + $mech->get_ok('/reports/City+of+Edinburgh?status=open'); }; $problems = $mech->extract_problem_list; -is scalar @$problems, 2, 'correct number of new problems displayed'; +is scalar @$problems, 3, 'correct number of open problems displayed'; FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->get_ok('/reports/City+of+Edinburgh?t=older'); + $mech->get_ok('/reports/City+of+Edinburgh?status=closed'); }; $problems = $mech->extract_problem_list; -is scalar @$problems, 1, 'correct number of older problems displayed'; +is scalar @$problems, 0, 'correct number of closed problems displayed'; for my $test ( { - desc => 'new fife problems on report page', - type => 'new', - expected => 5 + desc => 'open fife problems on report page', + type => 'open', + expected => 10 }, { - desc => 'older fife problems on report page', - type => 'older', - expected => 4 - }, - { - desc => 'unknown fife problems on report page', - type => 'unknown', - expected => 1 + desc => 'closed fife problems on report page', + type => 'closed', + expected => 0 }, { desc => 'fixed fife problems on report page', type => 'fixed', - expected => 3 - }, - { - desc => 'older_fixed fife problems on report page', - type => 'older_fixed', - expected => 1 + expected => 4 }, ) { subtest $test->{desc} => sub { FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->get_ok('/reports/Fife+Council?t=' . $test->{type}); + $mech->get_ok('/reports/Fife+Council?status=' . $test->{type}); }; $problems = $mech->extract_problem_list; @@ -186,9 +173,10 @@ is scalar @$problems, 4, 'only public problems are displayed'; $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible'); +# No change to numbers if report is non-public $mech->get_ok('/reports'); -$stats = $mech->extract_report_stats; -is $stats->{'Westminster City Council'}->[1], 5, 'non public reports included in stats'; +$mech->content_contains('"Apr","May","Jun","Jul"'); +$mech->content_contains('5,9,10,22'); subtest "test fiksgatami all reports page" => sub { FixMyStreet::override_config { diff --git a/t/app/controller/templates/about/homepage.html b/t/app/controller/templates/about/homepage.html new file mode 100644 index 000000000..c8d5c1eb3 --- /dev/null +++ b/t/app/controller/templates/about/homepage.html @@ -0,0 +1,3 @@ +<p> + THIS IS A STATIC FRONT PAGE. +</p> diff --git a/templates/web/base/main_nav_items.html b/templates/web/base/main_nav_items.html index 6b5e09e56..845ef7c65 100644 --- a/templates/web/base/main_nav_items.html +++ b/templates/web/base/main_nav_items.html @@ -1,4 +1,4 @@ -[%~ INCLUDE navitem uri='/' label=loc('Report a problem') attrs='class="report-a-problem-btn"' ~%] +[%~ INCLUDE navitem uri=(homepage_template ? '/report' : '/') label=loc('Report a problem') attrs='class="report-a-problem-btn"' ~%] [%~ IF c.user_exists ~%] [%~ INCLUDE navitem uri='/my' label=loc('Your account') ~%] diff --git a/templates/web/base/reports/index.html b/templates/web/base/reports/index.html index b07227144..a653a2686 100755 --- a/templates/web/base/reports/index.html +++ b/templates/web/base/reports/index.html @@ -1,50 +1,113 @@ +[% USE Number.Format -%] [% extra_js = [ - version('/js/jquery.fixedthead.js') + version('/vendor/chart.min.js'), + version('/vendor/accessible-autocomplete.min.js'), + version('/js/dashboard.js') ] -%] -[% INCLUDE 'header.html', title = loc('Summary reports'), bodyclass => 'fullwidthpage' %] +[% + problems_reported = problems_reported_by_period.last | format_number; + problems_fixed = problems_fixed_by_period.last | format_number; + last_seven_reported = last_seven_days.problems_total | format_number; + last_seven_updated = last_seven_days.updated_total | format_number; + last_seven_fixed = last_seven_days.fixed_total | format_number; + other_categories_formatted = other_categories | format_number; +-%] +[% INCLUDE 'header.html', title = loc('Dashboard'), bodyclass => 'dashboard fullwidthpage' %] -<h1>[% loc('All Reports') %]</h1> +<div class="dashboard-header"> + <h1>[% loc('Dashboard') %]</h1> +</div> -<div class="intro"> -<p> - [% loc('This is a summary of all reports on this site.') %] - [% IF bodies.size > 1 %] - [% loc('Select a particular council to see the reports sent there.') %] - [% END %] - [% IF any_empty_bodies %] - [% loc('Greyed-out lines are councils that no longer exist.') %] - [% END %] -</p> +<div class="dashboard-row"> + <div class="dashboard-item dashboard-item--12"> + <h2>[% loc('All time') %]</h2> + <div class="labelled-line-chart"> + <canvas id="chart-all-reports" width="600" height="300" + data-labels="["[% problem_periods.join('","') %]"]" + data-values-reports="[[% problems_reported_by_period.join(',') %]]" + data-values-fixed="[[% problems_fixed_by_period.join(',') %]]" + ></canvas> + <span class="label" data-datasetindex="0"><strong style="color: #F4A140">[% tprintf(nget("%s problem reported", "%s problems reported", problems_reported_by_period.last), decode(problems_reported) _ '</strong>') %]</span> + <span class="label" data-datasetindex="1"><strong style="color: #62B356">[% tprintf(nget("%s report marked as fixed", "%s reports marked as fixed", problems_fixed_by_period.last), decode(problems_fixed) _ '</strong>') %]</span> + </div> + </div> </div> -<table cellpadding="3" cellspacing="1" border="0" class="nicetable"> -<thead> -<tr> -<th class="title">[% loc('Name') %]</th> -<th title="[% loc('Reported within the last four weeks') %]" class="data">[% loc('New <br>problems') %]</th> -<th title="[% loc('Open for more than four weeks, with an update within the past eight weeks') %]" class="data">[% loc('Older <br>problems') %]</th> -<th title="[% loc('Open, but not had any update in eight weeks') %]" class="data">[% loc('Old / unknown <br>problems') %]</th> -<th title="[% loc('Marked fixed/closed in the past eight weeks') %]" class="data">[% loc('Recently <br>fixed') %]</th> -<th title="[% loc('Marked fixed/closed more than eight weeks ago') %]" class="data">[% loc('Older <br>fixed') %]</th> -</tr> -</thead> +<div class="dashboard-row"> + <div class="dashboard-item dashboard-item--6"> + <h2 class="dashboard-subheading">[% loc('Last 7 days') %]</h2> + <div class="dashboard-sparklines"> + <div> + <div class="labelled-sparkline"> + <canvas width="200" height="50" data-color="#F4A140" data-values="[% last_seven_days.problems.join(' ') %]"></canvas> + <span class="label" data-datasetindex="0"><strong style="color: #F4A140;">[% tprintf(nget("%s problem reported", "%s problems reported", last_seven_days.problems_total), decode(last_seven_reported) _ '</strong>') %]</span> + </div> + </div> + <div> + <div class="labelled-sparkline"> + <canvas width="200" height="50" data-color="#4FADED" data-values="[% last_seven_days.updated.join(' ') %]"></canvas> + <span class="label" data-datasetindex="0"><strong style="color: #4FADED;">[% tprintf(nget("%s update on problems", "%s updates on problems", last_seven_days.updated_total), decode(last_seven_updated) _ '</strong>') %]</span> + </div> + </div> + <div> + <div class="labelled-sparkline"> + <canvas width="200" height="50" data-color="#62B356" data-values="[% last_seven_days.fixed.join(' ') %]"></canvas> + <span class="label" data-datasetindex="0"><strong style="color: #62B356;">[% tprintf(nget("%s problem marked as fixed", "%s problems marked as fixed", last_seven_days.fixed_total), decode(last_seven_fixed) _ '</strong>') %]</span> + </div> + </div> + </div> + </div> + <div class="dashboard-item dashboard-item--6"> + <form class="dashboard-search" action="/reports"> + <h2>[% loc('Show reports in your area') %]</h2> + <label for="body">[% loc('Pick your council') %]</label> + <div class="dashboard-search__input"> + <select id="body" name="body" class="js-autocomplete"> + <option value="">[% loc('Pick your council') %]</option> + [% FOR body IN bodies %] + <option value="[% body.id %]">[% body.name | html ~%] + [% IF NOT body.get_column("area_count") %] [% loc('(no longer exists)') %][% END ~%] + </option> + [% END %] + </select> + </div> + <div class="dashboard-search__submit"> + <input type="submit" value="[% loc('Go') %]"> + </div> + </form> + </div> +</div> -<tbody> -[% FOREACH body IN bodies %] -<tr align="center" -[%- IF NOT body.get_column("area_count") %] class="gone" -[%- ELSIF ! (loop.count % 2) %] class="a" -[%- END %]> -<td class="title"><a href="[% body.url(c) %]">[% body.name %]</a></td> -<td class="data">[% IF open.${body.id}.new %]<a href="[% body.url(c, { t => 'new' }) %]">[% open.${body.id}.new %]</a>[% ELSE %]0[% END %]</td> -<td class="data">[% IF open.${body.id}.older %]<a href="[% body.url(c, { t => 'older' }) %]">[% open.${body.id}.older %]</a>[% ELSE %]0[% END %]</td> -<td class="data">[% IF open.${body.id}.unknown %]<a href="[% body.url(c, { t => 'unknown' }) %]">[% open.${body.id}.unknown %]</a>[% ELSE %]0[% END %]</td> -<td class="data">[% IF fixed.${body.id}.new %]<a href="[% body.url(c, { t => 'fixed' }) %]">[% fixed.${body.id}.new %]</a>[% ELSE %]0[% END %]</td> -<td class="data">[% IF fixed.${body.id}.old %]<a href="[% body.url(c, { t => 'older_fixed' }) %]">[% fixed.${body.id}.old %]</a>[% ELSE %]0[% END %]</td> -</tr> -[% TRY %][% PROCESS "reports/_extras.html" %][% CATCH file %][% END %] -[% END %] -</tbody> -</table> +<div class="dashboard-row"> + <div class="dashboard-item dashboard-item--6"> + <h2 class="dashboard-subheading">[% loc('Top 5 responsive councils') %]</h2> + <p>[% loc('Average time between a problem being reported and being fixed, last 100 reports.') %]</p> + <table class="dashboard-ranking-table"> + <tbody> + [% FOR line IN top_five_bodies %] + <tr><td>[% line.name %]</td><td>[% tprintf(nget("%s day", "%s days", line.days), line.days) %]</td></tr> + [% END %] + </tbody> + <tfoot> + <tr><td>[% loc('Overall average') %]</td><td>[% tprintf(nget("%s day", "%s days", average), average) %]</td></tr> + </tfoot> + </table> + </div> + <div class="dashboard-item dashboard-item--6"> + <h2 class="dashboard-subheading">[% loc('Top 5 most used categories') %]</h2> + <p>[% loc('Number of problems reported in each category, in the last 7 days.') %]</p> + <table class="dashboard-ranking-table"> + <tbody> + [% FOR line IN top_five_categories %] + [% line_count = line.count | format_number ~%] + <tr><td>[% line.category %]</td><td>[% tprintf(nget("%s report", "%s reports", line.count), decode(line_count)) %]</td></tr> + [% END %] + </tbody> + <tfoot> + <tr><td>[% loc('Other categories') %]</td><td>[% tprintf(nget("%s report", "%s reports", other_categories), decode(other_categories_formatted)) %]</td></tr> + </tfoot> + </table> + </div> +</div> -[% INCLUDE 'footer.html', pagefooter = 'yes' %] +[% INCLUDE 'footer.html' pagefooter = 'yes' %] diff --git a/templates/web/fixmystreet.com/reports/index.html b/templates/web/fixmystreet.com/reports/index.html deleted file mode 100755 index 4eafb2993..000000000 --- a/templates/web/fixmystreet.com/reports/index.html +++ /dev/null @@ -1,111 +0,0 @@ -[% USE Number.Format -%] -[% extra_js = [ - version('/vendor/chart.min.js'), - version('/vendor/accessible-autocomplete.min.js'), - version('/cobrands/fixmystreet.com/dashboard.js') -] -%] -[% - problems_reported = problems_reported_by_period.last | format_number; - problems_fixed = problems_fixed_by_period.last | format_number; - last_seven_reported = last_seven_days.problems_total | format_number; - last_seven_updated = last_seven_days.updated_total | format_number; - last_seven_fixed = last_seven_days.fixed_total | format_number; - other_categories_formatted = other_categories | format_number; --%] -[% INCLUDE 'header.html', title = loc('Dashboard'), bodyclass => 'dashboard fullwidthpage' %] - -<div class="dashboard-header"> - <h1>[% loc('Dashboard') %]</h1> -</div> - -<div class="dashboard-row"> - <div class="dashboard-item dashboard-item--12"> - <h2>UK: [% loc('All time') %]</h2> - <div class="labelled-line-chart"> - <canvas id="chart-all-reports" width="600" height="300" - data-labels="["[% problem_periods.join('","') %]"]" - data-values-reports="[[% problems_reported_by_period.join(',') %]]" - data-values-fixed="[[% problems_fixed_by_period.join(',') %]]" - ></canvas> - <span class="label" data-datasetindex="0"><strong style="color: #F4A140">[% tprintf(nget("%s problem reported", "%s problems reported", problems_reported_by_period.last), decode(problems_reported) _ '</strong>') %]</span> - <span class="label" data-datasetindex="1"><strong style="color: #62B356">[% tprintf(nget("%s report marked as fixed", "%s reports marked as fixed", problems_fixed_by_period.last), decode(problems_fixed) _ '</strong>') %]</span> - </div> - </div> -</div> - -<div class="dashboard-row"> - <div class="dashboard-item dashboard-item--6"> - <h2 class="dashboard-subheading">UK: [% loc('Last 7 days') %]</h2> - <div class="dashboard-sparklines"> - <div> - <div class="labelled-sparkline"> - <canvas width="200" height="50" data-color="#F4A140" data-values="[% last_seven_days.problems.join(' ') %]"></canvas> - <span class="label" data-datasetindex="0"><strong style="color: #F4A140;">[% tprintf(nget("%s problem reported", "%s problems reported", last_seven_days.problems_total), decode(last_seven_reported) _ '</strong>') %]</span> - </div> - </div> - <div> - <div class="labelled-sparkline"> - <canvas width="200" height="50" data-color="#4FADED" data-values="[% last_seven_days.updated.join(' ') %]"></canvas> - <span class="label" data-datasetindex="0"><strong style="color: #4FADED;">[% tprintf(nget("%s update on problems", "%s updates on problems", last_seven_days.updated_total), decode(last_seven_updated) _ '</strong>') %]</span> - </div> - </div> - <div> - <div class="labelled-sparkline"> - <canvas width="200" height="50" data-color="#62B356" data-values="[% last_seven_days.fixed.join(' ') %]"></canvas> - <span class="label" data-datasetindex="0"><strong style="color: #62B356;">[% tprintf(nget("%s problem marked as fixed", "%s problems marked as fixed", last_seven_days.fixed_total), decode(last_seven_fixed) _ '</strong>') %]</span> - </div> - </div> - </div> - </div> - <div class="dashboard-item dashboard-item--6"> - <form class="dashboard-search" action="/reports"> - <h2>[% loc('Show reports in your area') %]</h2> - <label for="body">[% loc('Pick your council') %]</label> - <div class="dashboard-search__input"> - <select id="body" name="body" class="js-autocomplete"> - <option value="">[% loc('Pick your council') %]</option> - [% FOR body IN bodies %] - <option value="[% body.id %]">[% body.name | html %]</option> - [% END %] - </select> - </div> - <div class="dashboard-search__submit"> - <input type="submit" value="[% loc('Go') %]"> - </div> - </form> - </div> -</div> - -<div class="dashboard-row"> - <div class="dashboard-item dashboard-item--6"> - <h2 class="dashboard-subheading">[% loc('Top 5 responsive councils') %]</h2> - <p>[% loc('Average time between a problem being reported and being fixed, last 100 reports.') %]</p> - <table class="dashboard-ranking-table"> - <tbody> - [% FOR line IN top_five_bodies %] - <tr><td>[% line.name %]</td><td>[% tprintf(nget("%s day", "%s days", line.days), line.days) %]</td></tr> - [% END %] - </tbody> - <tfoot> - <tr><td>[% loc('UK average') %]</td><td>[% tprintf(nget("%s day", "%s days", average), average) %]</td></tr> - </tfoot> - </table> - </div> - <div class="dashboard-item dashboard-item--6"> - <h2 class="dashboard-subheading">[% loc('Top 5 most used categories') %]</h2> - <p>[% loc('Number of problems reported in each category, in the last 7 days.') %]</p> - <table class="dashboard-ranking-table"> - <tbody> - [% FOR line IN top_five_categories %] - [% line_count = line.count | format_number ~%] - <tr><td>[% line.category %]</td><td>[% tprintf(nget("%s report", "%s reports", line.count), decode(line_count)) %]</td></tr> - [% END %] - </tbody> - <tfoot> - <tr><td>[% loc('Other categories') %]</td><td>[% tprintf(nget("%s report", "%s reports", other_categories), decode(other_categories_formatted)) %]</td></tr> - </tfoot> - </table> - </div> -</div> - -[% INCLUDE 'footer.html' pagefooter = 'yes' %] diff --git a/web/cobrands/fixmystreet.com/base.scss b/web/cobrands/fixmystreet.com/base.scss index c90b65c1a..4f2a7b1de 100644 --- a/web/cobrands/fixmystreet.com/base.scss +++ b/web/cobrands/fixmystreet.com/base.scss @@ -258,6 +258,3 @@ $grid-breakpoint-sm: $mysoc-footer-breakpoint-sm; margin-bottom: 0; } } - -@import "autocomplete"; -@import "dashboard"; diff --git a/web/cobrands/fixmystreet.com/_autocomplete.scss b/web/cobrands/sass/_autocomplete.scss index deebc1803..deebc1803 100644 --- a/web/cobrands/fixmystreet.com/_autocomplete.scss +++ b/web/cobrands/sass/_autocomplete.scss diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index a261c3b0a..87e474136 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -2429,3 +2429,5 @@ table.nicetable { @import "_fixedthead"; @import "_dropzone"; @import "_multiselect"; +@import "_autocomplete"; +@import "_dashboard"; diff --git a/web/cobrands/fixmystreet.com/_dashboard.scss b/web/cobrands/sass/_dashboard.scss index aae8aa98b..aae8aa98b 100644 --- a/web/cobrands/fixmystreet.com/_dashboard.scss +++ b/web/cobrands/sass/_dashboard.scss diff --git a/web/cobrands/fixmystreet.com/dashboard.js b/web/js/dashboard.js index f436b8d18..f436b8d18 100644 --- a/web/cobrands/fixmystreet.com/dashboard.js +++ b/web/js/dashboard.js |