common_search.mako 176 KB

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