From 5c5ac7580dcaffcab4dcaac7a5dd274683acdeaf Mon Sep 17 00:00:00 2001 From: axel Amghar Date: Mon, 29 Apr 2019 11:27:49 +0200 Subject: [PATCH] Bug 18829: Elasticsearch - Put a better display for the view of ES indexed record To test: - apply the patch - go to global sysPref - make sure that SearchEngine have "ElasticSearch" as value - Search whatever you want in Search the catalog and select a record - Search the link (Ctrl f) : "Elasticsearch Record :" , click on the link - make sure that the pop-up open and you should see the elasticsearch result in JSON (the pop-up look the same as MARC preview) --- catalogue/showelastic.pl | 64 ++++++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 38 ++++++++++++- .../prog/en/modules/catalogue/showelastic.tt | 35 ++++++++++++ 3 files changed, 134 insertions(+), 3 deletions(-) create mode 100755 catalogue/showelastic.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt diff --git a/catalogue/showelastic.pl b/catalogue/showelastic.pl new file mode 100755 index 0000000000..17e6fc94ec --- /dev/null +++ b/catalogue/showelastic.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +# Koha library project www.koha-community.org + +# Copyright 2007 Liblime +# Parts copyright 2010 BibLibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +# standard or CPAN modules used +use CGI qw(:standard -utf8); +use DBI; +use Encode; + +# Koha modules used +use C4::Context; +use C4::Output; +use C4::Auth; +use C4::Biblio; +use C4::ImportBatch; +use C4::XSLT ; +use Koha::SearchEngine::Elasticsearch; +use LWP::Simple qw/get/; + +my $input= new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "catalogue/showelastic.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { catalogue => 1 }, + debug => 1, + } +); + +my $biblionumber = $input->param('id'); + +my $es_conf = Koha::SearchEngine::Elasticsearch->new({index=>'biblios'})->get_elasticsearch_params(); +my $es_url; +my $es_record; + +foreach my $es_node ( @{$es_conf->{nodes}} ){ + $es_url = "http://".$es_node."/".$es_conf->{index_name}."/data/$biblionumber"; + $es_record = get($es_url); +} + +$template->param( esrecord => $es_record); +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 6af2687453..4d5d71ba15 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -97,7 +97,12 @@ [% END %] [% END %] - MARC Preview: Show + + MARC Preview: Show + + [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] + Elasticsearch Record : Show + [% END %] [% IF ( holdcount ) %] @@ -736,6 +741,23 @@ + + @@ -919,10 +941,18 @@ var page = $(this).attr("href"); $("#marcPreview .modal-body").load(page + " table"); $('#marcPreview').modal({show:true}); + }); - $("#marcPreview").on("hidden.bs.modal", function(){ - $("#marcPreview .modal-body").html("
\"\" "+_("Loading")+"
"); + + [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] + $("body").on("click",".previewElastic", function(event){ + event.preventDefault(); + let pageElastic = $(this).attr("href"); + $("#elasticPreview .modal-body").load(pageElastic); + $('#elasticPreview').modal({show:true}); }); + [% END %] + [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %] novSelect.loadContentForQuery({ ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]', @@ -943,6 +973,7 @@ [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() { verify_images(); });[% END %] + [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %] @@ -989,5 +1020,6 @@ [% END %] }); + [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt new file mode 100644 index 0000000000..5abdd1ffc2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt @@ -0,0 +1,35 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Cataloging › MARC import + + + +
+
+    
+ + + -- 2.11.0