search.mako 145 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971
  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="${ _('Player mode') }" rel="tooltip" data-placement="bottom" data-bind="click: function(){ hueUtils.goFullScreen(); $root.isEditing(false); $root.isPlayerMode(true); }">
  36. <i class="fa fa-expand"></i>
  37. </a>
  38. &nbsp;&nbsp;
  39. <a class="btn pointer" title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}">
  40. <i class="fa fa-pencil"></i>
  41. </a>
  42. % if is_owner:
  43. <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">
  44. <i class="fa fa-save"></i>
  45. </a>
  46. % endif
  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, 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"></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" data-bind="visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART"></i>
  516. <i class="hcha hcha-line-chart" 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" 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"></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"></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"></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() }"><i
  557. class="fa fa-cog"></i></a>
  558. </div>
  559. <form method="POST" action="${ url('search:download') }" style="display:inline">
  560. ${ csrf_token(request) | n,unicode }
  561. <input type="hidden" name="collection" data-bind="value: ko.mapping.toJSON($root.collection)"/>
  562. <input type="hidden" name="query" data-bind="value: ko.mapping.toJSON($root.query)"/>
  563. <input type="hidden" name="download">
  564. <input type="hidden" name="type" value="">
  565. <div class="dropdown">
  566. <a class="grid-side-btn dropdown-toggle" style="padding-left:7px" data-toggle="dropdown">
  567. <i class="fa fa-download"></i>
  568. </a>
  569. <ul class="dropdown-menu">
  570. <li>
  571. <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') }">
  572. <i class="hfo hfo-file-csv"></i> CSV
  573. </a>
  574. </li>
  575. <li>
  576. <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') }">
  577. <i class="hfo hfo-file-xls"></i> Excel
  578. </a>
  579. </li>
  580. <li>
  581. <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') }">
  582. <i class="hfo hfo-file-json"></i> JSON
  583. </a>
  584. </li>
  585. </ul>
  586. </div>
  587. </form>
  588. <!-- /ko -->
  589. </div>
  590. </div>
  591. </div>
  592. <div class="grid-results">
  593. <span data-bind="visible: $root.hasRetrievedResults() && $root.response().response">
  594. <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; border-right:1px solid #EEE">
  595. <input type="text" data-bind="clearable: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width:180px; margin-bottom:10px" />
  596. <div style="margin-bottom: 8px">
  597. <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>
  598. </div>
  599. <div style="border-bottom: 1px solid #CCC; padding-bottom: 4px;">
  600. <a href="javascript: void(0)" class="btn btn-mini"
  601. data-bind="click: toggleGridFieldsSelection, css: { 'btn-inverse': $root.collection.template.fields().length > 0 }"
  602. style="margin-right: 2px;">
  603. <i class="fa fa-square-o"></i>
  604. </a>
  605. <strong>${_('Field Name')}</strong>
  606. </div>
  607. <div class="fields-list" data-bind="foreach: $root.collection.template.filteredAttributeFields">
  608. <div style="margin-bottom: 3px; white-space: nowrap">
  609. <i class="fa fa-question-circle pull-right muted pointer analysis" data-bind="click: function() { $root.fieldAnalysesName(name()); $root.showFieldAnalysis(); }, attr: {'title': '${ _ko('Click to analyze field') } ' + name() + ' (' + type() + ')'}"></i>
  610. <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" style="margin: 0" />
  611. <div data-bind="text: name, css:{'field-selector': true, 'hoverable': $root.collection.template.fieldsSelected.indexOf(name()) > -1}, click: highlightColumn" style="margin-right:10px"></div>
  612. </div>
  613. </div>
  614. <div data-bind="visible: $root.collection.template.filteredAttributeFields().length == 0" style="padding-left:4px; padding-top:5px; font-size:40px; color:#CCC">
  615. <i class="fa fa-frown-o"></i>
  616. </div>
  617. </div>
  618. <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; border-right: 1px solid #EEE">
  619. <span data-bind="template: {name: 'grid-chart-settings', data: $root.collection.template.chartSettings}"></span>
  620. </div>
  621. </span>
  622. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults() || !$root.response().response">
  623. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  624. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  625. </div>
  626. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length == 0 && $root.response().response">
  627. <br/>
  628. ${ _('Your search did not match any documents.') }
  629. </div>
  630. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length > 0 && $root.collection.template.showGrid()">
  631. <!-- ko if: $root.response().response -->
  632. <div data-bind="template: {name: 'resultset-pagination', data: $root.response()}" style="padding:8px; color:#666"></div>
  633. <!-- /ko -->
  634. <div id="result-main" style="overflow-x: auto">
  635. <table id="result-container" data-bind="visible: $root.hasRetrievedResults()" style="margin-top: 0; width: 100%">
  636. <thead>
  637. <tr data-bind="visible: $root.collection.template.fieldsSelected().length > 0, template: {name: 'result-sorting'}">
  638. </tr>
  639. <tr data-bind="visible: $root.collection.template.fieldsSelected().length == 0">
  640. <th style="width: 18px">&nbsp;</th>
  641. <th>${ _('Document') }</th>
  642. </tr>
  643. </thead>
  644. <tbody data-bind="foreach: {data: $root.results, as: 'doc'}" class="result-tbody">
  645. <tr class="result-row" data-bind="style: {'backgroundColor': $index() % 2 == 0 ? '#FFF': '#F6F6F6'}">
  646. <td>
  647. <a href="javascript:void(0)" data-bind="click: toggleDocDetails">
  648. <i class="fa" data-bind="css: {'fa-caret-right' : ! doc.showDetails(), 'fa-caret-down': doc.showDetails()}"></i>
  649. </a>
  650. </td>
  651. <!-- ko foreach: row -->
  652. <td data-bind="html: $data"></td>
  653. <!-- /ko -->
  654. </tr>
  655. <tr data-bind="visible: doc.showDetails" class="show-details">
  656. <td>&nbsp;</td>
  657. <td data-bind="attr: {'colspan': $root.collection.template.fieldsSelected().length > 0 ? $root.collection.template.fieldsSelected().length + 1 : 2}">
  658. <span data-bind="template: {name: 'document-details', data: $data}"></span>
  659. </td>
  660. </tr>
  661. </tbody>
  662. </table>
  663. </div>
  664. </div>
  665. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length > 0 && $root.collection.template.showChart()">
  666. <div data-bind="visible: !$root.collection.template.hasDataForChart()" style="padding: 10px">${ _('Please select the chart parameters on the left.') }</div>
  667. <div class="grid-chart-container" data-bind="visible: $root.collection.template.hasDataForChart" style="overflow-x: auto">
  668. <div data-bind="attr:{'id': 'pieChart_'+id()}, pieChart: {data: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data}, fqs: ko.observableArray([]),
  669. transformer: pieChartDataTransformerGrid, maxWidth: 350, parentSelector: '.chart-container' }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="chart"></div>
  670. <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,
  671. transformer: multiSerieDataTransformerGrid, stacked: false, showLegend: true}, stacked: true, showLegend: true, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
  672. <div data-bind="attr:{'id': 'lineChart_'+id()}, lineChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
  673. transformer: multiSerieDataTransformerGrid, showControls: false }, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART" class="chart"></div>
  674. <div data-bind="attr:{'id': 'leafletMapChart_'+id()}, leafletMapChart: {datum: {counts: $root.results(), sorting: $root.collection.template.chartSettings.chartSorting(), snippet: $data},
  675. transformer: leafletMapChartDataTransformerGrid, showControls: false, height: 380, visible: $root.collection.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.MAP, forceRedraw: true}" class="chart"></div>
  676. </div>
  677. </div>
  678. </div>
  679. </div>
  680. <!-- /ko -->
  681. </script>
  682. <script type="text/html" id="grid-chart-settings">
  683. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  684. <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>
  685. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('region')}</li>
  686. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('latitude')}</li>
  687. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="nav-header">${_('legend')}</li>
  688. </ul>
  689. <div data-bind="visible: chartType() != ''">
  690. <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>
  691. </div>
  692. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  693. <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>
  694. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('longitude')}</li>
  695. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="nav-header">${_('value')}</li>
  696. </ul>
  697. <div style="overflow-y: scroll; max-height: 220px" data-bind="visible: chartType() != '' && (chartType() == ko.HUE_CHARTS.TYPES.BARCHART || chartType() == ko.HUE_CHARTS.TYPES.LINECHART)">
  698. <ul class="unstyled" data-bind="foreach: $root.collection.template.cleanedNumericMeta">
  699. <li><input type="checkbox" data-bind="checkedValue: name, checked: $parent.chartYMulti" /> <span data-bind="text: $data.name"></span></li>
  700. </ul>
  701. </div>
  702. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART || chartType() == ko.HUE_CHARTS.TYPES.MAP">
  703. <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>
  704. </div>
  705. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.MAP">
  706. <li class="nav-header">${_('label')}</li>
  707. </ul>
  708. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP">
  709. <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>
  710. </div>
  711. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP">
  712. <li class="nav-header">${_('sorting')}</li>
  713. </ul>
  714. <div class="btn-group" data-toggle="buttons-radio" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP">
  715. <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>
  716. <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>
  717. <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>
  718. </div>
  719. </script>
  720. <script type="text/html" id="html-resultset-widget">
  721. <!-- ko ifnot: $root.collection.template.isGridLayout() -->
  722. <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
  723. <ul class="nav nav-pills">
  724. <li class="active"><a href="javascript: void(0)" class="widget-editor-pill">${_('Editor')}</a></li>
  725. <li><a href="javascript: void(0)" class="widget-html-pill">${_('HTML')}</a></li>
  726. <li><a href="javascript: void(0)" class="widget-css-pill">${_('CSS & JS')}</a></li>
  727. <li><a href="javascript: void(0)" class="widget-settings-pill">${_('Sorting')}</a></li>
  728. </ul>
  729. </div>
  730. <!-- ko if: $root.isEditing() -->
  731. <div class="widget-section widget-editor-section">
  732. <div class="row-fluid">
  733. <div class="span9">
  734. <div data-bind="freshereditor: {data: $root.collection.template.template}"></div>
  735. </div>
  736. <div class="span3">
  737. <h5 class="editor-title">${_('Available Fields')}</h5>
  738. <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedVisualField" class="input-large chosen-select"></select>
  739. <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToVisual">
  740. <i class="fa fa-plus"></i>
  741. </button>
  742. <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h5>
  743. <select id="visualFunctions" data-bind="value: $root.collection.template.selectedVisualFunction" class="input-large chosen-select">
  744. <option title="${ _('Formats date or timestamp in DD-MM-YYYY') }" value="{{#date}} {{/date}}">{{#date}}</option>
  745. <option title="${ _('Formats date or timestamp in HH:mm:ss') }" value="{{#time}} {{/time}}">{{#time}}</option>
  746. <option title="${ _('Formats date or timestamp in DD-MM-YYYY HH:mm:ss') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
  747. <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
  748. <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
  749. <option title="${ _('Formats a Unix timestamp as Ns, Nmin, Ndays... ago') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
  750. <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
  751. <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
  752. <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
  753. <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
  754. <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
  755. <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
  756. </select>
  757. <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToVisual">
  758. <i class="fa fa-plus"></i>
  759. </button>
  760. <p class="muted" style="margin-top: 10px"></p>
  761. </div>
  762. </div>
  763. </div>
  764. <div class="widget-section widget-html-section" style="display: none">
  765. <div class="row-fluid">
  766. <div class="span9">
  767. <textarea data-bind="codemirror: {data: $root.collection.template.template, lineNumbers: true, htmlMode: true, mode: 'text/html', stripScript: true }" data-template="true"></textarea>
  768. </div>
  769. <div class="span3">
  770. <h5 class="editor-title">${_('Available Fields')}</h5>
  771. <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedSourceField" class="input-medium chosen-select"></select>
  772. <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToSource">
  773. <i class="fa fa-plus"></i>
  774. </button>
  775. <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h5>
  776. <select id="sourceFunctions" data-bind="value: $root.collection.template.selectedSourceFunction" class="input-medium chosen-select">
  777. <option title="${ _('Formats a date in the DD-MM-YYYY format') }" value="{{#date}} {{/date}}">{{#date}}</option>
  778. <option title="${ _('Formats a date in the HH:mm:ss format') }" value="{{#time}} {{/time}}">{{#time}}</option>
  779. <option title="${ _('Formats a date in the DD-MM-YYYY HH:mm:ss format') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
  780. <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
  781. <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
  782. <option title="${ _('Shows the relative time') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
  783. <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
  784. <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
  785. <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
  786. <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
  787. <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
  788. <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
  789. </select>
  790. <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToSource">
  791. <i class="fa fa-plus"></i>
  792. </button>
  793. <p class="muted" style="margin-top: 10px"></p>
  794. </div>
  795. </div>
  796. </div>
  797. <div class="widget-section widget-css-section" style="display: none">
  798. <textarea data-bind="codemirror: {data: $root.collection.template.extracode, lineNumbers: true, htmlMode: true, mode: 'text/html' }"></textarea>
  799. </div>
  800. <div class="widget-section widget-settings-section" style="display: none">
  801. <div style="overflow-x: scroll; min-height: 40px">
  802. <table>
  803. <tr data-bind="template: {name: 'result-sorting'}">
  804. </tr>
  805. </table>
  806. </div>
  807. <br/>
  808. </div>
  809. <!-- /ko -->
  810. <div id="result-main" style="overflow-x: auto">
  811. <div data-bind="visible: $root.hasRetrievedResults() && $root.results().length == 0">
  812. <br/>
  813. ${ _('Your search did not match any documents.') }
  814. </div>
  815. <!-- ko if: $root.response().response && $root.results().length > 0 -->
  816. <div data-bind="template: {name: 'resultset-pagination', data: $root.response() }"></div>
  817. <!-- /ko -->
  818. <table id="result-container" data-bind="visible: $root.hasRetrievedResults()" style="margin-top: 0; width: 100%">
  819. <thead>
  820. <tr>
  821. <th>&nbsp;</th>
  822. </tr>
  823. </thead>
  824. <tbody data-bind="foreach: {data: $root.results, as: 'doc'}" class="result-tbody">
  825. <tr data-bind="style: {'backgroundColor': $index() % 2 == 0 ? '#FFF': '#F6F6F6'}">
  826. <td><div data-bind="html: content" style="margin-bottom: -20px"></div></td>
  827. </tr>
  828. <tr>
  829. <td class="show-details-icon pointer" data-bind="click: toggleDocDetails">
  830. <i class="fa" data-bind="css: {'fa-caret-down' : ! doc.showDetails(), 'fa-caret-up': doc.showDetails()}"></i>
  831. </td>
  832. </tr>
  833. <tr data-bind="visible: doc.showDetails" class="show-details">
  834. <td data-bind="attr: {'colspan': $root.collection.template.fieldsSelected().length > 0 ? $root.collection.template.fieldsSelected().length + 1 : 2}">
  835. <span data-bind="template: {name: 'document-details', data: $data}"></span>
  836. </td>
  837. </tr>
  838. </tbody>
  839. </table>
  840. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
  841. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  842. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  843. </div>
  844. </div>
  845. <!-- /ko -->
  846. </script>
  847. <script type="text/html" id="document-details">
  848. <!-- ko if: $data.details().length == 0 -->
  849. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  850. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  851. <!-- /ko -->
  852. <!-- ko if: $data.details().length > 0 -->
  853. <div class="document-details-actions pull-left" data-bind="visible: ${ 'true' if can_edit_index else 'false' } || externalLink()">
  854. <a href="javascript:void(0)" data-bind="visible: ! showEdit(), click: function() { showEdit(true); }" title="${ _('Edit this document') }">
  855. <i class="fa fa-edit fa-fw"></i>
  856. </a>
  857. <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') }">
  858. <i class="fa fa-undo fa-fw"></i>
  859. </a>
  860. <a href="javascript:void(0)" data-bind="visible: showEdit() && originalDetails() != ko.toJSON(details), click: $root.updateDocument" title="${ _('Update this document') }">
  861. <i class="fa fa-save fa-fw"></i>
  862. </a>
  863. <a href="javascript:void(0)" data-bind="visible: externalLink(), attr: { href: externalLink}" target="_blank" title="${ _('Show original document') }">
  864. <i class="fa fa-external-link fa-fw"></i>
  865. </a>
  866. </div>
  867. <div class="document-details pull-left">
  868. <table>
  869. <tbody data-bind="foreach: details">
  870. <tr data-bind="css: {'readonly': ! $parent.showEdit()}">
  871. <th class="grid-th" data-bind="text: key"></th>
  872. <td width="100%">
  873. <span data-bind="text: value, visible: ! $parent.showEdit()"></span>
  874. <input data-bind="value: value, visible: $parent.showEdit, valueUpdate: 'afterkeydown',
  875. click: function(detail, e){
  876. var target = $(e.currentTarget);
  877. target.parents('.show-details').find('.document-details-actions').animate({
  878. 'marginTop': (target.position().top - target.parents('table').position().top) + 'px'
  879. }, 200)
  880. }" class="input-xxlarge" style="width: 600px" />
  881. </td>
  882. </tr>
  883. </tbody>
  884. </table>
  885. </div>
  886. <!-- /ko -->
  887. </script>
  888. <script type="text/html" id="result-sorting">
  889. <th style="width: 18px">&nbsp;</th>
  890. <!-- ko foreach: $root.collection.template.fieldsSelected -->
  891. <th data-bind="with: $root.collection.getTemplateField($data), event: { mouseover: $root.enableGridlayoutResultChevron, mouseout: $root.disableGridlayoutResultChevron }" style="white-space: nowrap">
  892. <div style="display: inline-block; width:20px;">
  893. <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'left'); }">
  894. <i class="fa fa-chevron-left" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() > 0"></i>
  895. <i class="fa fa-chevron-left" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == 0"></i>
  896. </a>
  897. </div>
  898. <div style="display: inline-block;">
  899. <a href="javascript: void(0)" data-bind="click: $root.collection.toggleSortColumnGridLayout" title="${ _('Click to sort') }">
  900. <span data-bind="text: name"></span>
  901. <i class="fa" data-bind="visible: sort.direction() != null, css: { 'fa-chevron-down': sort.direction() == 'desc', 'fa-chevron-up': sort.direction() == 'asc' }"></i>
  902. </a>
  903. </div>
  904. <div style="display: inline-block; width:20px;">
  905. <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'right'); }">
  906. <i class="fa fa-chevron-right" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() < $root.collection.template.fields().length - 1"></i>
  907. <i class="fa fa-chevron-up" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == $root.collection.template.fields().length - 1,"></i>
  908. </a>
  909. </div>
  910. </th>
  911. <!-- /ko -->
  912. </script>
  913. <script type="text/html" id="resultset-pagination">
  914. <div style="text-align: center; margin-top: 4px">
  915. <a href="javascript: void(0)" title="${ _('Previous') }">
  916. <span data-bind="click: $root.collection.toggleSortColumnGridLayout"></span>
  917. <i class="fa fa-arrow-left" data-bind="
  918. visible: $data.response.start * 1.0 >= $root.collection.template.rows() * 1.0,
  919. click: function() { $root.query.paginate('prev') }">
  920. </i>
  921. </a>
  922. ${ _('Showing') }
  923. <span data-bind="text: ($data.response.start + 1)"></span>
  924. ${ _('to') }
  925. <span data-bind="text: Math.min(($data.response.start + $root.collection.template.rows()), $data.response.numFound)"></span>
  926. ${ _('of') }
  927. <span data-bind="text: $data.response.numFound"></span>
  928. ${ _(' results') }
  929. <span data-bind="visible: $root.isEditing()">
  930. ${ _('Show') }
  931. <span class="spinedit-cnt">
  932. <input type="text" data-bind="spinedit: $root.collection.template.rows, valueUpdate:'afterkeydown'" style="text-align: center; margin-bottom: 0" />
  933. </span>
  934. ${ _('results per page') }
  935. </span>
  936. <a href="javascript: void(0)" title="${ _('Next') }">
  937. <span data-bind="click: $root.collection.toggleSortColumnGridLayout"></span>
  938. <i class="fa fa-arrow-right" data-bind="
  939. visible: ($root.collection.template.rows() * 1.0 + $data.response.start * 1.0) < $data.response.numFound,
  940. click: function() { $root.query.paginate('next') }">
  941. </i>
  942. </a>
  943. </div>
  944. </script>
  945. <script type="text/html" id="histogram-widget">
  946. <div class="widget-spinner" data-bind="visible: isLoading()">
  947. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  948. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  949. </div>
  950. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  951. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  952. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  953. <span data-bind="template: { name: 'facet-toggle' }">
  954. </span>
  955. </div>
  956. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px" data-bind="visible: counts().length > 0">
  957. <span data-bind="with: $root.collection.getFacetById($parent.id())">
  958. <span class="facet-field-label">${ _('Chart Type') }</span>
  959. <select class="input-small" data-bind="options: $root.timelineChartTypes,
  960. optionsText: 'label',
  961. optionsValue: 'value',
  962. value: properties.timelineChartType">
  963. </select>&nbsp;
  964. <span class="facet-field-label">${ _('Interval') }</span>
  965. <select class="input-small" data-bind="options: $root.intervalOptions,
  966. optionsText: 'label',
  967. optionsValue: 'value',
  968. value: properties.gap">
  969. </select>&nbsp;
  970. </span>
  971. <span class="facet-field-label">${ _('Zoom') }</span>
  972. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  973. <span class="facet-field-label" data-bind="visible: $root.query.multiqs().length > 1">${ _('Group by') }</span>
  974. <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>
  975. </div>
  976. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  977. <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,
  978. type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
  979. fqs: $root.query.fqs,
  980. onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  981. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  982. 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}) },
  983. onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
  984. <!-- /ko -->
  985. </div>
  986. <!-- /ko -->
  987. </script>
  988. <script type="text/html" id="bar-widget">
  989. <div class="widget-spinner" data-bind="visible: isLoading()">
  990. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  991. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  992. </div>
  993. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  994. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  995. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  996. <span data-bind="template: { name: 'facet-toggle' }">
  997. </span>
  998. </div>
  999. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1000. <!-- ko if: properties.canRange -->
  1001. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px">
  1002. <span class="facet-field-label">${ _('Zoom') }</span>
  1003. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1004. </div>
  1005. <!-- /ko -->
  1006. </div>
  1007. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  1008. <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(),
  1009. fqs: $root.query.fqs,
  1010. transformer: ($data.type == 'range-up' ? barChartRangeUpDataTransformer : barChartDataTransformer),
  1011. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1012. onClick: function(d) {
  1013. if (d.obj.field != undefined) {
  1014. if ($data.type == 'range-up') {
  1015. 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});
  1016. } else {
  1017. 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});
  1018. }
  1019. } else {
  1020. viewModel.query.toggleFacet({facet: d.obj, widget_id: d.obj.widget_id});
  1021. }
  1022. },
  1023. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1024. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1025. />
  1026. <!-- /ko -->
  1027. </div>
  1028. <!-- /ko -->
  1029. </script>
  1030. <script type="text/html" id="bucket-widget">
  1031. <div class="widget-spinner" data-bind="visible: isLoading()">
  1032. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1033. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1034. </div>
  1035. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1036. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1037. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1038. <span data-bind="foreach: properties.facets, visible: !$parents[1].isLoading()">
  1039. <div class="filter-box">
  1040. <div class="title">
  1041. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1042. <i class="fa fa-times"></i>
  1043. </a>
  1044. <div class="hit-title" data-bind="text: field, attr: {'title': field}"></div>
  1045. <div class="clearfix"></div>
  1046. </div>
  1047. <div class="content">
  1048. <div class="facet-field-cnt">
  1049. <span class="facet-field-label">${ _('Metric') }</span>
  1050. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: aggregate" class="hit-options"></select>
  1051. </div>
  1052. <div class="facet-field-cnt" data-bind="visible: $root.isEditing()">
  1053. <span class="spinedit-cnt">
  1054. <span class="facet-field-label">
  1055. ${ _('Limit') }
  1056. </span>
  1057. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1058. </span>
  1059. </div>
  1060. <div class="facet-field-cnt" data-bind="visible: $root.isEditing()">
  1061. <span class="spinedit-cnt">
  1062. <span class="facet-field-label">
  1063. ${ _('Min Count') }
  1064. </span>
  1065. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1066. </span>
  1067. </div>
  1068. </div>
  1069. </div>
  1070. </span>
  1071. <div class="filter-box" data-bind="visible: $root.isEditing() && properties.facets().length < 2" style="opacity: 0.7">
  1072. <div class="title" style="border: 1px dashed #d8d8d8; border-bottom: none">
  1073. <a data-bind="visible: ko.toJSON(properties.facets_form.field) != '', click: $root.collection.addPivotFacetValue" class="pull-right" href="javascript:void(0)">
  1074. <i class="fa fa-plus"></i> ${ _('Add') }
  1075. </a>
  1076. <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>
  1077. <div class="clearfix"></div>
  1078. </div>
  1079. <div class="content" style="border: 1px dashed #d8d8d8; border-top: none">
  1080. <div class="facet-field-cnt">
  1081. <span class="spinedit-cnt">
  1082. <span class="facet-field-label">
  1083. ${ _('Metric') }
  1084. </span>
  1085. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: properties.facets_form.aggregate" class="hit-options"></select>
  1086. </span>
  1087. </div>
  1088. <div class="facet-field-cnt">
  1089. <span class="spinedit-cnt">
  1090. <span class="facet-field-label">
  1091. ${ _('Limit') }
  1092. </span>
  1093. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.limit"/>
  1094. </span>
  1095. </div>
  1096. <div class="facet-field-cnt">
  1097. <span class="spinedit-cnt">
  1098. <span class="facet-field-label">
  1099. ${ _('Min Count') }
  1100. </span>
  1101. <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.mincount"/>
  1102. </span>
  1103. </div>
  1104. </div>
  1105. </div>
  1106. <div class="pull-right" style="margin-top: 40px">
  1107. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1108. <span class="facet-field-label">${ _('Sorting') }</span>
  1109. <a href="javascript: void(0)" title="${ _('Toggle sort order') }" data-bind="click: $root.collection.toggleSortFacet">
  1110. <i class="fa" data-bind="css: { 'fa-caret-down': properties.sort() == 'desc', 'fa-caret-up': properties.sort() == 'asc' }"></i>
  1111. <span data-bind="visible: properties.sort() == 'desc'">${_('descending')}</span>
  1112. <span data-bind="visible: properties.sort() == 'asc'">${_('ascending')}</span>
  1113. </a>
  1114. </div>
  1115. <!-- ko if: properties.isDate -->
  1116. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1117. <span class="facet-field-label">${ _('Chart Type') }</span>
  1118. <select class="input-small" data-bind="options: $root.timelineChartTypes,
  1119. optionsText: 'label',
  1120. optionsValue: 'value',
  1121. value: properties.timelineChartType">
  1122. </select>
  1123. </div>
  1124. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1125. <span class="facet-field-label">${ _('Interval') }</span>
  1126. <select class="input-small" data-bind="options: $root.intervalOptions,
  1127. optionsText: 'label',
  1128. optionsValue: 'value',
  1129. value: properties.gap">
  1130. </select>
  1131. </div>
  1132. <!-- /ko -->
  1133. <!-- ko if: properties.canRange -->
  1134. <div class="inline-block" style="padding-bottom: 10px; padding-right: 20px">
  1135. <span class="facet-field-label">${ _('Zoom') }</span>
  1136. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1137. </div>
  1138. <!-- /ko -->
  1139. </div>
  1140. <div class="clearfix"></div>
  1141. </div>
  1142. <!-- ko if: $root.collection.getFacetById($parent.id()) -->
  1143. <!-- ko if: dimension() == 1 -->
  1144. <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(),
  1145. fqs: $root.query.fqs,
  1146. transformer: ($data.type == 'range-up' ? barChartRangeUpDataTransformer : barChartDataTransformer),
  1147. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1148. onClick: function(d) {
  1149. if (d.obj.field != undefined) {
  1150. if ($data.type == 'range-up') {
  1151. 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});
  1152. } else {
  1153. 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});
  1154. }
  1155. } else {
  1156. viewModel.query.toggleFacet({facet: d.obj, widget_id: d.obj.widget_id});
  1157. }
  1158. },
  1159. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1160. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1161. />
  1162. <!-- /ko -->
  1163. <!-- ko if: dimension() == 2 -->
  1164. <div data-bind="barChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(),
  1165. isPivot: true,
  1166. fqs: $root.query.fqs,
  1167. transformer: pivotChartDataTransformer,
  1168. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1169. onClick: function(d) {
  1170. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1171. },
  1172. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1173. />
  1174. <!-- /ko -->
  1175. <!-- ko if: dimension() == 3 -->
  1176. <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,
  1177. type: $root.collection.getFacetById($parent.id()).properties.timelineChartType,
  1178. fqs: $root.query.fqs,
  1179. onSelectRange: function(from, to){ $root.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1180. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1181. 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}) },
  1182. onComplete: function(){ $root.getWidgetById($parent.id()).isLoading(false) }}" />
  1183. <!-- /ko -->
  1184. <!-- /ko -->
  1185. </div>
  1186. <!-- /ko -->
  1187. </script>
  1188. <script type="text/html" id="line-widget">
  1189. <div class="widget-spinner" data-bind="visible: isLoading()">
  1190. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1191. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1192. </div>
  1193. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1194. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1195. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1196. <span data-bind="template: { name: 'facet-toggle' }">
  1197. </span>
  1198. </div>
  1199. <div style="padding-bottom: 10px; text-align: right; padding-right: 20px" data-bind="visible: counts.length > 0">
  1200. <span class="facet-field-label">${ _('Zoom') }</span>
  1201. <a href="javascript:void(0)" data-bind="click: $root.collection.rangeZoomOut"><i class="fa fa-search-minus"></i> ${ _('reset') }</a>
  1202. </div>
  1203. <div data-bind="lineChart: {datum: {counts: counts(), widget_id: $parent.id(), label: label()}, field: field, label: label(),
  1204. transformer: lineChartDataTransformer,
  1205. 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}) },
  1206. onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
  1207. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1208. />
  1209. </div>
  1210. <!-- /ko -->
  1211. </script>
  1212. <script type="text/html" id="pie-widget">
  1213. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1214. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1215. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1216. <span data-bind="template: { name: 'facet-toggle' }">
  1217. </span>
  1218. </div>
  1219. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1220. <!-- ko if: type() == 'range' -->
  1221. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1222. transformer: rangePieChartDataTransformer,
  1223. maxWidth: 250,
  1224. 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}) },
  1225. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1226. <!-- /ko -->
  1227. <!-- ko if: type() == 'range-up' -->
  1228. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1229. transformer: rangeUpPieChartDataTransformer,
  1230. rangeUp: true,
  1231. maxWidth: 250,
  1232. 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}) },
  1233. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1234. <!-- /ko -->
  1235. <!-- ko if: type().indexOf('range') == -1 -->
  1236. <div data-bind="pieChart: {data: {counts: $parent.counts(), widget_id: $parent.id()}, field: field, fqs: $root.query.fqs,
  1237. transformer: pieChartDataTransformer,
  1238. maxWidth: 250,
  1239. onClick: function(d){ viewModel.query.toggleFacet({facet: d.data.obj, widget_id: d.data.obj.widget_id}) },
  1240. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false)} }" />
  1241. <!-- /ko -->
  1242. </div>
  1243. </div>
  1244. <!-- /ko -->
  1245. <div class="widget-spinner" data-bind="visible: isLoading()">
  1246. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1247. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1248. </div>
  1249. </script>
  1250. <script type="text/html" id="tree-widget">
  1251. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1252. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1253. <div class="responsive-facet-toggle-section" data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())">
  1254. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1255. </span>
  1256. </div>
  1257. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1258. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1259. <span class="muted">${ _('Selected dimensions') }</span>
  1260. </div>
  1261. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1262. <div class="filter-box">
  1263. <div class="title">
  1264. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1265. <i class="fa fa-times"></i>
  1266. </a>
  1267. <span data-bind="text: field"></span>
  1268. &nbsp;
  1269. </div>
  1270. <div class="content">
  1271. <div class="facet-field-cnt">
  1272. <span class="spinedit-cnt">
  1273. <span class="facet-field-label facet-field-label-fixed-width">
  1274. ${ _('Limit') }
  1275. </span>
  1276. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1277. </span>
  1278. </div>
  1279. <div class="facet-field-cnt">
  1280. <span class="spinedit-cnt">
  1281. <span class="facet-field-label facet-field-label-fixed-width">
  1282. ${ _('Min Count') }
  1283. </span>
  1284. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1285. </span>
  1286. </div>
  1287. </div>
  1288. </div>
  1289. </div>
  1290. <div class="clearfix"></div>
  1291. <!-- ko if: properties.scope() == 'tree' -->
  1292. <div data-bind="partitionChart: {datum: {counts: $parent.counts(), widget_id: $parent.id(), label: $parent.label()},
  1293. fqs: $root.query.fqs,
  1294. tooltip: '${ _ko('Click to zoom, double click to select') }',
  1295. transformer: partitionChartDataTransformer,
  1296. onStateChange: function(state){ },
  1297. onClick: function(d) {
  1298. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1299. },
  1300. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1301. />
  1302. <!-- /ko -->
  1303. </div>
  1304. </div>
  1305. <!-- /ko -->
  1306. <div class="widget-spinner" data-bind="visible: isLoading()">
  1307. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1308. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1309. </div>
  1310. </script>
  1311. <script type="text/html" id="heatmap-widget">
  1312. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1313. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1314. <div class="floating-facet-toggle-section" data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())">
  1315. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1316. </span>
  1317. </div>
  1318. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1319. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1320. <span class="muted">${ _('Selected dimension') }</span>
  1321. </div>
  1322. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1323. <div class="filter-box">
  1324. <div class="title">
  1325. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1326. <i class="fa fa-times"></i>
  1327. </a>
  1328. <span data-bind="text: field"></span>
  1329. &nbsp;
  1330. </div>
  1331. <div class="content">
  1332. <div class="facet-field-cnt">
  1333. <span class="spinedit-cnt">
  1334. <span class="facet-field-label facet-field-label-fixed-width">
  1335. ${ _('Limit') }
  1336. </span>
  1337. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1338. </span>
  1339. </div>
  1340. <div class="facet-field-cnt">
  1341. <span class="spinedit-cnt">
  1342. <span class="facet-field-label facet-field-label-fixed-width">
  1343. ${ _('Min Count') }
  1344. </span>
  1345. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1346. </span>
  1347. </div>
  1348. </div>
  1349. </div>
  1350. </div>
  1351. <div class="clearfix"></div>
  1352. <!-- ko if: properties.scope() == 'stack' -->
  1353. <div data-bind="barChart: {datum: {counts: $parent.counts(), widget_id: $parent.id(), label: $parent.label()}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(),
  1354. isPivot: true,
  1355. fqs: $root.query.fqs,
  1356. transformer: pivotChartDataTransformer,
  1357. onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
  1358. onClick: function(d) {
  1359. $root.query.togglePivotFacet({facet: d.obj, widget_id: id()});
  1360. },
  1361. onComplete: function(){ viewModel.getWidgetById($parent.id()).isLoading(false) } }"
  1362. />
  1363. <!-- /ko -->
  1364. </div>
  1365. </div>
  1366. <!-- /ko -->
  1367. <div class="widget-spinner" data-bind="visible: isLoading()">
  1368. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1369. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1370. </div>
  1371. </script>
  1372. <script type="text/html" id="hit-widget">
  1373. <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
  1374. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1375. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1376. </div>
  1377. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1378. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1379. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1380. <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
  1381. <span class="facet-field-label">${ _('Metric') }</span>
  1382. <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: properties.aggregate"></select>
  1383. </div>
  1384. <div data-bind="visible: ! $root.isEditing(), text: getHitOption(properties.aggregate())" class="muted"></div>
  1385. </div>
  1386. <span class="big-counter" data-bind="textSqueezer: counts"></span>
  1387. </div>
  1388. <!-- /ko -->
  1389. </script>
  1390. <script type="text/html" id="filter-widget">
  1391. <div data-bind="visible: $root.query.fqs().length == 0" style="margin-top: 10px; min-height: 87px">
  1392. ${ _('There are currently no filters applied.') }
  1393. </div>
  1394. <div data-bind="foreach: { data: $root.query.fqs, afterRender: function(){ isLoading(false); } }">
  1395. <!-- ko if: $data.type() == 'field' -->
  1396. <div class="filter-box">
  1397. <div class="title">
  1398. <a href="javascript:void(0)" class="pull-right" data-bind="click: function() { chartsUpdatingState(); $root.query.removeFilter($data); $root.search(); }">
  1399. <i class="fa fa-times"></i>
  1400. </a>
  1401. <span data-bind="text: $data.field"></span>
  1402. &nbsp;
  1403. </div>
  1404. <div class="content">
  1405. <strong>${_('selected')}</strong>
  1406. <span data-bind="foreach: $data.filter">
  1407. <span class="label label-info" style="margin-left: 4px" data-bind="visible: ! $data.exclude(), html: prettifyDate($data.value()), attr: {'title': $data.value()}"></span>
  1408. </span>
  1409. <br/>
  1410. <strong>${_('excluded')}</strong>
  1411. <span data-bind="foreach: $data.filter">
  1412. <span class="label label-important" style="margin-left: 4px" data-bind="visible: $data.exclude(), html: prettifyDate($data.value()), attr: {'title': $data.value()}"></span>
  1413. </span>
  1414. </div>
  1415. </div>
  1416. <!-- /ko -->
  1417. <!-- ko if: $data.type() == 'range' || $data.type() == 'range-up' -->
  1418. <div class="filter-box">
  1419. <div class="title">
  1420. <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ chartsUpdatingState(); $root.query.removeFilter($data); $root.search() }">
  1421. <i class="fa fa-times"></i>
  1422. </a>
  1423. <span data-bind="text: $data.field"></span>
  1424. &nbsp;
  1425. </div>
  1426. <div class="content">
  1427. <strong>${_('selected')}</strong>
  1428. <span data-bind="foreach: $data.properties" style="font-weight: normal">
  1429. <!-- ko if: $.grep($parent.filter(), function(f) { return f.value() == $data.from() && ! f.exclude() }).length > 0 -->
  1430. <span class="label label-info">
  1431. <!-- ko if: $parent.type() == 'range' -->
  1432. <span data-bind="html: prettifyDateRange($data.from(), $data.to(), null, true), attr: {'title': $data.from() + ' -> ' + $data.to()}"></span>
  1433. <!-- /ko -->
  1434. <!-- ko if: $parent.type() == 'range-up' -->
  1435. <strong data-bind="visible: ! $parent.is_up()">${ _('Until') }</strong>
  1436. <span data-bind="html: prettifyDate($data.from()), attr: {'title': $data.from()}"></span>
  1437. <strong data-bind="visible: $parent.is_up()"> & Up</strong>
  1438. <!-- /ko -->
  1439. </span>
  1440. <!-- /ko -->
  1441. </span>
  1442. <br/>
  1443. <strong>${_('excluded')}</strong>
  1444. <span data-bind="foreach: $data.properties" style="font-weight: normal" class="excluded">
  1445. <!-- ko if: $.grep($parent.filter(), function(f) { return f.value() == $data.from() && f.exclude() }).length > 0 -->
  1446. <span class="label label-important">
  1447. <span data-bind="html: prettifyDateRange($data.from(), $data.to(), null, true), attr: {'title': $data.from() + ' -> ' + $data.to()}"></span>
  1448. </span>
  1449. <!-- /ko -->
  1450. </span>
  1451. </div>
  1452. </div>
  1453. <!-- /ko -->
  1454. <!-- ko if: $data.type() == 'map' -->
  1455. <div class="filter-box">
  1456. <div class="title">
  1457. <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ chartsUpdatingState(); $root.query.removeFilter($data); $root.search() }">
  1458. <i class="fa fa-times"></i>
  1459. </a>
  1460. <span data-bind="text: $data.lat"></span>, <span data-bind="text: $data.lon"></span>
  1461. &nbsp;
  1462. </div>
  1463. <div class="content">
  1464. <strong>${_('selected')}</strong>
  1465. <span class="label label-info">
  1466. [
  1467. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lat_sw, attr: {'title': '${ _ko('Latitude South West') }'"></span>
  1468. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lon_sw, attr: {'title': '${ _ko('Longitude South West') }'"></span>
  1469. ]
  1470. ${ _("TO") }
  1471. [
  1472. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lat_ne, attr: {'title': '${ _ko('Latitude North East') }'"></span>
  1473. <span class="label label-info" style="margin-left: 4px" data-bind="text: $data.properties.lon_ne, attr: {'title': '${ _ko('Longitude North East') }'"></span>
  1474. ]
  1475. </span>
  1476. </div>
  1477. </div>
  1478. <!-- /ko -->
  1479. </div>
  1480. <div class="clearfix"></div>
  1481. <div class="widget-spinner" data-bind="visible: isLoading() && $root.query.fqs().length > 0">
  1482. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1483. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1484. </div>
  1485. </script>
  1486. <script type="text/html" id="map-widget">
  1487. <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
  1488. <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
  1489. <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
  1490. <div class="floating-facet-toggle-section">
  1491. <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id()).isLoading(false); } }">
  1492. </span>
  1493. </div>
  1494. <div class="dimensions-header margin-bottom-10" data-bind="visible: $root.isEditing() && $data.properties.facets().length > 0">
  1495. <span class="muted">${ _('Selected dimension') }</span>
  1496. </div>
  1497. <div data-bind="foreach: $data.properties.facets, visible: $root.isEditing">
  1498. <div class="filter-box">
  1499. <div class="title">
  1500. <a data-bind="click: function() { $root.collection.removePivotFacetValue({'pivot_facet': $parent, 'value': $data}); }" class="pull-right" href="javascript:void(0)">
  1501. <i class="fa fa-times"></i>
  1502. </a>
  1503. <span data-bind="text: field"></span>
  1504. &nbsp;
  1505. </div>
  1506. <div class="content">
  1507. <div class="facet-field-cnt">
  1508. <span class="spinedit-cnt">
  1509. <span class="facet-field-label facet-field-label-fixed-width">
  1510. ${ _('Limit') }
  1511. </span>
  1512. <input type="text" class="input-medium" data-bind="spinedit: limit"/>
  1513. </span>
  1514. </div>
  1515. <div class="facet-field-cnt">
  1516. <span class="spinedit-cnt">
  1517. <span class="facet-field-label facet-field-label-fixed-width">
  1518. ${ _('Min Count') }
  1519. </span>
  1520. <input type="text" class="input-medium" data-bind="spinedit: mincount"/>
  1521. </span>
  1522. </div>
  1523. </div>
  1524. </div>
  1525. </div>
  1526. <div class="clearfix"></div>
  1527. </div>
  1528. <div class="margin-bottom-10" data-bind="visible: ! $root.isEditing()">
  1529. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1530. <!-- ko if: $data.properties.facets().length == 1 -->
  1531. <div class="margin-bottom-10">
  1532. <span data-bind="text: $data.properties.facets()[0].field"></span>
  1533. </div>
  1534. <!-- /ko -->
  1535. </div>
  1536. </div>
  1537. <div data-bind="with: $root.collection.getFacetById($parent.id())">
  1538. <div data-bind="mapChart: {data: {counts: $parent.counts(), scope: $root.collection.getFacetById($parent.id()).properties.scope()},
  1539. transformer: mapChartDataTransformer,
  1540. maxWidth: 750,
  1541. isScale: true,
  1542. onClick: function(d) {
  1543. $root.query.togglePivotFacet({facet: {'fq_fields': d.fields, 'fq_values': d.value}, widget_id: id()});
  1544. },
  1545. onComplete: function(){ var widget = viewModel.getWidgetById($parent.id()); if (widget != null) { widget.isLoading(false)}; } }" />
  1546. </div>
  1547. </div>
  1548. <!-- /ko -->
  1549. <div class="widget-spinner" data-bind="visible: isLoading()">
  1550. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1551. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1552. </div>
  1553. </script>
  1554. <script type="text/html" id="leafletmap-widget">
  1555. <div class="row-fluid">
  1556. <div data-bind="visible: $root.isEditing" style="margin-top: 10px; margin-bottom: 20px;" class="leaflet-align">
  1557. <span class="facet-field-label">${_('Latitude')}</span><div class="break-on-small-column"></div>
  1558. <select data-bind="options: $root.collection.template.sortedGeogFieldsNames, value: $root.collection.template.leafletmap.latitudeField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1559. &nbsp;&nbsp;
  1560. <div class="break-on-small-column"></div>
  1561. <span class="facet-field-label">${_('Longitude')}</span><div class="break-on-small-column"></div>
  1562. <select data-bind="options: $root.collection.template.sortedGeogFieldsNames, value: $root.collection.template.leafletmap.longitudeField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1563. &nbsp;&nbsp;
  1564. <div class="break-on-small-column"></div>
  1565. <span class="facet-field-label">${_('Label')}</span><div class="break-on-small-column"></div>
  1566. <select data-bind="options: $root.collection.template.fieldsNames, value: $root.collection.template.leafletmap.labelField, optionsCaption: '${ _ko('Choose...') }'"></select>
  1567. </div>
  1568. <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()},
  1569. transformer: leafletMapChartDataTransformer,
  1570. 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()}); },
  1571. onComplete: function(){ var widget = viewModel.getWidgetById(id()); if (widget != null) { widget.isLoading(false)}; } }">
  1572. </div>
  1573. </div>
  1574. <div class="widget-spinner" data-bind="visible: isLoading()">
  1575. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1576. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1577. </div>
  1578. </script>
  1579. <script type="text/html" id="analysis-window">
  1580. <!-- ko if: $root.fieldAnalysesName() -->
  1581. <div data-bind="with: $root.getFieldAnalysis()">
  1582. <div class="pull-right">
  1583. <input type="text" data-bind="visible: section() == 'terms', clearable: terms.prefix, valueUpdate:'afterkeydown'" placeholder="${ _('Prefix filter...') }"/>
  1584. <input type="text" data-bind="visible: section() == 'stats', clearable: stats.facet, typeahead: { target: stats.facet, source: $root.fieldsAnalysisAttributesNames, triggerOnFocus: true }" placeholder="${ _('Field name...') }"/>
  1585. </div>
  1586. <ul class="nav nav-tabs" role="tablist">
  1587. <li class="active"><a href="#analysis-terms" role="tab" data-toggle="tab" data-bind="click: function() { section('terms'); }">${ _('Terms') }</a></li>
  1588. <li><a href="#analysis-stats" role="tab" data-toggle="tab" data-bind="click: function() { section('stats'); }">${ _('Stats') }</a></li>
  1589. </ul>
  1590. <div class="tab-content">
  1591. <div class="tab-pane active" id="analysis-terms" data-bind="with: terms">
  1592. <div class="widget-spinner" data-bind="visible: $parent.isLoading()">
  1593. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1594. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1595. </div>
  1596. <div class="alert" data-bind="visible: ! $parent.isLoading() && $data.data().length == 0">${ _('There are no terms to be shown') }</div>
  1597. <table style="width: 100%" data-bind="visible: ! $parent.isLoading() && $data.data().length > 0" class="table-striped">
  1598. <tbody data-bind="foreach: $data.data">
  1599. <tr>
  1600. <td data-bind="text: val.value"></td>
  1601. <td style="width: 22px" data-bind="click: $root.query.addSingleTermFacet">
  1602. <a href="javascript: void(0)"><i class="fa fa-plus" title="${ _('Select this value') }"></i></a>
  1603. </td>
  1604. <td style="width: 22px" data-bind="click: $root.query.removeSingleTermFacet">
  1605. <a href="javascript: void(0)"><i class="fa fa-minus" title="${ _('Exclude this value') }"></i></a>
  1606. </td>
  1607. <td style="width: 40px">
  1608. <div class="progress">
  1609. <div class="bar-label" data-bind="text:val.count"></div>
  1610. <div class="bar bar-info" style="margin-top:-20px;" data-bind="style: {'width': ((val.count / $parent.data()[0].val.count) * 100) + '%'}"></div>
  1611. </div>
  1612. </td>
  1613. </tr>
  1614. </tbody>
  1615. </table>
  1616. </div>
  1617. <div class="tab-pane" id="analysis-stats" data-bind="with: stats">
  1618. <div class="widget-spinner" data-bind="visible: $parent.isLoading()">
  1619. <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
  1620. <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
  1621. </div>
  1622. <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>
  1623. <div class="alert" data-bind="visible: ! $parent.isLoading() && $data.data().length == 0">${ _('There are no stats to be shown') }</div>
  1624. <table style="width: 100%" data-bind="visible: ! $parent.isLoading() && $data.data().length > 0 && $data.data()[0].key.toLowerCase() != 'error'" class="table-striped">
  1625. <tbody data-bind="foreach: $data.data">
  1626. <tr>
  1627. <td style="vertical-align: top"><strong data-bind="text: key"></strong></td>
  1628. <!-- ko if: key == 'facets' -->
  1629. <td>
  1630. <!-- ko if: val[Object.keys(val)[0]] != null -->
  1631. <table style="width: 400px">
  1632. <tbody data-bind="foreach: Object.keys(val[Object.keys(val)[0]])">
  1633. <tr>
  1634. <td style="vertical-align: top; padding-left: 4px; padding-right: 4px"><strong data-bind="text: $data"></strong></td>
  1635. <td data-bind="template: 'stats-facets'"></td>
  1636. </tr>
  1637. </tbody>
  1638. </table>
  1639. <!-- /ko -->
  1640. <!-- ko ifnot: val[Object.keys(val)[0]] != null -->
  1641. ${ _('Not available') }
  1642. <!-- /ko -->
  1643. </td>
  1644. <!-- /ko -->
  1645. <!-- ko ifnot: key == 'facets' -->
  1646. <td data-bind="text: val"></td>
  1647. <!-- /ko -->
  1648. </tr>
  1649. </tbody>
  1650. </table>
  1651. </div>
  1652. </div>
  1653. </div>
  1654. <!-- /ko -->
  1655. </script>
  1656. <script type="text/html" id="stats-facets">
  1657. <table style="width: 100%">
  1658. <tbody data-bind="foreach: Object.keys($parent.val[Object.keys($parent.val)[0]][$data])">
  1659. <tr>
  1660. <td style="vertical-align: top; padding-left: 4px; padding-right: 4px"><strong data-bind="text: $data"></strong></td>
  1661. <!-- ko ifnot: $data == 'facets' -->
  1662. <td style="vertical-align: top" data-bind="text: $parents[1].val[Object.keys($parents[1].val)[0]][$parent][$data]"></td>
  1663. <!-- /ko -->
  1664. </tr>
  1665. </tbody>
  1666. </table>
  1667. </script>
  1668. <div id="addFacetDemiModal" class="demi-modal fade" data-backdrop="false">
  1669. <div class="modal-body">
  1670. <a href="javascript: void(0)" data-dismiss="modal" data-bind="click: addFacetDemiModalFieldCancel" class="pull-right"><i class="fa fa-times"></i></a>
  1671. <div style="float: left; margin-right: 10px;text-align: center">
  1672. <input id="addFacetInput" type="text" data-bind="clearable: $root.collection.template.fieldsModalFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" class="input" style="float: left" /><br/>
  1673. </div>
  1674. <div>
  1675. <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"
  1676. class="unstyled inline fields-chooser" style="height: 100px; overflow-y: auto">
  1677. <li data-bind="click: addFacetDemiModalFieldPreview">
  1678. <span class="badge badge-info"><span data-bind="text: name(), attr: {'title': type()}"></span>
  1679. </span>
  1680. </li>
  1681. </ul>
  1682. <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">
  1683. ${_('There are no fields matching your search term.')}
  1684. </div>
  1685. </div>
  1686. </div>
  1687. <div><a class="pointer demi-modal-chevron" data-dismiss="modal" data-bind="click: addFacetDemiModalFieldCancel"><i class="fa fa-chevron-up"></i></a></div>
  1688. </div>
  1689. <div id="settingsDemiModal" class="demi-modal fade" data-backdrop="false">
  1690. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1691. <div class="modal-body">
  1692. <div class="row-fluid">
  1693. <div class="span12">
  1694. <form class="form-horizontal">
  1695. <fieldset>
  1696. <legend><i class="fa fa-cogs"></i> ${ _('General settings') }</legend>
  1697. <!-- ko if: $root.initial.inited() -->
  1698. <div class="control-group">
  1699. <label class="control-label" for="settingssolrindex">${ _('Solr index') }</label>
  1700. <div class="controls">
  1701. <select id="settingssolrindex" data-bind="options: $root.initial.collections, value: $root.collection.name"></select>
  1702. </div>
  1703. </div>
  1704. <!-- /ko -->
  1705. <div class="control-group">
  1706. <label class="control-label" for="settingsdescription">${ _('Description') }</label>
  1707. <div class="controls">
  1708. <input id="settingsdescription" type="text" class="input-xlarge" data-bind="value: $root.collection.description" style="margin-bottom: 0" />
  1709. </div>
  1710. </div>
  1711. <div class="control-group">
  1712. <label class="control-label">${ _('Autocomplete') }</label>
  1713. <div class="controls">
  1714. <label class="checkbox" style="padding-top:0">
  1715. <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') }">
  1716. </label>
  1717. </div>
  1718. </div>
  1719. </fieldset>
  1720. </form>
  1721. </div>
  1722. </div>
  1723. </div>
  1724. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1725. </div>
  1726. <div id="qdefinitionsDemiModal" class="demi-modal fade" data-backdrop="false">
  1727. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1728. <div class="modal-body">
  1729. <div class="row-fluid">
  1730. <div class="span12">
  1731. <form class="form-inline">
  1732. <fieldset>
  1733. <legend><i class="fa fa-bookmark-o"></i> ${ _('Query definitions') }
  1734. <div class="input-append" style="margin-left: 30px; margin-top: 4px">
  1735. <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...') }" />
  1736. <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">
  1737. <i class="fa fa-plus"></i>
  1738. </a>
  1739. </div>
  1740. </legend>
  1741. <div class="control-group" data-bind="visible: $root.collection.qdefinitions().length > 0" style="margin-top: 0">
  1742. <div class="controls">
  1743. <ul class="unstyled airy qdefinitions" data-bind="foreach: $root.collection.qdefinitions">
  1744. <li>
  1745. <span class="badge badge-info badge-left pointer">
  1746. <span data-bind="text: name, attr:{'title': ko.mapping.toJSON(data, null, 2)}, click: $root.collection.loadQDefinition"></span>
  1747. </span><span class="badge badge-right trash-share" data-bind="click: $root.collection.removeQDefinition"> <i class="fa fa-times"></i></span></li>
  1748. </li>
  1749. </ul>
  1750. </div>
  1751. </div>
  1752. <div class="control-group" data-bind="visible: $root.collection.qdefinitions().length == 0">
  1753. <div class="controls">
  1754. <h4>${ _('There are currently no query definitions.') }</h4>
  1755. </div>
  1756. </div>
  1757. </fieldset>
  1758. </form>
  1759. </div>
  1760. </div>
  1761. </div>
  1762. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1763. </div>
  1764. <script type="text/html" id="time-filter">
  1765. <span data-bind="visible: $root.availableDateFields().length > 0" >
  1766. <span data-bind="template: {name: 'time-filter-select'}"></span>
  1767. <a class="btn pointer" title="${ _('Time Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#timeSettingsDemiModal">
  1768. <i class="fa fa-calendar"></i>
  1769. </a>
  1770. </span>
  1771. </script>
  1772. <script type="text/html" id="time-fixed-filter">
  1773. <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">
  1774. &nbsp;
  1775. <span data-bind="text: moment($root.collection.timeFilter.from()).utc().format('YYYY-MM-DD HH:mm:SS')"></span>
  1776. <i class="fa fa-long-arrow-right"></i>
  1777. <span data-bind="text: moment($root.collection.timeFilter.to()).utc().format('YYYY-MM-DD HH:mm:SS')"></span>
  1778. </span>
  1779. </script>
  1780. <script type="text/html" id="time-filter-select">
  1781. <select id="settingstimeinterval" data-bind="value: collection.timeFilter.value" class="input-medium" style="margin-right: 4px">
  1782. <option value="all">${ _('All') }</option>
  1783. <option value="5MINUTES">${ _('Past 5 Minutes') }</option>
  1784. <option value="30MINUTES">${ _('Past 30 Minutes') }</option>
  1785. <option value="1HOURS">${ _('Past 1 Hour') }</option>
  1786. <option value="12HOURS">${ _('Past 12 Hours') }</option>
  1787. <option value="1DAYS">${ _('Past day') }</option>
  1788. <option value="2DAYS">${ _('Past 2 days') }</option>
  1789. <option value="7DAYS">${ _('Past 7 days') }</option>
  1790. <option value="1MONTHS">${ _('Past 1 Month') }</option>
  1791. <option value="3MONTHS">${ _('Past 3 Months') }</option>
  1792. <option value="1YEARS">${ _('Past Year') }</option>
  1793. <option value="2YEARS">${ _('Past 2 Years') }</option>
  1794. <option value="10YEARS">${ _('Past 10 Years') }</option>
  1795. </select>
  1796. </script>
  1797. <div id="timeSettingsDemiModal" class="demi-modal fade" data-backdrop="false">
  1798. <a href="javascript: void(0)" data-dismiss="modal" class="pull-right" style="margin: 10px"><i class="fa fa-times"></i></a>
  1799. <div class="modal-body">
  1800. <div class="row-fluid">
  1801. <div class="span12">
  1802. <form class="form-horizontal">
  1803. <fieldset>
  1804. <legend><i class="fa fa-calendar"></i> ${ _('Time settings') }</legend>
  1805. <span data-bind="visible: $root.availableDateFields().length > 0">
  1806. <div class="control-group">
  1807. <label class="control-label" for="settingstimefield">${ _('Date/time field') }</label>
  1808. <div class="controls">
  1809. <select id="settingstimefield" data-bind="options: $root.availableDateFields, value: collection.timeFilter.field, optionsValue: 'name'" class="input-medium"></select>
  1810. </div>
  1811. </div>
  1812. <div class="control-group">
  1813. <label class="control-label" for="settingstimetype">${ _('Type') }</label>
  1814. <div class="controls">
  1815. <label class="radio inline"><input type="radio" name="settingstimetype" value="rolling" data-bind="checked: collection.timeFilter.type" /> ${ _('Rolling') }</label>
  1816. <label class="radio inline"><input type="radio" name="settingstimetype" value="fixed" data-bind="checked: collection.timeFilter.type" /> ${ _('Fixed') }</label>
  1817. </div>
  1818. </div>
  1819. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'rolling'">
  1820. <label class="control-label" for="settingstimeinterval">${ _('Interval') }</label>
  1821. <div class="controls">
  1822. <span data-bind="template: {name: 'time-filter-select'}"></span>
  1823. </div>
  1824. </div>
  1825. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'fixed'">
  1826. <label class="control-label" for="settingstimestart">${ _('Start date/time') }</label>
  1827. <div class="controls">
  1828. <input id="settingstimestart" type="text" data-bind="value: collection.timeFilter.from, datepicker: {momentFormat: 'YYYY-MM-DD[T]HH:mm:SS[Z]'}" />
  1829. </div>
  1830. </div>
  1831. <div class="control-group" data-bind="visible: collection.timeFilter.type() == 'fixed'">
  1832. <label class="control-label" for="settingstimeend">${ _('End date/time') }</label>
  1833. <div class="controls">
  1834. <input id="settingstimeend" type="text" data-bind="value: collection.timeFilter.to, datepicker: {momentFormat: 'YYYY-MM-DD[T]HH:mm:SS[Z]'}" />
  1835. </div>
  1836. </div>
  1837. <div class="control-group">
  1838. <div class="controls">
  1839. <label class="checkbox">
  1840. <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') }
  1841. </label>
  1842. </div>
  1843. </div>
  1844. </span>
  1845. <!-- ko if: $root.availableDateFields().length == 0 -->
  1846. <label class="checkbox">
  1847. <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') }
  1848. </label>
  1849. <!-- /ko -->
  1850. </fieldset>
  1851. </form>
  1852. </div>
  1853. </div>
  1854. </div>
  1855. <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
  1856. </div>
  1857. <div id="fieldAnalysis" class="popover mega-popover right">
  1858. <div class="arrow"></div>
  1859. <h3 class="popover-title" style="text-align: left">
  1860. <a class="pull-right pointer" data-bind="click: function(){ $('#fieldAnalysis').hide(); $root.fieldAnalysesName(''); }"><i class="fa fa-times"></i></a>
  1861. <strong data-bind="text: $root.fieldAnalysesName"></strong> ${ _(' field analysis') }
  1862. </h3>
  1863. <div class="popover-content" data-bind="template: { name: 'analysis-window' }" style="text-align: left"></div>
  1864. </div>
  1865. ## Extra code for style and custom JS
  1866. <span id="extra" data-bind="augmenthtml: $root.collection.template.extracode"></span>
  1867. <link rel="stylesheet" href="${ static('search/css/search.css') }">
  1868. <link rel="stylesheet" href="${ static('desktop/ext/css/hue-filetypes.css') }">
  1869. <link rel="stylesheet" href="${ static('desktop/ext/css/hue-charts.css') }">
  1870. <link rel="stylesheet" href="${ static('desktop/ext/chosen/chosen.min.css') }">
  1871. <link rel="stylesheet" href="${ static('desktop/ext/select2/select2.css') }">
  1872. <script src="${ static('desktop/js/hue.json.js') }" type="text/javascript" charset="utf-8"></script>
  1873. ${ dashboard.import_layout(True) }
  1874. <script src="${ static('search/js/search.utils.js') }" type="text/javascript" charset="utf-8"></script>
  1875. <script src="${ static('desktop/js/jquery.textsqueezer.js') }" type="text/javascript" charset="utf-8"></script>
  1876. <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }" type="text/javascript" charset="utf-8"></script>
  1877. <script src="${ static('desktop/js/ko.editable.js') }" type="text/javascript" charset="utf-8"></script>
  1878. <script src="${ static('desktop/ext/js/shortcut.js') }" type="text/javascript" charset="utf-8"></script>
  1879. <script src="${ static('desktop/ext/js/mustache.js') }" type="text/javascript" charset="utf-8"></script>
  1880. <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
  1881. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.hotkeys.js') }"></script>
  1882. <script src="${ static('desktop/ext/select2/select2.min.js') }" type="text/javascript" charset="utf-8"></script>
  1883. <script src="${ static('search/js/search.ko.js') }" type="text/javascript" charset="utf-8"></script>
  1884. ${ dashboard.import_bindings() }
  1885. ${ dashboard.import_charts() }
  1886. <style type="text/css">
  1887. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  1888. .search-bar {
  1889. top: 58px!important;
  1890. }
  1891. .card-toolbar {
  1892. top: 100px!important;
  1893. }
  1894. #emptyDashboardEditing {
  1895. top: 190px!important;
  1896. }
  1897. .dashboard {
  1898. margin-top: 20px;
  1899. }
  1900. .dashboard.with-top-margin {
  1901. margin-top: 80px;
  1902. }
  1903. % endif
  1904. </style>
  1905. <script type="text/javascript" charset="utf-8">
  1906. var viewModel;
  1907. nv.dev = false;
  1908. moment.suppressDeprecationWarnings = true;
  1909. var HIT_OPTIONS = [
  1910. { value: "count", label: "${ _('Count') }" },
  1911. { value: "unique", label: "${ _('Unique Count') }" },
  1912. { value: "avg", label: "${ _('Average') }" },
  1913. { value: "sum", label: "${ _('Sum') }" },
  1914. { value: "min", label: "${ _('Min') }" },
  1915. { value: "max", label: "${ _('Max') }" },
  1916. { value: "sumsq", label: "${ _('Sum of square') }" },
  1917. { value: "median", label: "${ _('Median') }" }
  1918. ];
  1919. function getHitOption(value){
  1920. for (var i=0; i < HIT_OPTIONS.length; i++){
  1921. if (HIT_OPTIONS[i].value == value){
  1922. return HIT_OPTIONS[i].label;
  1923. }
  1924. }
  1925. return '';
  1926. }
  1927. function prettifyDate(from, widget, to) {
  1928. if (typeof from == "undefined" || $.isNumeric(from)) {
  1929. return from;
  1930. }
  1931. if (typeof to != "undefined" && !$.isNumeric(to)) {
  1932. return prettifyDateRange(from, to, widget);
  1933. }
  1934. var _mFrom = moment(from);
  1935. if (_mFrom.isValid()) {
  1936. var _format = "YYYY-MM-DD HH:mm:ss";
  1937. var _minMaxDiff = 0;
  1938. if (widget && widget.properties && widget.properties.min && widget.properties.min()) {
  1939. _minMaxDiff = moment(widget.properties.max()).diff(moment(widget.properties.min()), 'seconds');
  1940. if (moment(widget.properties.max()).seconds() == 0 && moment(widget.properties.min()).seconds() == 0) {
  1941. _format = _format.substring(0, 16); // gets rid of :00 seconds
  1942. }
  1943. }
  1944. _format = getFormat(_format, _minMaxDiff, widget);
  1945. return _mFrom.utc().format(_format);
  1946. }
  1947. else {
  1948. return from;
  1949. }
  1950. }
  1951. function prettifyDateRange(from, to, widget, withCommon) {
  1952. if (typeof from == "undefined" || $.isNumeric(from)) {
  1953. return from + " - " + to;
  1954. }
  1955. var _mFrom = moment(from);
  1956. var _mTo = moment(to);
  1957. if (_mFrom.isValid() && _mTo.isValid()) {
  1958. var _mFromFormatted = _mFrom.utc().format("YYYY-MM-DD HH:mm:ss");
  1959. var _mToFormatted = _mTo.utc().format("YYYY-MM-DD HH:mm:ss");
  1960. var _lastEqual = _mFromFormatted.length - 1;
  1961. for (var i = _mFromFormatted.length - 1; i >= 0; i--) {
  1962. if (_mFromFormatted[i] == _mToFormatted[i] && (_mFromFormatted[i] == "0" || _mFromFormatted[i] == ":")) {
  1963. _lastEqual = i;
  1964. }
  1965. else break;
  1966. }
  1967. var _minMaxDiff = moment(to).diff(moment(from), 'seconds');
  1968. var _format = "YYYY-MM-DD HH:mm:ss".substr(0, _lastEqual);
  1969. if (_format.length == 13){
  1970. _format += ":mm"; // hours without minutes are weird
  1971. }
  1972. var _formatWithCommon = _format.substring(10, _format.length);
  1973. var _common = "YYYY-MM-DD";
  1974. if (widget && widget.properties && widget.properties.min && widget.properties.min()) {
  1975. _minMaxDiff = moment(widget.properties.max()).diff(moment(widget.properties.min()), 'seconds');
  1976. }
  1977. if (withCommon && _mTo.diff(_mFrom, 'days') >= 365){
  1978. withCommon = false;
  1979. _format = _common;
  1980. }
  1981. else {
  1982. _format = getFormat(_format, _minMaxDiff, widget);
  1983. }
  1984. 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);
  1985. }
  1986. else {
  1987. return from + " - " + to;
  1988. }
  1989. }
  1990. function getFormat(format, minMaxDiff, widget) {
  1991. var _hasWidget = widget && widget.properties && widget.properties.min && widget.properties.min();
  1992. if (minMaxDiff > 0 && minMaxDiff <= 86400) { // max 1 day
  1993. if (_hasWidget && moment(widget.properties.max()).date() != moment(widget.properties.min()).date()) {
  1994. format = format.substring(5, format.length);
  1995. }
  1996. else {
  1997. format = format.substring(10, format.length);
  1998. }
  1999. }
  2000. if (minMaxDiff > 86400 && minMaxDiff <= 22464000) { // max 360 days
  2001. format = format.substring(5, format.length);
  2002. }
  2003. if (minMaxDiff > 22464000){
  2004. format = format.substr(0, 10);
  2005. }
  2006. if (format.indexOf("MM") == 0) {
  2007. format = "MMM " + format.substr(3);
  2008. }
  2009. return format;
  2010. }
  2011. var lastWindowScrollPosition = 0;
  2012. function pieChartDataTransformer(data) {
  2013. var _data = [];
  2014. $(data.counts).each(function (cnt, item) {
  2015. item.widget_id = data.widget_id;
  2016. _data.push({
  2017. label: item.value,
  2018. value: item.count,
  2019. obj: item
  2020. });
  2021. });
  2022. return _data;
  2023. }
  2024. function _rangePieChartDataTransformer(data, isUp) {
  2025. var _data = [];
  2026. $(data.counts).each(function (cnt, item) {
  2027. item.widget_id = data.widget_id;
  2028. var _label = isUp ? (item.from + (item.is_up ? ' & ${ _('Up') }' : ' & ${ _('Less') }')) : (item.from + ' - ' + item.to);
  2029. _data.push({
  2030. label: _label,
  2031. from: item.from,
  2032. to: item.to,
  2033. value: item.value,
  2034. obj: item
  2035. });
  2036. });
  2037. return _data;
  2038. }
  2039. function rangePieChartDataTransformer(data) {
  2040. return _rangePieChartDataTransformer(data, false);
  2041. }
  2042. function rangeUpPieChartDataTransformer(data) {
  2043. return _rangePieChartDataTransformer(data, true);
  2044. }
  2045. function pieChartDataTransformerGrid(data) {
  2046. var _data = [];
  2047. var chartX = viewModel.collection.template.chartSettings.chartX();
  2048. var chartY = viewModel.collection.template.chartSettings.chartYSingle();
  2049. $(data.counts).each(function (cnt, item) {
  2050. item.widget_id = data.widget_id;
  2051. if (chartX != "" && item.item[chartX] && chartY != "" && item.item[chartY]) {
  2052. _data.push({
  2053. label: item.item[chartX](),
  2054. value: item.item[chartY](),
  2055. obj: item
  2056. });
  2057. }
  2058. });
  2059. return _data;
  2060. }
  2061. function _barChartDataTransformer(rawDatum, isUp) {
  2062. var _datum = [];
  2063. var _data = [];
  2064. $(rawDatum.counts).each(function (cnt, item) {
  2065. item.widget_id = rawDatum.widget_id;
  2066. if (typeof item.from != "undefined") {
  2067. if (isUp){
  2068. _data.push({
  2069. series: 0,
  2070. x: item.from + (item.is_up ? ' & ${ _('Up') }' : ' & ${ _('Less') }'),
  2071. y: item.value,
  2072. obj: item
  2073. });
  2074. }
  2075. else {
  2076. _data.push({
  2077. series: 0,
  2078. x: item.from,
  2079. x_end: item.to,
  2080. y: item.value,
  2081. obj: item
  2082. });
  2083. }
  2084. }
  2085. else {
  2086. _data.push({
  2087. series: 0,
  2088. x: item.value,
  2089. y: item.count,
  2090. obj: item
  2091. });
  2092. }
  2093. });
  2094. _datum.push({
  2095. key: rawDatum.label,
  2096. values: _data
  2097. });
  2098. return _datum;
  2099. }
  2100. function barChartDataTransformer(rawDatum) {
  2101. return _barChartDataTransformer(rawDatum, false);
  2102. }
  2103. function barChartRangeUpDataTransformer(rawDatum) {
  2104. return _barChartDataTransformer(rawDatum, true);
  2105. }
  2106. function _partitionChartDataTransformer(counts) {
  2107. var _categories = [];
  2108. $(counts).each(function (cnt, item) {
  2109. var _category = null;
  2110. _categories.forEach(function (category) {
  2111. if (category.name == item.value) {
  2112. _category = category;
  2113. }
  2114. });
  2115. if (_category == null) {
  2116. _category = {
  2117. name: item.value,
  2118. size: item.count,
  2119. obj: item,
  2120. children: []
  2121. }
  2122. _categories.push(_category);
  2123. }
  2124. if (item.pivot != undefined) {
  2125. var children = []
  2126. $(item.pivot).each(function (cnt, child) {
  2127. children = children.concat(_partitionChartDataTransformer(child));
  2128. });
  2129. _category.children = children;
  2130. }
  2131. });
  2132. return _categories;
  2133. }
  2134. function partitionChartDataTransformer(rawDatum) {
  2135. var _partitionData = {
  2136. name: "${ _('Total') }",
  2137. children: []
  2138. }
  2139. _partitionData.children = _partitionChartDataTransformer(rawDatum.counts);
  2140. return _partitionData;
  2141. }
  2142. function pivotChartDataTransformer(rawDatum) {
  2143. var _categories = [];
  2144. $(rawDatum.counts).each(function (cnt, item) {
  2145. item.widget_id = rawDatum.widget_id;
  2146. var _key = Array.isArray(item.value) ? item.value[1] : item.value;
  2147. var _category = null;
  2148. _categories.forEach(function (category) {
  2149. if (category.key == _key) {
  2150. _category = category;
  2151. }
  2152. });
  2153. if (_category == null) {
  2154. _category = {
  2155. key: _key,
  2156. values: []
  2157. };
  2158. _categories.push(_category);
  2159. }
  2160. _category.values.push({
  2161. series: 0,
  2162. x: item.cat,
  2163. y: item.count,
  2164. obj: item
  2165. });
  2166. });
  2167. return _categories;
  2168. }
  2169. function lineChartDataTransformer(rawDatum) {
  2170. var _datum = [];
  2171. var _data = [];
  2172. $(rawDatum.counts).each(function (cnt, item) {
  2173. item.widget_id = rawDatum.widget_id;
  2174. if (typeof item.from != "undefined") {
  2175. _data.push({
  2176. series: 0,
  2177. x: item.from,
  2178. x_end: item.to,
  2179. y: item.value,
  2180. obj: item
  2181. });
  2182. }
  2183. else {
  2184. _data.push({
  2185. series: 0,
  2186. x: item.value,
  2187. y: item.count,
  2188. obj: item
  2189. });
  2190. }
  2191. });
  2192. _datum.push({
  2193. key: rawDatum.label,
  2194. values: _data
  2195. });
  2196. return _datum;
  2197. }
  2198. function timelineChartDataTransformer(rawDatum) {
  2199. var _datum = [];
  2200. var _data = [];
  2201. $(rawDatum.counts).each(function (cnt, item) {
  2202. _data.push({
  2203. series: 0,
  2204. x: new Date(moment(item.from).valueOf()),
  2205. y: item.value,
  2206. obj: item
  2207. });
  2208. });
  2209. _datum.push({
  2210. key: rawDatum.label,
  2211. values: _data
  2212. });
  2213. // If multi query
  2214. $(rawDatum.extraSeries).each(function (cnt, item) {
  2215. if (cnt == 0) {
  2216. _datum = [];
  2217. }
  2218. var _data = [];
  2219. $(item.counts).each(function (cnt, item) {
  2220. _data.push({
  2221. series: cnt + 1,
  2222. x: new Date(moment(item.from).valueOf()),
  2223. y: item.value,
  2224. obj: item
  2225. });
  2226. });
  2227. _datum.push({
  2228. key: item.label,
  2229. values: _data
  2230. });
  2231. });
  2232. return _datum;
  2233. }
  2234. function mapChartDataTransformer(data) {
  2235. var _data = [];
  2236. $(data.counts).each(function (cnt, item) {
  2237. item.fields = item.pivot ? item.pivot[0].fq_fields : item.fq_fields;
  2238. item.values = item.pivot ? item.pivot[0].fq_values : item.fq_values;
  2239. item.counts = item.pivot ? item.pivot[0].count : item.count; // unused yet
  2240. item.is2d = item.pivot ? true : false; // unused yet
  2241. if (item.value != null && item.value != "" && item.value.length < 4) {
  2242. var _label = data.scope == "world" ? HueGeo.getISOAlpha3(item.value) : item.value.toUpperCase();
  2243. var _found = false;
  2244. for (var i = 0; i < _data.length; i++) { // we group lower and upper cases together
  2245. if (_data[i].label == _label) {
  2246. _data[i].value += item.pivot ? item.pivot[0].fq_values : item.count;
  2247. _found = true;
  2248. break;
  2249. }
  2250. }
  2251. if (!_found) {
  2252. _data.push({
  2253. label: _label,
  2254. value: item.pivot ? item.pivot[0].fq_values : item.count,
  2255. obj: item
  2256. });
  2257. }
  2258. }
  2259. });
  2260. return _data;
  2261. }
  2262. function leafletMapChartDataTransformer(data) {
  2263. var _data = [];
  2264. if (!$.isEmptyObject(data.counts) && data.counts.response.docs && viewModel.collection.template.leafletmap.latitudeField() != "" && viewModel.collection.template.leafletmap.longitudeField() != "") {
  2265. data.counts.response.docs.forEach(function (record) {
  2266. var _obj = {
  2267. lat: record[viewModel.collection.template.leafletmap.latitudeField()],
  2268. lng: record[viewModel.collection.template.leafletmap.longitudeField()]
  2269. }
  2270. if (viewModel.collection.template.leafletmap.labelField() != "") {
  2271. _obj.label = record[viewModel.collection.template.leafletmap.labelField()];
  2272. }
  2273. _data.push(_obj);
  2274. });
  2275. }
  2276. return _data;
  2277. }
  2278. function leafletMapChartDataTransformerGrid(data) {
  2279. var _data = [];
  2280. $(data.counts).each(function (cnt, item) {
  2281. var chartX = viewModel.collection.template.chartSettings.chartX();
  2282. var chartY = viewModel.collection.template.chartSettings.chartYSingle();
  2283. var chartMapLabel = viewModel.collection.template.chartSettings.chartMapLabel();
  2284. if (chartX != "" && item.item[chartX] && chartY != "" && item.item[chartY]) {
  2285. var _obj = {
  2286. lat: item.item[chartX](),
  2287. lng: item.item[chartY]()
  2288. }
  2289. if (chartMapLabel != "" && item.item[chartMapLabel]) {
  2290. _obj.label = item.item[chartMapLabel]();
  2291. }
  2292. _data.push(_obj);
  2293. }
  2294. });
  2295. return _data;
  2296. }
  2297. function multiSerieDataTransformer(rawDatum) {
  2298. var _datum = [];
  2299. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYMulti().length > 0) {
  2300. var _plottedSerie = 0;
  2301. rawDatum.snippet.chartYMulti().forEach(function (col) {
  2302. var _idxValue = -1;
  2303. var _idxLabel = -1;
  2304. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2305. if (icol.name == rawDatum.snippet.chartX()) {
  2306. _idxLabel = idx;
  2307. }
  2308. if (icol.name == col) {
  2309. _idxValue = idx;
  2310. }
  2311. });
  2312. if (_idxValue > -1) {
  2313. var _data = [];
  2314. $(rawDatum.counts()).each(function (cnt, item) {
  2315. _data.push({
  2316. series: _plottedSerie,
  2317. x: item[_idxLabel],
  2318. y: item[_idxValue],
  2319. obj: item
  2320. });
  2321. });
  2322. if (rawDatum.sorting == "asc") {
  2323. _data.sort(function (a, b) {
  2324. return a.y - b.y
  2325. });
  2326. }
  2327. if (rawDatum.sorting == "desc") {
  2328. _data.sort(function (a, b) {
  2329. return b.y - a.y
  2330. });
  2331. }
  2332. _datum.push({
  2333. key: col,
  2334. values: _data
  2335. });
  2336. _plottedSerie++;
  2337. }
  2338. });
  2339. }
  2340. return _datum;
  2341. }
  2342. function multiSerieDataTransformerGrid(rawDatum) {
  2343. var _datum = [];
  2344. var chartX = viewModel.collection.template.chartSettings.chartX();
  2345. var chartY = viewModel.collection.template.chartSettings.chartYMulti();
  2346. if (chartX != null && chartY.length > 0 && rawDatum.counts.length > 0) {
  2347. var _plottedSerie = 0;
  2348. chartY.forEach(function (col) {
  2349. var _data = [];
  2350. $(rawDatum.counts).each(function (cnt, item) {
  2351. if (item.item[chartX] && item.item[col]) {
  2352. _data.push({
  2353. series: _plottedSerie,
  2354. x: item.item[chartX](),
  2355. y: item.item[col](),
  2356. obj: item.item
  2357. });
  2358. }
  2359. });
  2360. if (rawDatum.sorting == "asc") {
  2361. _data.sort(function (a, b) {
  2362. return a.y - b.y
  2363. });
  2364. }
  2365. if (rawDatum.sorting == "desc") {
  2366. _data.sort(function (a, b) {
  2367. return b.y - a.y
  2368. });
  2369. }
  2370. _datum.push({
  2371. key: col,
  2372. values: _data
  2373. });
  2374. _plottedSerie++;
  2375. });
  2376. }
  2377. return _datum;
  2378. }
  2379. function toggleDocDetails(doc) {
  2380. doc.showDetails(! doc.showDetails());
  2381. if (doc.details().length == 0) {
  2382. viewModel.getDocument(doc);
  2383. }
  2384. }
  2385. function resizeFieldsList() {
  2386. $(".fields-list").css("max-height", Math.max($("#result-container").height(), 230));
  2387. window.setTimeout(function () {
  2388. var _fillHeight = $("#result-container").height() - 40;
  2389. if ($(".fields-list").height() < _fillHeight) {
  2390. $(".fields-list").height(_fillHeight);
  2391. $(".fields-list").css("max-height", _fillHeight);
  2392. }
  2393. }, 100);
  2394. }
  2395. function queryTypeahead(query, process) {
  2396. var _source = viewModel.collection.template.fieldsNames();
  2397. _source = _source.concat("AND OR TO".split(" "))
  2398. if (viewModel.collection.suggest.enabled()) {
  2399. viewModel.suggest(query, function (data) {
  2400. var _tmp = [];
  2401. if (typeof data != "undefined" && data.response && data.response.suggest && data.response.suggest[viewModel.collection.suggest.dictionary()]) {
  2402. var suggestions = data.response.suggest[viewModel.collection.suggest.dictionary()][query].suggestions;
  2403. suggestions.forEach(function (sugg) {
  2404. _tmp.push(sugg.term + "<i class='muted fa fa-search'></i>");
  2405. });
  2406. }
  2407. process(_tmp.concat(_source));
  2408. });
  2409. }
  2410. else {
  2411. return _source;
  2412. }
  2413. }
  2414. $(document).ready(function () {
  2415. var _resizeTimeout = -1;
  2416. $(window).resize(function(){
  2417. window.clearTimeout(_resizeTimeout);
  2418. window.setTimeout(function(){
  2419. resizeFieldsList();
  2420. }, 200);
  2421. });
  2422. $(document).on("click", ".widget-settings-pill", function(){
  2423. $(this).parents(".card-body").find(".widget-section").hide();
  2424. selectAllCollectionFields(); // Make sure all the collection fields appear
  2425. $(this).parents(".card-body").find(".widget-settings-section").show();
  2426. $(this).parent().siblings().removeClass("active");
  2427. $(this).parent().addClass("active");
  2428. });
  2429. $(document).on("click", ".widget-editor-pill", function(){
  2430. $(this).parents(".card-body").find(".widget-section").hide();
  2431. $(this).parents(".card-body").find(".widget-editor-section").show();
  2432. $(this).parent().siblings().removeClass("active");
  2433. $(this).parent().addClass("active");
  2434. });
  2435. $(document).on("click", ".widget-html-pill", function(){
  2436. $(this).parents(".card-body").find(".widget-section").hide();
  2437. $(this).parents(".card-body").find(".widget-html-section").show();
  2438. $(document).trigger("refreshCodemirror");
  2439. $(this).parent().siblings().removeClass("active");
  2440. $(this).parent().addClass("active");
  2441. });
  2442. $(document).on("click", ".widget-css-pill", function(){
  2443. $(this).parents(".card-body").find(".widget-section").hide();
  2444. $(this).parents(".card-body").find(".widget-css-section").show();
  2445. $(document).trigger("refreshCodemirror");
  2446. $(this).parent().siblings().removeClass("active");
  2447. $(this).parent().addClass("active");
  2448. });
  2449. $(document).on("magicLayout", function(){
  2450. resizeFieldsList();
  2451. });
  2452. $(document).on("setLayout", function(){
  2453. resizeFieldsList();
  2454. });
  2455. huePubSub.subscribe('gridChartForceUpdate', function () {
  2456. window.setTimeout(function () {
  2457. $('.grid-chart-container').children().trigger('forceUpdate')
  2458. }, 200);
  2459. });
  2460. var _query = ${ query | n,unicode };
  2461. viewModel = new SearchViewModel(${ collection.get_json(user) | n,unicode }, _query, ${ initial | n,unicode });
  2462. viewModel.timelineChartTypes = ko.observableArray([
  2463. {
  2464. value: "line",
  2465. label: "${ _('Lines')}"
  2466. },
  2467. {
  2468. value: "bar",
  2469. label: "${ _('Bars')}"
  2470. }
  2471. ]);
  2472. ko.applyBindings(viewModel);
  2473. viewModel.init(function(data){
  2474. $(".chosen-select").trigger("chosen:updated");
  2475. });
  2476. viewModel.isRetrievingResults.subscribe(function(value){
  2477. if (! value){
  2478. resizeFieldsList();
  2479. }
  2480. });
  2481. viewModel.isEditing.subscribe(function(value){
  2482. if (value){
  2483. window.setTimeout(function(){
  2484. if ($(".slider-cnt").length > 0 && $(".slider-cnt").data("slider")){
  2485. $(".slider-cnt").slider("redraw");
  2486. }
  2487. }, 300);
  2488. }
  2489. });
  2490. viewModel.isPlayerMode.subscribe(function(value) {
  2491. if (value){
  2492. $(".navigator").hide();
  2493. $("body").css("paddingTop", "40px");
  2494. }
  2495. else {
  2496. $(".navigator").show();
  2497. $("body").css("paddingTop", "80px");
  2498. }
  2499. });
  2500. var _refreshTimeout = null;
  2501. viewModel.collection.autorefresh.subscribe(function (value) {
  2502. if (value) {
  2503. refresh();
  2504. }
  2505. else {
  2506. window.clearTimeout(_refreshTimeout);
  2507. }
  2508. });
  2509. if (viewModel.collection.autorefresh()) {
  2510. refresh();
  2511. }
  2512. function refresh() {
  2513. _refreshTimeout = window.setTimeout(function () {
  2514. if (viewModel.collection.autorefresh()) {
  2515. viewModel.search(refresh);
  2516. }
  2517. }, ($.isNumeric(viewModel.collection.autorefreshSeconds()) ? viewModel.collection.autorefreshSeconds() * 1 : 60) * 1000)
  2518. }
  2519. $("#addFacetDemiModal").on("hidden", function () {
  2520. if (typeof selectedWidget.hasBeenSelected == "undefined"){
  2521. addFacetDemiModalFieldCancel();
  2522. }
  2523. });
  2524. $(document).on("shownAnalysis", function(){
  2525. var _fieldElement = $(".field-selector").filter(function(){ return $(this).text().toLowerCase() === viewModel.fieldAnalysesName().toLowerCase();}).parent();
  2526. $("#fieldAnalysis").show().css("top", _fieldElement.position().top - $("#fieldAnalysis").outerHeight()/2 + _fieldElement.outerHeight()/2).css("left", _fieldElement.position().left + _fieldElement.outerWidth());
  2527. });
  2528. % if is_owner:
  2529. $(window).bind("keydown", "ctrl+s alt+s meta+s", function(e){
  2530. e.preventDefault();
  2531. viewModel.save();
  2532. return false;
  2533. });
  2534. % endif
  2535. $(window).bind("keydown", "esc", function () {
  2536. if ($(".demi-modal.fade.in").length > 0) {
  2537. $(".demi-modal.fade.in .demi-modal-chevron").click();
  2538. }
  2539. });
  2540. $("#newqname").bind("keydown", "return", function (e) {
  2541. e.preventDefault();
  2542. viewModel.collection.addQDefinition();
  2543. });
  2544. $(document).on("loadedQDefinition", function() {
  2545. if ($(".demi-modal.fade.in").length > 0) {
  2546. $(".demi-modal.fade.in .demi-modal-chevron").click();
  2547. }
  2548. });
  2549. function loadQueryDefinition(id) {
  2550. var _qdef = viewModel.collection.getQDefinition(id);
  2551. if (_qdef != null) {
  2552. viewModel.collection.loadQDefinition(_qdef);
  2553. }
  2554. }
  2555. if (window.location.hash != "" && window.location.hash.indexOf("qd=") > -1) {
  2556. loadQueryDefinition(window.location.hash.substr(1).replace(/(<([^>]+)>)/ig, "").split("=")[1]);
  2557. }
  2558. else if (_query.qd) {
  2559. loadQueryDefinition(_query.qd);
  2560. }
  2561. });
  2562. function toggleGridFieldsSelection() {
  2563. if (viewModel.collection.template.fields().length > 0) {
  2564. viewModel.collection.template.fieldsSelected([])
  2565. }
  2566. else {
  2567. selectAllCollectionFields();
  2568. }
  2569. }
  2570. function selectAllCollectionFields() {
  2571. var _fields = [];
  2572. $.each(viewModel.collection.fields(), function (index, field) {
  2573. _fields.push(field.name());
  2574. });
  2575. viewModel.collection.template.fieldsSelected(_fields);
  2576. }
  2577. function columnDropAdditionalHandler(widget) {
  2578. if (viewModel.collection.getFacetById(widget.id()) == null) {
  2579. showAddFacetDemiModal(widget);
  2580. }
  2581. viewModel.search();
  2582. }
  2583. function widgetDraggedAdditionalHandler(widget, row) {
  2584. showAddFacetDemiModal(widget, row);
  2585. }
  2586. function distributeRowWidgetsSize(row, waitForIt) {
  2587. if (row) {
  2588. if (waitForIt) {
  2589. var _initial = row.widgets().length;
  2590. var _widgetDropInterval = window.setInterval(function () {
  2591. if (row.widgets().length != _initial) {
  2592. window.clearInterval(_widgetDropInterval);
  2593. row.autosizeWidgets();
  2594. }
  2595. }, 100)
  2596. }
  2597. else {
  2598. row.autosizeWidgets();
  2599. }
  2600. }
  2601. }
  2602. var selectedWidget = null;
  2603. var selectedRow = null;
  2604. function showAddFacetDemiModal(widget, row) {
  2605. if (["resultset-widget", "html-resultset-widget", "filter-widget", "leafletmap-widget"].indexOf(widget.widgetType()) == -1) {
  2606. viewModel.collection.template.fieldsModalFilter("");
  2607. viewModel.collection.template.fieldsModalType(widget.widgetType());
  2608. viewModel.collection.template.fieldsModalFilter.valueHasMutated();
  2609. $('#addFacetInput').typeahead({
  2610. 'source': viewModel.collection.template.availableWidgetFieldsNames(),
  2611. 'updater': function (item) {
  2612. addFacetDemiModalFieldPreview({'name': function () {
  2613. return item
  2614. }});
  2615. return item;
  2616. }
  2617. });
  2618. selectedWidget = widget;
  2619. selectedRow = row;
  2620. $("#addFacetDemiModal").modal("show");
  2621. $("#addFacetDemiModal input[type='text']").focus();
  2622. }
  2623. else {
  2624. distributeRowWidgetsSize(row, true);
  2625. }
  2626. }
  2627. function addFacetDemiModalFieldPreview(field) {
  2628. var _existingFacet = viewModel.collection.getFacetById(selectedWidget.id());
  2629. if (selectedWidget != null) {
  2630. selectedWidget.hasBeenSelected = true;
  2631. selectedWidget.isLoading(true);
  2632. viewModel.collection.addFacet({'name': field.name(), 'widget_id': selectedWidget.id(), 'widgetType': selectedWidget.widgetType()});
  2633. if (_existingFacet != null) {
  2634. _existingFacet.label(field.name());
  2635. _existingFacet.field(field.name());
  2636. }
  2637. $("#addFacetDemiModal").modal("hide");
  2638. if (selectedRow != null) {
  2639. distributeRowWidgetsSize(selectedRow);
  2640. }
  2641. }
  2642. }
  2643. function addFacetDemiModalFieldCancel() {
  2644. viewModel.removeWidget(selectedWidget);
  2645. selectedRow = null;
  2646. }
  2647. $(document).on("setResultsHeight", function () {
  2648. $("#result-main").height($("#result-container").outerHeight() + 100);
  2649. resizeFieldsList();
  2650. });
  2651. function highlightColumn(column) {
  2652. var _colName = $.trim(column.name());
  2653. if (viewModel.collection.template.fieldsSelected.indexOf(_colName) > -1) {
  2654. var _t = $("#result-container");
  2655. var _col = _t.find("th").filter(function () {
  2656. return $.trim($(this).text()) == _colName;
  2657. });
  2658. if (_t.find("tr td:nth-child(" + (_col.index() + 1) + ").columnSelected").length == 0) {
  2659. _t.find(".columnSelected").removeClass("columnSelected");
  2660. _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
  2661. _t.parent().animate({
  2662. scrollLeft: _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").position().left + _t.parent().scrollLeft() - _t.parent().offset().left - 30
  2663. }, 300);
  2664. }
  2665. else {
  2666. _t.find(".columnSelected").removeClass("columnSelected");
  2667. }
  2668. }
  2669. }
  2670. function checkResultHighlightingAvailability() {
  2671. if (! viewModel.collection.idField()) {
  2672. $(document).trigger("warn", "${ _('Result highlighting is unavailable: the collection does not have an index field') }");
  2673. }
  2674. }
  2675. </script>
  2676. ${ commonfooter(request, messages) | n,unicode }