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

(-)a/catalogue/showelastic.pl (+76 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Koha library project  www.koha-community.org
4
5
# Copyright 2020 Koha Development Team
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it
10
# under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# Koha is distributed in the hope that it will be useful, but
15
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
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
use JSON;
30
use Try::Tiny;
31
32
# Koha modules used
33
use C4::Context;
34
use C4::Output;
35
use C4::Auth;
36
use C4::Biblio;
37
use C4::ImportBatch;
38
use C4::XSLT ;
39
use Koha::SearchEngine::Elasticsearch;
40
use LWP::Simple qw/get/;
41
42
my $input= new CGI;
43
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44
  {
45
    template_name   => "catalogue/showelastic.tt",
46
    query           => $input,
47
    type            => "intranet",
48
    flagsrequired   => { catalogue => 1  },
49
    debug           => 1,
50
  }
51
);
52
53
my $biblionumber = $input->param('id');
54
55
my $es = Koha::SearchEngine::Elasticsearch->new({index=>'biblios'});
56
57
my $es_record;
58
my @es_fields;
59
60
try {
61
    $es_record = $es->get_elasticsearch()->get({
62
        index => $es->index_name,
63
        type  => 'data',
64
        id    => $biblionumber,
65
    });
66
}
67
catch{
68
    @es_fields = ("Error fetching record: see logs for details");
69
    warn $_;
70
};
71
72
for my $field (sort keys %{$es_record} ){
73
    push @es_fields, { $field, $es_record->{$field} };
74
};
75
$template->param( esrecord => to_json( \@es_fields ) );
76
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +32 lines)
Lines 115-120 Link Here
115
        [% END %]
115
        [% END %]
116
        <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>
116
        <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>
117
117
118
        [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
119
            <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>
120
        [% END %]
121
118
        [% IF ( holdcount ) %]
122
        [% IF ( holdcount ) %]
119
            <span class="results_summary">
123
            <span class="results_summary">
120
                <span class="label">Holds:</span>
124
                <span class="label">Holds:</span>
Lines 933-938 Note that permanent location is a code, and location may be an authval. Link Here
933
    </div>
937
    </div>
934
</div>
938
</div>
935
939
940
<div id="elasticPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="elasticPreviewLabel" aria-hidden="true">
941
    <div class="modal-dialog modal-lg">
942
    <div class="modal-content">
943
    <div class="modal-header">
944
        <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
945
        <h3 id="elasticPreviewLabel">Elastic record</h3>
946
    </div>
947
    <div class="modal-body">
948
        <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
949
    </div>
950
    <div class="modal-footer">
951
        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
952
    </div>
953
    </div>
954
    </div>
955
</div>
956
936
            </main>
957
            </main>
937
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
958
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
938
959
Lines 1169-1178 Note that permanent location is a code, and location may be an authval. Link Here
1169
                var page = $(this).attr("href");
1190
                var page = $(this).attr("href");
1170
                $("#marcPreview .modal-body").load(page + " table");
1191
                $("#marcPreview .modal-body").load(page + " table");
1171
                $('#marcPreview').modal({show:true});
1192
                $('#marcPreview').modal({show:true});
1193
1172
            });
1194
            });
1173
            $("#marcPreview").on("hidden.bs.modal", function(){
1195
1174
                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1196
           [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
1197
            $("body").on("click",".previewElastic", function(e){
1198
                e.preventDefault();
1199
                var pageElastic = $(this).attr("href");
1200
                $("#elasticPreview .modal-body").load(pageElastic);
1201
                $('#elasticPreview').modal({show:true});
1175
            });
1202
            });
1203
           [% END %]
1204
1176
            [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1205
            [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1177
                novSelect.loadContentForQuery({
1206
                novSelect.loadContentForQuery({
1178
                    ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
1207
                    ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
Lines 1265-1269 Note that permanent location is a code, and location may be an authval. Link Here
1265
            [% END %]
1294
            [% END %]
1266
        });
1295
        });
1267
    </script>
1296
    </script>
1297
1268
[% END %]
1298
[% END %]
1269
[% INCLUDE 'intranet-bottom.inc' %]
1299
[% 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
[% USE raw %]
3
<title>Koha &rsaquo; Cataloging &rsaquo; MARC import</title>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
</head>
6
<body id="catalog_showelastic" class="catalog">
7
    <pre id="main" style="direction: ltr;">
8
9
    </pre>
10
</body>
11
<footer>
12
    <style>
13
        textarea
14
        {
15
            width: 100%;
16
            min-height: 40em;
17
            background-color : white;
18
            resize:none;
19
        }
20
    </style>
21
    <script>
22
        display();
23
24
        function display() {
25
            let myJSON = JSON.stringify([% esrecord | $raw %], 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