Skip to content

Commit

Permalink
Experimental result popover.
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Oct 18, 2023
1 parent c42143f commit ae7a25e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
9 changes: 9 additions & 0 deletions htdocs/js/JobManager/jobmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@
});
}
}

document.querySelectorAll('.result-popover-btn').forEach((popover) => {
new bootstrap.Popover(popover, {
trigger: 'hover focus',
customClass: 'job-queue-result-popover',
html: true,
placement: 'left'
});
});
})();
3 changes: 3 additions & 0 deletions htdocs/js/JobManager/jobmanager.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.job-queue-result-popover {
--bs-popover-max-width: 400px;
}
5 changes: 1 addition & 4 deletions lib/WeBWorK/ContentGenerator/Instructor/JobManager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use constant FIELDS => [
[ started => x('Started') ],
[ finished => x('Finished') ],
[ state => x('State') ],
[ result => x('Result') ]
];

use constant SORT_SUBS => {
Expand All @@ -42,8 +41,7 @@ use constant SORT_SUBS => {
created => \&byCreatedTime,
started => \&byStartedTime,
finished => \&byFinishedTime,
state => \&byState,
result => \&byResult
state => \&byState
};

sub initialize ($c) {
Expand Down Expand Up @@ -178,6 +176,5 @@ sub byCreatedTime { return $a->{created} <=> $b->{created} }
sub byStartedTime { return $a->{started} <=> $b->{started} }
sub byFinishedTime { return $a->{finished} <=> $b->{finished} }
sub byState { return $a->{state} cmp $b->{state} }
sub byResult { return lc $a->{result} cmp lc $b->{result} }

1;
41 changes: 28 additions & 13 deletions templates/ContentGenerator/Instructor/JobManager.html.ep
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
% use WeBWorK::Utils qw(getAssetURL);
%
% content_for css => begin
<%= stylesheet getAssetURL($ce, 'js/JobManager/jobmanager.css') =%>
% end
%
% content_for js => begin
<%= javascript getAssetURL($ce, 'js/ActionTabs/actiontabs.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/SelectAll/selectall.js'), defer => undef =%>
Expand Down Expand Up @@ -100,10 +104,6 @@
<%= link_to maketext('State') => '#', class => 'sort-header',
data => { sort_field => 'state' } =%>
</th>
<th>
<%= link_to maketext('Result') => '#', class => 'sort-header',
data => { sort_field => 'result' } =%>
</th>
</tr>
</thead>
<tbody class="table-group-divider">
Expand All @@ -120,7 +120,7 @@
</td>
<td><%= label_for "job_${jobID}_checkbox" => $jobID =%></td>
% }
<td><%= $jobs->{$jobID}{task} =~ s/_/ /gr =%></td>
<td class="text-nowrap"><%= $jobs->{$jobID}{task} =~ s/_/ /gr =%></td>
<td class="text-nowrap">
<%= $c->formatDateTime(
$jobs->{$jobID}{created}, '', 'datetime_format_medium', $ce->{language}) =%>
Expand All @@ -137,14 +137,29 @@
$jobs->{$jobID}{finished}, '', 'datetime_format_medium', $ce->{language}) =%>
% }
</td>
<td><%= $jobs->{$jobID}{state} %></td>
<td style="min-width:20em">
% if (ref($jobs->{$jobID}{result}) eq 'ARRAY') {
% for (@{ $jobs->{$jobID}{result} } ) {
<p class="m-0"><%= $_ %></p>
% }
% } else {
<%= $jobs->{$jobID}{result} // '' %>
<td class="text-nowrap">
<%= $jobs->{$jobID}{state} =%>
% if (defined $jobs->{$jobID}{result}) {
% content_for "result_$jobID", begin
% if (ref($jobs->{$jobID}{result}) eq 'ARRAY') {
<ul class="m-0">
% for (@{ $jobs->{$jobID}{result} } ) {
<li><%= $_ %></li>
% }
</ul>
% } else {
<%= $jobs->{$jobID}{result} =%>
% }
% end
<%= link_to '#', class => 'result-popover-btn', role => 'button',
data => {
bs_toggle => 'popover',
bs_title => maketext('Result'),
bs_content => content("result_$jobID")->xml_escape
}, begin =%>
<i class="fa-solid fa-circle-info fa-xl" aria-hidden="true"></i>
<span class="visually-hidden"><%= maketext('Result') %></span>
<% end =%>
% }
</td>
</tr>
Expand Down
18 changes: 7 additions & 11 deletions templates/HelpFiles/InstructorJobManager.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@
<dt><%= maketext('State') %></dt>
<dd>
<%= maketext('The current state of the job. This will be one of "inactive", "active", "finished", or '
. '"failed". If a job is "inactive" it means that the job has been added to the queue, but execution of '
. 'the job has not yet started. If a job is "active" it means that the job is currently being executed. '
. 'If a job is "finished" it means that the execution of the job has successfully completed. If a job is '
. '"failed" it means that the execution of job has completed, but there were errors in the execution of '
. 'the job.') =%>
</dd>
<dt><%= maketext('Result') %></dt>
<dd>
<%= maketext('The result set by the job when execution is completed. This will be shown if the job is in the '
. '"finished" or "failed" states, and will contain information about what happened when the job was '
. 'executed.') =%>
. '"failed". If a job is "inactive" it means that the job has been added to the queue, but execution '
. 'of the job has not yet started. If a job is "active" it means that the job is currently being '
. 'executed. If a job is "finished" it means that the execution of the job has successfully '
. 'completed. If a job is "failed" it means that the execution of job has completed, but there were '
. 'errors in the execution of the job. If the job is in the "finished" or "failed" state, then there '
. 'will also be a popover containing information about what happened when the job was executed.') =%>
</p>
</dd>
</dl>
%
Expand Down

0 comments on commit ae7a25e

Please sign in to comment.