View | Details | Raw Unified | Return to bug 31666
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/job_progress.inc (+5 lines)
Line 0 Link Here
1
<div class="progress">
2
    <div id="progress-bar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:100%">
3
        <span id="job_percent">0</span>% <span id="job_status"></span>
4
    </div>
5
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/str/job_progess.inc (+6 lines)
Line 0 Link Here
1
<!-- str/job_progess.inc -->
2
<script>
3
    var JOB_PROGRESS_NOT_STARTED = _("Not started");
4
    var JOB_PROGRESS_STARTED     = _("Started");
5
    var JOB_PROGRESS_FINISHED    = _("Finished");
6
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt (-4 / +5 lines)
Lines 74-79 Link Here
74
            <h1>MARC staging</h1>
74
            <h1>MARC staging</h1>
75
            <div class="dialog message">
75
            <div class="dialog message">
76
              <p>The job has been enqueued! It will be processed as soon as possible.</p>
76
              <p>The job has been enqueued! It will be processed as soon as possible.</p>
77
               [% INCLUDE "job_progress.inc" job_id=job_id %]
77
              <p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
78
              <p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
78
            </div>
79
            </div>
79
        [% ELSE %]
80
        [% ELSE %]
Lines 258-263 Link Here
258
    [% Asset.js("js/tools-menu.js") | $raw %]
259
    [% Asset.js("js/tools-menu.js") | $raw %]
259
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
260
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
260
    [% Asset.js("js/file-upload.js") | $raw %]
261
    [% Asset.js("js/file-upload.js") | $raw %]
262
263
    [% INCLUDE 'str/job_progess.inc' %]
264
    [% Asset.js("js/job_progess.js") | $raw %]
261
    <script>
265
    <script>
262
        var xhr;
266
        var xhr;
263
        var PROFILE_SAVE_MSG = _("Profile saved");
267
        var PROFILE_SAVE_MSG = _("Profile saved");
Lines 422-431 Link Here
422
                })
426
                })
423
            });
427
            });
424
            [% IF job_enqueued %]
428
            [% IF job_enqueued %]
425
                setTimeout(
429
                updateProgress([% job_id %]);
426
                    function() { window.location.href=$('a.job_details').attr('href'); },
427
                    5000, // 5 secs to read
428
                );
429
            [% END %]
430
            [% END %]
430
        });
431
        });
431
432
(-)a/koha-tmpl/intranet-tmpl/prog/js/job_progess.js (-1 / +28 lines)
Line 0 Link Here
0
- 
1
function updateProgress(job_id) {
2
    $.getJSON('/api/v1/jobs/' + job_id, function(job){
3
        let recheck = true;
4
5
        if ( job.status == "new" ) {
6
            $("#job_percent").text(0);
7
            $("#job_status").text(JOB_PROGRESS_NOT_STARTED);
8
            $("#progress-bar").attr('aria-valuenow', 0).css("width", "100%");
9
        } else if ( job.status == "started" ) {
10
            const progress = job["progress"];
11
            const size = job["size"];
12
            const percent = progress > 0 ? ( progress / size ) * 100 : 0;
13
            $("#job_percent").text(percent.toFixed(2));
14
            $("#job_status").text(JOB_PROGRESS_STARTED);
15
            $("#progress-bar").attr('aria-valuenow', percent).css("width", `${percent}%`);
16
        } else if ( job.status == "finished" ) {
17
            $("#job_percent").text(100);
18
            $("#job_status").text(JOB_PROGRESS_FINISHED);
19
            $("#progress-bar").addClass("progress-bar-success");
20
            $("#progress-bar").attr('aria-valuenow', 100).css("width", "100%");
21
            recheck = false;
22
        }
23
24
        if ( recheck ) {
25
            setTimeout(function(){updateProgress(job_id)}, 1 * 1000);
26
        }
27
    });
28
}

Return to bug 31666