@@ -, +, @@ functions code needs some refactoring before this option can be implemented --- admin/searchengine/elasticsearch/mappings.pl | 21 +++++++++++++++------ debian/scripts/koha-create | 3 +++ debian/templates/koha-conf-site.xml.in | 4 ++++ .../admin/searchengine/elasticsearch/mappings.tt | 21 ++++++++++++++++++++- 4 files changed, 42 insertions(+), 7 deletions(-) --- a/admin/searchengine/elasticsearch/mappings.pl +++ a/admin/searchengine/elasticsearch/mappings.pl @@ -37,6 +37,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $index = $input->param('index') || 'biblios'; my $op = $input->param('op') || 'list'; +my $action = $input->param('action') || ''; my @messages; my $database = Koha::Database->new(); @@ -97,12 +98,19 @@ if ( $op eq 'edit' ) { $schema->storage->txn_commit; } } -elsif( $op eq 'reset' ) { - # TODO Move this feature to the interface - my $sure = $input->param('i_know_what_i_am_doing'); - if ( $sure ) { - Koha::SearchMarcMaps->search->delete; - Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; +elsif( $op eq 'admin') { + if( $input->param('admin_password') eq C4::Context->config('elasticsearch_admin_password') ){ + if ( $action eq 'reset' ) { + Koha::SearchMarcMaps->search->delete; + Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; + $template->param( mappings_reset = 1 ); + } + elsif ( $action eq 'reindex' ) { + #TODO reindex needs some refactorig to allow this option + } + } + else { + $template->param( admin_badpassword => 1 ); } } @@ -139,6 +147,7 @@ $template->param( indexes => \@indexes, all_search_fields => \@all_search_fields, messages => \@messages, + show_admin_options => C4::Context->config('elasticsearch_admin_password') ? 1 : 0, ); output_html_with_http_headers $input, $cookie, $template->output; --- a/debian/scripts/koha-create +++ a/debian/scripts/koha-create @@ -106,6 +106,7 @@ generate_config_file() { -e "s/__START_AUTHORITIES_RETRIEVAL_INFO__/`echo $START_AUTHORITIES_RETRIEVAL_INFO`/g" \ -e "s/__END_AUTHORITIES_RETRIEVAL_INFO__/`echo $END_AUTHORITIES_RETRIEVAL_INFO`/g" \ -e "s/__API_SECRET__/$API_SECRET/g" \ + -e "s/__ES_ADMIN_PASSWORD__/$ES_ADMIN_PASSWORD/g" \ -e "s/__DB_NAME__/$mysqldb/g" \ -e "s/__DB_HOST__/$mysqlhost/g" \ -e "s/__DB_USER__/$mysqluser/g" \ @@ -406,6 +407,8 @@ UPLOAD_DIR="uploads" UPLOAD_PATH="" # Generate a randomizaed API secret API_SECRET="$(pwgen -s 64 1)" +# Generate a randomizaed ES Admin Password secret +ES_ADMIN_PASSWORD="$(pwgen -s 16 1)" # SRU server variables ENABLE_SRU="no" SRU_SERVER_PORT="" --- a/debian/templates/koha-conf-site.xml.in +++ a/debian/templates/koha-conf-site.xml.in @@ -326,6 +326,10 @@ __END_SRU_PUBLICSERVER__ localhost:9200 koha___KOHASITE__ + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Elastic Search mappings [% INCLUDE 'doc-head-close.inc' %] @@ -88,7 +89,25 @@ a.add, a.delete {

Search engine configuration

- Warning: Any modification in these configurations will need a total reindexation to be fully taken into account ! + Warning: Any modification in these configurations will need a total reindexation to be fully taken into account !
+ [% IF (show_admin_options) %] + [% IF (admin_badpassword) %]

The password you entered was incorrect!

[% END %] + [% IF (reindex_launched) %]

A rebuild has been started

+ [% ELSIF (mappings_reset) %]

Mappings have been reset

+ [% ELSE %] +

+
[% IF errors %]
--