Bugzilla – Attachment 89248 Details for
Bug 18829
Elasticsearch - Add ability to view the ES indexed record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18829: Elasticsearch - Put a better display for the view of ES indexed record
Bug-18829-Elasticsearch---Put-a-better-display-for.patch (text/plain), 10.90 KB, created by
axel Amghar
on 2019-05-02 14:55:13 UTC
(
hide
)
Description:
Bug 18829: Elasticsearch - Put a better display for the view of ES indexed record
Filename:
MIME Type:
Creator:
axel Amghar
Created:
2019-05-02 14:55:13 UTC
Size:
10.90 KB
patch
obsolete
>From ec9478d5be59175fb941c2a73ee8b80ca209f1e8 Mon Sep 17 00:00:00 2001 >From: Axel Amghar <axel.amghar@gmail.com> >Date: Tue, 30 Apr 2019 14:55:11 +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 "ElsaticSearch" as value >- Search whatever you want in Search the catalog and select a notice >- 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/detail.pl | 14 ----- > catalogue/showelastic.pl | 64 ++++++++++++++++++++++ > .../prog/en/modules/catalogue/detail.tt | 64 ++++++++++++---------- > .../prog/en/modules/catalogue/showelastic.tt | 35 ++++++++++++ > 4 files changed, 133 insertions(+), 44 deletions(-) > create mode 100755 catalogue/showelastic.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index b446d6c..027ca52 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -46,8 +46,6 @@ use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; > use Koha::Virtualshelves; >-use LWP::Simple; >-use Koha::SearchEngine::Elasticsearch; > use Koha::Plugins; > > my $query = CGI->new(); >@@ -545,16 +543,4 @@ $template->param (countdeletedorders => $count_deletedorders_using_biblio); > $template->param (basketsorders => \@baskets_orders); > $template->param (basketsdeletedorders => \@baskets_deletedorders); > >-if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { >- 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); >- last if defined $es_record; #can quit once we find the record (should be same in any node) >- } >- $template->param( esrecord => $es_record ); >-} >- > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/catalogue/showelastic.pl b/catalogue/showelastic.pl >new file mode 100755 >index 0000000..17e6fc9 >--- /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 3f13207..b24d843 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 %] > </span> > [% END %] >- <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 %]&viewas=html" title="MARC" class="previewMARC">Show</a></span> >+ >+ <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 %]&viewas=html " title="MARC" class="previewMARC">Show</a></span> >+ >+ [% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] >+ <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> >+ [% END %] > > [% IF ( holdcount ) %] > <span class="results_summary"> >@@ -169,7 +174,6 @@ > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %] > <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li> > [% END %] >-[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]<li><a href="#esrecord" id="estab">Elasticsearch Record</a></li>[% END %] > </ul> > > [% items_table_block_iter = 0 %] >@@ -699,18 +703,6 @@ > </div> > [% END %] > >-[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] >- <div id="esrecord" class="esrecord"> >- <div esid="[% biblionumber %]"></div> >- [% IF esrecord %] >- <p>[% esrecord %]</p> >- <script type="application/json" id="stuff">[% (esrecord) %]</script> >- [% ELSE %] >- <p>"This record was not found in the ES index"</p> >- [% END %] >- </div> >-[% END %] >- > </div><!-- /bibliodetails --> > > <div id="export" style="margin-top: 1em;"> >@@ -749,6 +741,23 @@ > </div> > </div> > >+<div id="elasticPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="elasticPreviewLabel" aria-hidden="true"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="elasticPreviewLabel">Elastic record</h3> >+ </div> >+ <div class="modal-body"> >+ <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> >+ </div> >+</div> >+ > </main> > </div> <!-- /.col-sm-10.col-sm-push-2 --> > >@@ -932,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("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>"); >+ >+ [% 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 %]', >@@ -957,20 +974,6 @@ > verify_images(); > });[% END %] > >- [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && 1==0 %] >- function ESRecord (biblionumber) { >- $.getJSON("http://localhost:9200/koha_kohadev_biblios/data/", biblionumber, function( data ){ >- $.each( data, function( key, val ) { >- console.log("key "+key+"val "+val); >- }); >- }); >- } >- $(document).ready( function(){ >- var esid = [% biblionumber %]; >- ESRecord( esid ); >- }); >- [% END %] >- > </script> > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %] > <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script> >@@ -1017,5 +1020,6 @@ > [% END %] > }); > </script> >+ > [% 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 0000000..5abdd1f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/showelastic.tt >@@ -0,0 +1,35 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Cataloging › MARC import</title> >+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+</head> >+<body id="catalog_showelastic" class="catalog"> >+ <pre id="main" style="direction: ltr;"> >+ >+ </pre> >+</body> >+<footer> >+ <style> >+ textarea >+ { >+ width: 100%; >+ min-height: 40em; >+ background-color : white; >+ resize:none; >+ } >+ </style> >+ <script> >+ >+ display(); >+ >+ function display() { >+ let myJSON = JSON.stringify([% esrecord %], null, '\t'); >+ let decode = decodeURIComponent(escape(myJSON)); >+ let para = document.createElement('textarea'); >+ para.disabled="yes"; >+ para.textContent = decode; >+ document.getElementById('main').appendChild(para); >+ } >+ >+ </script> >+</footer> >+</html> >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18829
:
64456
|
89001
|
89007
|
89248
|
89249
|
89250
|
90370
|
108103
|
108104
|
108191
|
108944
|
108945
|
148757
|
148758
|
148759
|
148760
|
149400
|
149401
|
149402
|
149403
|
149404
|
149745