search.mako 146 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010
  1. ## Licensed to Cloudera, Inc. under one
  2. ## or more contributor license agreements. See the NOTICE file
  3. ## distributed with this work for additional information
  4. ## regarding copyright ownership. Cloudera, Inc. licenses this file
  5. ## to you under the Apache License, Version 2.0 (the
  6. ## "License"); you may not use this file except in compliance
  7. ## with the License. You may obtain a copy of the License at
  8. ##
  9. ## http://www.apache.org/licenses/LICENSE-2.0
  10. ##
  11. ## Unless required by applicable law or agreed to in writing, software
  12. ## distributed under the License is distributed on an "AS IS" BASIS,
  13. ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ## See the License for the specific language governing permissions and
  15. ## limitations under the License.
  16. <%!
  17. from desktop.views import commonheader, commonfooter, _ko
  18. from desktop import conf
  19. from django.utils.translation import ugettext as _
  20. %>
  21. <%namespace name="dashboard" file="common_dashboard.mako" />
  22. ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
  23. <script type="text/javascript">
  24. if (window.location.hash != "") {
  25. if (window.location.hash.indexOf("collection") > -1) {
  26. location.href = "/search/?" + window.location.hash.substr(1).replace(/(<([^>]+)>)/ig, "");
  27. }
  28. }
  29. SLIDER_LABELS = {
  30. STEP: "${_('Increment')}"
  31. }
  32. </script>
  33. <div class="search-bar" data-bind="visible: ! $root.isPlayerMode()">
  34. <div class="pull-right" style="padding-right:50px">
  35. <a class="btn pointer" title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}">
  36. <i class="fa fa-pencil"></i>
  37. </a>
  38. % if is_owner:
  39. <a class="btn pointer" title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: save, css: {'btn': true}, visible: columns().length != 0">
  40. <i class="fa fa-save"></i>
  41. </a>
  42. % endif
  43. <a class="btn pointer" title="${ _('Player mode') }" rel="tooltip" data-placement="bottom" data-bind="click: function(){ hueUtils.goFullScreen(); $root.isEditing(false); $root.isPlayerMode(true); }">
  44. <i class="fa fa-expand"></i>
  45. </a>
  46. &nbsp;&nbsp;&nbsp;
  47. <a class="btn pointer" title="${ _('General Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#settingsDemiModal"
  48. data-bind="css: {'btn': true}, visible: columns().length != 0">
  49. <i class="fa fa-cog"></i>
  50. </a>
  51. <a class="btn pointer" title="${ _('Query Definitions') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#qdefinitionsDemiModal"
  52. data-bind="css: {'btn': true}, visible: columns().length != 0">
  53. <i class="fa fa-bookmark-o"></i>
  54. </a>
  55. <span data-bind="visible: columns().length != 0">&nbsp;&nbsp;&nbsp;</span>
  56. <a class="btn" href="${ url('search:new_search') }" title="${ _('New') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
  57. <i class="fa fa-file-o"></i>
  58. </a>
  59. <a class="btn" href="${ url('search:admin_collections') }" title="${ _('Dashboards') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
  60. <i class="fa fa-tags"></i>
  61. </a>
  62. </div>
  63. <form data-bind="visible: $root.isEditing() && columns().length == 0">
  64. ${ _('Select a search index') }
  65. <!-- ko if: columns().length == 0 -->
  66. <select data-bind="options: $root.initial.collections, value: $root.collection.name, disable: isSyncingCollections">
  67. </select>
  68. <label class="checkbox" style="display:inline-block; margin-left: 10px">
  69. <input type="checkbox" data-bind="checked: showCores" />${ _('Show cores') }
  70. <i class="fa fa-spinner fa-spin" data-bind="visible: isSyncingCollections"></i>
  71. </label>
  72. <!-- /ko -->
  73. <select data-bind="options: $root.availableDateFields, value: collection.timeFilter.field, optionsValue: 'name', visible: $root.isEditing() && $root.availableDateFields().length > 0" class="input-medium" style="margin-left: 4px"></select>
  74. <span data-bind="template: {name: 'time-filter'}, visible: collection.timeFilter.type() == 'rolling'"></span>
  75. <span data-bind="template: {name: 'time-fixed-filter'}, visible: collection.timeFilter.type() == 'fixed'"></span>
  76. </form>
  77. <form class="form-search" style="margin: 0" data-bind="submit: searchBtn, visible: columns().length != 0">
  78. <strong>${_("Search")}</strong>
  79. <div class="input-append">
  80. <div class="selectMask">
  81. <span
  82. data-bind="editable: collection.label, editableOptions: {enabled: $root.isEditing(), placement: 'right'}">
  83. </span>
  84. </div>
  85. <span data-bind="foreach: query.qs">
  86. <input data-bind="clearable: q, valueUpdate:'afterkeydown', typeahead: { target: q, nonBindableSource: queryTypeahead, multipleValues: true, multipleValuesSeparator: ':', extraKeywords: 'AND OR TO', completeSolrRanges: true }, css:{'input-xlarge': $root.query.qs().length == 1, 'input-medium': $root.query.qs().length < 4, 'input-small': $root.query.qs().length >= 4}" maxlength="4096" type="text" class="search-query">
  87. <!-- ko if: $index() >= 1 -->
  88. <a class="btn" href="javascript:void(0)" data-bind="click: $root.query.removeQ"><i class="fa fa-minus"></i></a>
  89. <!-- /ko -->
  90. </span>
  91. <a class="btn" href="javascript:void(0)" data-bind="click: $root.query.addQ"><i class="fa fa-plus"></i></a>
  92. <button type="submit" id="search-btn" class="btn btn-inverse" style="margin-left:10px; margin-right:10px">
  93. <i class="fa fa-search" data-bind="visible: ! isRetrievingResults()"></i>
  94. <!--[if !IE]> --><i class="fa fa-spinner fa-spin" data-bind="visible: isRetrievingResults()"></i><!-- <![endif]-->
  95. <!--[if IE]><img src="${ static('desktop/art/spinner-inverted.gif') }" data-bind="visible: isRetrievingResults()"/><![endif]-->
  96. </button>
  97. </div>
  98. <span data-bind="template: {name: 'time-filter'}, visible: collection.timeFilter.type() == 'rolling'"></span>
  99. <span data-bind="template: {name: 'time-fixed-filter'}, visible: collection.timeFilter.type() == 'fixed'"></span>
  100. </form>
  101. </div>
  102. <%dashboard:layout_toolbar>
  103. <%def name="results()">
  104. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableResultset() },
  105. draggable: {data: draggableResultset(), isEnabled: availableDraggableResultset,
  106. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  107. 'stop': function(event, ui){$('.card-body').slideDown('fast'); $root.collection.template.isGridLayout(true); checkResultHighlightingAvailability(); }}}"
  108. title="${_('Grid')}" rel="tooltip" data-placement="top">
  109. <a data-bind="style: { cursor: $root.availableDraggableResultset() ? 'move' : 'default' }">
  110. <i class="fa fa-table"></i>
  111. </a>
  112. </div>
  113. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableResultset() },
  114. draggable: {data: draggableHtmlResultset(),
  115. isEnabled: availableDraggableResultset,
  116. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  117. 'stop': function(event, ui){
  118. $('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});
  119. $root.collection.template.isGridLayout(false);
  120. checkResultHighlightingAvailability();
  121. }
  122. }
  123. }"
  124. title="${_('HTML')}" rel="tooltip" data-placement="top">
  125. <a data-bind="style: { cursor: $root.availableDraggableResultset() ? 'move' : 'default' }">
  126. <i class="fa fa-code"></i>
  127. </a>
  128. </div>
  129. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableFilter() },
  130. draggable: {data: draggableFilter(), isEnabled: availableDraggableFilter,
  131. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  132. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  133. title="${_('Filter Bar')}" rel="tooltip" data-placement="top">
  134. <a data-bind="style: { cursor: $root.availableDraggableFilter() ? 'move' : 'default' }">
  135. <i class="fa fa-filter"></i>
  136. </a>
  137. </div>
  138. <div data-bind="visible: $root.isLatest,
  139. css: { 'draggable-widget': true, 'disabled': !availableDraggableNumbers() },
  140. draggable: {data: draggableCounter(), isEnabled: availableDraggableNumbers,
  141. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  142. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  143. title="${_('Counter')}" rel="tooltip" data-placement="top">
  144. <a data-bind="style: { cursor: $root.availableDraggableNumbers() ? 'move' : 'default' }">
  145. <i class="fa fa-superscript" style="font-size: 110%"></i>
  146. </a>
  147. </div>
  148. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableLeaflet()},
  149. draggable: {data: draggableLeafletMap(), isEnabled: availableDraggableLeaflet,
  150. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  151. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  152. title="${_('Marker Map')}" rel="tooltip" data-placement="top">
  153. <a data-bind="style: { cursor: 'move' }">
  154. <i class="fa fa-map-marker"></i>
  155. </a>
  156. </div>
  157. </%def>
  158. <%def name="widgets()">
  159. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
  160. draggable: {data: draggableFacet(), isEnabled: availableDraggableChart,
  161. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  162. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  163. title="${_('Text Facet')}" rel="tooltip" data-placement="top">
  164. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  165. <i class="fa fa-sort-amount-asc"></i>
  166. </a>
  167. </div>
  168. <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
  169. draggable: {data: draggablePie(), isEnabled: availableDraggableChart,
  170. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  171. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  172. title="${_('Pie Chart')}" rel="tooltip" data-placement="top">
  173. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  174. <i class="hcha hcha-pie-chart"></i>
  175. </a>
  176. </div>
  177. <div data-bind="visible: ! $root.isLatest(),
  178. css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
  179. draggable: {data: draggableBar(), isEnabled: availableDraggableChart,
  180. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  181. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  182. title="${_('Bar Chart')}" rel="tooltip" data-placement="top">
  183. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  184. <i class="hcha hcha-bar-chart"></i>
  185. </a>
  186. </div>
  187. <div data-bind="visible: ! $root.isLatest(),
  188. css: { 'draggable-widget': true, 'disabled': !availableDraggableNumbers() },
  189. draggable: {data: draggableLine(), isEnabled: availableDraggableNumbers,
  190. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  191. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  192. title="${_('Line Chart')}" rel="tooltip" data-placement="top">
  193. <a data-bind="style: { cursor: $root.availableDraggableNumbers() ? 'move' : 'default' }">
  194. <i class="hcha hcha-line-chart"></i>
  195. </a>
  196. </div>
  197. <div data-bind="visible: $root.isLatest(),
  198. css: { 'draggable-widget': true, 'disabled': ! availableDraggableChart() },
  199. draggable: {data: draggableBucket(), isEnabled: availableDraggableChart,
  200. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  201. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  202. title="${_('Chart')}" rel="tooltip" data-placement="top">
  203. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  204. <i class="hcha hcha-bar-chart"></i>
  205. </a>
  206. </div>
  207. <div data-bind="css: { 'draggable-widget': true, 'disabled': false },
  208. draggable: {data: draggableTree(), isEnabled: true,
  209. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  210. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  211. title="${_('Tree')}" rel="tooltip" data-placement="top">
  212. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  213. <i class="fa fa-sitemap fa-rotate-270"></i>
  214. </a>
  215. </div>
  216. <div data-bind="visible: ! $root.isLatest(),
  217. css: { 'draggable-widget': true, 'disabled': false },
  218. draggable: {data: draggableHeatmap(), isEnabled: true,
  219. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  220. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  221. title="${_('Heatmap')}" rel="tooltip" data-placement="top">
  222. <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
  223. <i class="fa fa-th"></i>
  224. </a>
  225. </div>
  226. <div data-bind="css: { 'draggable-widget': true, 'disabled': ! availableDraggableHistogram() },
  227. draggable: {data: draggableHistogram(), isEnabled: availableDraggableHistogram,
  228. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  229. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  230. title="${_('Timeline')}" rel="tooltip" data-placement="top">
  231. <a data-bind="style: { cursor: $root.availableDraggableHistogram() ? 'move' : 'default' }">
  232. <i class="hcha hcha-timeline-chart"></i>
  233. </a>
  234. </div>
  235. <div data-bind="css: { 'draggable-widget': true, 'disabled': ! availableDraggableMap() },
  236. draggable: {data: draggableMap(), isEnabled: availableDraggableMap,
  237. options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
  238. 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
  239. title="${_('Gradient Map')}" rel="tooltip" data-placement="top">
  240. <a data-bind="style: { cursor: $root.availableDraggableMap() ? 'move' : 'default' }">
  241. <i class="hcha hcha-map-chart"></i>
  242. </a>
  243. </div>
  244. </%def>
  245. </%dashboard:layout_toolbar>
  246. <div class="player-toolbar" data-bind="visible: $root.isPlayerMode">
  247. <div class="pull-right pointer" data-bind="visible: $root.isPlayerMode, click: function(){ hueUtils.exitFullScreen(); $root.isPlayerMode(false); }"><i class="fa fa-times"></i></div>
  248. <img src="${ static('desktop/art/icon_hue_48.png') }" />
  249. <h4 data-bind="text: collection.label"></h4>
  250. <form class="form-search" data-bind="submit: searchBtn">
  251. <span data-bind="foreach: query.qs">
  252. <input data-bind="clearable: q, valueUpdate:'afterkeydown', typeahead: { target: q, source: $root.collection.template.fieldsNames, multipleValues: true, multipleValuesSeparator: ':', extraKeywords: 'AND OR TO', completeSolrRanges: true }, css:{'input-xlarge': $root.query.qs().length == 1, 'input-medium': $root.query.qs().length < 4, 'input-small': $root.query.qs().length >= 4}" maxlength="4096" type="text" class="search-query">
  253. <!-- ko if: $parent.query.qs().length > 1 -->
  254. <div class="pointer muted link" data-bind="click: $root.query.removeQ"><i class="fa fa-minus"></i></div>
  255. <!-- /ko -->
  256. </span>
  257. <div class="pointer muted link" data-bind="click: $root.query.addQ"><i class="fa fa-plus"></i></div>
  258. <div class="pointer muted link" data-bind="click: $root.searchBtn"><i class="fa fa-search" data-bind="visible: ! isRetrievingResults()"></i></div>
  259. <!--[if !IE]> --><i class="fa fa-spinner fa-spin muted" data-bind="visible: isRetrievingResults()"></i><!-- <![endif]-->
  260. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" data-bind="visible: isRetrievingResults()"/><![endif]-->
  261. </form>
  262. </div>
  263. ${ dashboard.layout_skeleton() }
  264. <script type="text/html" id="empty-widget">
  265. ${ _('This is an empty widget.')}
  266. </script>
  267. <script type="text/html" id="facet-toggle">
  268. <div class="facet-field-tile">
  269. <div class="facet-field-cnt">
  270. <span class="facet-field-label facet-field-label-fixed-width facet-field-label-fixed-width-double facet-field-label-title">${ _('Settings') }</span>
  271. <!--[if !IE]> --><i class="fa fa-spinner fa-spin" data-bind="visible: $root.isRetrievingResults()"></i><!-- <![endif]-->
  272. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" data-bind="visible: $root.isRetrievingResults()"/><![endif]-->
  273. </div>
  274. <div class="facet-field-cnt" data-bind="visible: properties.canRange">
  275. <span class="facet-field-label facet-field-label-fixed-width">${ _('Type') }</span>
  276. <a href="javascript: void(0)" title="${ _('Toggle how to group the values') }" data-bind="click: $root.collection.toggleRangeFacet">
  277. <i class="fa" data-bind="css: { 'fa-arrows-h': type() == 'range', 'fa-circle': type() == 'field', 'fa-level-up': type() == 'range-up' }, attr: { title: type() == 'field' ? 'Range' : type() == 'range-up' ? 'Range and up' : 'Term' }"></i>
  278. <span data-bind="visible: type() == 'range'">${_('range')}</span>
  279. <span data-bind="visible: type() == 'range-up'">${_('range & up')}</span>
  280. <span data-bind="visible: type() == 'field'">${_('field')}</span>
  281. </a>
  282. </div>
  283. <div class="facet-field-cnt">
  284. <span class="facet-field-label facet-field-label-fixed-width">${ _('Sorting') }</span>
  285. <a href="javascript: void(0)" title="${ _('Toggle sort order') }" data-bind="click: $root.collection.toggleSortFacet">
  286. <i class="fa" data-bind="css: { 'fa-caret-down': properties.sort() == 'desc', 'fa-caret-up': properties.sort() == 'asc' }"></i>
  287. <span data-bind="visible: properties.sort() == 'desc'">${_('descending')}</span>
  288. <span data-bind="visible: properties.sort() == 'asc'">${_('ascending')}</span>
  289. </a>
  290. </div>
  291. <!-- ko if: type() == 'pivot' -->
  292. <div class="facet-field-cnt">
  293. <span class="spinedit-cnt">
  294. <span class="facet-field-label facet-field-label-fixed-width">
  295. ${ _('Limit') }
  296. </span>
  297. <input type="text" class="input-medium" data-bind="spinedit: properties.limit"/>
  298. </span>
  299. </div>
  300. <div class="facet-field-cnt">
  301. <span class="spinedit-cnt">
  302. <span class="facet-field-label facet-field-label-fixed-width">
  303. ${ _('Min Count') }
  304. </span>
  305. <input type="text" class="input-medium" data-bind="spinedit: properties.mincount"/>
  306. </span>
  307. </div>
  308. <!-- /ko -->
  309. <!-- ko if: type() == 'range' || type() == 'range-up' || (type() == 'nested' && typeof properties.min != "undefined") -->
  310. <!-- ko ifnot: properties.isDate() -->
  311. <div class="slider-cnt" data-bind="slider: {start: properties.min, end: properties.max, gap: properties.initial_gap, min: properties.initial_start, max: properties.initial_end, properties: properties, labels: SLIDER_LABELS}"></div>
  312. <!-- /ko -->
  313. <!-- ko if: properties.isDate() && $root.collection.timeFilter && $root.collection.timeFilter.field && $root.collection.timeFilter.field() != field() -->
  314. <div data-bind="daterangepicker: {start: properties.start, end: properties.end, gap: properties.initial_gap, relatedgap: properties.gap, min: properties.min, max: properties.max}"></div>
  315. <br/>
  316. <!-- /ko -->
  317. <!-- /ko -->
  318. <!-- ko if: type() == 'field' -->
  319. <div class="facet-field-cnt">
  320. <span class="spinedit-cnt">
  321. <span class="facet-field-label facet-field-label-fixed-width">
  322. ${ _('Limit') }
  323. </span>
  324. <input type="text" class="input-medium" data-bind="spinedit: properties.limit"/>
  325. </span>
  326. </div>
  327. <!-- /ko -->
  328. <!-- ko if: widgetType() == 'map-widget' -->
  329. <div class="facet-field-cnt">
  330. <span class="spinedit-cnt">
  331. <span class="facet-field-label facet-field-label-fixed-width">
  332. ${ _('Scope') }
  333. </span>
  334. <select data-bind="selectedOptions: properties.scope" class="input-small">
  335. <option value="world">${ _("World") }</option>
  336. <option value="europe">${ _("Europe") }</option>
  337. <option value="aus">${ _("Australia") }</option>
  338. <option value="bra">${ _("Brazil") }</option>
  339. <option value="can">${ _("Canada") }</option>
  340. <option value="chn">${ _("China") }</option>
  341. <option value="fra">${ _("France") }</option>
  342. <option value="deu">${ _("Germany") }</option>
  343. <option value="ita">${ _("Italy") }</option>
  344. <option value="jpn">${ _("Japan") }</option>
  345. <option value="gbr">${ _("UK") }</option>
  346. <option value="usa">${ _("USA") }</option>
  347. </select>
  348. </span>
  349. </div>
  350. <!-- /ko -->
  351. </div>
  352. <!-- ko if: type() == 'pivot' || type() == 'nested' -->
  353. <div class="facet-field-tile" data-bind="visible: properties.scope() == 'tree' || (type() == 'pivot' && properties.facets().length == 0) || (type() == 'nested' && properties.facets().length < 3)">
  354. <div class="facet-field-cnt">
  355. <span class="facet-field-label facet-field-label-fixed-width facet-field-label-fixed-width-double facet-field-label-title">
  356. ${ _('Add a dimension') }
  357. </span>
  358. </div>
  359. <div class="facet-field-cnt">
  360. <span class="spinedit-cnt">
  361. <span class="facet-field-label facet-field-label-fixed-width">
  362. ${ _('Field') }
  363. </span>
  364. <select data-bind="options: $root.collection.template.fieldsNames, value: properties.facets_form.field, optionsCaption: '${ _ko('Choose...') }'"></select>
  365. </span>
  366. </div>
  367. <!-- ko if: type() == 'nested' -->
  368. <div class="facet-field-cnt">
  369. <span class="spinedit-cnt">
  370. <span class="facet-field-label facet-field-label-fixed-width">
  371. ${ _('Metric') }
  372. </span>
  373. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: properties.facets_form.aggregate"></select>
  374. </span>
  375. </div>
  376. <!-- /ko -->
  377. <div class="facet-field-cnt">
  378. <span class="spinedit-cnt">
  379. <span class="facet-field-label facet-field-label-fixed-width">
  380. ${ _('Limit') }
  381. </span>
  382. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.limit"/>
  383. </span>
  384. </div>
  385. <div class="facet-field-cnt">
  386. <span class="spinedit-cnt">
  387. <span class="facet-field-label facet-field-label-fixed-width">
  388. ${ _('Min Count') }
  389. </span>
  390. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.mincount"/>
  391. <a class="pull-right" href="javascript: void(0)" data-bind="visible: ko.toJSON(properties.facets_form.field) != '', click: $root.collection.addPivotFacetValue">
  392. <i class="fa fa-plus"></i>
  393. </a>
  394. </span>
  395. </div>
  396. </div>
  397. <!-- /ko -->
  398. <div class="clearfix"></div>
  399. </script>
  400. <script type="text/html" id="facet-widget">
  401. <div class="widget-spinner" data-bind="visible: isLoading()">
  402. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  403. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  404. </div>
  405. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  406. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  407. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  408. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  409. </span>
  410. </div>
  411. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  412. <!-- ko if: type() == 'field' -->
  413. <div data-bind="foreach: $parent.counts">
  414. <div class="trigger-exclude">
  415. <!-- ko if: $index() < $parent.properties.limit() -->
  416. <!-- ko if: ! $data.selected -->
  417. <a class="exclude pointer" data-bind="click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id(), 'exclude': true}) }" title="${ _('Exclude this value') }"><i class="fa fa-minus"></i></a>
  418. <div class="hellip">
  419. <a class="pointer" dir="ltr" data-bind="html: prettifyDate($data.value), click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }, attr: {'title': $data.value + ' (' + $data.count + ')'}"></a>
  420. <span class="pointer counter" dir="rtl" data-bind="text: ' (' + $data.count + ')', click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }"></span>
  421. </div>
  422. <!-- /ko -->
  423. <!-- ko if: $data.selected -->
  424. <span class="pointer" data-bind="click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }">
  425. <a class="include pointer" data-bind="visible: ! exclude"><i class="fa fa-times"></i></a>
  426. <a class="include pointer" data-bind="visible: exclude"><i class="fa fa-plus"></i></a>
  427. <div class="hellip">
  428. <strong data-bind="html: prettifyDate($data.value), attr: {'title': $data.value}"></strong>
  429. </div>
  430. </span>
  431. <!-- /ko -->
  432. <!-- /ko -->
  433. <!-- ko if: $index() == $parent.properties.limit() -->
  434. <!-- ko if: $parent.properties.prevLimit == undefined || $parent.properties.prevLimit == $parent.properties.limit() -->
  435. <a class="pointer" data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'up') }">
  436. ${ _('Show more...') }
  437. </a>
  438. <!-- /ko -->
  439. <!-- ko if: $parent.properties.prevLimit != undefined && $parent.properties.prevLimit != $parent.properties.limit() -->
  440. <a class="pointer" data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'up') }">
  441. ${ _('Show more') }
  442. </a>
  443. /
  444. <a class="pointer" data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'down') }">
  445. ${ _('less...') }
  446. </a>
  447. <!-- /ko -->
  448. <!-- /ko -->
  449. </div>
  450. </div>
  451. <!-- /ko -->
  452. <!-- ko if: type() == 'range' -->
  453. <div data-bind="foreach: $parent.counts">
  454. <div class="trigger-exclude">
  455. <!-- ko if: ! selected -->
  456. <a class="exclude pointer" data-bind="click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field, 'exclude': true}) }" title="${ _('Exclude this value') }"><i class="fa fa-minus"></i></a>
  457. <div class="hellip">
  458. <a class="pointer" data-bind="html: $data.is_single_unit_gap ? prettifyDate($data.from, $parent, $data.to) : prettifyDateRange($data.from, $data.to, $parent, false), click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field}) }, attr: {'title': ($data.is_single_unit_gap ? $data.from : $data.from + ' - ' + $data.to) + ' (' + $data.value + ')'}"></a>
  459. <span class="pointer counter" data-bind="text: ' (' + $data.value + ')', click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field}) }"></span>
  460. </div>
  461. <!-- /ko -->
  462. <!-- ko if: selected -->
  463. <span class="pointer" data-bind="click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field}) }">
  464. <a class="include pointer" data-bind="visible: ! exclude"><i class="fa fa-times"></i></a>
  465. <a class="include pointer" data-bind="visible: exclude"><i class="fa fa-plus"></i></a>
  466. <div class="hellip">
  467. <strong data-bind="html: $data.is_single_unit_gap ? prettifyDate($data.from, $parent, $data.to) : prettifyDateRange($data.from, $data.to, $parent, false), attr: {'title': ($data.is_single_unit_gap ? $data.from : $data.from + ' - ' + $data.to) + ' (' + $data.value + ')'}"></strong>
  468. </div>
  469. </span>
  470. <!-- /ko -->
  471. </div>
  472. </div>
  473. <!-- /ko -->
  474. <!-- ko if: type() == 'range-up' -->
  475. <div data-bind="foreach: $parent.counts">
  476. <div class="trigger-exclude">
  477. <!-- ko if: ! selected -->
  478. <a class="exclude pointer" data-bind="click: function(){ $root.query.selectRangeUpFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field, 'exclude': true, is_up: $data.is_up}) }" title="${ _('Exclude this value') }"><i class="fa fa-minus"></i></a>
  479. <div class="hellip">
  480. <a class="pointer" data-bind="html: prettifyDate($data.from, $parent) + ($data.is_up ? ' & Up' : ' & Less'), click: function(){ $root.query.selectRangeUpFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field, is_up: $data.is_up}) }, attr: {'title': $data.from + ($data.is_up ? ' & Up' : ' & Less') + ' (' + $data.total_counts + ')'}"></a>
  481. <span class="pointer counter" data-bind="text: ' (' + $data.total_counts + ')', click: function(){ $root.query.selectRangeUpFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field, is_up: $data.is_up}) }"></span>
  482. </div>
  483. <!-- /ko -->
  484. <!-- ko if: selected -->
  485. <span class="pointer" data-bind="click: function(){ $root.query.selectRangeUpFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field, is_up: $data.is_up}) }">
  486. <a class="include pointer" data-bind="visible: ! exclude"><i class="fa fa-times"></i></a>
  487. <a class="include pointer" data-bind="visible: exclude"><i class="fa fa-plus"></i></a>
  488. <div class="hellip">
  489. <strong data-bind="html: prettifyDate($data.from, $parent) + ($data.is_up ? ' & Up' : ' & Less')"></strong>
  490. </div>
  491. </span>
  492. <!-- /ko -->
  493. </div>
  494. </div>
  495. <!-- /ko -->
  496. </div>
  497. </div>
  498. <!-- /ko -->
  499. </script>
  500. <script type="text/html" id="resultset-widget">
  501. <!-- ko if: $root.collection.template.isGridLayout() -->
  502. <div class="grid-row">
  503. <div class="grid-left-bar">
  504. <div>
  505. <!-- ko if: $root.response && $root.response().response && $root.response().response.numFound > 0 -->
  506. <div style="margin-top:3px">
  507. <a class="grid-side-btn active" href="javascript: void(0)"
  508. data-bind="click: function(){ $root.collection.template.showChart(false); $root.collection.template.showGrid(true); }, css: {'active': $root.collection.template.showGrid() }" title="${_('Grid')}">
  509. <i class="fa fa-th fa-fw"></i>
  510. </a>
  511. </div>
  512. <div class="dropdown">
  513. <a class="grid-side-btn" style="padding-right:0" href="javascript:void(0)"
  514. data-bind="css: {'active': $root.collection.template.showChart() }, click: function(){ $root.collection.template.showChart(true); $root.collection.template.showGrid(false); huePubSub.publish('gridChartForceUpdate'); }">
  515. <i class="hcha hcha-bar-chart fa-fw" data-bind="visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART"></i>
  516. <i class="hcha hcha-line-chart fa-fw" data-bind="visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART"
  517. style="display: none;"></i>
  518. <i class="hcha hcha-pie-chart fa-fw" data-bind="visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART"
  519. style="display: none;"></i>
  520. <i class="fa fa-fw fa-map-marker" data-bind="visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP"
  521. style="display: none;"></i>
  522. </a>
  523. <a class="dropdown-toggle grid-side-btn" style="padding:0" data-toggle="dropdown"
  524. href="javascript: void(0)" data-bind="css: {'active': $root.collection.template.showChart()}">
  525. <i class="fa fa-caret-down"></i>
  526. </a>
  527. <ul class="dropdown-menu">
  528. <li>
  529. <a href="javascript:void(0)"
  530. data-bind="css: {'active': $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART}, click: function(){ $root.collection.template.showChart(true); $root.collection.template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.BARCHART); $root.collection.template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}"
  531. class="active">
  532. <i class="hcha hcha-bar-chart fa-fw"></i> ${_('Bars')}
  533. </a>
  534. </li>
  535. <li>
  536. <a href="javascript:void(0)"
  537. data-bind="css: {'active': $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART}, click: function(){ $root.collection.template.showChart(true); $root.collection.template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.LINECHART); $root.collection.template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
  538. <i class="hcha hcha-line-chart fa-fw"></i> ${_('Lines')}
  539. </a>
  540. </li>
  541. <li>
  542. <a href="javascript:void(0)"
  543. data-bind="css: {'active': $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART}, click: function(){ $root.collection.template.showChart(true); $root.collection.template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.PIECHART); $root.collection.template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
  544. <i class="hcha hcha-pie-chart fa-fw"></i> ${_('Pie')}
  545. </a>
  546. </li>
  547. <li>
  548. <a href="javascript:void(0)"
  549. data-bind="css: {'active': $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP}, click: function(){ $root.collection.template.showChart(true); $root.collection.template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.MAP); $root.collection.template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}">
  550. <i class="fa fa-fw fa-map-marker chart-icon"></i> ${_('Marker Map')}
  551. </a>
  552. </li>
  553. </ul>
  554. </div>
  555. <div>
  556. <a class="grid-side-btn" href="javascript:void(0)" data-bind="click: function(){ $root.collection.template.showFieldList(!$root.collection.template.showFieldList())}, css: { 'blue' : $root.collection.template.showFieldList() }">
  557. <!-- ko if: $root.collection.template.showFieldList() -->
  558. <i class="fa fa-fw fa-chevron-left"></i>
  559. <!-- /ko -->
  560. <!-- ko ifnot: $root.collection.template.showFieldList() -->
  561. <i class="fa fa-fw fa-columns"></i>
  562. <!-- /ko -->
  563. </a>
  564. </div>
  565. <form method="POST" action="${ url('search:download') }" style="display:inline">
  566. ${ csrf_token(request) | n,unicode }
  567. <input type="hidden" name="collection" data-bind="value: ko.mapping.toJSON($root.collection)"/>
  568. <input type="hidden" name="query" data-bind="value: ko.mapping.toJSON($root.query)"/>
  569. <input type="hidden" name="download">
  570. <input type="hidden" name="type" value="">
  571. <div class="dropdown">
  572. <a class="grid-side-btn dropdown-toggle" style="padding-left:7px" data-toggle="dropdown">
  573. <i class="fa fa-download fa-fw"></i>
  574. </a>
  575. <ul class="dropdown-menu">
  576. <li>
  577. <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function(widget, event){ var $f = $(event.currentTarget).parents('form'); $f.find('[name=\'type\']').val('csv'); $f.submit()}" title="${ _('Download first rows as JSON') }">
  578. <i class="hfo hfo-file-csv"></i> CSV
  579. </a>
  580. </li>
  581. <li>
  582. <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function(widget, event){ var $f = $(event.currentTarget).parents('form'); $f.find('[name=\'type\']').val('xls'); $f.submit()}" title="${ _('Download first rows as XLS') }">
  583. <i class="hfo hfo-file-xls"></i> Excel
  584. </a>
  585. </li>
  586. <li>
  587. <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function(widget, event){ var $f = $(event.currentTarget).parents('form'); $f.find('[name=\'type\']').val('json'); $f.submit()}" title="${ _('Download first rows as JSON') }">
  588. <i class="hfo hfo-file-json"></i> JSON
  589. </a>
  590. </li>
  591. </ul>
  592. </div>
  593. </form>
  594. <!-- /ko -->
  595. </div>
  596. </div>
  597. </div>
  598. <div class="grid-results">
  599. <span data-bind="visible: $root.hasRetrievedResults() && $root.response().response">
  600. <div data-bind="visible: $root.collection.template.showFieldList() && $root.collection.template.showGrid()" style="float:left; width:200px; margin-right:10px; background-color:#FFF; padding:5px;">
  601. <input type="text" data-bind="clearable: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width:180px; margin-bottom:10px" />
  602. <div style="margin-bottom: 8px">
  603. <a href="javascript: void(0)" data-bind="click: function(){$root.collection.template.filteredAttributeFieldsAll(true)}, style: {'font-weight': $root.collection.template.filteredAttributeFieldsAll() ? 'bold': 'normal'}">${_('All')} (<span data-bind="text: $root.collection.template.fieldsAttributes().length"></span>)</a> / <a href="javascript: void(0)" data-bind="click: function(){$root.collection.template.filteredAttributeFieldsAll(false)}, style: {'font-weight': ! $root.collection.template.filteredAttributeFieldsAll() ? 'bold': 'normal'}">${_('Current')} (<span data-bind="text: $root.collection.template.fields().length"></span>)</a>
  604. </div>
  605. <div style="border-bottom: 1px solid #CCC; padding-bottom: 4px;">
  606. <a href="javascript: void(0)" class="btn btn-mini"
  607. data-bind="click: toggleGridFieldsSelection, css: { 'btn-inverse': $root.collection.template.fields().length > 0 }"
  608. style="margin-right: 2px;">
  609. <i class="fa fa-square-o"></i>
  610. </a>
  611. <strong>${_('Field Name')}</strong>
  612. </div>
  613. <div class="fields-list" data-bind="foreach: $root.collection.template.filteredAttributeFields">
  614. <div style="margin-bottom: 3px; white-space: nowrap; position:relative">
  615. <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" style="margin: 0" />
  616. <div data-bind="text: name, css:{'field-selector': true, 'hoverable': $root.collection.template.fieldsSelected.indexOf(name()) > -1}, click: highlightColumn" style="margin-right:10px"></div>
  617. <i class="fa fa-question-circle muted pointer analysis" data-bind="click: function() { $root.fieldAnalysesName(name()); $root.showFieldAnalysis(); }, attr: {'title': '${ _ko('Click to analyze field') } ' + name() + ' (' + type() + ')'}" style="position:absolute; left: 168px; background-color: #FFF"></i>
  618. </div>
  619. </div>
  620. <div data-bind="visible: $root.collection.template.filteredAttributeFields().length == 0" style="padding-left:4px; padding-top:5px; font-size:40px; color:#CCC">
  621. <i class="fa fa-frown-o"></i>
  622. </div>
  623. </div>
  624. <div data-bind="visible: $root.collection.template.showFieldList() && $root.collection.template.showChart()" style="float:left; width:200px; margin-right:10px; background-color:#FFF; padding:5px;">
  625. <span data-bind="template: {name: 'grid-chart-settings', data: $root.collection.template.chartSettings}"></span>
  626. </div>
  627. <div style="position: absolute; margin-left: 208px; top: 0px; margin-top: 130px;" data-bind="visible: $root.collection.template.showFieldList()">
  628. <a class="inactive-action pointer" title="${_('Hide settings')}" data-bind="click: function() { $root.collection.template.showFieldList(false) }">
  629. <i class="fa fa-chevron-left"></i>
  630. </a>
  631. </div>
  632. </span>
  633. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults() || !$root.response().response">
  634. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  635. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  636. </div>
  637. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length == 0 && $root.response().response">
  638. <br/>
  639. ${ _('Your search did not match any documents.') }
  640. </div>
  641. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length > 0 && $root.collection.template.showGrid()">
  642. <!-- ko if: $root.response().response -->
  643. <div data-bind="template: {name: 'resultset-pagination', data: $root.response()}" style="padding:8px; color:#666"></div>
  644. <!-- /ko -->
  645. <div id="result-main" style="overflow-x: auto">
  646. <table id="result-container" data-bind="visible: $root.hasRetrievedResults()" style="margin-top: 0; width: 100%">
  647. <thead>
  648. <tr data-bind="visible: $root.collection.template.fieldsSelected().length > 0, template: {name: 'result-sorting'}">
  649. </tr>
  650. <tr data-bind="visible: $root.collection.template.fieldsSelected().length == 0">
  651. <th style="width: 18px">&nbsp;</th>
  652. <th>${ _('Document') }</th>
  653. </tr>
  654. </thead>
  655. <tbody data-bind="foreach: {data: $root.results, as: 'doc'}" class="result-tbody">
  656. <tr class="result-row" data-bind="style: {'backgroundColor': $index() % 2 == 0 ? '#FFF': '#F6F6F6'}">
  657. <td>
  658. <a href="javascript:void(0)" data-bind="click: toggleDocDetails">
  659. <i class="fa" data-bind="css: {'fa-caret-right' : ! doc.showDetails(), 'fa-caret-down': doc.showDetails()}"></i>
  660. </a>
  661. </td>
  662. <!-- ko foreach: row -->
  663. <td data-bind="html: $data"></td>
  664. <!-- /ko -->
  665. </tr>
  666. <tr data-bind="visible: doc.showDetails" class="show-details">
  667. <td>&nbsp;</td>
  668. <td data-bind="attr: {'colspan': $root.collection.template.fieldsSelected().length > 0 ? $root.collection.template.fieldsSelected().length + 1 : 2}">
  669. <span data-bind="template: {name: 'document-details', data: $data}"></span>
  670. </td>
  671. </tr>
  672. </tbody>
  673. </table>
  674. </div>
  675. </div>
  676. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length > 0 && $root.collection.template.showChart()">
  677. <div data-bind="visible: !$root.collection.template.hasDataForChart()" style="padding: 10px">${ _('Please select the chart parameters on the left.') }</div>
  678. <div class="grid-chart-container" data-bind="visible: $root.collection.template.hasDataForChart" style="overflow-x: auto">
  679. <div data-bind="attr:{'id': 'pieChart_'+id()}, pieChart: {data: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data}, fqs: ko.observableArray([]),
  680. transformer: pieChartDataTransformerGrid, maxWidth: 350, parentSelector: '.chart-container' }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="chart"></div>
  681. <div data-bind="attr:{'id': 'barChart_'+id()}, barChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data}, fqs: ko.observableArray([]), hideSelection: true,
  682. transformer: multiSerieDataTransformerGrid, stacked: false, showLegend: true}, stacked: true, showLegend: true, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
  683. <div data-bind="attr:{'id': 'lineChart_'+id()}, lineChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
  684. transformer: multiSerieDataTransformerGrid, showControls: false }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART" class="chart"></div>
  685. <div data-bind="attr:{'id': 'leafletMapChart_'+id()}, leafletMapChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
  686. transformer: leafletMapChartDataTransformerGrid, showControls: false, height: 380, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP, forceRedraw: true}" class="chart"></div>
  687. </div>
  688. </div>
  689. </div>
  690. </div>
  691. <!-- /ko -->
  692. </script>
  693. <script type="text/html" id="grid-chart-settings">
  694. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  695. <li data-bind="visible: [ko.HUE_CHARTS.TYPES.MAP, ko.HUE_CHARTS.TYPES.GRADIENTMAP, ko.HUE_CHARTS.TYPES.PIECHART].indexOf(chartType()) == -1" class="nav-header">${_('x-axis')}</li>
  696. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('region')}</li>
  697. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('latitude')}</li>
  698. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="nav-header">${_('legend')}</li>
  699. </ul>
  700. <div data-bind="visible: chartType() != ''">
  701. <select data-bind="options: (chartType() == ko.HUE_CHARTS.TYPES.BARCHART || chartType() == ko.HUE_CHARTS.TYPES.PIECHART) ? $root.collection.template.cleanedMeta : $root.collection.template.cleanedNumericMeta, value: chartX, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartX}" class="input-medium"></select>
  702. </div>
  703. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  704. <li data-bind="visible: [ko.HUE_CHARTS.TYPES.MAP, ko.HUE_CHARTS.TYPES.GRADIENTMAP, ko.HUE_CHARTS.TYPES.PIECHART].indexOf(chartType()) == -1" class="nav-header">${_('y-axis')}</li>
  705. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('longitude')}</li>
  706. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="nav-header">${_('value')}</li>
  707. </ul>
  708. <div style="overflow-y: auto; max-height: 220px" data-bind="visible: chartType() != '' && (chartType() == ko.HUE_CHARTS.TYPES.BARCHART || chartType() == ko.HUE_CHARTS.TYPES.LINECHART)">
  709. <ul class="unstyled" data-bind="foreach: $root.collection.template.cleanedNumericMeta">
  710. <li><input type="checkbox" data-bind="checkedValue: name, checked: $parent.chartYMulti" /> <span data-bind="text: $data.name"></span></li>
  711. </ul>
  712. </div>
  713. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART || chartType() == ko.HUE_CHARTS.TYPES.MAP">
  714. <select data-bind="options: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? $root.collection.template.cleanedMeta : $root.collection.template.cleanedNumericMeta, value: chartYSingle, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartYSingle}" class="input-medium"></select>
  715. </div>
  716. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.MAP">
  717. <li class="nav-header">${_('label')}</li>
  718. </ul>
  719. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP">
  720. <select data-bind="options: $root.collection.template.cleanedMeta, value: chartMapLabel, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartMapLabel}" class="input-medium"></select>
  721. </div>
  722. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP">
  723. <li class="nav-header">${_('sorting')}</li>
  724. </ul>
  725. <div class="btn-group" data-toggle="buttons-radio" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP">
  726. <a rel="tooltip" data-placement="top" title="${_('No sorting')}" href="javascript:void(0)" class="btn" data-bind="css: {'active': chartSorting() == 'none'}, click: function(){ chartSorting('none'); }"><i class="fa fa-align-left fa-rotate-270"></i></a>
  727. <a rel="tooltip" data-placement="top" title="${_('Sort ascending')}" href="javascript:void(0)" class="btn" data-bind="css: {'active': chartSorting() == 'asc'}, click: function(){ chartSorting('asc'); }"><i class="fa fa-sort-amount-asc fa-rotate-270"></i></a>
  728. <a rel="tooltip" data-placement="top" title="${_('Sort descending')}" href="javascript:void(0)" class="btn" data-bind="css: {'active': chartSorting() == 'desc'}, click: function(){ chartSorting('desc'); }"><i class="fa fa-sort-amount-desc fa-rotate-270"></i></a>
  729. </div>
  730. </script>
  731. <script type="text/html" id="html-resultset-widget">
  732. <!-- ko ifnot: $root.collection.template.isGridLayout() -->
  733. <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
  734. <ul class="nav nav-pills">
  735. <li class="active"><a href="javascript: void(0)" class="widget-editor-pill">${_('Editor')}</a></li>
  736. <li><a href="javascript: void(0)" class="widget-html-pill">${_('HTML')}</a></li>
  737. <li><a href="javascript: void(0)" class="widget-css-pill">${_('CSS & JS')}</a></li>
  738. <li><a href="javascript: void(0)" class="widget-settings-pill">${_('Sorting')}</a></li>
  739. </ul>
  740. </div>
  741. <!-- ko if: $root.isEditing() -->
  742. <div class="widget-section widget-editor-section">
  743. <div class="row-fluid">
  744. <div class="span9">
  745. <div data-bind="freshereditor: {data: $root.collection.template.template}"></div>
  746. </div>
  747. <div class="span3">
  748. <h5 class="editor-title">${_('Available Fields')}</h5>
  749. <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedVisualField" class="input-large chosen-select"></select>
  750. <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToVisual">
  751. <i class="fa fa-plus"></i>
  752. </button>
  753. <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h5>
  754. <select id="visualFunctions" data-bind="value: $root.collection.template.selectedVisualFunction" class="input-large chosen-select">
  755. <option title="${ _('Formats date or timestamp in DD-MM-YYYY') }" value="{{#date}} {{/date}}">{{#date}}</option>
  756. <option title="${ _('Formats date or timestamp in HH:mm:ss') }" value="{{#time}} {{/time}}">{{#time}}</option>
  757. <option title="${ _('Formats date or timestamp in DD-MM-YYYY HH:mm:ss') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
  758. <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
  759. <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
  760. <option title="${ _('Formats a Unix timestamp as Ns, Nmin, Ndays... ago') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
  761. <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
  762. <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
  763. <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
  764. <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
  765. <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
  766. <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
  767. </select>
  768. <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToVisual">
  769. <i class="fa fa-plus"></i>
  770. </button>
  771. <p class="muted" style="margin-top: 10px"></p>
  772. </div>
  773. </div>
  774. </div>
  775. <div class="widget-section widget-html-section" style="display: none">
  776. <div class="row-fluid">
  777. <div class="span9">
  778. <textarea data-bind="codemirror: {data: $root.collection.template.template, lineNumbers: true, htmlMode: true, mode: 'text/html', stripScript: true }" data-template="true"></textarea>
  779. </div>
  780. <div class="span3">
  781. <h5 class="editor-title">${_('Available Fields')}</h5>
  782. <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedSourceField" class="input-medium chosen-select"></select>
  783. <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToSource">
  784. <i class="fa fa-plus"></i>
  785. </button>
  786. <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h5>
  787. <select id="sourceFunctions" data-bind="value: $root.collection.template.selectedSourceFunction" class="input-medium chosen-select">
  788. <option title="${ _('Formats a date in the DD-MM-YYYY format') }" value="{{#date}} {{/date}}">{{#date}}</option>
  789. <option title="${ _('Formats a date in the HH:mm:ss format') }" value="{{#time}} {{/time}}">{{#time}}</option>
  790. <option title="${ _('Formats a date in the DD-MM-YYYY HH:mm:ss format') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
  791. <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
  792. <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
  793. <option title="${ _('Shows the relative time') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
  794. <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
  795. <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
  796. <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
  797. <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
  798. <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
  799. <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
  800. </select>
  801. <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToSource">
  802. <i class="fa fa-plus"></i>
  803. </button>
  804. <p class="muted" style="margin-top: 10px"></p>
  805. </div>
  806. </div>
  807. </div>
  808. <div class="widget-section widget-css-section" style="display: none">
  809. <textarea data-bind="codemirror: {data: $root.collection.template.extracode, lineNumbers: true, htmlMode: true, mode: 'text/html' }"></textarea>
  810. </div>
  811. <div class="widget-section widget-settings-section" style="display: none">
  812. <div style="overflow-x: scroll; min-height: 40px">
  813. <table>
  814. <tr data-bind="template: {name: 'result-sorting'}">
  815. </tr>
  816. </table>
  817. </div>
  818. <br/>
  819. </div>
  820. <!-- /ko -->
  821. <div id="result-main" style="overflow-x: auto">
  822. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length == 0">
  823. <br/>
  824. ${ _('Your search did not match any documents.') }
  825. </div>
  826. <!-- ko if: $root.response().response && $root.results().length > 0 -->
  827. <div data-bind="template: {name: 'resultset-pagination', data: $root.response() }"></div>
  828. <!-- /ko -->
  829. <table id="result-container" data-bind="visible: $root.hasRetrievedResults()" style="margin-top: 0; width: 100%">
  830. <thead>
  831. <tr>
  832. <th>&nbsp;</th>
  833. </tr>
  834. </thead>
  835. <tbody data-bind="foreach: {data: $root.results, as: 'doc'}" class="result-tbody">
  836. <tr data-bind="style: {'backgroundColor': $index() % 2 == 0 ? '#FFF': '#F6F6F6'}">
  837. <td><div data-bind="html: content" style="margin-bottom: -20px"></div></td>
  838. </tr>
  839. <tr>
  840. <td class="show-details-icon pointer" data-bind="click: toggleDocDetails">
  841. <i class="fa" data-bind="css: {'fa-caret-down' : ! doc.showDetails(), 'fa-caret-up': doc.showDetails()}"></i>
  842. </td>
  843. </tr>
  844. <tr data-bind="visible: doc.showDetails" class="show-details">
  845. <td data-bind="attr: {'colspan': $root.collection.template.fieldsSelected().length > 0 ? $root.collection.template.fieldsSelected().length + 1 : 2}">
  846. <span data-bind="template: {name: 'document-details', data: $data}"></span>
  847. </td>
  848. </tr>
  849. </tbody>
  850. </table>
  851. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
  852. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  853. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  854. </div>
  855. </div>
  856. <!-- /ko -->
  857. </script>
  858. <script type="text/html" id="document-details">
  859. <!-- ko if: $data.details().length == 0 -->
  860. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  861. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  862. <!-- /ko -->
  863. <!-- ko if: $data.details().length > 0 -->
  864. <div class="document-details-actions pull-left" data-bind="visible: ${ 'true' if can_edit_index else 'false' } || externalLink()">
  865. <a href="javascript:void(0)" data-bind="visible: ! showEdit(), click: function() { showEdit(true); }" title="${ _('Edit this document') }">
  866. <i class="fa fa-edit fa-fw"></i>
  867. </a>
  868. <a href="javascript:void(0)" data-bind="visible: showEdit(), click: function(data, e) { $(e.currentTarget).parent().css('marginTop', '8px'); $root.getDocument($data); showEdit(false); }" title="${ _('Undo changes') }">
  869. <i class="fa fa-undo fa-fw"></i>
  870. </a>
  871. <a href="javascript:void(0)" data-bind="visible: showEdit() && originalDetails() != ko.toJSON(details), click: $root.updateDocument" title="${ _('Update this document') }">
  872. <i class="fa fa-save fa-fw"></i>
  873. </a>
  874. <a href="javascript:void(0)" data-bind="visible: externalLink(), attr: { href: externalLink}" target="_blank" title="${ _('Show original document') }">
  875. <i class="fa fa-external-link fa-fw"></i>
  876. </a>
  877. </div>
  878. <div class="document-details pull-left">
  879. <table>
  880. <tbody data-bind="foreach: details">
  881. <tr data-bind="css: {'readonly': ! $parent.showEdit()}">
  882. <th class="grid-th" data-bind="text: key"></th>
  883. <td width="100%">
  884. <span data-bind="text: value, visible: ! $parent.showEdit()"></span>
  885. <input data-bind="value: value, visible: $parent.showEdit, valueUpdate: 'afterkeydown',
  886. click: function(detail, e){
  887. var target = $(e.currentTarget);
  888. target.parents('.show-details').find('.document-details-actions').animate({
  889. 'marginTop': (target.position().top - target.parents('table').position().top) + 'px'
  890. }, 200)
  891. }" class="input-xxlarge" style="width: 600px" />
  892. </td>
  893. </tr>
  894. </tbody>
  895. </table>
  896. </div>
  897. <!-- /ko -->
  898. </script>
  899. <script type="text/html" id="result-sorting">
  900. <th style="width: 18px">&nbsp;</th>
  901. <!-- ko foreach: $root.collection.template.fieldsSelected -->
  902. <th data-bind="with: $root.collection.getTemplateField($data), event: { mouseover: $root.enableGridlayoutResultChevron, mouseout: $root.disableGridlayoutResultChevron }" style="white-space: nowrap">
  903. <div style="display: inline-block; width:20px;">
  904. <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'left'); }">
  905. <i class="fa fa-chevron-left" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() > 0"></i>
  906. <i class="fa fa-chevron-left" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == 0"></i>
  907. </a>
  908. </div>
  909. <div style="display: inline-block;">
  910. <a href="javascript: void(0)" data-bind="click: $root.collection.toggleSortColumnGridLayout" title="${ _('Click to sort') }">
  911. <span data-bind="text: name"></span>
  912. <i class="fa" data-bind="visible: sort.direction() != null, css: { 'fa-chevron-down': sort.direction() == 'desc', 'fa-chevron-up': sort.direction() == 'asc' }"></i>
  913. </a>
  914. </div>
  915. <div style="display: inline-block; width:20px;">
  916. <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'right'); }">
  917. <i class="fa fa-chevron-right" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() < $root.collection.template.fields().length - 1"></i>
  918. <i class="fa fa-chevron-up" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == $root.collection.template.fields().length - 1,"></i>
  919. </a>
  920. </div>
  921. </th>
  922. <!-- /ko -->
  923. </script>
  924. <script type="text/html" id="resultset-pagination">
  925. <div style="text-align: center; margin-top: 4px">
  926. <a href="javascript: void(0)" title="${ _('Previous') }">
  927. <span data-bind="click: $root.collection.toggleSortColumnGridLayout"></span>
  928. <i class="fa fa-arrow-left" data-bind="
  929. visible: $data.response.start * 1.0 >= $root.collection.template.rows() * 1.0,
  930. click: function() { $root.query.paginate('prev') }">
  931. </i>
  932. </a>
  933. ${ _('Showing') }
  934. <span data-bind="text: ($data.response.start + 1)"></span>
  935. ${ _('to') }
  936. <span data-bind="text: Math.min(($data.response.start + $root.collection.template.rows()), $data.response.numFound)"></span>
  937. ${ _('of') }
  938. <span data-bind="text: $data.response.numFound"></span>
  939. ${ _(' results') }
  940. <span data-bind="visible: $root.isEditing()">
  941. ${ _('Show') }
  942. <span class="spinedit-cnt">
  943. <input type="text" data-bind="spinedit: $root.collection.template.rows, valueUpdate:'afterkeydown'" style="text-align: center; margin-bottom: 0" />
  944. </span>
  945. ${ _('results per page') }
  946. </span>
  947. <a href="javascript: void(0)" title="${ _('Next') }">
  948. <span data-bind="click: $root.collection.toggleSortColumnGridLayout"></span>
  949. <i class="fa fa-arrow-right" data-bind="
  950. visible: ($root.collection.template.rows() * 1.0 + $data.response.start * 1.0) < $data.response.numFound,
  951. click: function() { $root.query.paginate('next') }">
  952. </i>
  953. </a>
  954. </div>
  955. </script>
  956. <script type="text/html" id="histogram-widget">
  957. <div class="widget-spinner" data-bind="visible: isLoading()">
  958. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  959. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  960. </div>
  961. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  962. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  963. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  964. <span data-bind="template: { name: 'facet-toggle' }">
  965. </span>
  966. </div>
  967. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px" data-bind="visible: counts().length > 0">
  968. <span data-bind="with: $root.collection.getFacetById($parent.id())">
  969. <span class="facet-field-label">${ _('Chart Type') }</span>
  970. <select class="input-small" data-bind="options: $root.timelineChartTypes,
  971. optionsText: 'label',
  972. optionsValue: 'value',
  973. value: properties.timelineChartType">
  974. </select>&nbsp;
  975. <span class="facet-field-label">${ _('Interval') }</span>
  976. <select class="input-small" data-bind="options: $root.intervalOptions,
  977. optionsText: 'label',
  978. optionsValue: 'value',
  979. value: properties.gap">
  980. </select>&nbsp;
  981. </span>
  982. <span class="facet-field-label">${ _('Zoom') }</span>
  983. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  984. <span class="facet-field-label" data-bind="visible: $root.query.multiqs().length > 1">${ _('Group by') }</span>
  985. <select class="input-medium" data-bind="visible: $root.query.multiqs().length > 1, options: $root.query.multiqs, optionsValue: 'id', optionsText: 'label', value: $root.query.selectedMultiq"></select>
  986. </div>
  987. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  988. <div data-bind="timelineChart: {datum: {counts: counts(), extraSeries: extraSeries(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(), transformer: timelineChartDataTransformer,
  989. type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
  990. fqs: $root.query.fqs,
  991. onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  992. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  993. onClick: function(d){ $root.query.selectRangeFacet({count: d.obj.value, widget_id: $parent.id(), from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
  994. onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
  995. <!-- /ko -->
  996. </div>
  997. <!-- /ko -->
  998. </script>
  999. <script type="text/html" id="bar-widget">
  1000. <div class="widget-spinner" data-bind="visible: isLoading()">
  1001. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1002. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1003. </div>
  1004. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1005. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1006. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1007. <span data-bind="template: { name: 'facet-toggle' }">
  1008. </span>
  1009. </div>
  1010. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1011. <!-- ko if: properties.canRange -->
  1012. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px">
  1013. <span class="facet-field-label">${ _('Zoom') }</span>
  1014. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1015. </div>
  1016. <!-- /ko -->
  1017. </div>
  1018. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  1019. <div data-bind="barChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(),
  1020. fqs: $root.query.fqs,
  1021. transformer: ($data.type == 'range-up' ? barChartRangeUpDataTransformer : barChartDataTransformer),
  1022. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1023. onClick: function(d) {
  1024. if (d.obj.field != undefined) {
  1025. if ($data.type == 'range-up') {
  1026. viewModel.query.selectRangeUpFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field, 'exclude': false, is_up: d.obj.is_up});
  1027. } else {
  1028. viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field});
  1029. }
  1030. } else {
  1031. viewModel.query.toggleFacet({facet: d.obj, widget_id: d.obj.widget_id});
  1032. }
  1033. },
  1034. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1035. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1036. />
  1037. <!-- /ko -->
  1038. </div>
  1039. <!-- /ko -->
  1040. </script>
  1041. <script type="text/html" id="bucket-widget">
  1042. <div class="widget-spinner" data-bind="visible: isLoading()">
  1043. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1044. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1045. </div>
  1046. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1047. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1048. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1049. <span data-bind="foreach: properties.facets, visible: !$parents[1].isLoading()">
  1050. <div class="filter-box">
  1051. <div class="title">
  1052. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1053. <i class="fa fa-times"></i>
  1054. </a>
  1055. <div class="hit-title" data-bind="text: field, attr: {'title': field}"></div>
  1056. <div class="clearfix"></div>
  1057. </div>
  1058. <div class="content">
  1059. <div class="facet-field-cnt">
  1060. <span class="facet-field-label">${ _('Metric') }</span>
  1061. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: aggregate" class="hit-options"></select>
  1062. </div>
  1063. <div class="facet-field-cnt" data-bind="visible: $root.isEditing()">
  1064. <span class="spinedit-cnt">
  1065. <span class="facet-field-label">
  1066. ${ _('Limit') }
  1067. </span>
  1068. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1069. </span>
  1070. </div>
  1071. <div class="facet-field-cnt" data-bind="visible: $root.isEditing()">
  1072. <span class="spinedit-cnt">
  1073. <span class="facet-field-label">
  1074. ${ _('Min Count') }
  1075. </span>
  1076. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1077. </span>
  1078. </div>
  1079. </div>
  1080. </div>
  1081. </span>
  1082. <div class="filter-box" data-bind="visible: $root.isEditing() && properties.facets().length < 2" style="opacity: 0.7">
  1083. <div class="title" style="border: 1px dashed #d8d8d8; border-bottom: none">
  1084. <a data-bind="visible: ko.toJSON(properties.facets_form.field) != '', click: $root.collection.addPivotFacetValue" class="pull-right" href="javascript:void(0)">
  1085. <i class="fa fa-plus"></i> ${ _('Add') }
  1086. </a>
  1087. <select data-bind="options: $root.collection.template.fieldsNames, value: properties.facets_form.field, optionsCaption: '${ _ko('Field...') }'" class="hit-options" style="margin-bottom: 0; height: 20px"></select>
  1088. <div class="clearfix"></div>
  1089. </div>
  1090. <div class="content" style="border: 1px dashed #d8d8d8; border-top: none">
  1091. <div class="facet-field-cnt">
  1092. <span class="spinedit-cnt">
  1093. <span class="facet-field-label">
  1094. ${ _('Metric') }
  1095. </span>
  1096. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: properties.facets_form.aggregate" class="hit-options"></select>
  1097. </span>
  1098. </div>
  1099. <div class="facet-field-cnt">
  1100. <span class="spinedit-cnt">
  1101. <span class="facet-field-label">
  1102. ${ _('Limit') }
  1103. </span>
  1104. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.limit"/>
  1105. </span>
  1106. </div>
  1107. <div class="facet-field-cnt">
  1108. <span class="spinedit-cnt">
  1109. <span class="facet-field-label">
  1110. ${ _('Min Count') }
  1111. </span>
  1112. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.mincount"/>
  1113. </span>
  1114. </div>
  1115. </div>
  1116. </div>
  1117. <div class="pull-right" style="margin-top: 40px">
  1118. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1119. <span class="facet-field-label">${ _('Sorting') }</span>
  1120. <a href="javascript: void(0)" title="${ _('Toggle sort order') }" data-bind="click: $root.collection.toggleSortFacet">
  1121. <i class="fa" data-bind="css: { 'fa-caret-down': properties.sort() == 'desc', 'fa-caret-up': properties.sort() == 'asc' }"></i>
  1122. <span data-bind="visible: properties.sort() == 'desc'">${_('descending')}</span>
  1123. <span data-bind="visible: properties.sort() == 'asc'">${_('ascending')}</span>
  1124. </a>
  1125. </div>
  1126. <!-- ko if: properties.isDate -->
  1127. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1128. <span class="facet-field-label">${ _('Chart Type') }</span>
  1129. <select class="input-small" data-bind="options: $root.timelineChartTypes,
  1130. optionsText: 'label',
  1131. optionsValue: 'value',
  1132. value: properties.timelineChartType">
  1133. </select>
  1134. </div>
  1135. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1136. <span class="facet-field-label">${ _('Interval') }</span>
  1137. <select class="input-small" data-bind="options: $root.intervalOptions,
  1138. optionsText: 'label',
  1139. optionsValue: 'value',
  1140. value: properties.gap">
  1141. </select>
  1142. </div>
  1143. <!-- /ko -->
  1144. <!-- ko if: properties.canRange -->
  1145. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1146. <span class="facet-field-label">${ _('Zoom') }</span>
  1147. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1148. </div>
  1149. <!-- /ko -->
  1150. </div>
  1151. <div class="clearfix"></div>
  1152. </div>
  1153. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  1154. <!-- ko if: dimension() == 1 -->
  1155. <div data-bind="barChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(),
  1156. fqs: $root.query.fqs,
  1157. transformer: ($data.type == 'range-up' ? barChartRangeUpDataTransformer : barChartDataTransformer),
  1158. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1159. onClick: function(d) {
  1160. if (d.obj.field != undefined) {
  1161. if ($data.type == 'range-up') {
  1162. viewModel.query.selectRangeUpFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field, 'exclude': false, is_up: d.obj.is_up});
  1163. } else {
  1164. viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field});
  1165. }
  1166. } else {
  1167. viewModel.query.toggleFacet({facet: d.obj, widget_id: d.obj.widget_id});
  1168. }
  1169. },
  1170. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1171. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1172. />
  1173. <!-- /ko -->
  1174. <!-- ko if: dimension() == 2 -->
  1175. <div data-bind="barChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(),
  1176. isPivot: true,
  1177. fqs: $root.query.fqs,
  1178. transformer: pivotChartDataTransformer,
  1179. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1180. onClick: function(d) {
  1181. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1182. },
  1183. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1184. />
  1185. <!-- /ko -->
  1186. <!-- ko if: dimension() == 3 -->
  1187. <div data-bind="timelineChart: {datum: {counts: counts(), extraSeries: extraSeries(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label(), transformer: timelineChartDataTransformer,
  1188. type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
  1189. fqs: $root.query.fqs,
  1190. onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1191. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1192. onClick: function(d){ $root.query.selectRangeFacet({count: d.obj.value, widget_id: $parent.id(), from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
  1193. onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
  1194. <!-- /ko -->
  1195. <!-- /ko -->
  1196. </div>
  1197. <!-- /ko -->
  1198. </script>
  1199. <script type="text/html" id="line-widget">
  1200. <div class="widget-spinner" data-bind="visible: isLoading()">
  1201. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1202. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1203. </div>
  1204. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1205. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1206. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1207. <span data-bind="template: { name: 'facet-toggle' }">
  1208. </span>
  1209. </div>
  1210. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px" data-bind="visible: counts.length > 0">
  1211. <span class="facet-field-label">${ _('Zoom') }</span>
  1212. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1213. </div>
  1214. <div data-bind="lineChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, field: field, label: label(),
  1215. transformer: lineChartDataTransformer,
  1216. onClick: function(d){ viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
  1217. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1218. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1219. />
  1220. </div>
  1221. <!-- /ko -->
  1222. </script>
  1223. <script type="text/html" id="pie-widget">
  1224. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1225. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1226. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1227. <span data-bind="template: { name: 'facet-toggle' }">
  1228. </span>
  1229. </div>
  1230. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1231. <!-- ko if: type() == 'range' -->
  1232. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1233. transformer: rangePieChartDataTransformer,
  1234. maxWidth: 250,
  1235. onClick: function(d){ viewModel.query.selectRangeFacet({count: d.data.obj.value, widget_id: d.data.obj.widget_id, from: d.data.obj.from, to: d.data.obj.to, cat: d.data.obj.field}) },
  1236. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1237. <!-- /ko -->
  1238. <!-- ko if: type() == 'range-up' -->
  1239. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1240. transformer: rangeUpPieChartDataTransformer,
  1241. rangeUp: true,
  1242. maxWidth: 250,
  1243. onClick: function(d){ viewModel.query.selectRangeUpFacet({count: d.data.obj.value, widget_id: d.data.obj.widget_id, from: d.data.obj.from, to: d.data.obj.to, cat: d.data.obj.field, 'exclude': false, is_up: d.data.obj.is_up}) },
  1244. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1245. <!-- /ko -->
  1246. <!-- ko if: type().indexOf('range') == -1 -->
  1247. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1248. transformer: pieChartDataTransformer,
  1249. maxWidth: 250,
  1250. onClick: function(d){ viewModel.query.toggleFacet({facet: d.data.obj, widget_id: d.data.obj.widget_id}) },
  1251. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1252. <!-- /ko -->
  1253. </div>
  1254. </div>
  1255. <!-- /ko -->
  1256. <div class="widget-spinner" data-bind="visible: isLoading()">
  1257. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1258. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1259. </div>
  1260. </script>
  1261. <script type="text/html" id="tree-widget">
  1262. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1263. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1264. <div class="responsive-facet-toggle-section" data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())">
  1265. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1266. </span>
  1267. </div>
  1268. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1269. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1270. <span class="muted">${ _('Selected dimensions') }</span>
  1271. </div>
  1272. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1273. <div class="filter-box">
  1274. <div class="title">
  1275. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1276. <i class="fa fa-times"></i>
  1277. </a>
  1278. <span data-bind="text: field"></span>
  1279. &nbsp;
  1280. </div>
  1281. <div class="content">
  1282. <div class="facet-field-cnt">
  1283. <span class="spinedit-cnt">
  1284. <span class="facet-field-label facet-field-label-fixed-width">
  1285. ${ _('Limit') }
  1286. </span>
  1287. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1288. </span>
  1289. </div>
  1290. <div class="facet-field-cnt">
  1291. <span class="spinedit-cnt">
  1292. <span class="facet-field-label facet-field-label-fixed-width">
  1293. ${ _('Min Count') }
  1294. </span>
  1295. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1296. </span>
  1297. </div>
  1298. </div>
  1299. </div>
  1300. </div>
  1301. <div class="clearfix"></div>
  1302. <!-- ko if: properties.scope() == 'tree' -->
  1303. <div data-bind="partitionChart: {datum: {counts: $parent.counts(), widget_id: $parent.id(), label: $parent.label()},
  1304. fqs: $root.query.fqs,
  1305. tooltip: '${ _ko('Click to zoom, double click to select') }',
  1306. transformer: partitionChartDataTransformer,
  1307. onStateChange: function(state){ },
  1308. onClick: function(d) {
  1309. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1310. },
  1311. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1312. />
  1313. <!-- /ko -->
  1314. </div>
  1315. </div>
  1316. <!-- /ko -->
  1317. <div class="widget-spinner" data-bind="visible: isLoading()">
  1318. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1319. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1320. </div>
  1321. </script>
  1322. <script type="text/html" id="heatmap-widget">
  1323. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1324. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1325. <div class="floating-facet-toggle-section" data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())">
  1326. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1327. </span>
  1328. </div>
  1329. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1330. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1331. <span class="muted">${ _('Selected dimension') }</span>
  1332. </div>
  1333. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1334. <div class="filter-box">
  1335. <div class="title">
  1336. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1337. <i class="fa fa-times"></i>
  1338. </a>
  1339. <span data-bind="text: field"></span>
  1340. &nbsp;
  1341. </div>
  1342. <div class="content">
  1343. <div class="facet-field-cnt">
  1344. <span class="spinedit-cnt">
  1345. <span class="facet-field-label facet-field-label-fixed-width">
  1346. ${ _('Limit') }
  1347. </span>
  1348. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1349. </span>
  1350. </div>
  1351. <div class="facet-field-cnt">
  1352. <span class="spinedit-cnt">
  1353. <span class="facet-field-label facet-field-label-fixed-width">
  1354. ${ _('Min Count') }
  1355. </span>
  1356. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1357. </span>
  1358. </div>
  1359. </div>
  1360. </div>
  1361. </div>
  1362. <div class="clearfix"></div>
  1363. <!-- ko if: properties.scope() == 'stack' -->
  1364. <div data-bind="barChart: {datum: {counts: $parent.counts(), widget_id: $parent.id(), label: $parent.label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(),
  1365. isPivot: true,
  1366. fqs: $root.query.fqs,
  1367. transformer: pivotChartDataTransformer,
  1368. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1369. onClick: function(d) {
  1370. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1371. },
  1372. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1373. />
  1374. <!-- /ko -->
  1375. </div>
  1376. </div>
  1377. <!-- /ko -->
  1378. <div class="widget-spinner" data-bind="visible: isLoading()">
  1379. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1380. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1381. </div>
  1382. </script>
  1383. <script type="text/html" id="hit-widget">
  1384. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
  1385. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1386. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1387. </div>
  1388. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1389. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1390. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1391. <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
  1392. <span class="facet-field-label">${ _('Metric') }</span>
  1393. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: properties.aggregate"></select>
  1394. </div>
  1395. <div data-bind="visible: ! $root.isEditing(), text: getHitOption(properties.aggregate())" class="muted"></div>
  1396. </div>
  1397. <span class="big-counter" data-bind="textSqueezer: counts"></span>
  1398. </div>
  1399. <!-- /ko -->
  1400. </script>
  1401. <script type="text/html" id="filter-widget">
  1402. <div data-bind="visible: $root.query.fqs().length == 0" style="margin-top: 10px; min-height: 87px">
  1403. ${ _('There are currently no filters applied.') }
  1404. </div>
  1405. <div data-bind="foreach: { data: $root.query.fqs, afterRender: function(){ isLoading(false); } }">
  1406. <!-- ko if: $data.type() == 'field' -->
  1407. <div class="filter-box">
  1408. <div class="title">
  1409. <a href="javascript:void(0)" class="pull-right" data-bind="click: function() { chartsUpdatingState(); $root.query.removeFilter($data); $root.search(); }">
  1410. <i class="fa fa-times"></i>
  1411. </a>
  1412. <span data-bind="text: $data.field"></span>
  1413. &nbsp;
  1414. </div>
  1415. <div class="content">
  1416. <strong>${_('selected')}</strong>
  1417. <span data-bind="foreach: $data.filter">
  1418. <span class="label label-info" style="margin-left: 4px" data-bind="visible: ! $data.exclude(), html: prettifyDate($data.value()), attr: {'title': $data.value()}"></span>
  1419. </span>
  1420. <br/>
  1421. <strong>${_('excluded')}</strong>
  1422. <span data-bind="foreach: $data.filter">
  1423. <span class="label label-important" style="margin-left: 4px" data-bind="visible: $data.exclude(), html: prettifyDate($data.value()), attr: {'title': $data.value()}"></span>
  1424. </span>
  1425. </div>
  1426. </div>
  1427. <!-- /ko -->
  1428. <!-- ko if: $data.type() == 'range' || $data.type() == 'range-up' -->
  1429. <div class="filter-box">
  1430. <div class="title">
  1431. <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ chartsUpdatingState(); $root.query.removeFilter($data); $root.search() }">
  1432. <i class="fa fa-times"></i>
  1433. </a>
  1434. <span data-bind="text: $data.field"></span>
  1435. &nbsp;
  1436. </div>
  1437. <div class="content">
  1438. <strong>${_('selected')}</strong>
  1439. <span data-bind="foreach: $data.properties" style="font-weight: normal">
  1440. <!-- ko if: $.grep($parent.filter(), function(f) { return f.value() == $data.from() && ! f.exclude() }).length > 0 -->
  1441. <span class="label label-info">
  1442. <!-- ko if: $parent.type() == 'range' -->
  1443. <span data-bind="html: prettifyDateRange($data.from(), $data.to(), null, true), attr: {'title': $data.from() + ' -> ' + $data.to()}"></span>
  1444. <!-- /ko -->
  1445. <!-- ko if: $parent.type() == 'range-up' -->
  1446. <strong data-bind="visible: ! $parent.is_up()">${ _('Until') }</strong>
  1447. <span data-bind="html: prettifyDate($data.from()), attr: {'title': $data.from()}"></span>
  1448. <strong data-bind="visible: $parent.is_up()"> & Up</strong>
  1449. <!-- /ko -->
  1450. </span>
  1451. <!-- /ko -->
  1452. </span>
  1453. <br/>
  1454. <strong>${_('excluded')}</strong>
  1455. <span data-bind="foreach: $data.properties" style="font-weight: normal" class="excluded">
  1456. <!-- ko if: $.grep($parent.filter(), function(f) { return f.value() == $data.from() && f.exclude() }).length > 0 -->
  1457. <span class="label label-important">
  1458. <span data-bind="html: prettifyDateRange($data.from(), $data.to(), null, true), attr: {'title': $data.from() + ' -> ' + $data.to()}"></span>
  1459. </span>
  1460. <!-- /ko -->
  1461. </span>
  1462. </div>
  1463. </div>
  1464. <!-- /ko -->
  1465. <!-- ko if: $data.type() == 'map' -->
  1466. <div class="filter-box">
  1467. <div class="title">
  1468. <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ chartsUpdatingState(); $root.query.removeFilter($data); $root.search() }">
  1469. <i class="fa fa-times"></i>
  1470. </a>
  1471. <span data-bind="text: $data.lat"></span>, <span data-bind="text: $data.lon"></span>
  1472. &nbsp;
  1473. </div>
  1474. <div class="content">
  1475. <strong>${_('selected')}</strong>
  1476. <span class="label label-info">
  1477. [
  1478. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lat_sw, attr: {'title': '${ _ko('Latitude South West') }'"></span>
  1479. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lon_sw, attr: {'title': '${ _ko('Longitude South West') }'"></span>
  1480. ]
  1481. ${ _("TO") }
  1482. [
  1483. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lat_ne, attr: {'title': '${ _ko('Latitude North East') }'"></span>
  1484. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lon_ne, attr: {'title': '${ _ko('Longitude North East') }'"></span>
  1485. ]
  1486. </span>
  1487. </div>
  1488. </div>
  1489. <!-- /ko -->
  1490. </div>
  1491. <div class="clearfix"></div>
  1492. <div class="widget-spinner" data-bind="visible: isLoading() && $root.query.fqs().length > 0">
  1493. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1494. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1495. </div>
  1496. </script>
  1497. <script type="text/html" id="map-widget">
  1498. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1499. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1500. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1501. <div class="floating-facet-toggle-section">
  1502. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1503. </span>
  1504. </div>
  1505. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1506. <span class="muted">${ _('Selected dimension') }</span>
  1507. </div>
  1508. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1509. <div class="filter-box">
  1510. <div class="title">
  1511. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1512. <i class="fa fa-times"></i>
  1513. </a>
  1514. <span data-bind="text: field"></span>
  1515. &nbsp;
  1516. </div>
  1517. <div class="content">
  1518. <div class="facet-field-cnt">
  1519. <span class="spinedit-cnt">
  1520. <span class="facet-field-label facet-field-label-fixed-width">
  1521. ${ _('Limit') }
  1522. </span>
  1523. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1524. </span>
  1525. </div>
  1526. <div class="facet-field-cnt">
  1527. <span class="spinedit-cnt">
  1528. <span class="facet-field-label facet-field-label-fixed-width">
  1529. ${ _('Min Count') }
  1530. </span>
  1531. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1532. </span>
  1533. </div>
  1534. </div>
  1535. </div>
  1536. </div>
  1537. <div class="clearfix"></div>
  1538. </div>
  1539. <div class="margin-bottom-10" data-bind="visible: ! $root.isEditing()">
  1540. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1541. <!-- ko if: $data.properties.facets().length == 1 -->
  1542. <div class="margin-bottom-10">
  1543. <span data-bind="text: $data.properties.facets()[0].field"></span>
  1544. </div>
  1545. <!-- /ko -->
  1546. </div>
  1547. </div>
  1548. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1549. <div data-bind="mapChart: {data: {counts: $parent.counts(), scope: $root.collection.getFacetById($parent.id()).properties.scope()},
  1550. transformer: mapChartDataTransformer,
  1551. maxWidth: 750,
  1552. isScale: true,
  1553. onClick: function(d) {
  1554. $root.query.togglePivotFacet({facet: {'fq_fields': d.fields, 'fq_values': d.value}, widget_id: id()});
  1555. },
  1556. onComplete: function(){ var widget = viewModel.getWidgetById($parent.id()); if (widget != null) { widget.isLoading(false)}; } }" />
  1557. </div>
  1558. </div>
  1559. <!-- /ko -->
  1560. <div class="widget-spinner" data-bind="visible: isLoading()">
  1561. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1562. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1563. </div>
  1564. </script>
  1565. <script type="text/html" id="leafletmap-widget">
  1566. <div class="row-fluid">
  1567. <div data-bind="visible: $root.isEditing" style="margin-top: 10px; margin-bottom: 20px;" class="leaflet-align">
  1568. <span class="facet-field-label">${_('Latitude')}</span><div class="break-on-small-column"></div>
  1569. <select data-bind="options: $root.collection.template.sortedGeogFieldsNames, value: $root.collection.template.leafletmap.latitudeField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1570. &nbsp;&nbsp;
  1571. <div class="break-on-small-column"></div>
  1572. <span class="facet-field-label">${_('Longitude')}</span><div class="break-on-small-column"></div>
  1573. <select data-bind="options: $root.collection.template.sortedGeogFieldsNames, value: $root.collection.template.leafletmap.longitudeField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1574. &nbsp;&nbsp;
  1575. <div class="break-on-small-column"></div>
  1576. <span class="facet-field-label">${_('Label')}</span><div class="break-on-small-column"></div>
  1577. <select data-bind="options: $root.collection.template.fieldsNames, value: $root.collection.template.leafletmap.labelField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1578. </div>
  1579. <div data-bind="leafletMapChart: {showMoveCheckbox: true, moveCheckboxLabel: '${ _ko('Search as I move the map') }', visible: $root.hasRetrievedResults() && $root.collection.template.leafletmapOn(), isLoading: isLoading(), datum: {counts: $root.response()},
  1580. transformer: leafletMapChartDataTransformer,
  1581. onRegionChange: function(bounds){ $root.query.selectMapRegionFacet({widget_id: id(), 'bounds': ko.toJS(bounds, null, 2), lat: $root.collection.template.leafletmap.latitudeField(), lon: $root.collection.template.leafletmap.longitudeField()}); },
  1582. onComplete: function(){ var widget = viewModel.getWidgetById(id()); if (widget != null) { widget.isLoading(false)}; } }">
  1583. </div>
  1584. </div>
  1585. <div class="widget-spinner" data-bind="visible: isLoading()">
  1586. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1587. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1588. </div>
  1589. </script>
  1590. <script type="text/html" id="analysis-window">
  1591. <!-- ko if: $root.fieldAnalysesName() -->
  1592. <div data-bind="with: $root.getFieldAnalysis()">
  1593. <div class="pull-right">
  1594. <input type="text" data-bind="visible: section() == 'terms', clearable: terms.prefix, valueUpdate:'afterkeydown'" placeholder="${ _('Prefix filter...') }"/>
  1595. <input type="text" data-bind="visible: section() == 'stats', clearable: stats.facet, typeahead: { target: stats.facet, source: $root.fieldsAnalysisAttributesNames, triggerOnFocus: true }" placeholder="${ _('Field name...') }"/>
  1596. </div>
  1597. <ul class="nav nav-tabs" role="tablist">
  1598. <li class="active"><a href="#analysis-terms" role="tab" data-toggle="tab" data-bind="click: function() { section('terms'); }">${ _('Terms') }</a></li>
  1599. <li><a href="#analysis-stats" role="tab" data-toggle="tab" data-bind="click: function() { section('stats'); }">${ _('Stats') }</a></li>
  1600. </ul>
  1601. <div class="tab-content">
  1602. <div class="tab-pane active" id="analysis-terms" data-bind="with: terms">
  1603. <div class="widget-spinner" data-bind="visible: $parent.isLoading()">
  1604. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1605. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1606. </div>
  1607. <div class="alert" data-bind="visible: ! $parent.isLoading() && $data.data().length == 0">${ _('There are no terms to be shown') }</div>
  1608. <table style="width: 100%" data-bind="visible: ! $parent.isLoading() && $data.data().length > 0" class="table-striped">
  1609. <tbody data-bind="foreach: $data.data">
  1610. <tr>
  1611. <td data-bind="text: val.value"></td>
  1612. <td style="width: 22px" data-bind="click: $root.query.addSingleTermFacet">
  1613. <a href="javascript: void(0)"><i class="fa fa-plus" title="${ _('Select this value') }"></i></a>
  1614. </td>
  1615. <td style="width: 22px" data-bind="click: $root.query.removeSingleTermFacet">
  1616. <a href="javascript: void(0)"><i class="fa fa-minus" title="${ _('Exclude this value') }"></i></a>
  1617. </td>
  1618. <td style="width: 40px">
  1619. <div class="progress">
  1620. <div class="bar-label" data-bind="text:val.count"></div>
  1621. <div class="bar bar-info" style="margin-top:-20px;" data-bind="style: {'width': ((val.count / $parent.data()[0].val.count) * 100) + '%'}"></div>
  1622. </div>
  1623. </td>
  1624. </tr>
  1625. </tbody>
  1626. </table>
  1627. </div>
  1628. <div class="tab-pane" id="analysis-stats" data-bind="with: stats">
  1629. <div class="widget-spinner" data-bind="visible: $parent.isLoading()">
  1630. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1631. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1632. </div>
  1633. <div class="alert" data-bind="visible: ! $parent.isLoading() && $data.data().length > 0 && $data.data()[0].key.toLowerCase() == 'error'">${ _('This field does not support stats') }</div>
  1634. <div class="alert" data-bind="visible: ! $parent.isLoading() && $data.data().length == 0">${ _('There are no stats to be shown') }</div>
  1635. <table style="width: 100%" data-bind="visible: ! $parent.isLoading() && $data.data().length > 0 && $data.data()[0].key.toLowerCase() != 'error'" class="table-striped">
  1636. <tbody data-bind="foreach: $data.data">
  1637. <tr>
  1638. <td style="vertical-align: top"><strong data-bind="text: key"></strong></td>
  1639. <!-- ko if: key == 'facets' -->
  1640. <td>
  1641. <!-- ko if: val[Object.keys(val)[0]] != null -->
  1642. <table style="width: 400px">
  1643. <tbody data-bind="foreach: Object.keys(val[Object.keys(val)[0]])">
  1644. <tr>
  1645. <td style="vertical-align: top; padding-left: 4px; padding-right: 4px"><strong data-bind="text: $data"></strong></td>
  1646. <td data-bind="template: 'stats-facets'"></td>
  1647. </tr>
  1648. </tbody>
  1649. </table>
  1650. <!-- /ko -->
  1651. <!-- ko ifnot: val[Object.keys(val)[0]] != null -->
  1652. ${ _('Not available') }
  1653. <!-- /ko -->
  1654. </td>
  1655. <!-- /ko -->
  1656. <!-- ko ifnot: key == 'facets' -->
  1657. <td data-bind="text: val"></td>
  1658. <!-- /ko -->
  1659. </tr>
  1660. </tbody>
  1661. </table>
  1662. </div>
  1663. </div>
  1664. </div>
  1665. <!-- /ko -->
  1666. </script>
  1667. <script type="text/html" id="stats-facets">
  1668. <table style="width: 100%">
  1669. <tbody data-bind="foreach: Object.keys($parent.val[Object.keys($parent.val)[0]][$data])">
  1670. <tr>
  1671. <td style="vertical-align: top; padding-left: 4px; padding-right: 4px"><strong data-bind="text: $data"></strong></td>
  1672. <!-- ko ifnot: $data == 'facets' -->
  1673. <td style="vertical-align: top" data-bind="text: $parents[1].val[Object.keys($parents[1].val)[0]][$parent][$data]"></td>
  1674. <!-- /ko -->
  1675. </tr>
  1676. </tbody>
  1677. </table>
  1678. </script>
  1679. <div id="addFacetDemiModal" class="demi-modal fade" data-backdrop="false">
  1680. <div class="modal-body">
  1681. <a href="javascript: void(0)" data-dismiss="modal" data-bind="click: addFacetDemiModalFieldCancel" class="pull-right"><i class="fa fa-times"></i></a>
  1682. <div style="float: left; margin-right: 10px;text-align: center">
  1683. <input id="addFacetInput" type="text" data-bind="clearable: $root.collection.template.fieldsModalFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" class="input" style="float: left" /><br/>
  1684. </div>
  1685. <div>
  1686. <ul data-bind="foreach: $root.collection.template.filteredModalFields().sort(function (l, r) { return l.name() > r.name() ? 1 : -1 }), visible: $root.collection.template.filteredModalFields().length > 0"
  1687. class="unstyled inline fields-chooser" style="height: 100px; overflow-y: auto">
  1688. <li data-bind="click: addFacetDemiModalFieldPreview">
  1689. <span class="badge badge-info"><span data-bind="text: name(), attr: {'title': type()}"></span>
  1690. </span>
  1691. </li>
  1692. </ul>
  1693. <div class="alert alert-info inline" data-bind="visible: $root.collection.template.filteredModalFields().length == 0" style="margin-left: 250px;margin-right: 50px; height: 42px;line-height: 42px">
  1694. ${_('There are no fields matching your search term.')}
  1695. </div>
  1696. </div>
  1697. </div>
  1698. <div><a class="pointer demi-modal-chevron" data-dismiss="modal" data-bind="click: addFacetDemiModalFieldCancel"><i class="fa fa-chevron-up"></i></a></div>
  1699. </div>
  1700. <div id="settingsDemiModal" class="demi-modal fade" data-backdrop="false">
  1701. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1702. <div class="modal-body">
  1703. <div class="row-fluid">
  1704. <div class="span12">
  1705. <form class="form-horizontal">
  1706. <fieldset>
  1707. <legend><i class="fa fa-cogs"></i> ${ _('General settings') }</legend>
  1708. <!-- ko if: $root.initial.inited() -->
  1709. <div class="control-group">
  1710. <label class="control-label" for="settingssolrindex">${ _('Solr index') }</label>
  1711. <div class="controls">
  1712. <select id="settingssolrindex" data-bind="options: $root.initial.collections, value: $root.collection.name"></select>
  1713. </div>
  1714. </div>
  1715. <!-- /ko -->
  1716. <div class="control-group">
  1717. <label class="control-label" for="settingsdescription">${ _('Description') }</label>
  1718. <div class="controls">
  1719. <input id="settingsdescription" type="text" class="input-xlarge" data-bind="value: $root.collection.description" style="margin-bottom: 0" />
  1720. </div>
  1721. </div>
  1722. <div class="control-group">
  1723. <label class="control-label">${ _('Autocomplete') }</label>
  1724. <div class="controls">
  1725. <label class="checkbox" style="padding-top:0">
  1726. <input type="checkbox" style="margin-right: 4px; margin-top: 9px" data-bind="checked: $root.collection.suggest.enabled"> ${ _('Dictionary') } <input type="text" class="input-xlarge" style="margin-bottom: 0; margin-left: 6px;" data-bind="value: $root.collection.suggest.dictionary" placeholder="${ _('Dictionary name or blank for default') }">
  1727. </label>
  1728. </div>
  1729. </div>
  1730. </fieldset>
  1731. </form>
  1732. </div>
  1733. </div>
  1734. </div>
  1735. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1736. </div>
  1737. <div id="qdefinitionsDemiModal" class="demi-modal fade" data-backdrop="false">
  1738. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1739. <div class="modal-body">
  1740. <div class="row-fluid">
  1741. <div class="span12">
  1742. <form class="form-inline">
  1743. <fieldset>
  1744. <legend><i class="fa fa-bookmark-o"></i> ${ _('Query definitions') }
  1745. <div class="input-append" style="margin-left: 30px; margin-top: 4px">
  1746. <input id="newqname" type="text" class="input-xxlarge" data-bind="value: $root.collection.newQDefinitionName, valueUpdate:'afterkeydown'" style="margin-bottom: 0" placeholder="${ _('Add current query as...') }" />
  1747. <a title="${ _('Click on this button to add the currenty query as a new definition') }" class="btn plus-btn" data-bind="click: $root.collection.addQDefinition, css:{'disabled': $.trim($root.collection.newQDefinitionName()) == ''}" style="margin-top: 1px">
  1748. <i class="fa fa-plus"></i>
  1749. </a>
  1750. </div>
  1751. </legend>
  1752. <div class="control-group" data-bind="visible: $root.collection.qdefinitions().length > 0" style="margin-top: 0">
  1753. <div class="controls">
  1754. <ul class="unstyled airy qdefinitions" data-bind="foreach: $root.collection.qdefinitions">
  1755. <li>
  1756. <span class="badge badge-info badge-left pointer">
  1757. <span data-bind="text: name, attr:{'title': ko.mapping.toJSON(data, null, 2)}, click: $root.collection.loadQDefinition"></span>
  1758. </span><span class="badge badge-right trash-share" data-bind="click: $root.collection.removeQDefinition"> <i class="fa fa-times"></i></span></li>
  1759. </li>
  1760. </ul>
  1761. </div>
  1762. </div>
  1763. <div class="control-group" data-bind="visible: $root.collection.qdefinitions().length == 0">
  1764. <div class="controls">
  1765. <h4>${ _('There are currently no query definitions.') }</h4>
  1766. </div>
  1767. </div>
  1768. </fieldset>
  1769. </form>
  1770. </div>
  1771. </div>
  1772. </div>
  1773. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1774. </div>
  1775. <script type="text/html" id="time-filter">
  1776. <span data-bind="visible: $root.availableDateFields().length > 0" >
  1777. <span data-bind="template: {name: 'time-filter-select'}"></span>
  1778. <a class="btn pointer" title="${ _('Time Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#timeSettingsDemiModal">
  1779. <i class="fa fa-calendar"></i>
  1780. </a>
  1781. </span>
  1782. </script>
  1783. <script type="text/html" id="time-fixed-filter">
  1784. <span data-bind="visible: $root.availableDateFields().length > 0" class="muted" title="${ _('Time Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#timeSettingsDemiModal" style="cursor:pointer">
  1785. &nbsp;
  1786. <span data-bind="text: moment($root.collection.timeFilter.from()).utc().format('YYYY-MM-DD HH:mm:SS')"></span>
  1787. <i class="fa fa-long-arrow-right"></i>
  1788. <span data-bind="text: moment($root.collection.timeFilter.to()).utc().format('YYYY-MM-DD HH:mm:SS')"></span>
  1789. </span>
  1790. </script>
  1791. <script type="text/html" id="time-filter-select">
  1792. <select id="settingstimeinterval" data-bind="value: collection.timeFilter.value" class="input-medium" style="margin-right: 4px">
  1793. <option value="all">${ _('All') }</option>
  1794. <option value="5MINUTES">${ _('Past 5 Minutes') }</option>
  1795. <option value="30MINUTES">${ _('Past 30 Minutes') }</option>
  1796. <option value="1HOURS">${ _('Past 1 Hour') }</option>
  1797. <option value="12HOURS">${ _('Past 12 Hours') }</option>
  1798. <option value="1DAYS">${ _('Past day') }</option>
  1799. <option value="2DAYS">${ _('Past 2 days') }</option>
  1800. <option value="7DAYS">${ _('Past 7 days') }</option>
  1801. <option value="1MONTHS">${ _('Past 1 Month') }</option>
  1802. <option value="3MONTHS">${ _('Past 3 Months') }</option>
  1803. <option value="1YEARS">${ _('Past Year') }</option>
  1804. <option value="2YEARS">${ _('Past 2 Years') }</option>
  1805. <option value="10YEARS">${ _('Past 10 Years') }</option>
  1806. </select>
  1807. </script>
  1808. <div id="timeSettingsDemiModal" class="demi-modal fade" data-backdrop="false">
  1809. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1810. <div class="modal-body">
  1811. <div class="row-fluid">
  1812. <div class="span12">
  1813. <form class="form-horizontal">
  1814. <fieldset>
  1815. <legend><i class="fa fa-calendar"></i> ${ _('Time settings') }</legend>
  1816. <span data-bind="visible: $root.availableDateFields().length > 0">
  1817. <div class="control-group">
  1818. <label class="control-label" for="settingstimefield">${ _('Date/time field') }</label>
  1819. <div class="controls">
  1820. <select id="settingstimefield" data-bind="options: $root.availableDateFields, value: collection.timeFilter.field, optionsValue: 'name'" class="input-medium"></select>
  1821. </div>
  1822. </div>
  1823. <div class="control-group">
  1824. <label class="control-label" for="settingstimetype">${ _('Type') }</label>
  1825. <div class="controls">
  1826. <label class="radio inline"><input type="radio" name="settingstimetype" value="rolling" data-bind="checked: collection.timeFilter.type" /> ${ _('Rolling') }</label>
  1827. <label class="radio inline"><input type="radio" name="settingstimetype" value="fixed" data-bind="checked: collection.timeFilter.type" /> ${ _('Fixed') }</label>
  1828. </div>
  1829. </div>
  1830. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'rolling'">
  1831. <label class="control-label" for="settingstimeinterval">${ _('Interval') }</label>
  1832. <div class="controls">
  1833. <span data-bind="template: {name: 'time-filter-select'}"></span>
  1834. </div>
  1835. </div>
  1836. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'fixed'">
  1837. <label class="control-label" for="settingstimestart">${ _('Start date/time') }</label>
  1838. <div class="controls">
  1839. <input id="settingstimestart" type="text" data-bind="value: collection.timeFilter.from, datepicker: {momentFormat: 'YYYY-MM-DD[T]HH:mm:SS[Z]'}" />
  1840. </div>
  1841. </div>
  1842. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'fixed'">
  1843. <label class="control-label" for="settingstimeend">${ _('End date/time') }</label>
  1844. <div class="controls">
  1845. <input id="settingstimeend" type="text" data-bind="value: collection.timeFilter.to, datepicker: {momentFormat: 'YYYY-MM-DD[T]HH:mm:SS[Z]'}" />
  1846. </div>
  1847. </div>
  1848. <div class="control-group">
  1849. <div class="controls">
  1850. <label class="checkbox">
  1851. <input type="checkbox" style="margin-right: 4px; margin-top: 9px" data-bind="checked: $root.collection.autorefresh"/> ${ _('Auto-refresh every') } <input type="number" class="input-mini" style="margin-bottom: 0; margin-left: 6px; margin-right: 6px; width: 46px; text-align:center" data-bind="value: $root.collection.autorefreshSeconds"/> ${ _('seconds') }
  1852. </label>
  1853. </div>
  1854. </div>
  1855. </span>
  1856. <!-- ko if: $root.availableDateFields().length == 0 -->
  1857. <label class="checkbox">
  1858. <input type="checkbox" style="margin-right: 4px; margin-top: 9px" data-bind="checked: $root.collection.autorefresh"/> ${ _('Auto-refresh every') } <input type="number" class="input-mini" style="margin-bottom: 0; margin-left: 6px; margin-right: 6px; width: 46px; text-align:center" data-bind="value: $root.collection.autorefreshSeconds"/> ${ _('seconds') }
  1859. </label>
  1860. <!-- /ko -->
  1861. </fieldset>
  1862. </form>
  1863. </div>
  1864. </div>
  1865. </div>
  1866. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1867. </div>
  1868. <div id="fieldAnalysis" class="popover mega-popover right">
  1869. <div class="arrow"></div>
  1870. <h3 class="popover-title" style="text-align: left">
  1871. <a class="pull-right pointer" data-bind="click: function(){ $('#fieldAnalysis').hide(); $root.fieldAnalysesName(''); }"><i class="fa fa-times"></i></a>
  1872. <strong data-bind="text: $root.fieldAnalysesName"></strong> ${ _(' field analysis') }
  1873. </h3>
  1874. <div class="popover-content" data-bind="template: { name: 'analysis-window' }" style="text-align: left"></div>
  1875. </div>
  1876. ## Extra code for style and custom JS
  1877. <span id="extra" data-bind="augmenthtml: $root.collection.template.extracode"></span>
  1878. <link rel="stylesheet" href="${ static('search/css/search.css') }">
  1879. <link rel="stylesheet" href="${ static('desktop/ext/css/hue-filetypes.css') }">
  1880. <link rel="stylesheet" href="${ static('desktop/ext/css/hue-charts.css') }">
  1881. <link rel="stylesheet" href="${ static('desktop/ext/chosen/chosen.min.css') }">
  1882. <link rel="stylesheet" href="${ static('desktop/ext/select2/select2.css') }">
  1883. <script src="${ static('desktop/js/hue.json.js') }" type="text/javascript" charset="utf-8"></script>
  1884. ${ dashboard.import_layout(True) }
  1885. <script src="${ static('search/js/search.utils.js') }" type="text/javascript" charset="utf-8"></script>
  1886. <script src="${ static('desktop/js/jquery.textsqueezer.js') }" type="text/javascript" charset="utf-8"></script>
  1887. <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }" type="text/javascript" charset="utf-8"></script>
  1888. <script src="${ static('desktop/js/ko.editable.js') }" type="text/javascript" charset="utf-8"></script>
  1889. <script src="${ static('desktop/ext/js/shortcut.js') }" type="text/javascript" charset="utf-8"></script>
  1890. <script src="${ static('desktop/ext/js/mustache.js') }" type="text/javascript" charset="utf-8"></script>
  1891. <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
  1892. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.hotkeys.js') }"></script>
  1893. <script src="${ static('desktop/ext/select2/select2.min.js') }" type="text/javascript" charset="utf-8"></script>
  1894. <script src="${ static('search/js/search.ko.js') }" type="text/javascript" charset="utf-8"></script>
  1895. ${ dashboard.import_bindings() }
  1896. ${ dashboard.import_charts() }
  1897. <style type="text/css">
  1898. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  1899. .search-bar {
  1900. top: 58px!important;
  1901. }
  1902. .card-toolbar {
  1903. top: 100px!important;
  1904. }
  1905. #emptyDashboardEditing {
  1906. top: 190px!important;
  1907. }
  1908. .dashboard {
  1909. margin-top: 20px;
  1910. }
  1911. .dashboard.with-top-margin {
  1912. margin-top: 80px;
  1913. }
  1914. % endif
  1915. </style>
  1916. <script type="text/javascript" charset="utf-8">
  1917. var viewModel;
  1918. nv.dev = false;
  1919. moment.suppressDeprecationWarnings = true;
  1920. var HIT_OPTIONS = [
  1921. { value: "count", label: "${ _('Count') }" },
  1922. { value: "unique", label: "${ _('Unique Count') }" },
  1923. { value: "avg", label: "${ _('Average') }" },
  1924. { value: "sum", label: "${ _('Sum') }" },
  1925. { value: "min", label: "${ _('Min') }" },
  1926. { value: "max", label: "${ _('Max') }" },
  1927. { value: "sumsq", label: "${ _('Sum of square') }" },
  1928. { value: "median", label: "${ _('Median') }" }
  1929. ];
  1930. function getHitOption(value){
  1931. for (var i=0; i < HIT_OPTIONS.length; i++){
  1932. if (HIT_OPTIONS[i].value == value){
  1933. return HIT_OPTIONS[i].label;
  1934. }
  1935. }
  1936. return '';
  1937. }
  1938. function prettifyDate(from, widget, to) {
  1939. if (typeof from == "undefined" || $.isNumeric(from)) {
  1940. return from;
  1941. }
  1942. if (typeof to != "undefined" && !$.isNumeric(to)) {
  1943. return prettifyDateRange(from, to, widget);
  1944. }
  1945. var _mFrom = moment(from);
  1946. if (_mFrom.isValid()) {
  1947. var _format = "YYYY-MM-DD HH:mm:ss";
  1948. var _minMaxDiff = 0;
  1949. if (widget && widget.properties && widget.properties.min && widget.properties.min()) {
  1950. _minMaxDiff = moment(widget.properties.max()).diff(moment(widget.properties.min()), 'seconds');
  1951. if (moment(widget.properties.max()).seconds() == 0 && moment(widget.properties.min()).seconds() == 0) {
  1952. _format = _format.substring(0, 16); // gets rid of :00 seconds
  1953. }
  1954. }
  1955. _format = getFormat(_format, _minMaxDiff, widget);
  1956. return _mFrom.utc().format(_format);
  1957. }
  1958. else {
  1959. return from;
  1960. }
  1961. }
  1962. function prettifyDateRange(from, to, widget, withCommon) {
  1963. if (typeof from == "undefined" || $.isNumeric(from)) {
  1964. return from + " - " + to;
  1965. }
  1966. var _mFrom = moment(from);
  1967. var _mTo = moment(to);
  1968. if (_mFrom.isValid() && _mTo.isValid()) {
  1969. var _mFromFormatted = _mFrom.utc().format("YYYY-MM-DD HH:mm:ss");
  1970. var _mToFormatted = _mTo.utc().format("YYYY-MM-DD HH:mm:ss");
  1971. var _lastEqual = _mFromFormatted.length - 1;
  1972. for (var i = _mFromFormatted.length - 1; i >= 0; i--) {
  1973. if (_mFromFormatted[i] == _mToFormatted[i] && (_mFromFormatted[i] == "0" || _mFromFormatted[i] == ":")) {
  1974. _lastEqual = i;
  1975. }
  1976. else break;
  1977. }
  1978. var _minMaxDiff = moment(to).diff(moment(from), 'seconds');
  1979. var _format = "YYYY-MM-DD HH:mm:ss".substr(0, _lastEqual);
  1980. if (_format.length == 13){
  1981. _format += ":mm"; // hours without minutes are weird
  1982. }
  1983. var _formatWithCommon = _format.substring(10, _format.length);
  1984. var _common = "YYYY-MM-DD";
  1985. if (widget && widget.properties && widget.properties.min && widget.properties.min()) {
  1986. _minMaxDiff = moment(widget.properties.max()).diff(moment(widget.properties.min()), 'seconds');
  1987. }
  1988. if (withCommon && _mTo.diff(_mFrom, 'days') >= 365){
  1989. withCommon = false;
  1990. _format = _common;
  1991. }
  1992. else {
  1993. _format = getFormat(_format, _minMaxDiff, widget);
  1994. }
  1995. return ((_common != "" && withCommon) ? _mFrom.utc().format(_common) + "&nbsp;" : "") + _mFrom.utc().format(withCommon ? _formatWithCommon : _format) + " <i class='fa fa-long-arrow-right'></i> " + ((_common != "" && withCommon) ? _mTo.utc().format(_common) + "&nbsp;" : "") + _mTo.utc().format(withCommon ? _formatWithCommon : _format);
  1996. }
  1997. else {
  1998. return from + " - " + to;
  1999. }
  2000. }
  2001. function getFormat(format, minMaxDiff, widget) {
  2002. var _hasWidget = widget && widget.properties && widget.properties.min && widget.properties.min();
  2003. if (minMaxDiff > 0 && minMaxDiff <= 86400) { // max 1 day
  2004. if (_hasWidget && moment(widget.properties.max()).date() != moment(widget.properties.min()).date()) {
  2005. format = format.substring(5, format.length);
  2006. }
  2007. else {
  2008. format = format.substring(10, format.length);
  2009. }
  2010. }
  2011. if (minMaxDiff > 86400 && minMaxDiff <= 22464000) { // max 360 days
  2012. format = format.substring(5, format.length);
  2013. }
  2014. if (minMaxDiff > 22464000){
  2015. format = format.substr(0, 10);
  2016. }
  2017. if (format.indexOf("MM") == 0) {
  2018. format = "MMM " + format.substr(3);
  2019. }
  2020. return format;
  2021. }
  2022. var lastWindowScrollPosition = 0;
  2023. function pieChartDataTransformer(data) {
  2024. var _data = [];
  2025. $(data.counts).each(function (cnt, item) {
  2026. item.widget_id = data.widget_id;
  2027. _data.push({
  2028. label: item.value,
  2029. value: item.count,
  2030. obj: item
  2031. });
  2032. });
  2033. return _data;
  2034. }
  2035. function _rangePieChartDataTransformer(data, isUp) {
  2036. var _data = [];
  2037. $(data.counts).each(function (cnt, item) {
  2038. item.widget_id = data.widget_id;
  2039. var _label = isUp ? (item.from + (item.is_up ? ' & ${ _('Up') }' : ' & ${ _('Less') }')) : (item.from + ' - ' + item.to);
  2040. _data.push({
  2041. label: _label,
  2042. from: item.from,
  2043. to: item.to,
  2044. value: item.value,
  2045. obj: item
  2046. });
  2047. });
  2048. return _data;
  2049. }
  2050. function rangePieChartDataTransformer(data) {
  2051. return _rangePieChartDataTransformer(data, false);
  2052. }
  2053. function rangeUpPieChartDataTransformer(data) {
  2054. return _rangePieChartDataTransformer(data, true);
  2055. }
  2056. function pieChartDataTransformerGrid(data) {
  2057. var _data = [];
  2058. var chartX = viewModel.collection.template.chartSettings.chartX();
  2059. var chartY = viewModel.collection.template.chartSettings.chartYSingle();
  2060. $(data.counts).each(function (cnt, item) {
  2061. item.widget_id = data.widget_id;
  2062. if (chartX != "" && item.item[chartX] && chartY != "" && item.item[chartY]) {
  2063. _data.push({
  2064. label: item.item[chartX](),
  2065. value: item.item[chartY](),
  2066. obj: item
  2067. });
  2068. }
  2069. });
  2070. return _data;
  2071. }
  2072. function _barChartDataTransformer(rawDatum, isUp) {
  2073. var _datum = [];
  2074. var _data = [];
  2075. $(rawDatum.counts).each(function (cnt, item) {
  2076. item.widget_id = rawDatum.widget_id;
  2077. if (typeof item.from != "undefined") {
  2078. if (isUp){
  2079. _data.push({
  2080. series: 0,
  2081. x: item.from + (item.is_up ? ' & ${ _('Up') }' : ' & ${ _('Less') }'),
  2082. y: item.value,
  2083. obj: item
  2084. });
  2085. }
  2086. else {
  2087. _data.push({
  2088. series: 0,
  2089. x: item.from,
  2090. x_end: item.to,
  2091. y: item.value,
  2092. obj: item
  2093. });
  2094. }
  2095. }
  2096. else {
  2097. _data.push({
  2098. series: 0,
  2099. x: item.value,
  2100. y: item.count,
  2101. obj: item
  2102. });
  2103. }
  2104. });
  2105. _datum.push({
  2106. key: rawDatum.label,
  2107. values: _data
  2108. });
  2109. return _datum;
  2110. }
  2111. function barChartDataTransformer(rawDatum) {
  2112. return _barChartDataTransformer(rawDatum, false);
  2113. }
  2114. function barChartRangeUpDataTransformer(rawDatum) {
  2115. return _barChartDataTransformer(rawDatum, true);
  2116. }
  2117. function _partitionChartDataTransformer(counts) {
  2118. var _categories = [];
  2119. $(counts).each(function (cnt, item) {
  2120. var _category = null;
  2121. _categories.forEach(function (category) {
  2122. if (category.name == item.value) {
  2123. _category = category;
  2124. }
  2125. });
  2126. if (_category == null) {
  2127. _category = {
  2128. name: item.value,
  2129. size: item.count,
  2130. obj: item,
  2131. children: []
  2132. }
  2133. _categories.push(_category);
  2134. }
  2135. if (item.pivot != undefined) {
  2136. var children = []
  2137. $(item.pivot).each(function (cnt, child) {
  2138. children = children.concat(_partitionChartDataTransformer(child));
  2139. });
  2140. _category.children = children;
  2141. }
  2142. });
  2143. return _categories;
  2144. }
  2145. function partitionChartDataTransformer(rawDatum) {
  2146. var _partitionData = {
  2147. name: "${ _('Total') }",
  2148. children: []
  2149. }
  2150. _partitionData.children = _partitionChartDataTransformer(rawDatum.counts);
  2151. return _partitionData;
  2152. }
  2153. function pivotChartDataTransformer(rawDatum) {
  2154. var _categories = [];
  2155. $(rawDatum.counts).each(function (cnt, item) {
  2156. item.widget_id = rawDatum.widget_id;
  2157. var _key = Array.isArray(item.value) ? item.value[1] : item.value;
  2158. var _category = null;
  2159. _categories.forEach(function (category) {
  2160. if (category.key == _key) {
  2161. _category = category;
  2162. }
  2163. });
  2164. if (_category == null) {
  2165. _category = {
  2166. key: _key,
  2167. values: []
  2168. };
  2169. _categories.push(_category);
  2170. }
  2171. _category.values.push({
  2172. series: 0,
  2173. x: item.cat,
  2174. y: item.count,
  2175. obj: item
  2176. });
  2177. });
  2178. return _categories;
  2179. }
  2180. function lineChartDataTransformer(rawDatum) {
  2181. var _datum = [];
  2182. var _data = [];
  2183. $(rawDatum.counts).each(function (cnt, item) {
  2184. item.widget_id = rawDatum.widget_id;
  2185. if (typeof item.from != "undefined") {
  2186. _data.push({
  2187. series: 0,
  2188. x: item.from,
  2189. x_end: item.to,
  2190. y: item.value,
  2191. obj: item
  2192. });
  2193. }
  2194. else {
  2195. _data.push({
  2196. series: 0,
  2197. x: item.value,
  2198. y: item.count,
  2199. obj: item
  2200. });
  2201. }
  2202. });
  2203. _datum.push({
  2204. key: rawDatum.label,
  2205. values: _data
  2206. });
  2207. return _datum;
  2208. }
  2209. function timelineChartDataTransformer(rawDatum) {
  2210. var _datum = [];
  2211. var _data = [];
  2212. $(rawDatum.counts).each(function (cnt, item) {
  2213. _data.push({
  2214. series: 0,
  2215. x: new Date(moment(item.from).valueOf()),
  2216. y: item.value,
  2217. obj: item
  2218. });
  2219. });
  2220. _datum.push({
  2221. key: rawDatum.label,
  2222. values: _data
  2223. });
  2224. // If multi query
  2225. $(rawDatum.extraSeries).each(function (cnt, item) {
  2226. if (cnt == 0) {
  2227. _datum = [];
  2228. }
  2229. var _data = [];
  2230. $(item.counts).each(function (cnt, item) {
  2231. _data.push({
  2232. series: cnt + 1,
  2233. x: new Date(moment(item.from).valueOf()),
  2234. y: item.value,
  2235. obj: item
  2236. });
  2237. });
  2238. _datum.push({
  2239. key: item.label,
  2240. values: _data
  2241. });
  2242. });
  2243. return _datum;
  2244. }
  2245. function mapChartDataTransformer(data) {
  2246. var _data = [];
  2247. $(data.counts).each(function (cnt, item) {
  2248. item.fields = item.pivot ? item.pivot[0].fq_fields : item.fq_fields;
  2249. item.values = item.pivot ? item.pivot[0].fq_values : item.fq_values;
  2250. item.counts = item.pivot ? item.pivot[0].count : item.count; // unused yet
  2251. item.is2d = item.pivot ? true : false; // unused yet
  2252. if (item.value != null && item.value != "" && item.value.length < 4) {
  2253. var _label = data.scope == "world" ? HueGeo.getISOAlpha3(item.value) : item.value.toUpperCase();
  2254. var _found = false;
  2255. for (var i = 0; i < _data.length; i++) { // we group lower and upper cases together
  2256. if (_data[i].label == _label) {
  2257. _data[i].value += item.pivot ? item.pivot[0].fq_values : item.count;
  2258. _found = true;
  2259. break;
  2260. }
  2261. }
  2262. if (!_found) {
  2263. _data.push({
  2264. label: _label,
  2265. value: item.pivot ? item.pivot[0].fq_values : item.count,
  2266. obj: item
  2267. });
  2268. }
  2269. }
  2270. });
  2271. return _data;
  2272. }
  2273. function leafletMapChartDataTransformer(data) {
  2274. var _data = [];
  2275. if (!$.isEmptyObject(data.counts) && data.counts.response.docs && viewModel.collection.template.leafletmap.latitudeField() != "" && viewModel.collection.template.leafletmap.longitudeField() != "") {
  2276. data.counts.response.docs.forEach(function (record) {
  2277. var _obj = {
  2278. lat: record[viewModel.collection.template.leafletmap.latitudeField()],
  2279. lng: record[viewModel.collection.template.leafletmap.longitudeField()]
  2280. }
  2281. if (viewModel.collection.template.leafletmap.labelField() != "") {
  2282. _obj.label = record[viewModel.collection.template.leafletmap.labelField()];
  2283. }
  2284. _data.push(_obj);
  2285. });
  2286. }
  2287. return _data;
  2288. }
  2289. function leafletMapChartDataTransformerGrid(data) {
  2290. var _data = [];
  2291. $(data.counts).each(function (cnt, item) {
  2292. var chartX = viewModel.collection.template.chartSettings.chartX();
  2293. var chartY = viewModel.collection.template.chartSettings.chartYSingle();
  2294. var chartMapLabel = viewModel.collection.template.chartSettings.chartMapLabel();
  2295. if (chartX != "" && item.item[chartX] && chartY != "" && item.item[chartY]) {
  2296. var _obj = {
  2297. lat: item.item[chartX](),
  2298. lng: item.item[chartY]()
  2299. }
  2300. if (chartMapLabel != "" && item.item[chartMapLabel]) {
  2301. _obj.label = item.item[chartMapLabel]();
  2302. }
  2303. _data.push(_obj);
  2304. }
  2305. });
  2306. return _data;
  2307. }
  2308. function multiSerieDataTransformer(rawDatum) {
  2309. var _datum = [];
  2310. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYMulti().length > 0) {
  2311. var _plottedSerie = 0;
  2312. rawDatum.snippet.chartYMulti().forEach(function (col) {
  2313. var _idxValue = -1;
  2314. var _idxLabel = -1;
  2315. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2316. if (icol.name == rawDatum.snippet.chartX()) {
  2317. _idxLabel = idx;
  2318. }
  2319. if (icol.name == col) {
  2320. _idxValue = idx;
  2321. }
  2322. });
  2323. if (_idxValue > -1) {
  2324. var _data = [];
  2325. $(rawDatum.counts()).each(function (cnt, item) {
  2326. _data.push({
  2327. series: _plottedSerie,
  2328. x: item[_idxLabel],
  2329. y: item[_idxValue],
  2330. obj: item
  2331. });
  2332. });
  2333. if (rawDatum.sorting == "asc") {
  2334. _data.sort(function (a, b) {
  2335. return a.y - b.y
  2336. });
  2337. }
  2338. if (rawDatum.sorting == "desc") {
  2339. _data.sort(function (a, b) {
  2340. return b.y - a.y
  2341. });
  2342. }
  2343. _datum.push({
  2344. key: col,
  2345. values: _data
  2346. });
  2347. _plottedSerie++;
  2348. }
  2349. });
  2350. }
  2351. return _datum;
  2352. }
  2353. function multiSerieDataTransformerGrid(rawDatum) {
  2354. var _datum = [];
  2355. var chartX = viewModel.collection.template.chartSettings.chartX();
  2356. var chartY = viewModel.collection.template.chartSettings.chartYMulti();
  2357. if (chartX != null && chartY.length > 0 && rawDatum.counts.length > 0) {
  2358. var _plottedSerie = 0;
  2359. chartY.forEach(function (col) {
  2360. var _data = [];
  2361. $(rawDatum.counts).each(function (cnt, item) {
  2362. if (item.item[chartX] && item.item[col]) {
  2363. _data.push({
  2364. series: _plottedSerie,
  2365. x: item.item[chartX](),
  2366. y: item.item[col](),
  2367. obj: item.item
  2368. });
  2369. }
  2370. });
  2371. if (rawDatum.sorting == "asc") {
  2372. _data.sort(function (a, b) {
  2373. return a.y - b.y
  2374. });
  2375. }
  2376. if (rawDatum.sorting == "desc") {
  2377. _data.sort(function (a, b) {
  2378. return b.y - a.y
  2379. });
  2380. }
  2381. _datum.push({
  2382. key: col,
  2383. values: _data
  2384. });
  2385. _plottedSerie++;
  2386. });
  2387. }
  2388. return _datum;
  2389. }
  2390. function resizeFieldsList() {
  2391. $(".fields-list").css("max-height", Math.max($("#result-container").height(), 230));
  2392. window.setTimeout(function () {
  2393. var _fillHeight = $("#result-container").height() - 40;
  2394. if ($(".fields-list").height() < _fillHeight) {
  2395. $(".fields-list").height(_fillHeight);
  2396. $(".fields-list").css("max-height", _fillHeight);
  2397. }
  2398. }, 100);
  2399. var positionInfo = function () {
  2400. var leftPos = 184;
  2401. if ($('.fields-list').get(0).scrollHeight > $('.fields-list').height()) {
  2402. leftPos -= hueUtils.scrollbarWidth();
  2403. }
  2404. $('.fields-list i').css('left', (leftPos + $('.fields-list').scrollLeft()) + 'px');
  2405. }
  2406. var checkHeight = function () {
  2407. if ($('.fields-list').height() > 0) {
  2408. positionInfo();
  2409. } else {
  2410. window.setTimeout(checkHeight, 100);
  2411. }
  2412. }
  2413. checkHeight();
  2414. $('.fields-list').off('scroll');
  2415. $('.fields-list').on('scroll', positionInfo);
  2416. }
  2417. function toggleDocDetails(doc) {
  2418. doc.showDetails(! doc.showDetails());
  2419. if (doc.details().length == 0) {
  2420. viewModel.getDocument(doc, resizeFieldsList);
  2421. }
  2422. else {
  2423. window.setTimeout(resizeFieldsList, 0);
  2424. }
  2425. }
  2426. function queryTypeahead(query, process) {
  2427. var _source = viewModel.collection.template.fieldsNames();
  2428. _source = _source.concat("AND OR TO".split(" "))
  2429. if (viewModel.collection.suggest.enabled()) {
  2430. viewModel.suggest(query, function (data) {
  2431. var _tmp = [];
  2432. if (typeof data != "undefined" && data.response && data.response.suggest && data.response.suggest[viewModel.collection.suggest.dictionary()]) {
  2433. var suggestions = data.response.suggest[viewModel.collection.suggest.dictionary()][query].suggestions;
  2434. suggestions.forEach(function (sugg) {
  2435. _tmp.push(sugg.term + "<i class='muted fa fa-search'></i>");
  2436. });
  2437. }
  2438. process(_tmp.concat(_source));
  2439. });
  2440. }
  2441. else {
  2442. return _source;
  2443. }
  2444. }
  2445. $(document).ready(function () {
  2446. var _resizeTimeout = -1;
  2447. $(window).resize(function(){
  2448. window.clearTimeout(_resizeTimeout);
  2449. window.setTimeout(function(){
  2450. resizeFieldsList();
  2451. }, 200);
  2452. });
  2453. $(document).on("click", ".widget-settings-pill", function(){
  2454. $(this).parents(".card-body").find(".widget-section").hide();
  2455. selectAllCollectionFields(); // Make sure all the collection fields appear
  2456. $(this).parents(".card-body").find(".widget-settings-section").show();
  2457. $(this).parent().siblings().removeClass("active");
  2458. $(this).parent().addClass("active");
  2459. });
  2460. $(document).on("click", ".widget-editor-pill", function(){
  2461. $(this).parents(".card-body").find(".widget-section").hide();
  2462. $(this).parents(".card-body").find(".widget-editor-section").show();
  2463. $(this).parent().siblings().removeClass("active");
  2464. $(this).parent().addClass("active");
  2465. });
  2466. $(document).on("click", ".widget-html-pill", function(){
  2467. $(this).parents(".card-body").find(".widget-section").hide();
  2468. $(this).parents(".card-body").find(".widget-html-section").show();
  2469. $(document).trigger("refreshCodemirror");
  2470. $(this).parent().siblings().removeClass("active");
  2471. $(this).parent().addClass("active");
  2472. });
  2473. $(document).on("click", ".widget-css-pill", function(){
  2474. $(this).parents(".card-body").find(".widget-section").hide();
  2475. $(this).parents(".card-body").find(".widget-css-section").show();
  2476. $(document).trigger("refreshCodemirror");
  2477. $(this).parent().siblings().removeClass("active");
  2478. $(this).parent().addClass("active");
  2479. });
  2480. $(document).on("magicLayout", function(){
  2481. resizeFieldsList();
  2482. });
  2483. $(document).on("setLayout", function(){
  2484. resizeFieldsList();
  2485. });
  2486. huePubSub.subscribe('gridChartForceUpdate', function () {
  2487. window.setTimeout(function () {
  2488. $('.grid-chart-container').children().trigger('forceUpdate')
  2489. }, 200);
  2490. });
  2491. var _query = ${ query | n,unicode };
  2492. viewModel = new SearchViewModel(${ collection.get_json(user) | n,unicode }, _query, ${ initial | n,unicode });
  2493. viewModel.timelineChartTypes = ko.observableArray([
  2494. {
  2495. value: "line",
  2496. label: "${ _('Lines')}"
  2497. },
  2498. {
  2499. value: "bar",
  2500. label: "${ _('Bars')}"
  2501. }
  2502. ]);
  2503. ko.applyBindings(viewModel);
  2504. viewModel.init(function(data){
  2505. $(".chosen-select").trigger("chosen:updated");
  2506. });
  2507. viewModel.isRetrievingResults.subscribe(function(value){
  2508. if (! value){
  2509. resizeFieldsList();
  2510. }
  2511. });
  2512. viewModel.isEditing.subscribe(function(value){
  2513. if (value){
  2514. window.setTimeout(function(){
  2515. if ($(".slider-cnt").length > 0 && $(".slider-cnt").data("slider")){
  2516. $(".slider-cnt").slider("redraw");
  2517. }
  2518. }, 300);
  2519. }
  2520. });
  2521. viewModel.isPlayerMode.subscribe(function(value) {
  2522. if (value){
  2523. $(".navigator").hide();
  2524. $("body").css("paddingTop", "40px");
  2525. }
  2526. else {
  2527. $(".navigator").show();
  2528. $("body").css("paddingTop", "80px");
  2529. }
  2530. });
  2531. var _refreshTimeout = null;
  2532. viewModel.collection.autorefresh.subscribe(function (value) {
  2533. if (value) {
  2534. refresh();
  2535. }
  2536. else {
  2537. window.clearTimeout(_refreshTimeout);
  2538. }
  2539. });
  2540. if (viewModel.collection.autorefresh()) {
  2541. refresh();
  2542. }
  2543. function refresh() {
  2544. _refreshTimeout = window.setTimeout(function () {
  2545. if (viewModel.collection.autorefresh()) {
  2546. viewModel.search(refresh);
  2547. }
  2548. }, ($.isNumeric(viewModel.collection.autorefreshSeconds()) ? viewModel.collection.autorefreshSeconds() * 1 : 60) * 1000)
  2549. }
  2550. $("#addFacetDemiModal").on("hidden", function () {
  2551. if (typeof selectedWidget.hasBeenSelected == "undefined"){
  2552. addFacetDemiModalFieldCancel();
  2553. }
  2554. });
  2555. $(document).on("shownAnalysis", function(){
  2556. var _fieldElement = $(".field-selector").filter(function(){ return $(this).text().toLowerCase() === viewModel.fieldAnalysesName().toLowerCase();}).parent();
  2557. $("#fieldAnalysis").show().css("top", _fieldElement.position().top - $("#fieldAnalysis").outerHeight()/2 + _fieldElement.outerHeight()/2).css("left", _fieldElement.position().left + _fieldElement.outerWidth());
  2558. });
  2559. % if is_owner:
  2560. $(window).bind("keydown", "ctrl+s alt+s meta+s", function(e){
  2561. e.preventDefault();
  2562. viewModel.save();
  2563. return false;
  2564. });
  2565. % endif
  2566. $(window).bind("keydown", "esc", function () {
  2567. if ($(".demi-modal.fade.in").length > 0) {
  2568. $(".demi-modal.fade.in .demi-modal-chevron").click();
  2569. }
  2570. });
  2571. $("#newqname").bind("keydown", "return", function (e) {
  2572. e.preventDefault();
  2573. viewModel.collection.addQDefinition();
  2574. });
  2575. $(document).on("loadedQDefinition", function() {
  2576. if ($(".demi-modal.fade.in").length > 0) {
  2577. $(".demi-modal.fade.in .demi-modal-chevron").click();
  2578. }
  2579. });
  2580. function loadQueryDefinition(id) {
  2581. var _qdef = viewModel.collection.getQDefinition(id);
  2582. if (_qdef != null) {
  2583. viewModel.collection.loadQDefinition(_qdef);
  2584. }
  2585. }
  2586. if (window.location.hash != "" && window.location.hash.indexOf("qd=") > -1) {
  2587. loadQueryDefinition(window.location.hash.substr(1).replace(/(<([^>]+)>)/ig, "").split("=")[1]);
  2588. }
  2589. else if (_query.qd) {
  2590. loadQueryDefinition(_query.qd);
  2591. }
  2592. });
  2593. function toggleGridFieldsSelection() {
  2594. viewModel.resultsHash = '';
  2595. if (viewModel.collection.template.fields().length > 0) {
  2596. viewModel.collection.template.fieldsSelected([])
  2597. }
  2598. else {
  2599. selectAllCollectionFields();
  2600. }
  2601. }
  2602. function selectAllCollectionFields() {
  2603. var _fields = [];
  2604. $.each(viewModel.collection.fields(), function (index, field) {
  2605. _fields.push(field.name());
  2606. });
  2607. viewModel.collection.template.fieldsSelected(_fields);
  2608. }
  2609. function columnDropAdditionalHandler(widget) {
  2610. if (viewModel.collection.getFacetById(widget.id()) == null) {
  2611. showAddFacetDemiModal(widget);
  2612. }
  2613. viewModel.search();
  2614. }
  2615. function widgetDraggedAdditionalHandler(widget, row) {
  2616. showAddFacetDemiModal(widget, row);
  2617. }
  2618. function distributeRowWidgetsSize(row, waitForIt) {
  2619. if (row) {
  2620. if (waitForIt) {
  2621. var _initial = row.widgets().length;
  2622. var _widgetDropInterval = window.setInterval(function () {
  2623. if (row.widgets().length != _initial) {
  2624. window.clearInterval(_widgetDropInterval);
  2625. row.autosizeWidgets();
  2626. }
  2627. }, 100)
  2628. }
  2629. else {
  2630. row.autosizeWidgets();
  2631. }
  2632. }
  2633. }
  2634. var selectedWidget = null;
  2635. var selectedRow = null;
  2636. function showAddFacetDemiModal(widget, row) {
  2637. if (["resultset-widget", "html-resultset-widget", "filter-widget", "leafletmap-widget"].indexOf(widget.widgetType()) == -1) {
  2638. viewModel.collection.template.fieldsModalFilter("");
  2639. viewModel.collection.template.fieldsModalType(widget.widgetType());
  2640. viewModel.collection.template.fieldsModalFilter.valueHasMutated();
  2641. $('#addFacetInput').typeahead({
  2642. 'source': viewModel.collection.template.availableWidgetFieldsNames(),
  2643. 'updater': function (item) {
  2644. addFacetDemiModalFieldPreview({'name': function () {
  2645. return item
  2646. }});
  2647. return item;
  2648. }
  2649. });
  2650. selectedWidget = widget;
  2651. selectedRow = row;
  2652. $("#addFacetDemiModal").modal("show");
  2653. $("#addFacetDemiModal input[type='text']").focus();
  2654. }
  2655. else {
  2656. distributeRowWidgetsSize(row, true);
  2657. }
  2658. }
  2659. function addFacetDemiModalFieldPreview(field) {
  2660. var _existingFacet = viewModel.collection.getFacetById(selectedWidget.id());
  2661. if (selectedWidget != null) {
  2662. selectedWidget.hasBeenSelected = true;
  2663. selectedWidget.isLoading(true);
  2664. viewModel.collection.addFacet({'name': field.name(), 'widget_id': selectedWidget.id(), 'widgetType': selectedWidget.widgetType()});
  2665. if (_existingFacet != null) {
  2666. _existingFacet.label(field.name());
  2667. _existingFacet.field(field.name());
  2668. }
  2669. $("#addFacetDemiModal").modal("hide");
  2670. if (selectedRow != null) {
  2671. distributeRowWidgetsSize(selectedRow);
  2672. }
  2673. }
  2674. }
  2675. function addFacetDemiModalFieldCancel() {
  2676. viewModel.removeWidget(selectedWidget);
  2677. selectedRow = null;
  2678. }
  2679. $(document).on("setResultsHeight", function () {
  2680. $("#result-main").height($("#result-container").outerHeight() + 100);
  2681. resizeFieldsList();
  2682. });
  2683. function highlightColumn(column) {
  2684. var _colName = $.trim(column.name());
  2685. if (viewModel.collection.template.fieldsSelected.indexOf(_colName) > -1) {
  2686. var _t = $("#result-container");
  2687. var _col = _t.find("th").filter(function () {
  2688. return $.trim($(this).text()) == _colName;
  2689. });
  2690. if (_t.find("tr td:nth-child(" + (_col.index() + 1) + ").columnSelected").length == 0) {
  2691. _t.find(".columnSelected").removeClass("columnSelected");
  2692. _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
  2693. _t.parent().animate({
  2694. scrollLeft: _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").position().left + _t.parent().scrollLeft() - _t.parent().offset().left - 30
  2695. }, 300);
  2696. }
  2697. else {
  2698. _t.find(".columnSelected").removeClass("columnSelected");
  2699. }
  2700. }
  2701. }
  2702. function checkResultHighlightingAvailability() {
  2703. if (! viewModel.collection.idField()) {
  2704. $(document).trigger("warn", "${ _('Result highlighting is unavailable: the collection does not have an index field') }");
  2705. }
  2706. }
  2707. </script>
  2708. ${ commonfooter(request, messages) | n,unicode }