Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt
Jonathan Druart 4d1566d324 Bug 27344: Implement Elastic's update_index_background using Koha::BackgroundJob
This patch adds a background job submodule, UpdateElasticIndex, to deal
with async ES index update (not the deletion).

Using NYTProf (on a checkin):
Without
618ms, executing 35676 statements and 26355 subroutine calls in 266 source files and 83 string evals.

With
521ms, executing 13282 statements and 7979 subroutine calls in 195 source files and 26 string evals.

However there are some problems with this patch:
1. We don't want *all* the index update to be in the background_jobs
tabtle (we could add a filter on the list view)
2. We don't track the "progress" of the job as we are sending all the
records to Elastic. It is okish in my opinion but it must be noted.

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-05-03 11:19:49 -10:00

233 lines
7.6 KiB
Text

[% USE raw %]
[% USE KohaDates %]
[% USE Asset %]
[% USE KohaDates %]
[% SET footerjs = 1 %]
[% BLOCK show_job_status %]
[% SWITCH job.status %]
[% CASE "new" %]
<span>New</span>
[% CASE "cancelled" %]
<span>Cancelled</span>
[% CASE "finished" %]
<span>Finished</span>
[% CASE "started" %]
<span>Started</span>
[% CASE "running" %]
<span>Running</span>
[% CASE "failed" %]
<span>Failed</span>
[% CASE # Default case %]
[% job.status | html %]
[% END -%]
[% END %]
[% BLOCK show_job_type %]
[% SWITCH job_type %]
[% CASE 'batch_biblio_record_modification' %]
<span>Batch bibliographic record modification</span>
[% CASE 'batch_biblio_record_deletion' %]
<span>Batch bibliographic record record deletion</span>
[% CASE 'batch_authority_record_modification' %]
<span>Batch authority record modification</span>
[% CASE 'batch_authority_record_deletion' %]
<span>Batch authority record deletion</span>
[% CASE 'batch_item_record_modification' %]
<span>Batch item record modification</span>
[% CASE 'batch_item_record_deletion' %]
<span>Batch item record deletion</span>
[% CASE "batch_hold_cancel" %]
<span>Batch hold cancellation</span>
[% CASE 'update_elastic_index' %]
<span>Update Elasticsearch index</span>
[% CASE %]<span>Unknown job type '[% job_type | html %]'</span>
[% END %]
[% END %]
[% INCLUDE 'doc-head-open.inc' %]
<title>
[% IF op == 'view' %]
Details of job #[% job.id | html %] &rsaquo;
[% END %]
Background jobs &rsaquo;
Administration &rsaquo; Koha
</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="admin_background_jobs" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
[% IF CAN_user_parameters_manage_background_jobs %]
<li>
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
</li>
[% IF op == 'view' %]
<li>
<a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a>
</li>
<li>
<a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
</li>
[% ELSE %]
<li>
<a href="#" aria-current="page">Background jobs</a>
</li>
[% END %]
[% ELSE %]
<li>
<a href="#" aria-current="page">Administration</a>
</li>
[% END %]
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% FOR m IN messages %]
<div class="dialog message">
[% SWITCH m.code %]
[% CASE 'cannot_view_job' %]
<div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
[% CASE %]
[% m.code | html %]
[% END %]
</div>
[% END %]
[% IF op == 'view' %]
<h1>Details of job #[% job.id | html %]</h1>
[% PROCESS "background_jobs/${job.type}.inc" %]
<fieldset class="rows">
<ol>
<li><span class="label">Job ID: </span>[% job.id | html %]</li>
<li>
<label for="job_status">Status: </label>
[% PROCESS show_job_status %]
</li>
<li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
<li>
<label for="job_type">Type: </label>
[% PROCESS show_job_type job_type => job.type %]
</li>
<li>
<label for="job_enqueued_on">Queued: </label>
[% job.enqueued_on | $KohaDates with_hours = 1 %]
</li>
<li>
<label for="job_started_on">Started: </label>
[% job.started_on | $KohaDates with_hours = 1 %]
</li>
<li>
<label for="job_ended_on">Ended: </label>
[% job.ended_on | $KohaDates with_hours = 1 %]
</li>
<li><label for="job_data">Report: </label>
[% PROCESS 'report' %]
</li>
<li><label for="job_data">Detailed messages: </label>
[% PROCESS 'detail' %]
</li>
</ol>
</fieldset>
[% IF CAN_user_parameters_manage_background_jobs %]
<fieldset class="action">
<a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
</fieldset>
[% END %]
[% END %]
[% IF op == 'list' %]
<h1>Background jobs</h1>
[% IF jobs.count %]
<table id="table_background_jobs">
<thead>
<tr>
<th>Job ID</th>
<th>Status</th>
<th>Progress</th>
<th>Type</th>
<th>Queued</th>
<th>Started</th>
<th>Ended</th>
<th class="noExport">Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH job IN jobs %]
<tr>
<td>[% job.id | html %]</td>
<td>
[% PROCESS show_job_status %]
</td>
<td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
<td>
[% PROCESS show_job_type job_type => job.type %]
</td>
<td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
<td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
<td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
<td class="actions">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&amp;id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a>
[% IF job.status == 'new' || job.status == 'started' %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&amp;id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a>
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<div class="dialog message">
There are no background jobs yet.
</div>
[% END %]
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'admin-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script>
$(document).ready(function() {
$("#table_background_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
],
"aaSorting": [[ 0, "desc" ]],
"iDisplayLength": 10,
"sPaginationType": "full_numbers"
}));
});
</script>
[% IF op == 'view' %]
[% PROCESS 'js' %]
[% END %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]