search.mako 150 KB

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