Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Improve display of unsent reports on summary page #5142

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions perllib/FixMyStreet/App/Controller/Admin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ sub index : Path : Args(0) {
$c->stash->{edit_body_contacts} = 1
if grep { $_ eq 'body' } keys %{$c->stash->{allowed_pages}};

my @unsent = $c->cobrand->problems->search( {
my $problems = ($c->cobrand->moniker eq 'fixmystreet' && $c->user->is_superuser) ? $c->model('DB::Problem') : $c->cobrand->problems;

my @unsent = $problems->search( {
send_state => ['unprocessed', 'acknowledged'],
'me.state' => [ FixMyStreet::DB::Result::Problem::open_states() ],
bodies_str => { '!=', undef },
Expand All @@ -82,7 +84,7 @@ sub index : Path : Args(0) {
},
{
'+columns' => ['user.email'],
prefetch => 'contact',
prefetch => [ 'contact', 'user_planned_reports' ],
join => 'user',
order_by => 'confirmed',
} )->all;
Expand Down
9 changes: 5 additions & 4 deletions templates/web/base/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@
</div>

[% IF unsent_reports.size %]
<h2>[% loc('Reports waiting to be sent') %]</h2>
<h2>[% tprintf( nget(loc('%d report waiting to be sent'), loc('%d reports waiting to be sent'), unsent_reports.size), unsent_reports.size ) %]</h2>

<table cellspacing="0" cellpadding="2" border="1">
<tr>
<th>[% loc('ID') %]</th>
<th>[% loc('Title') %]</th>
<th>[% loc('Name') %]</th>
<th>[% loc('Body') %]</th>
<th>[% loc('State') %]</th>
<th>[% loc('Age') %]</th>
<th>[% loc('Failures') %]</th>
<th>[% loc('Last failure') %]</th>
<th>*</th>
</tr>
[% INCLUDE 'admin/problem_row.html' problems = unsent_reports %]
[% INCLUDE 'admin/unsent_problem_row.html' problems = unsent_reports %]
</table>
[% END %]

Expand Down
47 changes: 47 additions & 0 deletions templates/web/base/admin/unsent_problem_row.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[%- FOR problem IN problems %]
<tr[% ' class="adminhidden"' IF problem.state == 'hidden' OR problem.send_state == 'acknowledged' %]>
<td class="record-id">[%- IF problem.is_visible -%]
[%- uri = c.uri_for_email( '/report', problem.id ) %]
<a href="[% uri %]" class="admin-offsite-link">[% problem.id %]</a>
[%- ELSE %]
[%- problem.id %]
[%- END -%]
[%~ IF problem.cobrand_data %]<br><small>[% problem.cobrand_data %]</small>[%~ END ~%]
</td>
<td>[% PROCESS value_or_nbsp value=problem.title %]</td>
<td>
[% PROCESS value_or_nbsp value=problem.category_display %]
[%- IF edit_body_contacts -%]
[% IF problem.whensent %]
<br>[% loc('When sent') %]:&nbsp;[% PROCESS format_time time=problem.whensent %]
[%- send_fail_bodies = problem.send_fail_bodies -%]
[%- IF send_fail_bodies.size %]
<br>[% loc('Failed bodies:') %]&nbsp;[% send_fail_bodies.join(', ') %]
[% END -%]
[% ELSE -%]
[% FOR body IN problem.bodies.values %]
<br><a href="[% c.uri_for_action('admin/bodies/edit', [ body.id ] ) %]">[% PROCESS value_or_nbsp value=body.name %]</a>
[% END %]
[% END -%]
[%- ELSE -%]
<br>[%- PROCESS value_or_nbsp value=problem.bodies_str -%]
[%- END -%]
</td>
<td>
[% problem.time_ago %]
<br><small>[% PROCESS format_time time=problem.confirmed %]
</td>
<td>[% problem.send_fail_count %]</td>
<td title="[% problem.send_fail_reason.split('POST http').0 | truncate(250, '…') %]">
[% IF problem.send_fail_timestamp %]
[% PROCESS format_time time=problem.send_fail_timestamp %]
<br><small>[% problem.time_ago('send_fail_timestamp') %] ago
[% END %]
</td>
<td>
[% IF c.user.has_permission_to('report_edit', problem.bodies_str_ids) %]
<a href="[% c.uri_for_action( '/admin/reports/edit', [ problem.id ] ) %]">[% loc('Edit') %]</a>
[% END %]
</td>
</tr>
[%- END -%]
Loading