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

(-)a/catalogue/detail.pl (-14 lines)
Lines 46-53 use Koha::Items; Link Here
46
use Koha::ItemTypes;
46
use Koha::ItemTypes;
47
use Koha::Patrons;
47
use Koha::Patrons;
48
use Koha::Virtualshelves;
48
use Koha::Virtualshelves;
49
use LWP::Simple;
50
use Koha::SearchEngine::Elasticsearch;
51
use Koha::Plugins;
49
use Koha::Plugins;
52
50
53
my $query = CGI->new();
51
my $query = CGI->new();
Lines 545-560 $template->param (countdeletedorders => $count_deletedorders_using_biblio); Link Here
545
$template->param (basketsorders => \@baskets_orders);
543
$template->param (basketsorders => \@baskets_orders);
546
$template->param (basketsdeletedorders => \@baskets_deletedorders);
544
$template->param (basketsdeletedorders => \@baskets_deletedorders);
547
545
548
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
549
    my $es_conf = Koha::SearchEngine::Elasticsearch->new({index=>'biblios'})->get_elasticsearch_params();
550
    my $es_url;
551
    my $es_record;
552
    foreach my $es_node ( @{$es_conf->{nodes}} ){
553
        $es_url = "http://".$es_node."/".$es_conf->{index_name}."/data/$biblionumber";
554
        $es_record = get($es_url);
555
        last if defined $es_record; #can quit once we find the record (should be same in any node)
556
    }
557
    $template->param( esrecord => $es_record );
558
}
559
560
output_html_with_http_headers $query, $cookie, $template->output;
546
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/showelastic.pl (+64 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Koha library project  www.koha-community.org
4
5
# Copyright 2007 Liblime
6
# Parts copyright 2010 BibLibre
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it under the
11
# terms of the GNU General Public License as published by the Free Software
12
# Foundation; either version 3 of the License, or (at your option) any later
13
# version.
14
#
15
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License along
20
# with Koha; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23
use Modern::Perl;
24
25
# standard or CPAN modules used
26
use CGI qw(:standard -utf8);
27
use DBI;
28
use Encode;
29
30
# Koha modules used
31
use C4::Context;
32
use C4::Output;
33
use C4::Auth;
34
use C4::Biblio;
35
use C4::ImportBatch;
36
use C4::XSLT ;
37
use Koha::SearchEngine::Elasticsearch;
38
use LWP::Simple qw/get/;
39
40
my $input= new CGI;
41
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42
  {
43
    template_name   => "catalogue/showelastic.tt",
44
    query           => $input,
45
    type            => "intranet",
46
    authnotrequired => 0,
47
    flagsrequired   => { catalogue => 1  },
48
    debug           => 1,
49
  }
50
);
51
52
my $biblionumber = $input->param('id');
53
54
my $es_conf = Koha::SearchEngine::Elasticsearch->new({index=>'biblios'})->get_elasticsearch_params();
55
my $es_url;
56
my $es_record;
57
58
foreach my $es_node ( @{$es_conf->{nodes}} ){
59
    $es_url = "http://".$es_node."/".$es_conf->{index_name}."/data/$biblionumber";
60
    $es_record = get($es_url);
61
}
62
63
$template->param( esrecord => $es_record);
64
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-30 / +34 lines)
Lines 97-103 Link Here
97
                    [% END %]
97
                    [% END %]
98
                    </span>
98
                    </span>
99
        [% END %]
99
        [% END %]
100
        <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC Preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
100
101
        <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC Preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]&amp;viewas=html " title="MARC" class="previewMARC">Show</a></span>
