Bug 20484: (RM follow-up) Highlight ES disablement
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / searchengine / elasticsearch / mappings.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% PROCESS 'i18n.inc' %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Administration &rsaquo; Search engine configuration (Elasticsearch)</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
8 <script>
9     function clean_line( line ) {
10         $(line).find('input[type="text"]').val("");
11         $(line).find('select').find('option:first').attr("selected", "selected");
12     }
13
14     function clone_line( line ) {
15         var new_line = $(line).clone();
16         $(new_line).removeClass("nodrag nodrop");
17         $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete"));
18         $(new_line).find('[data-id]').each( function() {
19             $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
20         } );
21         $(new_line).find("select").each( function() {
22             var attr = $(this).attr('name');
23             var val = $(line).find('[data-id="' + attr + '"]').val();
24             $(this).find('option[value="' + val + '"]').attr("selected", "selected");
25         } );
26         return new_line;
27     }
28
29     $(document).ready(function() {
30         $("#tabs").tabs();
31         $('.delete').click(function() {
32             $(this).parents('tr').remove();
33         });
34
35         $("table.mappings").tableDnD( {
36             onDragClass: "dragClass",
37         } );
38         $('.add').click(function() {
39             var table = $(this).closest('table');
40             var index_name   = $(table).attr('data-index_name');
41             var line = $(this).closest("tr");
42             var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
43             if ( marc_field.length > 0 ) {
44                 var new_line = clone_line( line );
45                 new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody'));
46                 $('.delete').click(function() {
47                     $(this).parents('tr').remove();
48                 });
49                 clean_line(line);
50
51                 $(table).tableDnD( {
52                     onDragClass: "dragClass",
53                 } );
54             }
55         });
56         $("#facet_biblios > table").tableDnD( {
57             onDragClass: "dragClass",
58         } );
59     });
60 </script>
61 <style>
62 a.add, a.delete {
63     cursor: pointer;
64 }
65 </style>
66 </head>
67 <body id="admin_searchengine_mappings" class="admin">
68 [% INCLUDE 'header.inc' %]
69 [% INCLUDE 'prefs-admin-search.inc' %]
70
71 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Search engine configuration (Elasticsearch)</div>
72
73 [% INCLUDE 'blocking_errors.inc' %]
74
75 <div class="main container-fluid">
76     <div class="row">
77         <div class="col-sm-10 col-sm-push-2">
78             <main>
79
80     [% FOR m IN messages %]
81       <div class="dialog [% m.type | html %]">
82         [% SWITCH m.code %]
83         [% CASE 'error_on_update' %]
84           [% tx("An error occurred when updating mappings: {message}.", { message = m.message }) | html %]
85         [% CASE 'error_on_delete' %]
86           [% t("An error occurred when deleting the existing mappings. Nothing has been changed!") | $raw %]
87           [% tx("(search field {field_name} with mapping {marc_field}.)", { field_name = m.values.field_name, marc_field = m.values.marc_field }) | html %]
88         [% CASE 'invalid_field_weight' %]
89           [% tx("Invalid field weight '{weight}', must be a positive decimal number.", { weight = m.weight }) | html %]
90         [% CASE 'error_on_update_es_mappings' %]
91           [% tx("An error occurred when updating Elasticsearch index mappings: {message}.", { message = m.message }) | html %]
92         [% CASE 'reindex_required' %]
93           [% tx("Index '{index}' needs to be reindexed.", { index = m.index }) | html %]
94         [% CASE 'recreate_required' %]
95           [% tx("Index '{index}' needs to be recreated.", { index = m.index }) | html %]
96         [% CASE 'success_on_update' %]
97           [% t("Mappings updated successfully.") | $raw %]
98         [% CASE 'success_on_reset' %]
99           [% t("Mappings have been reset successfully.") | $raw %]
100         [% CASE 'elasticsearch_disabled' %]
101           [% t("Elasticsearch is currently disabled.") | $raw %]
102         [% CASE %]
103           [% m.code | html %]
104         [% END %]
105       </div>
106     [% END %]
107
108     <h1>Search engine configuration (Elasticsearch)</h1>
109     <div class="dialog message">
110         Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
111
112         <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
113         <strong>Note that fields weighting works only for simple search.</strong></p>
114         <ol>
115           <li>only search fields mapped with biblios can be weighted</li>
116           <li>search will boost/increase weighted field(s) relevancy</li>
117         </ol>
118     </div>
119     [% IF errors %]
120         <div class="dialog alert">
121         Changes have not been applied. Please check the following values:
122           <ul>
123             [% FOREACH e IN errors %]
124                 <li>
125                     [% IF ( e.type == "malformed_mapping" ) %]
126                         <span>The value "[% e.value | html %]" is not supported for mappings</span>
127                     [% ELSIF ( e.type == "no_mapping" ) %]
128                         <span>There is no mapping for the index [% e.value | html %]</span>
129                     [% END %]
130                 </li>
131             [% END %]
132           </ul>
133         </div>
134     [% END %]
135
136     [% IF reset_confirm %]
137         <div class="dialog alert">
138             <h3>The current mappings you see on the screen will be erased and replaced by the mappings in the mappings.yaml file.</h3>
139             <form method="post">
140                 <input type="hidden" name="op" value="reset_confirmed" />
141                 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, reset mappings</button>
142             </form>
143             <br>
144             <form method="post">
145                 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not reset mappings</button>
146             </form>
147         </div>
148     [% END %]
149     <form method="post">
150         <div id="tabs" class="toptabs" style="clear:both">
151             <ul>
152                 <li><a href="#search_fields">Search fields</a></li>
153                 [% FOREACH index IN indexes %]
154                     [% SWITCH index.index_name %]
155                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Bibliographic records</a></li>
156                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
157                     [% END %]
158                 [% END %]
159             </ul>
160             <div id="search_fields">
161               <table class="search_fields">
162                 <thead>
163                   <tr>
164                     <th>Name</th>
165                     <th>Label</th>
166                     <th>Type</th>
167                     <th colspan="2">Searchable</th>
168                     <th>Weight</th>
169                   </tr>
170                   <tr>
171                     <th colspan=3>&nbsp;</th>
172                     <th>Staff client</th>
173                     <th>OPAC</th>
174                     <th>&nbsp;</th>
175                   </tr>
176                 </thead>
177                 <tbody>
178                   [% FOREACH search_field IN all_search_fields %]
179                     <tr>
180                       <td>
181                         <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
182                       </td>
183                       <td>
184                         <input type="text" name="search_field_label" value="[% search_field.label | html %]" />
185                       </td>
186                       <td>
187                         <select name="search_field_type">
188                           <option value=""></option>
189                           [% IF search_field.type == "string" %]
190                             <option value="string" selected="selected">String</option>
191                           [% ELSE %]
192                             <option value="string">String</option>
193                           [% END %]
194                           [% IF search_field.type == "date" %]
195                             <option value="date" selected="selected">Date</option>
196                           [% ELSE %]
197                             <option value="date">Date</option>
198                           [% END %]
199                           [% IF search_field.type == "number" %]
200                             <option value="number" selected="selected">Number</option>
201                           [% ELSE %]
202                             <option value="number">Number</option>
203                           [% END %]
204                           [% IF search_field.type == "boolean" %]
205                             <option value="boolean" selected="selected">Boolean</option>
206                           [% ELSE %]
207                             <option value="boolean">Boolean</option>
208                           [% END %]
209                           [% IF search_field.type == "sum" %]
210                             <option value="sum" selected="selected">Sum</option>
211                           [% ELSE %]
212                             <option value="sum">Sum</option>
213                           [% END %]
214                           [% IF search_field.type == "isbn" %]
215                             <option value="isbn" selected="selected">ISBN</option>
216                           [% ELSE %]
217                             <option value="isbn">ISBN</option>
218                           [% END %]
219                           [% IF search_field.type == "stdno" %]
220                             <option value="stdno" selected="selected">Std. Number</option>
221                           [% ELSE %]
222                             <option value="stdno">Std. Number</option>
223                           [% END %]
224                         </select>
225                       </td>
226                       <td>
227                         <select name="search_field_staff_client">
228                           [% IF search_field.staff_client %]
229                             <option value="1" selected="selected">Yes</option>
230                             <option value="0">No</option>
231                           [% ELSE %]
232                             <option value="1">Yes</option>
233                             <option value="0" selected="selected">No</option>
234                           [% END %]
235                         </select>
236                       </td>
237                       <td>
238                         <select name="search_field_opac">
239                           [% IF search_field.opac %]
240                             <option value="1" selected="selected">Yes</option>
241                             <option value="0">No</option>
242                           [% ELSE %]
243                             <option value="1">Yes</option>
244                             <option value="0" selected="selected">No</option>
245                           [% END %]
246                         </select>
247                       </td>
248                       <td>
249                         [% IF search_field.mapped_biblios %]
250                             <input type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" />
251                         [% ELSE %]
252                             <input type="hidden" name="search_field_weight" value="">
253                         [% END %]
254                       </td>
255                     </tr>
256                   [% END %]
257                 </tbody>
258               </table>
259             </div>
260             [% FOREACH index IN indexes %]
261                 <div id="mapping_[% index.index_name | html %]">
262                     <table class="mappings" data-index_name="[% index.index_name | html %]">
263                       <thead>
264                         <tr class="nodrag nodrop">
265                           <th>Search field</th>
266                           <th>Sortable</th>
267                           <th>Facetable</th>
268                           <th>Suggestible</th>
269                           <th>Searchable</th>
270                           <th>Mapping</th>
271                           <th></th>
272                         </tr>
273                       </thead>
274                       <tbody>
275                         [% FOREACH mapping IN index.mappings %]
276                           <tr>
277                             <td>
278                               <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
279                               <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
280                               [% mapping.search_field_label | html %]
281                             </td>
282                             <td>
283                               <select name="mapping_sort">
284                                 [% IF mapping.sort == 'undef' %]
285                                   <option value="undef" selected="selected">Undef</option>
286                                 [% ELSE %]
287                                   <option value="undef">Undef</option>
288                                 [% END %]
289                                 [% IF mapping.sort == 0 %]
290                                   <option value="0" selected="selected">0</option>
291                                 [% ELSE %]
292                                   <option value="0">0</option>
293                                 [% END %]
294                                 [% IF  mapping.sort == 1 %]
295                                   <option value="1" selected="selected">1</option>
296                                 [% ELSE %]
297                                   <option value="1">1</option>
298                                 [% END %]
299                               </select>
300                             </td>
301                             <td>
302                               [% IF mapping.is_facetable %]
303                                 <select name="mapping_facet">
304                                   [% IF mapping.facet %]
305                                     <option value="0">No</option>
306                                     <option value="1" selected="selected">Yes</option>
307                                   [% ELSE %]
308                                     <option value="0" selected="selected">No</option>
309                                     <option value="1">Yes</option>
310                                   [% END %]
311                                 </select>
312                               [% ELSE %]
313                                 <input type="hidden" name="mapping_facet" value="0" />
314                                 No
315                               [% END %]
316                             </td>
317                             <td>
318                               <select name="mapping_suggestible">
319                                 [% IF mapping.suggestible %]
320                                   <option value="0">No</option>
321                                   <option value="1" selected="selected">Yes</option>
322                                 [% ELSE %]
323                                   <option value="0" selected="selected">No</option>
324                                   <option value="1">Yes</option>
325                                 [% END %]
326                               </select>
327                             </td>
328                             <td>
329                               <select name="mapping_search">
330                                 [% IF mapping.search %]
331                                   <option value="0">No</option>
332                                   <option value="1" selected="selected">Yes</option>
333                                 [% ELSE %]
334                                   <option value="0" selected="selected">No</option>
335                                   <option value="1">Yes</option>
336                                 [% END %]
337                               </select>
338                             </td>
339                             <td>
340                                 <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
341                             </td>
342                             <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
343                           </tr>
344                         [% END %]
345                       </tbody>
346                       <tfoot>
347                         <tr class="nodrag nodrop">
348                           <td>
349                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
350                             <select data-id="mapping_search_field_name">
351                              [% FOREACH f IN all_search_fields %]
352                                <option value="[% f.name | html %]">[% f.name | html %]</option>
353                              [% END %]
354                             </select>
355                           </td>
356                           <td>
357                             <select data-id="mapping_sort">
358                               <option value="undef">Undef</option>
359                               <option value="0">0</option>
360                               <option value="1">1</option>
361                             </select>
362                           </td>
363                           <td>
364                             <select data-id="mapping_facet">
365                               [% IF mapping.facet %]
366                                 <option value="0">No</option>
367                                 <option value="1" selected="selected">Yes</option>
368                               [% ELSE %]
369                                 <option value="0" selected="selected">No</option>
370                                 <option value="1">Yes</option>
371                               [% END %]
372                             </select>
373                           </td>
374                           <td>
375                             <select data-id="mapping_suggestible">
376                               [% IF mapping.suggestible %]
377                                 <option value="0">No</option>
378                                 <option value="1" selected="selected">Yes</option>
379                               [% ELSE %]
380                                 <option value="0" selected="selected">No</option>
381                                 <option value="1">Yes</option>
382                               [% END %]
383                             </select>
384                           </td>
385                           <td>
386                             <select data-id="mapping_search">
387                               [% IF mapping.search %]
388                                 <option value="0">No</option>
389                                 <option value="1" selected="selected">Yes</option>
390                               [% ELSE %]
391                                 <option value="0" selected="selected">No</option>
392                                 <option value="1">Yes</option>
393                               [% END %]
394                             </select>
395                           </td>
396                           <td><input data-id="mapping_marc_field" type="text" /></td>
397                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
398                         </tr>
399                       </tfoot>
400                     </table>
401
402                     [% IF index.index_name == 'biblios' %]
403                         <h3>Facet order</h3>
404                         <div id="facet_[% index.index_name | html %]">
405                             <table>
406                                 <thead>
407                                     <tr>
408                                         <th>Search field</th>
409                                         <th>Label</th>
410                                         <th>Display</th>
411                                     </tr>
412                                 </thead>
413                                 <tbody>
414                                     [% FOREACH f IN facetable_fields %]
415                                         <tr>
416                                             <td>
417                                                 [% f.name | html %]
418                                             </td>
419                                             <td>
420                                                 [% SWITCH f.name %]
421                                                 [% CASE 'author' %]Authors
422                                                 [% CASE 'itype' %]Item Types
423                                                 [% CASE 'location' %]Locations
424                                                 [% CASE 'su-geo' %]Places
425                                                 [% CASE 'title-series' %]Series
426                                                 [% CASE 'subject' %]Topics
427                                                 [% CASE 'ccode' %]Collections
428                                                 [% CASE 'holdingbranch' %]Holding libraries
429                                                 [% CASE 'homebranch' %]Home libraries
430                                                 [% CASE 'ln' %]Language
431                                                 [% CASE %][% f | html %]
432                                                 [% END %]
433                                             </td>
434                                             <td>
435                                                 [% IF f.facet_order %]
436                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" checked="checked" />
437                                                 [% ELSE %]
438                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" />
439                                                 [% END %]
440                                             </td>
441                                         </tr>
442                                     [% END %]
443                                 </tbody>
444                             </table>
445                         </div>
446                     [% END %]
447                 </div>
448             [% END %]
449         </div>
450         <p>
451             <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
452             <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
453         </p>
454     </form>
455
456             </main>
457         </div> <!-- /.col-sm-10.col-sm-push-2 -->
458
459         <div class="col-sm-2 col-sm-pull-10">
460             <aside>
461                 [% INCLUDE 'admin-menu.inc' %]
462             </aside>
463         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
464      </div> <!-- /.row -->
465
466 [% INCLUDE 'intranet-bottom.inc' %]