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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/background-job.inc (-2 / +2 lines)
Lines 15-21 Link Here
15
            if (json.job_status == 'completed') {
15
            if (json.job_status == 'completed') {
16
                percentage = 100;
16
                percentage = 100;
17
            }
17
            }
18
				var bgproperty = (parseInt(percentage)*2-300)+"px 0px";
18
				var bgproperty = (parseInt(percentage/2)*3-300)+"px 0px";
19
                $("#jobprogress").css("background-position",bgproperty);
19
                $("#jobprogress").css("background-position",bgproperty);
20
				$("#jobprogresspercent").text(percentage);
20
				$("#jobprogresspercent").text(percentage);
21
21
Lines 66-72 Link Here
66
                data: inputs.join('&'),
66
                data: inputs.join('&'),
67
                url: f.action,
67
                url: f.action,
68
                dataType: 'json',
68
                dataType: 'json',
69
		type: 'post',
69
		        type: 'post',
70
                success: function(json) {
70
                success: function(json) {
71
                    jobID = json.jobID;
71
                    jobID = json.jobID;
72
                    inBackgroundJobProgressTimer = false;
72
                    inBackgroundJobProgressTimer = false;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/test/README (+1 lines)
Line 0 Link Here
1
Test templates, to be used with test scripts
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/test/progressbar.tmpl (+43 lines)
Line 0 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title>Koha &rsaquo; Tools &rsaquo; Stage MARC Records For Import</title>
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
<!-- TMPL_INCLUDE NAME="file-upload.inc" -->
5
<!-- TMPL_INCLUDE NAME="background-job.inc" -->
6
<style type="text/css">
7
	#uploadpanel,#fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
8
	#fileuploadstatus,#jobstatus { margin:.4em; }
9
	#fileuploadprogress,#jobprogress{ width:150px;height:10px;border:1px solid #666;background:url('/intranet-tmpl/prog/img/progress.png') -300px 0px no-repeat; }</style>
10
<script type="text/javascript">
11
//<![CDATA[
12
$(document).ready(function(){
13
});
14
function CheckForm(f) {
15
    submitBackgroundJob(f);
16
    return false;
17
}
18
19
//]]>
20
</script>
21
</head>
22
<body>
23
<div id="doc3" class="yui-t2">
24
   
25
<form method="post" action="progressbarsubmit.pl">
26
<input type="hidden" name="submitted" id="submitted" value="1" />
27
<input type="hidden" name="runinbackground" id="runinbackground" value="" />
28
<input type="hidden" name="completedJobID" id="completedJobID" value="" />
29
30
<input type="button" id="mainformsubmit" onclick="return CheckForm(this.form);" value="Start" />
31
 
32
       <div id="jobpanel">
33
           <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
34
           <div id="jobfailed"></div>
35
       </div>
36
  
37
</form>
38
</div>
39
40
<div>
41
Completed: <span id="completed"><!-- TMPL_VAR NAME="completedJobID" --> </span>
42
</div>
43
</body>
(-)a/test/README (+3 lines)
Line 0 Link Here
1
A collection of cgi and command line scripts that are useful for some testing,
2
but for one reason or another cannot be made into automated test in t.
3
Use with templates in koha-tmpl/intranet-tmpl/prog/en/modules/test
(-)a/test/progressbar.pl (+55 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Script for testing progressbar, part 1 - initial screem
4
# it is split into two scripts so we can use firebug to debug it
5
6
# Koha library project  www.koha.org
7
8
# Licensed under the GPL
9
10
# Copyright 2000-2002 Katipo Communications
11
#
12
# This file is part of Koha.
13
#
14
# Koha is free software; you can redistribute it and/or modify it under the
15
# terms of the GNU General Public License as published by the Free Software
16
# Foundation; either version 2 of the License, or (at your option) any later
17
# version.
18
#
19
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
22
#
23
# You should have received a copy of the GNU General Public License along
24
# with Koha; if not, write to the Free Software Foundation, Inc.,
25
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27
use strict;
28
#use warnings; FIXME - Bug 2505
29
30
# standard or CPAN modules used
31
use CGI;
32
use CGI::Cookie;
33
34
# Koha modules used
35
use C4::Context;
36
use C4::Auth;
37
use C4::Output;
38
use C4::BackgroundJob;
39
40
my $input = new CGI;
41
my $dbh = C4::Context->dbh;
42
$dbh->{AutoCommit} = 0;
43
44
my ($template, $loggedinuser, $cookie)
45
	= get_template_and_user({template_name => "test/progressbar.tmpl",
46
					query => $input,
47
					type => "intranet",
48
					debug => 1,
49
					});
50
51
output_html_with_http_headers $input, $cookie, $template->output;
52
53
exit 0;
54
55
(-)a/test/progressbarsubmit.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Script for testing progressbar, part 2 - json submit handler
4
#   and Z39.50 lookups
5
6
# Koha library project  www.koha.org
7
8
# Licensed under the GPL
9
10
# Copyright 2000-2002 Katipo Communications
11
#
12
# This file is part of Koha.
13
#
14
# Koha is free software; you can redistribute it and/or modify it under the
15
# terms of the GNU General Public License as published by the Free Software
16
# Foundation; either version 2 of the License, or (at your option) any later
17
# version.
18
#
19
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
22
#
23
# You should have received a copy of the GNU General Public License along
24
# with Koha; if not, write to the Free Software Foundation, Inc.,
25
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27
use strict;
28
#use warnings; FIXME - Bug 2505
29
30
# standard or CPAN modules used
31
use CGI;
32
use CGI::Cookie;
33
34
# Koha modules used
35
use C4::Context;
36
use C4::Auth;
37
use C4::Output;
38
use C4::BackgroundJob;
39
40
my $input = new CGI;
41
42
my $submitted=$input->param('submitted');
43
my $runinbackground = $input->param('runinbackground');
44
my $jobID = $input->param('jobID');
45
my $completedJobID = $input->param('completedJobID');
46
47
my ($template, $loggedinuser, $cookie)
48
    = get_template_and_user({template_name => "test/progressbar.tmpl",
49
                    query => $input,
50
                    type => "intranet",
51
                    debug => 1,
52
                    });
53
54
my %cookies = parse CGI::Cookie($cookie);
55
my $sessionID = $cookies{'CGISESSID'}->value;
56
if ($completedJobID) {
57
} elsif ($submitted) {
58
    my $job = undef;
59
    if ($runinbackground) {
60
        my $job_size = 100;
61
        $job = C4::BackgroundJob->new($sessionID, undef, $ENV{'SCRIPT_NAME'}, $job_size);
62
        $jobID = $job->id();
63
64
        # fork off
65
        if (my $pid = fork) {
66
            # parent
67
            # return job ID as JSON
68
            
69
            # prevent parent exiting from
70
            # destroying the kid's database handle
71
            # FIXME: according to DBI doc, this may not work for Oracle
72
73
            my $reply = CGI->new("");
74
            print $reply->header(-type => 'text/html');
75
            print "{ jobID: '$jobID' }";
76
            exit 0;
77
        } elsif (defined $pid) {
78
        # if we get here, we're a child that has detached
79
        # itself from Apache
80
81
            # close STDOUT to signal to Apache that
82
            # we're now running in the background
83
            close STDOUT;
84
            close STDERR;
85
86
            foreach (1..100) {
87
                sleep 1;
88
                $job->progress( $_ );
89
            }
90
            $job->finish();
91
        } else {
92
            # fork failed, so exit immediately
93
            die "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
94
        }
95
96
    }
97
} else {
98
    # initial form
99
    die "We should not be here";
100
}
101
102
exit 0;
103
104
(-)a/test/search.pl (-1 / +74 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl -w
2
3
use C4::Search;
4
5
my @SEARCH = (
6
    { operators => [
7
          'and',
8
          'and'
9
      ],
10
      operands => [
11
          'shakespeare, "(william)"',
12
          'dream'
13
      ],
14
      indexes => [
15
          'au,wrdl',
16
          'ti',
17
          'kw'
18
      ],
19
      limits => [
20
          'yr,st-numeric=2000-'
21
      ],
22
      sort_by => [
23
          'relevance'
24
      ],
25
      lang => 'en',
26
    },
27
);
28
29
30
foreach ( @SEARCH ) {
31
    my ($expected, @mismatch);
32
    my( $error,
33
        $query,
34
        $simple_query,
35
        $query_cgi,
36
        $query_desc,
37
        $limit,
38
        $limit_cgi,
39
        $limit_desc,
40
        $stopwords_removed,
41
        $query_type )
42
      = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0,  $_->{lang} );
43
44
    die $error if $error;
45
46
    $expected = $_->{query};
47
    push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected;
48
49
    $expected = $_->{simple_query};
50
    push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected;
51
52
    $expected = $_->{query_cgi};
53
    push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected;
54
55
    $expected = $_->{query_desc};
56
    push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected;
57
58
    $expected = $_->{limit};
59
    push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected;
60
61
    $expected = $_->{limit_cgi};
62
    push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected;
63
64
    $expected = $_->{limit_desc};
65
    push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
66
67
    $expected = $_->{stopwords_removed};
68
    push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected;
69
70
    $expected = $_->{query_type};
71
    push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
72
73
    die map "$_\n", @mismatch if @mismatch;
74
}

Return to bug 5309