Bug 34788: Add a background job to import a KBART file
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / background_jobs / import_from_kbart_file.inc
1 [% USE Koha %]
2
3 [% BLOCK report %]
4     [% SET report = job.report %]
5     [% IF report %]
6         <div class="dialog message">
7             [% IF job.status == 'finished' %]
8                 <table id="finishedtable">
9                     <tr>
10                         <td>Filename</td>
11                         <td>[% report.file_name | html %]</td>
12                     </tr>
13                     <tr>
14                         <td>Total lines processed</td>
15                         <td>[% report.total_lines | html %]</td>
16                     </tr>
17                     <tr>
18                         <td>Titles imported</td>
19                         <td>[% report.titles_imported | html %]</td>
20                     </tr>
21                     <tr>
22                         <td>Duplicates found</td>
23                         <td>[% report.duplicates_found | html %]</td>
24                     </tr>
25                     <tr>
26                         <td>Failed imports</td>
27                         <td>[% report.failed_imports | html %]</td>
28                     </tr>
29                 </table>
30             [% ELSIF job.status == 'started' %]
31                 <p id="jobactionlabel"></p>
32             [% END %]
33             [% IF job.status != 'finished' %]
34                 [% INCLUDE "job_progress.inc" job_id=job.id %]
35             [% END %]
36             [% IF job.status == 'cancelled' %]
37                 <p>The job has been cancelled before it finished.</p>
38             [% END %]
39         </div>
40     [% END %]
41 [% END %]
42
43 [% Asset.js("js/job_progress.js") | $raw %]
44
45 [% BLOCK detail %]
46     [% FOR m IN job.messages %]
47         <div class="dialog message">
48             [% IF m.type == 'success' %]
49                 <i class="fa fa-check success"></i>
50             [% ELSIF m.type == 'warning' %]
51                 <i class="fa fa-warning warn"></i>
52             [% ELSIF m.type == 'error' %]
53                 <i class="fa fa-exclamation error"></i>
54             [% END %]
55             [% SWITCH m.code %]
56             [% CASE 'title_already_exists' %]
57                 <span><strong>[% m.title | html %]</strong> already exists and was not created.</span>
58             [% CASE 'title_failed' %]
59                 <span><strong>[% m.title | html %]</strong> failed to import - [% m.error_message | html %][% IF m.title_id %][% m.title_id | html %][% END %]</span>
60             [% CASE 'job_failed' %]
61                 <span>Job failed - [% m.error_message | html %]</span>
62             [% END %]
63         </div>
64     [% END %]
65 [% END %]
66     [% Asset.js("js/job_progress.js") | $raw %]
67
68 [% BLOCK js %]
69     [% INCLUDE 'str/job_progress.inc' job_id=job.id %]
70     [% INCLUDE 'str/import_from_kbart_file.inc' %]
71 <script>
72         $(document).ready(function(){
73             let job_id = [% job.id | html %];
74             updateProgress(job_id, {
75                 progress_callback : function(){
76                     $.getJSON('/api/v1/jobs/'+job_id, function(job){
77                         if(job.progress == 0){
78                             $('#jobactionlabel').text(READING_FILE);
79                         }else if(job.progress >= 1){
80                             $('#jobactionlabel').text(PROCESSING_FILE);
81                         }
82                     });
83                 },
84                 finish_callback : function(){
85                     $.getJSON('/api/v1/jobs/'+job_id, function(job){
86                         if(!$('#finishedtable').length){
87                             window.location.reload();
88                         }
89                     });
90                 }
91             });
92         });
93
94 </script>
95 [% END %]