102
103
        [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
104
            <span id="catalogue_detail_elastic_record" class="results_summary"><span class="label">Elasticsearch Record :</span> <a href="/cgi-bin/koha/catalogue/showelastic.pl?id=[% biblionumber | uri %]" title="ELASTIC" class="previewElastic">Show</a></span>
105
        [% END %]
101
106
102
        [% IF ( holdcount ) %]
107
        [% IF ( holdcount ) %]
103
            <span class="results_summary">
108
            <span class="results_summary">
Lines 169-175 Link Here
169
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
174
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
170
    <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
175
    <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
171
[% END %]
176
[% END %]
172
[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]<li><a href="#esrecord" id="estab">Elasticsearch Record</a></li>[% END %]
173
</ul>
177
</ul>
174
178
175
[% items_table_block_iter = 0 %]
179
[% items_table_block_iter = 0 %]
Lines 699-716 Link Here
699
    </div>
703
    </div>
700
[% END %]
704
[% END %]
701
705
702
[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
703
    <div id="esrecord" class="esrecord">
704
        <div esid="[% biblionumber %]"></div>
705
        [% IF esrecord %]
706
            <p>[% esrecord %]</p>
707
            <script type="application/json" id="stuff">[% (esrecord) %]</script>
708
        [% ELSE %]
709
            <p>"This record was not found in the ES index"</p>
710
        [% END %]
711
    </div>
712
[% END %]
713
714
</div><!-- /bibliodetails -->
706
</div><!-- /bibliodetails -->
715
707
716
<div id="export" style="margin-top: 1em;">
708
<div id="export" style="margin-top: 1em;">
Lines 749-754 Link Here
749
    </div>
741
    </div>
750
</div>
742
</div>
751
743
744
<div id="elasticPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="elasticPreviewLabel" aria-hidden="true">
745
    <div class="modal-dialog modal-lg">
746
    <div class="modal-content">
747
    <div class="modal-header">
748
        <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
749
        <h3 id="elasticPreviewLabel">Elastic record</h3>
750
    </div>
751
    <div class="modal-body">
752
        <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
753
    </div>
754
    <div class="modal-footer">
755
        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
756
    </div>
757
    </div>
758
    </div>
759
</div>
760
752
            </main>
761
            </main>
753
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
762
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
754
763
Lines 932-941 Link Here
932
                var page = $(this).attr("href");
941
                var page = $(this).attr("href");
933
                $("#marcPreview .modal-body").load(page + " table");
942
                $("#marcPreview .modal-body").load(page + " table");
934
                $('#marcPreview').modal({show:true});
943
                $('#marcPreview').modal({show:true});
944
935
            });
945
            });
936
            $("#marcPreview").on("hidden.bs.modal", function(){
946
937
                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
947
           [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
948
            $("body").on("click",".previewElastic", function(event){
949
                event.preventDefault();
950
                let pageElastic = $(this).attr("href");
951
                $("#elasticPreview .modal-body").load(pageElastic);
952
                $('#elasticPreview').modal({show:true});
938
            });
953
            });
954
            [% END %]
955
939
            [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
956
            [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
940
                novSelect.loadContentForQuery({
957
                novSelect.loadContentForQuery({
941
                    ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
958
                    ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
Lines 957-976 Link Here
957
            verify_images();
974
            verify_images();
958
        });[% END %]
975
        });[% END %]
959
976
960
        [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && 1==0 %]
961
            function ESRecord (biblionumber) {
962
                $.getJSON("http://localhost:9200/koha_kohadev_biblios/data/", biblionumber, function( data ){
963
                    $.each( data, function( key, val ) {
964
                         console.log("key "+key+"val "+val);
965
                    });
966
                });
967
            }
968
            $(document).ready( function(){
969
                var esid = [% biblionumber %];
970
                ESRecord( esid );
971
            });
972
        [% END %]
973
974
    </script>
977
    </script>
975
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
978
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
976
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
979
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
Lines 1017-1021 Link Here
1017
            [% END %]
1020
            [% END %]
1018
        });
1021
        });
1019
    </script>
1022
    </script>
1023
1020
[% END %]
1024
[% END %]
1021
[% INCLUDE 'intranet-bottom.inc' %]
1025
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt (-1 / +35 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Cataloging &rsaquo; MARC import</title>
3
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
</head>
5
<body id="catalog_showelastic" class="catalog">
6
    <pre id="main" style="direction: ltr;">
7
8
    </pre>
9
</body>
10
<footer>
11
    <style>
12
        textarea
13
        {
14
            width: 100%;
15
            min-height: 40em;
16
            background-color : white;
17
            resize:none;
18
        }
19
    </style>
20
    <script>
21
22
        display();
23
24
        function display() {
25
            let myJSON = JSON.stringify([% esrecord %], null, '\t');
26
            let decode = decodeURIComponent(escape(myJSON));
27
            let para = document.createElement('textarea');
28
            para.disabled="yes";
29
            para.textContent = decode;
30
            document.getElementById('main').appendChild(para);
31
        }
32
33
    </script>
34
</footer>
35
</html>

Return to bug 18829