common_search.mako 191 KB

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