editor_components.mako 186 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728
  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.lib.i18n import smart_unicode
  20. from desktop.views import _ko, antixss
  21. from metadata.conf import has_optimizer
  22. from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_BATCH_EXECUTE, ENABLE_EXTERNAL_STATEMENT, ENABLE_PRESENTATION
  23. %>
  24. <%def name="includes(is_embeddable=False, suffix='')">
  25. <link rel="stylesheet" href="${ static('dashboard/css/common_dashboard.css') }">
  26. % if not is_embeddable:
  27. <link rel="stylesheet" href="${ static('notebook/css/notebook-layout.css') }">
  28. % endif
  29. <link rel="stylesheet" href="${ static('notebook/css/notebook.css') }">
  30. <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-editable.css') }">
  31. <link rel="stylesheet" href="${ static('desktop/ext/chosen/chosen.min.css') }">
  32. <link rel="stylesheet" href="${ static('desktop/ext/css/hue-charts.css') }">
  33. <link rel="stylesheet" href="${ static('desktop/ext/css/leaflet.css') }">
  34. <link rel="stylesheet" href="${ static('desktop/ext/css/leaflet.markercluster.css') }">
  35. <link rel="stylesheet" href="${ static('desktop/ext/css/nv.d3.min.css') }">
  36. <link rel="stylesheet" href="${ static('desktop/css/nv.d3.css') }">
  37. <link rel="stylesheet" href="${ static('desktop/ext/select2/select2.css') }">
  38. <link rel="stylesheet" href="${ static('desktop/ext/css/medium-editor.min.css') }">
  39. <link rel="stylesheet" href="${ static('desktop/css/bootstrap-medium-editor.css') }">
  40. <link rel="stylesheet" href="${ static('desktop/ext/css/jquery.mCustomScrollbar.min.css') }">
  41. % if not is_embeddable:
  42. <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
  43. <script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
  44. <script src="${ static('desktop/js/ko.charts.js') }"></script>
  45. <script src="${ static('desktop/js/ko.editable.js') }"></script>
  46. <script src="${ static('desktop/js/share2.vm.js') }"></script>
  47. % endif
  48. <script src="${ static('desktop/ext/js/clipboard.min.js') }"></script>
  49. <script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
  50. <script src="${ static('notebook/js/notebook.ko.js') }"></script>
  51. % if ENABLE_QUERY_SCHEDULING.get():
  52. <script src="${ static('oozie/js/coordinator-editor.ko.js') }"></script>
  53. <script src="${ static('oozie/js/list-oozie-coordinator.ko.js') }"></script>
  54. % endif
  55. <script src="${ static('desktop/js/ko.selectize.js') }"></script>
  56. <script src="${ static('desktop/js/sqlFunctions.js') }"></script>
  57. <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
  58. <script src="${ static('desktop/js/autocomplete/sqlStatementsParser.js') }"></script>
  59. <script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
  60. <script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
  61. <script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
  62. <script src="${ static('desktop/js/sqlAutocompleter3.js') }"></script>
  63. <script src="${ static('desktop/js/hdfsAutocompleter.js') }"></script>
  64. <script src="${ static('desktop/js/autocompleter.js') }"></script>
  65. <script src="${ static('desktop/js/hue.json.js') }"></script>
  66. <script src="${ static('desktop/js/jquery.hdfstree.js') }"></script>
  67. <script src="${ static('desktop/ext/js/markdown.min.js') }"></script>
  68. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.hotkeys.js') }"></script>
  69. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.mousewheel.min.js') }"></script>
  70. <script src="${ static('desktop/ext/js/jquery.mCustomScrollbar.concat.min.js') }"></script>
  71. %if ENABLE_QUERY_BUILDER.get():
  72. <!-- For query builder -->
  73. <link rel="stylesheet" href="${ static('desktop/ext/css/jquery.contextMenu.min.css') }">
  74. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.contextMenu.min.js') }"></script>
  75. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.ui.position.min.js') }"></script>
  76. <script src="${ static('desktop/js/queryBuilder.js') }"></script>
  77. <script>
  78. // query-builder-menu is the class to use
  79. // Callback will run after each rule add, just focus to the queryBuilder tab
  80. QueryBuilder.bindMenu('.query-builder-menu', function () {
  81. $("a[href='#queryBuilderTab']").click();
  82. });
  83. function generateQuery() {
  84. var result = QueryBuilder.buildHiveQuery();
  85. if (result.status == "fail") {
  86. $("#invalidQueryBuilder${ suffix }").modal("show");
  87. } else {
  88. replaceAce(result.query);
  89. }
  90. }
  91. window.setInterval(function(){
  92. if ($('#queryBuilder tbody').length > 0 && $('#queryBuilder tbody').find('tr').length > 0){
  93. $('.button-panel').show();
  94. $('#queryBuilder').show();
  95. $('#queryBuilderAlert').hide();
  96. } else {
  97. $('.button-panel').hide();
  98. $('#queryBuilder').hide();
  99. $('#queryBuilderAlert').show();
  100. }
  101. }, 500, 'editor' + (window.location.getParameter('type') ? '-' + window.location.getParameter('type') : ''));
  102. </script>
  103. <!-- End query builder imports -->
  104. % endif
  105. <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }" type="text/javascript" charset="utf-8"></script>
  106. <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
  107. <script src="${ static('desktop/js/hue.geo.js') }" type="text/javascript" charset="utf-8"></script>
  108. <script src="${ static('desktop/ext/js/leaflet/leaflet.js') }" type="text/javascript" charset="utf-8"></script>
  109. <script src="${ static('desktop/ext/js/leaflet/leaflet.markercluster.js') }" type="text/javascript" charset="utf-8"></script>
  110. <script src="${ static('desktop/ext/js/leaflet/leaflet.heat.js') }" type="text/javascript" charset="utf-8"></script>
  111. <script src="${ static('desktop/js/nv.d3.js') }" type="text/javascript" charset="utf-8"></script>
  112. <script src="${ static('desktop/ext/js/topojson.v1.min.js') }" type="text/javascript" charset="utf-8"></script>
  113. <script src="${ static('desktop/ext/js/topo/world.topo.js') }" type="text/javascript" charset="utf-8"></script>
  114. <script src="${ static('desktop/ext/js/topo/usa.topo.js') }" type="text/javascript" charset="utf-8"></script>
  115. <script src="${ static('desktop/ext/js/topo/chn.topo.js') }" type="text/javascript" charset="utf-8"></script>
  116. <script src="${ static('desktop/ext/js/topo/bra.topo.js') }" type="text/javascript" charset="utf-8"></script>
  117. <script src="${ static('desktop/ext/js/topo/can.topo.js') }" type="text/javascript" charset="utf-8"></script>
  118. <script src="${ static('desktop/ext/js/topo/ind.topo.js') }" type="text/javascript" charset="utf-8"></script>
  119. <script src="${ static('desktop/ext/js/topo/gbr.topo.js') }" type="text/javascript" charset="utf-8"></script>
  120. <script src="${ static('desktop/ext/js/topo/ita.topo.js') }" type="text/javascript" charset="utf-8"></script>
  121. <script src="${ static('desktop/ext/js/topo/fra.topo.js') }" type="text/javascript" charset="utf-8"></script>
  122. <script src="${ static('desktop/ext/js/topo/deu.topo.js') }" type="text/javascript" charset="utf-8"></script>
  123. <script src="${ static('desktop/ext/js/topo/jpn.topo.js') }" type="text/javascript" charset="utf-8"></script>
  124. <script src="${ static('desktop/ext/js/topo/aus.topo.js') }" type="text/javascript" charset="utf-8"></script>
  125. <script src="${ static('desktop/js/nv.d3.datamaps.js') }" type="text/javascript" charset="utf-8"></script>
  126. <script src="${ static('desktop/js/nv.d3.legend.js') }" type="text/javascript" charset="utf-8"></script>
  127. <script src="${ static('desktop/js/nv.d3.multiBarWithBrushChart.js') }" type="text/javascript" charset="utf-8"></script>
  128. <script src="${ static('desktop/js/nv.d3.lineWithBrushChart.js') }" type="text/javascript" charset="utf-8"></script>
  129. <script src="${ static('desktop/js/nv.d3.growingDiscreteBar.js') }" type="text/javascript" charset="utf-8"></script>
  130. <script src="${ static('desktop/js/nv.d3.growingDiscreteBarChart.js') }" type="text/javascript" charset="utf-8"></script>
  131. <script src="${ static('desktop/js/nv.d3.growingMultiBar.js') }" type="text/javascript" charset="utf-8"></script>
  132. <script src="${ static('desktop/js/nv.d3.growingMultiBarChart.js') }" type="text/javascript" charset="utf-8"></script>
  133. <script src="${ static('desktop/js/nv.d3.growingPie.js') }" type="text/javascript" charset="utf-8"></script>
  134. <script src="${ static('desktop/js/nv.d3.growingPieChart.js') }" type="text/javascript" charset="utf-8"></script>
  135. <script src="${ static('desktop/js/nv.d3.scatter.js') }" type="text/javascript" charset="utf-8"></script>
  136. <script src="${ static('desktop/js/nv.d3.scatterChart.js') }" type="text/javascript" charset="utf-8"></script>
  137. <script src="${ static('desktop/ext/select2/select2.min.js') }" type="text/javascript" charset="utf-8"></script>
  138. <!--[if IE 9]>
  139. <script src="${ static('desktop/ext/js/classList.min.js') }" type="text/javascript" charset="utf-8"></script>
  140. <![endif]-->
  141. <script src="${ static('desktop/ext/js/medium-editor.min.js') }" type="text/javascript" charset="utf-8"></script>
  142. <%namespace name="dashboard" file="/common_dashboard.mako" />
  143. <%namespace name="sqlSyntaxDropdown" file="/sql_syntax_dropdown.mako" />
  144. <script src="${ static('desktop/js/ko.common-dashboard.js') }" type="text/javascript" charset="utf-8"></script>
  145. </%def>
  146. <%def name="topBar(suffix='')">
  147. <style type="text/css">
  148. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  149. .search-bar {
  150. top: 58px!important;
  151. }
  152. .show-assist,
  153. .show-assist-right {
  154. top: 110px!important;
  155. }
  156. .main-content {
  157. top: 112px!important;
  158. }
  159. .context-panel {
  160. height: calc(100% - 104px);
  161. top: 104px;
  162. }
  163. % endif
  164. </style>
  165. ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
  166. <div class="print-logo">
  167. <img class="pull-right" src="${ static('desktop/art/icon_hue_48.png') }" alt="${ _('Hue logo') }"/>
  168. </div>
  169. <div class="navbar hue-title-bar" data-bind="visible: ! $root.isPresentationMode() && ! $root.isResultFullScreenMode()">
  170. <div class="navbar-inner">
  171. <div class="container-fluid">
  172. <div class="pull-right margin-right-10">
  173. <div class="btn-group">
  174. % if ENABLE_PRESENTATION.get():
  175. <a class="share-link btn" title="${ _ko('View as a presentation') }" data-bind="click: function() { $root.isPresentationMode(true); },
  176. css: {'btn-inverse': $root.isPresentationMode(), 'btn': true}">
  177. <i class="fa fa-line-chart"></i>
  178. </a>
  179. % endif
  180. <!-- ko if: $root.canSave -->
  181. <a class="share-link btn" title="${ _ko('Share') }" data-bind="click: prepareShareModal,
  182. css: {'isShared': isShared(), 'btn': true}">
  183. <i class="fa fa-users"></i>
  184. </a>
  185. <!-- /ko -->
  186. </div>
  187. <div class="btn-group">
  188. <a class="btn" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: function() { if ($root.canSave() ) { saveNotebook() } else { $('#saveAsModal${ suffix }').modal('show');} }, attr: { title: $root.canSave() ? '${ _ko('Save') }' : '${ _ko('Save As') }' }"><i class="fa fa-save"></i></a>
  189. <!-- ko if: $root.canSave -->
  190. <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
  191. <ul class="dropdown-menu">
  192. <li>
  193. <a class="pointer" data-bind="click: function() { $('#saveAsModal${ suffix }').modal('show'); }">
  194. <i class="fa fa-fw fa-save"></i> ${ _('Save as...') }
  195. </a>
  196. </li>
  197. </ul>
  198. <!-- /ko -->
  199. </div>
  200. <!-- ko template: { ifnot: editorMode, name: 'notebook-actions' }--><!-- /ko -->
  201. <!-- ko if: editorMode -->
  202. <a class="btn" href="javascript:void(0)" data-bind="click: function() { newNotebook($root.editorType(), null, selectedNotebook() ? $root.selectedNotebook().snippets()[0].currentQueryTab() : null); }, attr: { 'title': '${ _('New ') }' + editorTypeTitle() + '${ _(' Query') }' }" rel="tooltip" data-placement="bottom">
  203. <i class="fa fa-file-o"></i>
  204. </a>
  205. <!-- /ko -->
  206. <!-- ko ifnot: editorMode -->
  207. <a class="btn" href="javascript:void(0)" data-bind="click: newNotebook" title="${ _('New Notebook') }" rel="tooltip" data-placement="bottom">
  208. <i class="fa fa-file-o"></i>
  209. </a>
  210. <!-- /ko -->
  211. <a class="btn pointer" title="${ _('Session') }" data-bind="css: {'active': $root.isContextPanelVisible }, click: function() { $root.isContextPanelVisible(!$root.isContextPanelVisible()); }">
  212. <i class="fa fa-cogs"></i>
  213. </a>
  214. <!-- ko if: IS_HUE_4 -->
  215. <a class="btn" data-bind="hueLink: '/home/?type=' + (editorMode() ? 'query-' : '') + editorType(), attr: { 'title': editorMode() ? '${ _('Queries') }' : '${ _('Notebooks') }' }" rel="tooltip" data-placement="bottom">
  216. <svg class="hi"><use xlink:href="#hi-documents"></use></svg>
  217. </a>
  218. <!-- /ko -->
  219. <!-- ko ifnot: IS_HUE_4 -->
  220. <a class="btn" data-bind="hueLink: '${ url('notebook:notebooks') }?type=' + editorType(), attr: { 'title': editorMode() ? '${ _('Queries') }' : '${ _('Notebooks') }' }" rel="tooltip" data-placement="bottom">
  221. <svg class="hi"><use xlink:href="#hi-documents"></use></svg>
  222. </a>
  223. <!-- /ko -->
  224. </div>
  225. <div class="nav-collapse">
  226. <ul class="nav editor-nav">
  227. <li class="app-header">
  228. <!-- ko if: editorMode -->
  229. <a data-bind="hueLink: '${ url('notebook:editor') }?type=' + editorType(), attr: { 'title': editorTypeTitle() + '${ _(' Editor') }'}" style="cursor: pointer">
  230. <!-- ko template: { name: 'app-icon-template', data: { icon: editorType() } } --><!-- /ko -->
  231. <!-- ko if: editorType() == 'impala' -->
  232. Impala
  233. <!-- /ko -->
  234. <!-- ko if: editorType() == 'rdbms' -->
  235. DB Query
  236. <!-- /ko -->
  237. <!-- ko if: editorType() == 'pig' -->
  238. Pig
  239. <!-- /ko -->
  240. <!-- ko if: editorType() == 'java' -->
  241. Java
  242. <!-- /ko -->
  243. <!-- ko if: editorType() == 'spark2' -->
  244. Spark
  245. <!-- /ko -->
  246. <!-- ko if: editorType() == 'sqoop1' -->
  247. Sqoop 1
  248. <!-- /ko -->
  249. <!-- ko if: editorType() == 'distcp' -->
  250. DistCp
  251. <!-- /ko -->
  252. <!-- ko if: editorType() == 'shell' -->
  253. Shell
  254. <!-- /ko -->
  255. <!-- ko if: editorType() == 'mapreduce' -->
  256. MapReduce
  257. <!-- /ko -->
  258. <!-- ko if: editorType() == 'beeswax' || editorType() == 'hive' -->
  259. Hive
  260. <!-- /ko -->
  261. <!-- ko if: ['impala', 'pig', 'hive', 'beeswax', 'rdbms', 'java', 'spark2', 'sqoop1', 'distcp', 'shell', 'mapreduce'].indexOf(editorType()) == -1 -->
  262. SQL
  263. <!-- /ko -->
  264. <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: 'editor', interpreter: editorType() }} --><!-- /ko -->
  265. </a>
  266. <!-- /ko -->
  267. <!-- ko ifnot: editorMode -->
  268. <i class="fa fa-file-text-o app-icon" style="vertical-align: middle"></i>
  269. Notebook
  270. <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: 'notebook' }} --><!-- /ko -->
  271. <!-- /ko -->
  272. </li>
  273. <!-- ko with: selectedNotebook -->
  274. <li class="no-horiz-padding">
  275. <a>&nbsp;</a>
  276. </li>
  277. <li data-bind="visible: isHistory" style="display: none" class="no-horiz-padding muted">
  278. <a title="${ _('This is a history query') }"><i class="fa fa-fw fa-history"></i></a>
  279. </li>
  280. <li data-bind="visible: directoryUuid" style="display: none" class="no-horiz-padding muted">
  281. <a title="${ _('Open directory of this query') }" data-bind="hueLink: '/home/?uuid=' + directoryUuid()"
  282. class="pointer inactive-action" href="javascript:void(0)"><i class="fa fa-fw fa-folder-o"></i>
  283. </a>
  284. </li>
  285. <li data-bind="visible: parentSavedQueryUuid" style="display: none" class="no-horiz-padding muted">
  286. <a title="${ _('Click to open original saved query') }" data-bind="click: function() { $root.openNotebook(parentSavedQueryUuid()) }" class="pointer inactive-action">
  287. <i class="fa fa-fw fa-file-o"></i>
  288. </a>
  289. </li>
  290. <li data-bind="visible: isSaved() && ! isHistory() && ! parentSavedQueryUuid()" style="display: none" class="no-horiz-padding muted">
  291. <a title="${ _('This is a saved query') }"><i class="fa fa-fw fa-file-o"></i></a>
  292. </li>
  293. <li class="query-name no-horiz-padding skip-width-calculation">
  294. <a href="javascript:void(0)">
  295. <div class="notebook-name-desc" data-bind="editable: name, editableOptions: { inputclass: 'notebook-name-input', enabled: true, placement: 'bottom', emptytext: '${_ko('Add a name...')}', tpl: '<input type=\'text\' maxlength=\'255\'>' }"></div>
  296. </a>
  297. </li>
  298. <li class="skip-width-calculation" data-bind="tooltip: { placement: 'bottom', title: description }">
  299. <a href="javascript:void(0)">
  300. <div class="notebook-name-desc" data-bind="editable: description, editableOptions: { type: 'textarea', enabled: true, placement: 'bottom', emptytext: '${_ko('Add a description...')}' }"></div>
  301. </a>
  302. </li>
  303. <!-- /ko -->
  304. </ul>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="player-toolbar margin-top-10" data-bind="visible: $root.isPresentationMode() || $root.isResultFullScreenMode()" style="display: none;">
  310. <!-- ko if: $root.isResultFullScreenMode() -->
  311. <a class="hueAnchor collapse-results" href="javascript:void(0)" title="${ _('Collapse results') }" data-bind="click: function(){ $root.isResultFullScreenMode(false); }">
  312. <i class="fa fa-times fa-fw"></i>
  313. </a>
  314. <!-- /ko -->
  315. <!-- ko if: $root.isPresentationMode() -->
  316. <a class="hueAnchor collapse-results" href="javascript:void(0)" title="${ _('Exit presentation') }" data-bind="click: function(){ $root.isPresentationMode(false); }">
  317. <i class="fa fa-times fa-fw"></i>
  318. </a>
  319. <!-- ko if: $root.selectedNotebook() -->
  320. <!-- ko if: $root.selectedNotebook().name() || $root.selectedNotebook().description() -->
  321. <h2 class="margin-left-30 margin-right-10 inline padding-left-5" data-bind="text: $root.selectedNotebook().name"></h2>
  322. <h2 class="muted inline" data-bind="text: $root.selectedNotebook().description"></h2>
  323. <div class="clearfix"></div>
  324. <!-- /ko -->
  325. <div class="margin-left-30 margin-top-10 padding-left-5 margin-bottom-20">
  326. <!-- ko template: { name: 'notebook-actions' }--><!-- /ko -->
  327. <!-- ko if: $root.preEditorTogglingSnippet -->
  328. <!-- ko template: { if: $root.isPresentationMode(), name: 'snippet-variables', data: $root.preEditorTogglingSnippet }--><!-- /ko -->
  329. <!-- /ko -->
  330. </div>
  331. <!-- /ko -->
  332. <!-- /ko -->
  333. </div>
  334. </%def>
  335. <%def name="commonHTML(is_embeddable=False, suffix='')">
  336. <div id="helpModal${ suffix }" class="modal transparent-modal hide" data-backdrop="true" style="width:980px;margin-left:-510px!important">
  337. <div class="modal-header">
  338. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  339. <h2 class="modal-title">${_('Editor keyboard shortcuts')}</h2>
  340. </div>
  341. <div class="modal-body">
  342. <!-- ko component: 'aceKeyboardShortcuts' --><!-- /ko -->
  343. </div>
  344. <div class="modal-footer">
  345. <a href="#" class="btn" data-dismiss="modal">${_('Close')}</a>
  346. </div>
  347. </div>
  348. <div id="combinedContentModal${ suffix }" class="modal hide" data-backdrop="true" style="width:780px;margin-left:-410px!important">
  349. <div class="modal-header">
  350. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  351. <h2 class="modal-title">${_('All Notebook content')}</h2>
  352. </div>
  353. <div class="modal-body">
  354. <pre data-bind="oneClickSelect, text: combinedContent"></pre>
  355. </div>
  356. <div class="modal-footer">
  357. <a href="#" class="btn" data-dismiss="modal">${_('Close')}</a>
  358. </div>
  359. </div>
  360. % if ENABLE_QUERY_BUILDER.get():
  361. <div id="invalidQueryBuilder${ suffix }" class="modal hide">
  362. <div class="modal-header">
  363. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  364. <h2 class="modal-title">${_('Invalid Query')}</h2>
  365. </div>
  366. <div class="modal-body">
  367. <p>${_('Query requires a select or an aggregate.')}</p>
  368. </div>
  369. <div class="modal-footer">
  370. <a class="btn" data-dismiss="modal">${_('Close')}</a>
  371. </div>
  372. </div>
  373. % endif
  374. % if not is_embeddable:
  375. <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function() { $root.isLeftPanelVisible(true); huePubSub.publish('assist.set.manual.visibility'); }">
  376. <i class="fa fa-chevron-right"></i>
  377. </a>
  378. <a title="${_('Toggle Assist')}" class="pointer show-assist-right" data-bind="visible: !$root.isRightPanelVisible() && $root.isRightPanelAvailable(), click: function() { $root.isRightPanelVisible(true); huePubSub.publish('assist.set.manual.visibility'); }">
  379. <i class="fa fa-chevron-left"></i>
  380. </a>
  381. % endif
  382. <div data-bind="css: {'main-content': true, 'editor-mode': $root.editorMode()}">
  383. <div class="vertical-full container-fluid" data-bind="style: { 'padding-left' : $root.isLeftPanelVisible() || $root.isPresentationMode() || $root.isResultFullScreenMode() ? '0' : '20px' }" >
  384. <div class="vertical-full">
  385. <div class="vertical-full tab-pane row-fluid panel-container" data-bind="css: { active: selectedNotebook() === $data }, template: { name: 'notebook${ suffix }'}">
  386. </div>
  387. </div>
  388. </div>
  389. </div>
  390. <script type="text/html" id="notebook${ suffix }">
  391. % if not is_embeddable:
  392. <div class="assist-container left-panel" data-bind="visible: isLeftPanelVisible() && assistAvailable()">
  393. <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { isLeftPanelVisible(false); huePubSub.publish('assist.set.manual.visibility'); }">
  394. <i class="fa fa-chevron-left"></i>
  395. </a>
  396. <div class="assist" data-bind="component: {
  397. name: 'assist-panel',
  398. params: {
  399. user: user,
  400. sql: {
  401. sourceTypes: sqlSourceTypes,
  402. activeSourceType: activeSqlSourceType,
  403. navigationSettings: {
  404. openDatabase: false,
  405. openItem: false,
  406. showStats: true,
  407. pinEnabled: true
  408. },
  409. },
  410. visibleAssistPanels: editorMode() ? ['sql'] : []
  411. }
  412. }"></div>
  413. </div>
  414. <div class="resizer" data-bind="visible: isLeftPanelVisible() && assistAvailable(), splitDraggable : { appName: 'notebook', leftPanelVisible: isLeftPanelVisible, rightPanelVisible: isRightPanelVisible, rightPanelAvailable: isRightPanelAvailable, onPosition: function(){ huePubSub.publish('split.draggable.position') } }"><div class="resize-bar">&nbsp;</div></div>
  415. % endif
  416. <div class="content-panel" data-bind="event: { scroll: function(){ var ls = $(MAIN_SCROLLABLE).data('lastScroll'); if (ls && ls != $(MAIN_SCROLLABLE).scrollTop()){ $(document).trigger('hideAutocomplete'); }; $(MAIN_SCROLLABLE).data('lastScroll', $(MAIN_SCROLLABLE).scrollTop()) } }, with: selectedNotebook">
  417. <div>
  418. <div class="row-fluid row-container sortable-snippets" data-bind="css: {'is-editing': $root.isEditing},
  419. sortable: {
  420. template: 'snippet${ suffix }',
  421. data: snippets,
  422. isEnabled: true,
  423. options: {
  424. 'handle': '.move-widget',
  425. 'axis' : 'y',
  426. 'opacity': 0.8,
  427. 'placeholder': 'snippet-move-placeholder',
  428. 'greedy': true,
  429. 'stop': function(event, ui) {
  430. var $element = $(event.target);
  431. $element.find('.snippet-body').slideDown('fast', function () { $(MAIN_SCROLLABLE).scrollTop(lastWindowScrollPosition); });
  432. },
  433. 'helper': function(event) {
  434. lastWindowScrollPosition = $(MAIN_SCROLLABLE).scrollTop();
  435. var $element = $(event.target);
  436. $element.find('.snippet-body').slideUp('fast', function () {
  437. $('.sortable-snippets').sortable('refreshPositions')
  438. });
  439. var _par = $('<div>')
  440. .css('overflow', 'hidden')
  441. .addClass('card-widget snippet-move-helper')
  442. .width($element.parents('.snippet').width());
  443. $('<h2>')
  444. .addClass('card-heading')
  445. .html($element.parents('h2').html())
  446. .appendTo(_par)
  447. .find('.hover-actions, .snippet-actions')
  448. .removeClass('hover-actions')
  449. .removeClass('snippet-actions');
  450. $('<pre>')
  451. .addClass('dragging-pre muted')
  452. .html(ko.dataFor($element.parents('.card-widget')[0]).statement())
  453. .appendTo(_par);
  454. _par.css('height', '100px');
  455. return _par;
  456. }
  457. },
  458. dragged: function (widget) {
  459. $('.snippet-body').slideDown('fast', function () { $(MAIN_SCROLLABLE).scrollTop(lastWindowScrollPosition); });
  460. }
  461. }">
  462. </div>
  463. % if hasattr(caller, "addSnippetHTML"):
  464. ${ caller.addSnippetHTML() }
  465. % endif
  466. </div>
  467. </div>
  468. % if not is_embeddable:
  469. <!-- ko if: isRightPanelAvailable -->
  470. <div class="resizer" data-bind="visible: isRightPanelVisible, splitDraggable : { isRightPanel: true, appName: 'notebook', leftPanelVisible: isLeftPanelVisible, rightPanelVisible: isRightPanelVisible, rightPanelAvailable: isRightPanelAvailable, onPosition: function(){ huePubSub.publish('split.draggable.position') } }" style="display: none;"><div class="resize-bar">&nbsp;</div></div>
  471. <!-- /ko -->
  472. <div class="assist-container right-panel" data-bind="visible: isRightPanelVisible() && isRightPanelAvailable()" style="display:none;">
  473. <a title="${_('Toggle Assist')}" class="pointer hide-assist-right" data-bind="click: function() { isRightPanelVisible(false); huePubSub.publish('assist.set.manual.visibility'); }">
  474. <i class="fa fa-chevron-right"></i>
  475. </a>
  476. <div class="assist" data-bind="component: {
  477. name: 'right-assist-panel',
  478. params: {
  479. rightAssistAvailable: isRightPanelAvailable
  480. }
  481. }" >
  482. </div>
  483. </div>
  484. % endif
  485. <div class="context-panel" data-bind="css: {'visible': isContextPanelVisible}" style="${ 'height: 100%' if not is_embeddable else '' }">
  486. <ul class="nav nav-tabs">
  487. <li class="active"><a href="#sessionsTab" data-toggle="tab">${_('Sessions')}</a></li>
  488. </ul>
  489. <div class="tab-content" style="border: none">
  490. <div class="tab-pane active" id="sessionsTab">
  491. <div class="row-fluid">
  492. <div class="span12" data-bind="template: { name: 'notebook-session-config-template${ suffix }', data: $root }"></div>
  493. </div>
  494. </div>
  495. </div>
  496. </div>
  497. </script>
  498. <script type="text/html" id="notebook-session-config-template${ suffix }">
  499. <!-- ko with: selectedNotebook() -->
  500. <form class="form-horizontal session-config">
  501. <fieldset>
  502. <!-- ko ifnot: sessions().length -->
  503. <p>${ _('There are currently no active sessions, please reload the page.') }</p>
  504. <!-- /ko -->
  505. <!-- ko foreach: sessions -->
  506. <h4 data-bind="text: $parents[1].getSnippetName(type())" style="clear:left; display: inline-block"></h4>
  507. <div class="session-actions">
  508. <a class="inactive-action pointer" title="${ _('Recreate session') }" rel="tooltip" data-bind="click: function() { $parent.restartSession($data) }">
  509. <i class="fa fa-refresh" data-bind="css: { 'fa-spin': restarting }"></i> ${ _('Recreate') }
  510. </a>
  511. <a class="inactive-action pointer margin-left-10" title="${ _('Close session') }" rel="tooltip" data-bind="click: function() { $parent.closeAndRemoveSession($data) }">
  512. <i class="fa fa-times"></i> ${ _('Close') }
  513. </a>
  514. % if conf.USE_DEFAULT_CONFIGURATION.get():
  515. <a class="inactive-action pointer margin-left-10" title="${ _('Save session settings as default') }" rel="tooltip" data-bind="click: function() { $parent.saveDefaultUserProperties($data) }"><i class="fa fa-save"></i> ${ _('Set as default settings') }</a>
  516. % endif
  517. <!-- ko if: type() == 'impala' && typeof http_addr != 'undefined' -->
  518. <a class="margin-left-10" data-bind="attr: {'href': http_addr()}" target="_blank"><i class="fa fa-external-link"></i> <span data-bind="text: http_addr().replace(/^(https?):\/\//, '')"></span></a>
  519. <!-- /ko -->
  520. </div>
  521. <div style="width:100%;">
  522. <!-- ko component: { name: 'property-selector', params: { properties: properties } } --><!-- /ko -->
  523. </div>
  524. <div style="clear:both; padding-left: 120px;">
  525. <!-- ko if: availableNewProperties().length -->
  526. <a class="pointer" style="padding:5px;" data-bind="click: selectedSessionProperty() && function() {
  527. properties.push(ko.mapping.fromJS({'name': selectedSessionProperty(), 'value': ''}));
  528. selectedSessionProperty('');
  529. }" style="margin-left:10px;vertical-align: text-top;">
  530. </a>
  531. <!-- /ko -->
  532. </div>
  533. <!-- /ko -->
  534. <!-- /ko -->
  535. <br/>
  536. </fieldset>
  537. </form>
  538. <!-- /ko -->
  539. </script>
  540. <script type="text/html" id="snippetIcon${ suffix }">
  541. <!-- ko if: viewSettings().snippetImage -->
  542. <img class="snippet-icon-image" data-bind="attr: { 'src': viewSettings().snippetImage }" alt="${ _('Snippet icon') }">
  543. <!-- /ko -->
  544. <!-- ko if: viewSettings().snippetIcon -->
  545. <i class="fa snippet-icon" data-bind="css: viewSettings().snippetIcon"></i>
  546. <!-- /ko -->
  547. </script>
  548. <script type="text/html" id="snippet-log${ suffix }">
  549. <div class="snippet-log-container margin-bottom-10" data-bind="visible: showLogs() && status() != 'ready' && status() != 'loading'" style="display: none;">
  550. <div data-bind="delayedOverflow, css: resultsKlass" style="margin-top: 5px; position: relative;">
  551. <a href="javascript: void(0)" class="inactive-action close-logs-overlay" data-bind="click: function(){ showLogs(false) }"><i class="fa fa-times"></i></a>
  552. <ul data-bind="visible: jobs().length > 0, foreach: jobs" class="unstyled jobs-overlay">
  553. <li data-bind="attr: {'id': $data.name.substr(4)}">
  554. %if is_embeddable:
  555. <a class="pointer" data-bind="text: $.trim($data.name), click: function() { huePubSub.publish('show.jobs.panel', $data.name); }, clickBubble: false"></a>
  556. %else:
  557. <a data-bind="text: $.trim($data.name), hueLink: $data.url"></a>
  558. %endif
  559. <!-- ko if: typeof percentJob !== 'undefined' && percentJob() > -1 -->
  560. <div class="progress-job progress pull-left" style="background-color: #FFF; width: 100%" data-bind="css: {'progress-warning': percentJob() < 100, 'progress-success': percentJob() === 100}">
  561. <div class="bar" data-bind="style: {'width': percentJob() + '%'}"></div>
  562. </div>
  563. <!-- /ko -->
  564. <div class="clearfix"></div>
  565. </li>
  566. </ul>
  567. <pre data-bind="visible: result.logs() && result.logs().length == 0" class="logs logs-bigger">${ _('No logs available at this moment.') }</pre>
  568. <pre data-bind="visible: result.logs() && result.logs().length > 0, text: result.logs, logScroller: result.logs, logScrollerVisibilityEvent: showLogs, niceScroll" class="logs logs-bigger logs-populated"></pre>
  569. </div>
  570. <div class="snippet-log-resizer" data-bind="visible: result.logs().length > 0, logResizer: {parent: '.snippet-log-container', target: '.logs-populated', mainScrollable: MAIN_SCROLLABLE, onStart: hideFixedHeaders, onResize: function(){ hideFixedHeaders(); redrawFixedHeaders(500); }, minHeight: 50}">
  571. <i class="fa fa-ellipsis-h"></i>
  572. </div>
  573. </div>
  574. <div class="snippet-log-container margin-bottom-10">
  575. <div data-bind="visible: ! result.hasResultset() && status() == 'available' && result.fetchedOnce(), css: resultsKlass, click: function(){ }" style="display:none;">
  576. <pre class="margin-top-10 no-margin-bottom"><i class="fa fa-check muted"></i> ${ _('Success.') }</pre>
  577. </div>
  578. <div data-bind="visible: result.hasResultset() && status() == 'available' && result.data().length == 0 && result.fetchedOnce() && result.explanation().length <= 0, css: resultsKlass" style="display:none;">
  579. <pre class="margin-top-10 no-margin-bottom"><i class="fa fa-check muted"></i> ${ _("Done. 0 results.") }</pre>
  580. </div>
  581. <div data-bind="visible: status() == 'expired', css: resultsKlass" style="display:none;">
  582. <pre class="margin-top-10 no-margin-bottom"><i class="fa fa-check muted"></i> ${ _("Results have expired, rerun the query if needed.") }</pre>
  583. </div>
  584. <!-- ko if: status() == 'available' && ! result.fetchedOnce() -->
  585. <div data-bind="css: resultsKlass">
  586. <pre class="margin-top-10 no-margin-bottom"><i class="fa fa-spin fa-spinner"></i> ${ _('Loading...') }</pre>
  587. </div>
  588. <!-- /ko -->
  589. </div>
  590. </script>
  591. <script type="text/html" id="query-tabs${ suffix }">
  592. <div class="query-history-container" data-bind="onComplete: function(){ redrawFixedHeaders(200); }">
  593. <div data-bind="delayedOverflow, css: resultsKlass" style="margin-top: 5px; position: relative;">
  594. <ul class="nav nav-tabs">
  595. <li data-bind="click: function(){ currentQueryTab('queryHistory'); }, css: {'active': currentQueryTab() == 'queryHistory'}, onClickOutside: function () { if ($parent.historyFilterVisible() && $parent.historyFilter() === '') { $parent.historyFilterVisible(false) } }">
  596. <a class="inactive-action" href="#queryHistory" data-toggle="tab">${_('Query History')}
  597. <div class="inline-block inactive-action margin-left-10 pointer" title="${_('Search the query history')}" data-bind="click: function(data, e){ $parent.historyFilterVisible(!$parent.historyFilterVisible()); if ($parent.historyFilterVisible()) { window.setTimeout(function(){ $(e.target).parent().siblings('input').focus(); }, 0); } else { $parent.historyFilter('') }}"><i class="snippet-icon fa fa-search"></i></div>
  598. <input class="input-small inline-tab-filter" type="text" data-bind="visible: $parent.historyFilterVisible, clearable: $parent.historyFilter, valueUpdate:'afterkeydown'" placeholder="${ _('Search...') }">
  599. <div class="inline-block inactive-action pointer" title="${_('Clear the query history')}" data-target="#clearHistoryModal${ suffix }" data-toggle="modal" rel="tooltip" data-bind="visible: $parent.history().length > 0"><i class="snippet-icon fa fa-calendar-times-o"></i></div>
  600. </a>
  601. </li>
  602. <li data-bind="click: function(){ currentQueryTab('savedQueries'); }, css: {'active': currentQueryTab() == 'savedQueries'}, onClickOutside: function () { if (queriesFilterVisible() && queriesFilter() === '') { queriesFilterVisible(false) } }">
  603. <a class="inactive-action" href="#savedQueries" data-toggle="tab">${_('Saved Queries')}
  604. <div class="inline-block inactive-action margin-left-10 pointer" title="${_('Search the saved queries')}" data-bind="visible: !queriesHasErrors(), click: function(data, e){ queriesFilterVisible(!queriesFilterVisible()); if (queriesFilterVisible()) { window.setTimeout(function(){ $(e.target).parent().siblings('input').focus(); }, 0); } else { queriesFilter('') }}"><i class="snippet-icon fa fa-search"></i></div>
  605. <input class="input-small inline-tab-filter" type="text" data-bind="visible: queriesFilterVisible, clearable: queriesFilter, valueUpdate:'afterkeydown'" placeholder="${ _('Search...') }">
  606. </a>
  607. </li>
  608. % if ENABLE_QUERY_BUILDER.get():
  609. <!-- ko if: isSqlDialect -->
  610. <li data-bind="click: function(){ currentQueryTab('queryBuilderTab'); }, css: {'active': currentQueryTab() == 'queryBuilderTab'}"><a class="inactive-action" href="#queryBuilderTab" data-toggle="tab">${_('Query Builder')}</a></li>
  611. <!-- /ko -->
  612. % endif
  613. <!-- ko if: result.hasSomeResults -->
  614. <li data-bind="click: function(){ currentQueryTab('queryResults'); }, css: {'active': currentQueryTab() == 'queryResults'}">
  615. <a class="inactive-action" href="#queryResults" data-toggle="tab">${_('Results')}
  616. <!-- ko if: result.rows() != null -->
  617. (<span data-bind="text: result.rows().toLocaleString() + (type() == 'impala' && result.rows() == 1024 ? '+' : '')" title="${ _('Number of rows') }"></span>)
  618. <!-- /ko -->
  619. <!-- ko if: showGrid -->
  620. <div class="inline-block inactive-action pointer margin-left-10" title="${_('Search the results')}" data-bind="click: function(data, e){ $(e.target).parents('.snippet').find('.resultTable').hueDataTable().fnShowSearch() }">
  621. <i class="snippet-icon fa fa-search"></i>
  622. </div>
  623. <!-- /ko -->
  624. <div class="inline-block inactive-action pointer" title="${_('Expand results')}" rel="tooltip" data-bind="css: { 'margin-left-10': !showGrid()}, visible: !$root.isResultFullScreenMode(), click: function(){ $root.isResultFullScreenMode(true); }">
  625. <i class="snippet-icon fa fa-expand"></i>
  626. </div>
  627. <div class="inline-block inactive-action pointer" title="${_('Collapse results')}" rel="tooltip" data-bind="visible: $root.isResultFullScreenMode(), click: function(){ $root.isResultFullScreenMode(false); }">
  628. <i class="snippet-icon fa fa-compress"></i>
  629. </div>
  630. </a>
  631. </li>
  632. <!-- /ko -->
  633. <!-- ko if: result.explanation().length > 0 -->
  634. <li data-bind="click: function(){ currentQueryTab('queryExplain'); }, css: {'active': currentQueryTab() == 'queryExplain'}"><a class="inactive-action" href="#queryExplain" data-toggle="tab">${_('Explain')}</a></li>
  635. <!-- /ko -->
  636. <!-- ko foreach: pinnedContextTabs -->
  637. <li data-bind="click: function() { $parent.currentQueryTab(tabId) }, css: { 'active': $parent.currentQueryTab() === tabId }">
  638. <a class="inactive-action" data-toggle="tab" data-bind="attr: { 'href': '#' + tabId }">
  639. <i class="snippet-icon fa" data-bind="css: iconClass"></i> <span data-bind="text: title"></span>
  640. <div class="inline-block inactive-action margin-left-10 pointer" data-bind="click: function () { $parent.removeContextTab($data); }">
  641. <i class="snippet-icon fa fa-times"></i>
  642. </div>
  643. </a>
  644. </li>
  645. <!-- /ko -->
  646. </ul>
  647. <div class="tab-content" style="border: none; overflow-x: hidden">
  648. <div class="tab-pane" id="queryHistory" data-bind="css: {'active': currentQueryTab() == 'queryHistory'}">
  649. <!-- ko if: $parent.loadingHistory -->
  650. <div style="padding: 20px">
  651. <i class="fa fa-spinner fa-spin muted"></i>
  652. </div>
  653. <!-- /ko -->
  654. <!-- ko ifnot: $parent.loadingHistory -->
  655. <!-- ko if: $parent.history().length === 0 && $parent.historyFilter() === '' -->
  656. <div class="margin-top-20 margin-left-10" style="font-style: italic">${ _("No queries to be shown.") }</div>
  657. <!-- /ko -->
  658. <!-- ko if: $parent.history().length === 0 && $parent.historyFilter() !== '' -->
  659. <div class="margin-top-20 margin-left-10" style="font-style: italic">${ _('No queries found for') } <strong data-bind="text: $parent.historyFilter"></strong>.</div>
  660. <!-- /ko -->
  661. <!-- ko if: $parent.history().length > 0 -->
  662. <table class="table table-condensed margin-top-10 history-table">
  663. <tbody data-bind="foreach: $parent.history">
  664. <tr data-bind="click: function() { if (uuid() != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid()); } }, css: { 'highlight': uuid() == $root.selectedNotebook().uuid(), 'pointer': uuid() != $root.selectedNotebook().uuid() }">
  665. <td style="width: 100px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}">
  666. <span data-bind="momentFromNow: {data: lastExecuted, interval: 10000, titleFormat: 'LLL'}"></span>
  667. </td>
  668. <td style="width: 25px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}">
  669. <!-- ko switch: status -->
  670. <!-- ko case: 'running' -->
  671. <div class="history-status" data-bind="tooltip: { title: '${ _ko("Query running") }', placement: 'bottom' }"><i class="fa fa-fighter-jet fa-fw"></i></div>
  672. <!-- /ko -->
  673. <!-- ko case: 'failed' -->
  674. <div class="history-status" data-bind="tooltip: { title: '${ _ko("Query failed") }', placement: 'bottom' }"><i class="fa fa-exclamation fa-fw"></i></div>
  675. <!-- /ko -->
  676. <!-- ko case: 'available' -->
  677. <div class="history-status" data-bind="tooltip: { title: '${ _ko("Result available") }', placement: 'bottom' }"><i class="fa fa-check fa-fw"></i></div>
  678. <!-- /ko -->
  679. <!-- ko case: 'expired' -->
  680. <div class="history-status" data-bind="tooltip: { title: '${ _ko("Result expired") }', placement: 'bottom' }"><i class="fa fa-unlink fa-fw"></i></div>
  681. <!-- /ko -->
  682. <!-- /ko -->
  683. </td>
  684. <td style="width: 25px" class="muted" data-bind="ellipsis: {data: name(), length: 30}, style: {'border-top-width': $index() == 0 ? '0' : ''}"></td>
  685. <td data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}, click: function(){ if (window.getSelection().toString() === '' && uuid() != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid()) } }, clickBubble: false"><div data-bind="highlight: { value: query, dialect: $parent.type }"></div></td>
  686. </tr>
  687. </tbody>
  688. </table>
  689. <!-- /ko -->
  690. <!-- ko with: $parent -->
  691. <div class="pagination" data-bind="visible: historyTotalPages() > 1">
  692. <ul>
  693. <li data-bind="css: { 'disabled' : historyCurrentPage() === 1 }"><a href="javascript: void(0);" data-bind="click: function() { prevHistoryPage(); }">${ _("Prev") }</a></li>
  694. <li class="active"><span data-bind="text: historyCurrentPage() + '/' + historyTotalPages()"></span></li>
  695. <li data-bind="css: { 'disabled' : historyCurrentPage() === historyTotalPages() }"><a href="javascript: void(0);" data-bind="click: function() { nextHistoryPage(); }">${ _("Next") }</a></li>
  696. </ul>
  697. </div>
  698. <!-- /ko -->
  699. <!-- /ko -->
  700. </div>
  701. <div class="tab-pane" id="savedQueries" data-bind="css: {'active': currentQueryTab() == 'savedQueries'}" style="overflow: hidden">
  702. <!-- ko if: loadingQueries -->
  703. <div style="padding: 20px">
  704. <i class="fa fa-spinner fa-spin muted"></i>
  705. </div>
  706. <!-- /ko -->
  707. <!-- ko if: queriesHasErrors() -->
  708. <div class="margin-top-20 margin-left-10" style="font-style: italic">${ _("Error loading my queries") }</div>
  709. <!-- /ko -->
  710. <!-- ko if: !queriesHasErrors() && !loadingQueries() && queries().length === 0 && queriesFilter() === '' -->
  711. <div class="margin-top-20 margin-left-10" style="font-style: italic">${ _("You don't have any saved query.") }</div>
  712. <!-- /ko -->
  713. <!-- ko if: !queriesHasErrors() && !loadingQueries() && queries().length === 0 && queriesFilter() !== '' -->
  714. <div class="margin-top-20 margin-left-10" style="font-style: italic">${ _('No queries found for') } <strong data-bind="text: queriesFilter"></strong>.</div>
  715. <!-- /ko -->
  716. <!-- ko if: !queriesHasErrors() && !loadingQueries() && queries().length > 0 -->
  717. <table class="table table-condensed margin-top-10 history-table">
  718. <thead>
  719. <tr>
  720. <th style="width: 16%">${ _("Name") }</th>
  721. <th style="width: 50%">${ _("Description") }</th>
  722. <th style="width: 18%">${ _("Owner") }</th>
  723. <th style="width: 16%">${ _("Last Modified") }</th>
  724. </tr>
  725. </thead>
  726. <tbody data-bind="foreach: queries">
  727. <tr data-bind="click: function() { if (uuid() != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid(), 'savedQueries'); } }, css: { 'highlight': uuid() == $root.selectedNotebook().uuid(), 'pointer': uuid() != $root.selectedNotebook().uuid() }">
  728. <td style="width: 16%"><span data-bind="ellipsis: {data: name(), length: 50}"></span></td>
  729. <td style="width: 50%; white-space: normal"><span data-bind="text: description"></span></td>
  730. <td style="width: 18%"><span data-bind="text: owner"></span></td>
  731. <td style="width: 16%"><span data-bind="text: localeFormat(last_modified())"></span></td>
  732. </tr>
  733. </tbody>
  734. </table>
  735. <!-- /ko -->
  736. <div class="pagination" data-bind="visible: queriesTotalPages() > 1">
  737. <ul>
  738. <li data-bind="css: { 'disabled' : queriesCurrentPage() === 1 }"><a href="javascript: void(0);" data-bind="click: prevQueriesPage">${ _("Prev") }</a></li>
  739. <li class="active"><span data-bind="text: queriesCurrentPage() + '/' + queriesTotalPages()"></span></li>
  740. <li data-bind="css: { 'disabled' : queriesCurrentPage() === queriesTotalPages() }"><a href="javascript: void(0);" data-bind="click: nextQueriesPage">${ _("Next") }</a></li>
  741. </ul>
  742. </div>
  743. </div>
  744. % if ENABLE_QUERY_BUILDER.get():
  745. <div class="tab-pane margin-top-10" id="queryBuilderTab" data-bind="css: {'active': currentQueryTab() == 'queryBuilderTab'}">
  746. <div id="queryBuilderAlert" style="display: none" class="alert">${ _('There are currently no rules defined. To get started, right click on any table column in the SQL Assist panel.') }</div>
  747. <table id="queryBuilder" class="table table-condensed">
  748. <thead>
  749. <tr>
  750. <th width="10%">${ _('Table') }</th>
  751. <th>${ _('Column') }</th>
  752. <th width="10%">${ _('Operation') }</th>
  753. <th width="5%">&nbsp;</th>
  754. <th width="1%">&nbsp;</th>
  755. </tr>
  756. </thead>
  757. </table>
  758. <div class="button-panel">
  759. <button class="btn btn-primary disable-feedback" data-bind="click: generateQuery">${_('Build query')}</button>
  760. </div>
  761. </div>
  762. % endif
  763. <div class="tab-pane" id="queryResults" data-bind="css: {'active': currentQueryTab() == 'queryResults'}">
  764. <!-- ko template: { if: ['text', 'jar', 'py', 'markdown'].indexOf(type()) == -1, name: 'snippet-results${ suffix }' } --><!-- /ko -->
  765. </div>
  766. <!-- ko if: result.explanation().length > 0 -->
  767. <div class="tab-pane" id="queryExplain" data-bind="css: {'active': currentQueryTab() == 'queryExplain'}">
  768. <!-- ko template: { name: 'snippet-explain${ suffix }' } --><!-- /ko -->
  769. </div>
  770. <!-- /ko -->
  771. <!-- ko foreach: pinnedContextTabs -->
  772. <div class="tab-pane" style="height: 300px; position: relative; overflow: hidden;" data-bind="attr: { 'id': tabId }, css: {'active': $parent.currentQueryTab() === tabId }">
  773. <div style="display: flex; flex-direction: column; margin-top: 10px; overflow: hidden; height: 100%; position: relative;" data-bind="template: 'sql-context-contents'"></div>
  774. </div>
  775. <!-- /ko -->
  776. </div>
  777. </div>
  778. </div>
  779. </script>
  780. <script type="text/html" id="doc-search-autocomp-item">
  781. <a>
  782. <div>
  783. <strong style="font-size: 14px;" data-bind="html: name"></strong>
  784. <div style="width: 190px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis; font-size: 12px;" class="muted" data-bind="text: description"></div>
  785. </div>
  786. </a>
  787. </script>
  788. <script type="text/html" id="longer-operation${ suffix }">
  789. <div rel="tooltip" data-placement="bottom" data-bind="tooltip, fadeVisible: showLongOperationWarning" title="${ _('The query is hanging and taking longer than expected.') }" class="inline-block margin-right-10">
  790. <i class="fa fa-exclamation-triangle warning"></i>
  791. </div>
  792. </script>
  793. <script type="text/html" id="query-redacted${ suffix }">
  794. <div rel="tooltip" data-placement="bottom" data-bind="tooltip, fadeVisible: is_redacted" title="${ _('The current query has been redacted to hide sensitive information.') }" class="inline-block margin-right-10">
  795. <i class="fa fa-low-vision warning"></i>
  796. </div>
  797. </script>
  798. <script type="text/html" id="notebook-snippet-header${ suffix }">
  799. <!-- ko if: $root.isPresentationMode() || $root.isResultFullScreenMode() -->
  800. <div class="inline">
  801. <span data-bind="text: name"></span>
  802. </div>
  803. <!-- /ko -->
  804. <!-- ko if: ! $root.isPresentationMode() && ! $root.isResultFullScreenMode() -->
  805. <div class="inactive-action hover-actions inline">
  806. <span class="inactive-action" data-bind="css: { 'empty-title': name() === '' }, editable: name, editableOptions: { emptytext: '${_ko('My Snippet')}', mode: 'inline', enabled: true, placement: 'right' }" style="border:none;color: #DDD"></span>
  807. </div>
  808. <div class="hover-actions inline pull-right" style="font-size: 15px;">
  809. <!-- ko template: { name: 'query-redacted${ suffix }' } --><!-- /ko -->
  810. <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
  811. <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
  812. <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
  813. <a class="inactive-action move-widget" href="javascript:void(0)"><i class="fa fa-arrows"></i></a>
  814. <a class="inactive-action" href="javascript:void(0)" data-bind="toggle: settingsVisible, visible: hasProperties, css: { 'blue' : settingsVisible }" title="${ _('Settings and properties') }"><i class="fa fa-cog"></i></a>
  815. <a class="inactive-action" href="javascript:void(0)" data-bind="click: function(){ $root.removeSnippet($parent, $data); }"><i class="fa fa-times"></i></a>
  816. </div>
  817. <!-- /ko -->
  818. </script>
  819. <script type="text/html" id="editor-snippet-header${ suffix }">
  820. <div class="hover-actions inline pull-right" style="font-size: 15px; position: relative;" data-bind="style: { 'marginRight': $root.isPresentationMode() || $root.isResultFullScreenMode() ? '40px' : '0' }">
  821. <!-- ko template: { name: 'query-redacted${ suffix }' } --><!-- /ko -->
  822. <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
  823. <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
  824. <!-- ko if: availableDatabases().length > 0 && isSqlDialect() -->
  825. <div class="margin-left-10" data-bind="component: { name: 'hue-drop-down', params: { icon: 'fa-database', value: database, entries: availableDatabases, foreachVisible: true, searchable: true, linkTitle: '${ _ko('Active database') }' } }" style="display: inline-block"></div>
  826. <!-- /ko -->
  827. <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
  828. <a class="inactive-action margin-left-10" href="javascript:void(0)" data-bind="toggle: settingsVisible, visible: hasProperties, css: { 'blue' : settingsVisible }" title="${ _('Settings and properties') }"><i class="fa fa-cog"></i></a>
  829. <a class="inactive-action margin-left-10 pointer" title="${ _('Show editor shortcuts') }" data-toggle="modal" data-target="#helpModal${ suffix }"><i class="fa fa-question"></i></a>
  830. </div>
  831. </script>
  832. <script type="text/html" id="snippet-header-statement-type${ suffix }">
  833. % if ENABLE_EXTERNAL_STATEMENT.get():
  834. <!-- ko if: isSqlDialect() -->
  835. <div class="margin-left-10 statement-type-selector" data-bind="component: { name: 'hue-drop-down', params: { value: statementType, entries: statementTypes, linkTitle: '${ _ko('Statement type') }' } }" style="display: inline-block"></div>
  836. <!-- /ko -->
  837. % endif
  838. </script>
  839. <script type="text/html" id="snippet${ suffix }">
  840. <div data-bind="visibleOnHover: { override: inFocus() || settingsVisible() || dbSelectionVisible() || $root.editorMode() || saveResultsModalVisible(), selector: '.hover-actions' }">
  841. <div class="snippet-container row-fluid" data-bind="visibleOnHover: { override: $root.editorMode() || inFocus() || saveResultsModalVisible(), selector: '.snippet-actions' }">
  842. <div class="snippet card card-widget" data-bind="css: {'notebook-snippet' : ! $root.editorMode(), 'editor-mode': $root.editorMode(), 'active-editor': inFocus, 'snippet-text' : type() == 'text'}, attr: {'id': 'snippet_' + id()}, clickForAceFocus: ace">
  843. <div style="position: relative;">
  844. <div class="snippet-row" style="position: relative;">
  845. <div class="snippet-left-bar">
  846. <!-- ko template: { if: ! $root.editorMode() && ! $root.isPresentationMode() && ! $root.isResultFullScreenMode(), name: 'notebook-snippet-type-controls${ suffix }' } --><!-- /ko -->
  847. <!-- ko template: { if: ['text', 'markdown'].indexOf(type()) == -1 && ! $root.isResultFullScreenMode(), name: 'snippet-execution-controls${ suffix }' } --><!-- /ko -->
  848. </div>
  849. <div class="snippet-body" data-bind="clickForAceFocus: ace, visible: ! $root.isResultFullScreenMode()">
  850. <h5 class="card-heading-print" data-bind="text: name, css: {'visible': name() != ''}"></h5>
  851. <h2 style="margin-left:5px;padding: 3px 0" class="card-heading simple" data-bind="dblclick: function(){ if (!$root.editorMode()) { $parent.newSnippetAbove(id()) } }, clickForAceFocus: ace">
  852. <!-- ko template: { if: $root.editorMode(), name: 'editor-snippet-header${ suffix }' } --><!-- /ko -->
  853. <!-- ko template: { if: ! $root.editorMode(), name: 'notebook-snippet-header${ suffix }' } --><!-- /ko -->
  854. </h2>
  855. <!-- ko template: { if: ['text', 'jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce', 'py', 'markdown'].indexOf(type()) == -1, name: 'code-editor-snippet-body${ suffix }' } --><!-- /ko -->
  856. <!-- ko template: { if: type() == 'text', name: 'text-snippet-body${ suffix }' } --><!-- /ko -->
  857. <!-- ko template: { if: type() == 'markdown', name: 'markdown-snippet-body${ suffix }' } --><!-- /ko -->
  858. <!-- ko template: { if: ['java', 'distcp', 'shell', 'mapreduce', 'jar', 'py', 'spark2'].indexOf(type()) != -1, name: 'executable-snippet-body${ suffix }' } --><!-- /ko -->
  859. </div>
  860. <div style="position: absolute; top:25px; margin-left:35px; width: calc(100% - 35px)" data-bind="style: { 'z-index': 400 - $index() }">
  861. <!-- ko template: 'snippet-settings${ suffix }' --><!-- /ko -->
  862. </div>
  863. </div>
  864. <!-- ko template: { if: ['text', 'markdown'].indexOf(type()) == -1, name: 'snippet-execution-status${ suffix }' } --><!-- /ko -->
  865. <!-- ko template: { if: $root.editorMode() && ! $root.isResultFullScreenMode() && ['jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce'].indexOf(type()) == -1, name: 'snippet-code-resizer${ suffix }' } --><!-- /ko -->
  866. <!-- ko if: ! $root.isPresentationMode() && ! $root.isResultFullScreenMode() -->
  867. <!-- ko template: 'snippet-log${ suffix }' --><!-- /ko -->
  868. <!-- /ko -->
  869. <!-- ko if: $root.editorMode() -->
  870. <!-- ko template: 'query-tabs${ suffix }' --><!-- /ko -->
  871. <!-- /ko -->
  872. <!-- ko ifnot: $root.editorMode() -->
  873. <!-- ko template: { if: ['text', 'jar', 'java', 'distcp', 'shell', 'mapreduce', 'py', 'markdown'].indexOf(type()) == -1, name: 'snippet-results${ suffix }' } --><!-- /ko -->
  874. <!-- /ko -->
  875. <div class="clearfix"></div>
  876. </div>
  877. </div>
  878. </div>
  879. </div>
  880. </script>
  881. <script type="text/html" id="snippet-settings${ suffix }">
  882. <div class="snippet-settings" data-bind="slideVisible: settingsVisible" style="position: relative; z-index: 100;">
  883. <div class="snippet-settings-header">
  884. <h4><i class="fa fa-cog"></i> ${ _('Settings') }</h4>
  885. </div>
  886. <div class="snippet-settings-body">
  887. <form class="form-horizontal">
  888. <!-- ko template: { if: typeof properties().driverCores != 'undefined', name: 'property', data: { type: 'number', label: '${ _ko('Driver Cores') }', value: properties().driverCores, title: '${ _ko('Number of cores used by the driver, only in cluster mode (Default: 1)') }'}} --><!-- /ko -->
  889. <!-- ko template: { if: typeof properties().executorCores != 'undefined', name: 'property', data: { type: 'number', label: '${ _ko('Executor Cores') }', value: properties().executorCores, title: '${ _ko('Number of cores per executor (Default: 1)') }' }} --><!-- /ko -->
  890. <!-- ko template: { if: typeof properties().numExecutors != 'undefined', name: 'property', data: { type: 'number', label: '${ _ko('Executors') }', value: properties().numExecutors, title: '${ _ko('Number of executors to launch (Default: 2)') }' }} --><!-- /ko -->
  891. <!-- ko template: { if: typeof properties().queue != 'undefined', name: 'property', data: { type: 'string', label: '${ _ko('Queue') }', value: properties().queue, title: '${ _ko('The YARN queue to submit to (Default: default)') }' }} --><!-- /ko -->
  892. <!-- ko template: { if: typeof properties().archives != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko('Archives') }', value: properties().archives, title: '${ _ko('Archives to be extracted into the working directory of each executor (YARN only)') }', placeholder: '${ _ko('e.g. file.zip') }'}} --><!-- /ko -->
  893. <!-- ko template: { if: typeof properties().files != 'undefined', name: 'property', data: { type: 'hdfs-files', label: '${ _ko('Files') }', value: properties().files, visibleObservable: settingsVisible, title: '${ _ko('Files to be placed in the working directory of each executor.') }'}} --><!-- /ko -->
  894. <!-- ko template: { if: typeof properties().functions != 'undefined', name: 'property', data: { type: 'functions', label: '${ _ko('Functions') }', value: properties().functions, visibleObservable: settingsVisible, title: '${ _ko('UDFs name and class') }'}} --><!-- /ko -->
  895. <!-- ko template: { if: typeof properties().settings != 'undefined', name: 'property', data: { type: 'settings', label: '${ _ko('Settings') }', value: properties().settings, visibleObservable: settingsVisible, title: '${ _ko('Properties') }'}} --><!-- /ko -->
  896. <!-- ko template: { if: typeof properties().parameters != 'undefined', name: 'property', data: { type: 'csv', label: '${ _ko('Parameters') }', value: properties().parameters, title: '${ _ko('Names and values of Pig parameters and options') }', placeholder: '${ _ko('e.g. input /user/data, -param input=/user/data, -optimizer_off SplitFilter, -verbose') }'}} --><!-- /ko -->
  897. <!-- ko template: { if: typeof properties().hadoopProperties != 'undefined', name: 'property', data: { type: 'csv', label: '${ _ko('Hadoop properties') }', value: properties().hadoopProperties, title: '${ _ko('Name and values of Hadoop properties') }', placeholder: '${ _ko('e.g. mapred.job.queue.name=production, mapred.map.tasks.speculative.execution=false') }'}} --><!-- /ko -->
  898. <!-- ko template: { if: typeof properties().resources != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko('Resources') }', value: properties().resources, title: '${ _ko('HDFS Files or compressed files') }', placeholder: '${ _ko('e.g. /tmp/file, /tmp.file.zip') }'}} --><!-- /ko -->
  899. <!-- ko template: { if: typeof properties().capture_output != 'undefined', name: 'property', data: { type: 'boolean', label: '${ _ko('Capture output') }', value: properties().capture_output, title: '${ _ko('If capturing the output of the shell script') }' }} --><!-- /ko -->
  900. </form>
  901. </div>
  902. <a class="pointer demi-modal-chevron" data-bind="click: function() { settingsVisible(! settingsVisible()) }"><i class="fa fa-chevron-up"></i></a>
  903. </div>
  904. </script>
  905. <script type="text/html" id="code-editor-snippet-body${ suffix }">
  906. <!-- ko if: HAS_OPTIMIZER && (type() == 'impala' || type() == 'hive') && ! $root.isPresentationMode() && ! $root.isResultFullScreenMode() -->
  907. <div class="optimizer-container" data-bind="css: { 'active': showOptimizer }">
  908. <!-- ko if: hasSuggestion() -->
  909. <!-- ko with: suggestion() -->
  910. <!-- ko if: parseError -->
  911. <!-- ko if: $parent.compatibilityTargetPlatform() == $parent.type() && $parent.compatibilitySourcePlatform() == $parent.type() -->
  912. <div class="round-icon error" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }, attr: { 'title': $parent.showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
  913. <i class="fa fa-exclamation"></i>
  914. </div>
  915. <!-- ko if: $parent.showOptimizer -->
  916. <span class="optimizer-explanation alert-error alert-neutral">${ _('The query has a parse error.') }</span>
  917. <!-- /ko -->
  918. <!-- /ko -->
  919. ## Oracle, MySQL compatibility... as they return a parseError and not encounteredString.
  920. <!-- ko if: $parent.compatibilityTargetPlatform() != $parent.type() || $parent.type() != $parent.compatibilitySourcePlatform() -->
  921. <div class="round-icon warning" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }, attr: { 'title': $parent.showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
  922. <i class="fa fa-exclamation"></i>
  923. </div>
  924. <!-- ko if: $parent.showOptimizer -->
  925. <span class="optimizer-explanation alert-warning alert-neutral">${ _('This ') } <span data-bind="text: $parent.compatibilitySourcePlatform"></span> ${ _(' query is not compatible with ') } <span data-bind="text: $parent.compatibilityTargetPlatform"></span>.</span>
  926. <!-- /ko -->
  927. <!-- /ko -->
  928. <!-- /ko -->
  929. <!-- ko if: !parseError() && ($parent.compatibilityTargetPlatform() != $parent.type() || $parent.compatibilitySourcePlatform() != $parent.type()) -->
  930. <!-- ko if: queryError.encounteredString().length == 0 -->
  931. <div class="round-icon success" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }, attr: { 'title': $parent.showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
  932. <i class="fa fa-check"></i>
  933. </div>
  934. <!-- ko if: $parent.showOptimizer -->
  935. <span class="optimizer-explanation alert-success alert-neutral">
  936. ${ _('The ') } <select data-bind="options: $parent.compatibilitySourcePlatforms, optionsText: 'name', value: $parent.compatibilitySourcePlatform, optionsValue: 'value'" class="input-medium"></select>
  937. <!-- ko if: $parent.compatibilitySourcePlatform() == $parent.type() -->
  938. ${ _(' query is compatible with ') } <span data-bind="text: $parent.compatibilityTargetPlatform"></span>.
  939. <a href="javascript:void(0)" data-bind="click: function() { $parent.type($parent.compatibilityTargetPlatform()); }">${ _('Execute it with ') } <span data-bind="text: $parent.compatibilityTargetPlatform"></span></a>.
  940. <!-- /ko -->
  941. <!-- ko if: $parent.compatibilitySourcePlatform() != $parent.type() -->
  942. ${ _(' query is compatible with ') } <span data-bind="text: $parent.compatibilityTargetPlatform"></span>.
  943. <!-- /ko -->
  944. </span>
  945. <!-- /ko -->
  946. <!-- /ko -->
  947. <!-- ko ifnot: queryError.encounteredString().length == 0 -->
  948. <div class="round-icon warning" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }, attr: { 'title': $parent.showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
  949. <i class="fa fa-exclamation"></i>
  950. </div>
  951. <!-- ko if: $parent.showOptimizer -->
  952. <span class="optimizer-explanation alert-warning alert-neutral">${ _('This query is not compatible with ') } <span data-bind="text: $parent.compatibilityTargetPlatform"></span>.</span>
  953. <!-- /ko -->
  954. <!-- /ko -->
  955. <!-- /ko -->
  956. <!-- /ko -->
  957. <!-- /ko -->
  958. <!-- ko if: ! hasSuggestion() && topRisk() -->
  959. <!-- ko if: topRisk().risk === 'low' -->
  960. <div class="round-icon success" data-bind="click: function () { huePubSub.publish('assist.highlight.risk.suggestions'); }, tooltip: { placement: 'bottom' }" title="${ _('Some low risks were detected, see the assistant for details.') }">
  961. <i class="fa fa-check"></i>
  962. </div>
  963. <!-- /ko -->
  964. <!-- ko if: topRisk().risk == 'medium' -->
  965. <div class="round-icon warning" data-bind="click: function () { huePubSub.publish('assist.highlight.risk.suggestions'); }, tooltip: { placement: 'bottom' }" title="${ _('Some medium risks were detected, see the assistant for details.') }">
  966. <i class="fa fa-exclamation"></i>
  967. </div>
  968. <!-- /ko -->
  969. <!-- ko if: topRisk().risk == 'high' -->
  970. <div class="round-icon error" data-bind="click: function () { huePubSub.publish('assist.highlight.risk.suggestions'); }, tooltip: { placement: 'bottom' }" title="${ _('Some high risks were detected, see the assistant for details.') }">
  971. <i class="fa fa-exclamation"></i>
  972. </div>
  973. <!-- /ko -->
  974. <!-- /ko -->
  975. <!-- ko if: hasSuggestion() == '' && ! topRisk() -->
  976. <div class="round-icon success" data-bind="click: function () { huePubSub.publish('assist.highlight.risk.suggestions'); }, tooltip: { placement: 'bottom' }" title="${ _('Query validated, no issues found.') }">
  977. <i class="fa fa-check"></i>
  978. </div>
  979. <!-- /ko -->
  980. </div>
  981. <!-- /ko -->
  982. <div class="row-fluid" style="margin-bottom: 5px">
  983. <div class="editor span12" data-bind="css: {'single-snippet-editor ace-container-resizable' : $root.editorMode() }, clickForAceFocus: ace, visible: ! $root.isResultFullScreenMode() && ! ($root.isPresentationMode() && $root.isHidingCode())">
  984. <!-- ko if: statementType() == 'file' -->
  985. <div class="margin-top-10">
  986. <label class="pull-left" style="margin-top: 6px;margin-right: 10px;">${_('Query File')}</label>
  987. <input type="text" class="pull-left input-xxlarge filechooser-input" data-bind="value: statementPath, valueUpdate: 'afterkeydown', filechooser: statementPath, filechooserOptions: { skipInitialPathIfEmpty: true, linkMarkup: true }" placeholder="${ _('Path to file, e.g. /user/hue/sample.sql') }"/>
  988. <!-- ko if: statementPath() -->
  989. <div class="inline-block" style="margin-top: 4px">
  990. <a data-bind="hueLink: '/filebrowser/view=' + statementPath()" title="${ _('Open') }">
  991. <i class="fa fa-external-link-square"></i>
  992. </a>
  993. </div>
  994. <a class="btn" data-bind="click: function() { getExternalStatement(); }"><i class="fa fa-lg fa-refresh"></i></a>
  995. ##<a class="btn" data-bind="tooltip: { placement: 'bottom', title: 'Save content back to file' }, click: function() { huePubSub.publish('show.saveToFile.modal'); }"><i class="fa fa-save"></i></a>
  996. <!-- /ko -->
  997. </div>
  998. <div class="clearfix margin-bottom-20"></div>
  999. <!-- /ko -->
  1000. <!-- ko if: statementType() == 'document' -->
  1001. <div class="margin-top-10">
  1002. <!-- ko if: associatedDocumentLoading -->
  1003. <i class="fa fa-spinner fa-spin muted"></i>
  1004. <!-- /ko -->
  1005. <label class="pull-left" style="margin-top: 6px;margin-right: 10px;" data-bind="visible: !associatedDocumentLoading()">${_('Document')}</label>
  1006. <div class="selectize-wrapper" style="width: 300px;" data-bind="visible: !associatedDocumentLoading()">
  1007. <select placeholder="${ _('Search your documents...') }" data-bind="documentChooser: { loading: associatedDocumentLoading, value: associatedDocumentUuid, document: associatedDocument, type: type }"></select>
  1008. </div>
  1009. <!-- ko if: associatedDocument() -->
  1010. <div class="pull-left" style="margin-top: 4px">
  1011. <a data-bind="hueLink: associatedDocument().absoluteUrl" title="${ _('Open') }">
  1012. <i class="fa fa-external-link-square"></i>
  1013. </a>
  1014. <span data-bind='text: associatedDocument().description' style="padding: 3px; margin-top: 2px" class="muted"></span>
  1015. </div>
  1016. <!-- /ko -->
  1017. </div>
  1018. <div class="clearfix margin-bottom-20"></div>
  1019. <!-- /ko -->
  1020. <div class="ace-editor" data-bind="visible: statementType() === 'text' || statementType() !== 'text' && externalStatementLoaded(), css: {'single-snippet-editor ace-editor-resizable' : $root.editorMode(), 'active-editor': inFocus }, attr: { id: id() }, delayedOverflow, aceEditor: {
  1021. snippet: $data,
  1022. contextTooltip: '${ _ko("Right-click for details") }',
  1023. expandStar: '${ _ko("Right-click to expand with columns") }',
  1024. highlightedRange: result.statement_range,
  1025. useNewAutocompleter: $root.useNewAutocompleter,
  1026. readOnly: $root.isPresentationMode(),
  1027. aceOptions: {
  1028. showLineNumbers: $root.editorMode(),
  1029. showGutter: $root.editorMode(),
  1030. maxLines: $root.editorMode() ? null : 25,
  1031. minLines: $root.editorMode() ? null : 3
  1032. }
  1033. }, style: {opacity: statementType() !== 'text' || $root.isPresentationMode() ? '0.75' : '1', 'min-height': $root.editorMode() ? '0' : '48px', 'top': $root.editorMode() && statementType() !== 'text' ? '60px' : '0'}"></div>
  1034. % if conf.USE_NEW_AUTOCOMPLETER.get():
  1035. <!-- ko component: { name: 'hueAceAutocompleter', params: { editor: ace, snippet: $data } } --><!-- /ko -->
  1036. % endif
  1037. <ul class="table-drop-menu hue-context-menu">
  1038. <li class="editor-drop-value"><a href="javascript:void(0);">"<span class="editor-drop-identifier"></span>"</a></li>
  1039. <li class="divider"></li>
  1040. <li class="editor-drop-select"><a href="javascript:void(0);">SELECT FROM <span class="editor-drop-identifier"></span>...</a></li>
  1041. <li class="editor-drop-insert"><a href="javascript:void(0);">INSERT INTO <span class="editor-drop-identifier"></span>...</a></li>
  1042. <li class="editor-drop-update"><a href="javascript:void(0);">UPDATE <span class="editor-drop-identifier"></span>...</a></li>
  1043. <li class="editor-drop-drop"><a href="javascript:void(0);">DROP TABLE <span class="editor-drop-identifier"></span>...</a></li>
  1044. </ul>
  1045. </div>
  1046. <div class="clearfix"></div>
  1047. <!-- ko template: { if: ! $root.isPresentationMode() && ! $root.isResultFullScreenMode(), name: 'snippet-variables' }--><!-- /ko -->
  1048. </div>
  1049. <div class="clearfix"></div>
  1050. </script>
  1051. <script type="text/html" id="notebook-actions">
  1052. <div class="btn-group">
  1053. <!-- ko if: $root.selectedNotebook() -->
  1054. <!-- ko with: $root.selectedNotebook() -->
  1055. <a class="btn" rel="tooltip" data-placement="bottom" title="${ _("Execute all") }" data-bind="visible: ! isExecutingAll(), click: function() { executeAll(); }">
  1056. <i class="fa fa-fw fa-play"></i>
  1057. </a>
  1058. <!-- ko if: ! (snippets()[executingAllIndex()] && snippets()[executingAllIndex()].isCanceling()) -->
  1059. <a class="btn red" rel="tooltip" data-placement="bottom" title="${ _("Stop all") }" data-bind="visible: isExecutingAll(), click: function() { cancelExecutingAll(); }">
  1060. <i class="fa fa-fw fa-stop"></i>
  1061. </a>
  1062. <!-- /ko -->
  1063. <!-- ko if: snippets()[executingAllIndex()] && snippets()[executingAllIndex()].isCanceling() -->
  1064. <a class="btn" style="cursor: default;" title="${ _('Canceling operation...') }">
  1065. <i class="fa fa-fw fa-spinner snippet-side-single fa-spin"></i>
  1066. </a>
  1067. <!-- /ko -->
  1068. <!-- /ko -->
  1069. <!-- /ko -->
  1070. <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
  1071. <span class="caret"></span>
  1072. </a>
  1073. <ul class="dropdown-menu">
  1074. <li>
  1075. <a class="pointer" data-bind="click: function() { $root.selectedNotebook().clearResults() }">
  1076. <i class="fa fa-fw fa-eraser"></i> ${ _('Clear results') }
  1077. </a>
  1078. </li>
  1079. <li>
  1080. <a class="pointer" rel="tooltip" data-placement="bottom" data-bind="click: function() { $root.isHidingCode(! $root.isHidingCode()); }, attr: { 'title': $root.isHidingCode() ? '${ _ko('Show code') }' : '${ _ko('Hide code') }' }">
  1081. <i class="fa fa-fw" data-bind="css: { 'fa-expand': $root.isHidingCode(), 'fa-compress': ! $root.isHidingCode() }"></i>
  1082. <span data-bind="visible: $root.isHidingCode">${ _('Show the code') }</span>
  1083. <span data-bind="visible: ! $root.isHidingCode()">${ _('Hide the code') }</span>
  1084. </a>
  1085. </li>
  1086. <li>
  1087. <a href="javascript:void(0)" data-bind="click: displayCombinedContent, visible: ! $root.isPresentationMode() ">
  1088. <i class="fa fa-fw fa-file-text-o"></i> ${ _('Show all content') }
  1089. </a>
  1090. </li>
  1091. </ul>
  1092. </div>
  1093. </script>
  1094. <script type="text/html" id="snippet-variables">
  1095. <div class="variables">
  1096. <ul data-bind="foreach: variables" class="unstyled inline">
  1097. <li>
  1098. <div class="input-prepend margin-top-10">
  1099. <span class="muted add-on" data-bind="text: name"></span>
  1100. <input class="input-medium" type="text" data-bind="value: value, attr: { placeholder: defaultValue() || '${ _ko('Variable value') }' }, valueUpdate: 'afterkeydown', autogrowInput: { minWidth: 150, maxWidth: 270, comfortZone: 15 }, event: { 'keydown': function (context, e){ if ((e.ctrlKey || e.metaKey) && e.which === 13) { $parent.ace().commands.commands['execute'].exec(); } return true; } }">
  1101. </div>
  1102. </li>
  1103. </ul>
  1104. </div>
  1105. </script>
  1106. <script type="text/html" id="snippet-chart-settings${ suffix }">
  1107. <div>
  1108. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART -->
  1109. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1110. <li class="nav-header">${_('type')}</li>
  1111. </ul>
  1112. <div data-bind="visible: chartType() != ''">
  1113. <select data-bind="selectedOptions: chartTimelineType, optionsCaption: '${_ko('Choose a type...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a type...") }', update: chartTimelineType, dropdownAutoWidth: true}">
  1114. <option value="bar">${ _("Bars") }</option>
  1115. <option value="line">${ _("Lines") }</option>
  1116. </select>
  1117. </div>
  1118. <!-- /ko -->
  1119. <!-- ko if: chartType() != '' && chartType() === ko.HUE_CHARTS.TYPES.PIECHART -->
  1120. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1121. <li class="nav-header">${_('value')}</li>
  1122. </ul>
  1123. <div>
  1124. <select data-bind="options: result.cleanedNumericMeta, value: chartYSingle, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartYSingle, dropdownAutoWidth: true}" class="input-medium"></select>
  1125. </div>
  1126. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1127. <li class="nav-header">${_('legend')}</li>
  1128. </ul>
  1129. <div>
  1130. <select data-bind="options: result.cleanedMeta, value: chartX, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartX, dropdownAutoWidth: true}" class="input-medium"></select>
  1131. </div>
  1132. <!-- /ko -->
  1133. <!-- ko if: chartType() != '' && chartType() !== ko.HUE_CHARTS.TYPES.PIECHART -->
  1134. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1135. <li data-bind="visible: [ko.HUE_CHARTS.TYPES.MAP, ko.HUE_CHARTS.TYPES.GRADIENTMAP].indexOf(chartType()) == -1" class="nav-header">${_('x-axis')}</li>
  1136. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('region')}</li>
  1137. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('latitude')}</li>
  1138. </ul>
  1139. <div>
  1140. <select data-bind="options: ([ko.HUE_CHARTS.TYPES.BARCHART, ko.HUE_CHARTS.TYPES.GRADIENTMAP, ko.HUE_CHARTS.TYPES.TIMELINECHART].indexOf(chartType()) > -1) ? ( chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART ? result.cleanedDateTimeMeta : result.cleanedMeta ) : result.cleanedNumericMeta, value: chartX, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartX, dropdownAutoWidth: true}" class="input-medium"></select>
  1141. </div>
  1142. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1143. <li data-bind="visible: [ko.HUE_CHARTS.TYPES.MAP, ko.HUE_CHARTS.TYPES.GRADIENTMAP].indexOf(chartType()) == -1" class="nav-header">${_('y-axis')}</li>
  1144. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('value')}</li>
  1145. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('longitude')}</li>
  1146. </ul>
  1147. <div style="overflow-y: auto; max-height: 220px" data-bind="visible: chartType() != '' && ((chartType() == ko.HUE_CHARTS.TYPES.BARCHART && !chartXPivot()) || chartType() == ko.HUE_CHARTS.TYPES.LINECHART || chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART)">
  1148. <ul class="unstyled" data-bind="foreach: result.cleanedNumericMeta" style="margin-bottom: 0">
  1149. <li><label class="checkbox"><input type="checkbox" data-bind="checkedValue: name, checked: $parent.chartYMulti" /> <span data-bind="text: $data.name"></span></label></li>
  1150. </ul>
  1151. </div>
  1152. <div data-bind="visible: (chartType() == ko.HUE_CHARTS.TYPES.BARCHART && chartXPivot()) || chartType() == ko.HUE_CHARTS.TYPES.MAP || chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP || chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1153. <select data-bind="options: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? result.cleanedMeta : result.cleanedNumericMeta, value: chartYSingle, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartYSingle, dropdownAutoWidth: true}" class="input-medium"></select>
  1154. </div>
  1155. <!-- /ko -->
  1156. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() === ko.HUE_CHARTS.TYPES.BARCHART">
  1157. <li class="nav-header">${_('group')}</li>
  1158. </ul>
  1159. <div data-bind="visible: chartType() === ko.HUE_CHARTS.TYPES.BARCHART">
  1160. <select data-bind="options: result.cleanedMeta, value: chartXPivot, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column to pivot...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column to pivot...") }', update: chartXPivot, dropdownAutoWidth: true}" class="input-medium"></select>
  1161. </div>
  1162. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1163. <li class="nav-header">${_('limit')}</li>
  1164. </ul>
  1165. <div>
  1166. <select data-bind="options: chartLimits, value: chartLimit, optionsCaption: '${_ko('Limit the number of results to...')}', select2: { width: '100%', placeholder: '${ _ko("Limit the number of results to...") }', update: chartLimit, dropdownAutoWidth: true}" class="input-medium"></select>
  1167. </div>
  1168. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.MAP -->
  1169. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1170. <li class="nav-header">${_('type')}</li>
  1171. </ul>
  1172. <div data-bind="visible: chartType() != ''">
  1173. <select data-bind="selectedOptions: chartMapType, optionsCaption: '${_ko('Choose a type...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a type...") }', update: chartMapType, dropdownAutoWidth: true}">
  1174. <option value="marker">${ _("Markers") }</option>
  1175. <option value="heat">${ _("Heatmap") }</option>
  1176. </select>
  1177. </div>
  1178. <!-- ko if: chartMapType() == 'marker' -->
  1179. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1180. <li class="nav-header">${_('label')}</li>
  1181. </ul>
  1182. <div>
  1183. <select data-bind="options: result.cleanedMeta, value: chartMapLabel, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartMapLabel, dropdownAutoWidth: true}" class="input-medium"></select>
  1184. </div>
  1185. <!-- /ko -->
  1186. <!-- ko if: chartMapType() == 'heat' -->
  1187. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1188. <li class="nav-header">${_('intensity')}</li>
  1189. </ul>
  1190. <div>
  1191. <select data-bind="options: result.cleanedNumericMeta, value: chartMapHeat, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartMapHeat, dropdownAutoWidth: true}" class="input-medium"></select>
  1192. </div>
  1193. <!-- /ko -->
  1194. <!-- /ko -->
  1195. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1196. <li class="nav-header">${_('scatter size')}</li>
  1197. </ul>
  1198. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1199. <select data-bind="options: result.cleanedNumericMeta, value: chartScatterSize, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartScatterSize, dropdownAutoWidth: true}" class="input-medium"></select>
  1200. </div>
  1201. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1202. <li class="nav-header">${_('scatter group')}</li>
  1203. </ul>
  1204. <div data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1205. <select data-bind="options: result.cleanedMeta, value: chartScatterGroup, optionsText: 'name', optionsValue: 'name', optionsCaption: '${_ko('Choose a column...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a column...") }', update: chartScatterGroup, dropdownAutoWidth: true}" class="input-medium"></select>
  1206. </div>
  1207. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP -->
  1208. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1209. <li class="nav-header">${_('scope')}</li>
  1210. </ul>
  1211. <div data-bind="visible: chartType() != ''">
  1212. <select data-bind="selectedOptions: chartScope, optionsCaption: '${_ko('Choose a scope...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a scope...") }', update: chartScope, dropdownAutoWidth: true}">
  1213. <option value="world">${ _("World") }</option>
  1214. <option value="europe">${ _("Europe") }</option>
  1215. <option value="aus">${ _("Australia") }</option>
  1216. <option value="bra">${ _("Brazil") }</option>
  1217. <option value="can">${ _("Canada") }</option>
  1218. <option value="chn">${ _("China") }</option>
  1219. <option value="fra">${ _("France") }</option>
  1220. <option value="deu">${ _("Germany") }</option>
  1221. <option value="ita">${ _("Italy") }</option>
  1222. <option value="jpn">${ _("Japan") }</option>
  1223. <option value="gbr">${ _("UK") }</option>
  1224. <option value="usa">${ _("USA") }</option>
  1225. </select>
  1226. </div>
  1227. <!-- /ko -->
  1228. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP && chartType() != ko.HUE_CHARTS.TYPES.GRADIENTMAP && chartType() != ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1229. <li class="nav-header">${_('sorting')}</li>
  1230. </ul>
  1231. <div class="btn-group" data-toggle="buttons-radio" data-bind="visible: chartType() != '' && chartType() != ko.HUE_CHARTS.TYPES.MAP && chartType() != ko.HUE_CHARTS.TYPES.GRADIENTMAP && chartType() != ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1232. <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>
  1233. <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>
  1234. <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>
  1235. </div>
  1236. </div>
  1237. </script>
  1238. <script type="text/html" id="snippet-grid-settings${ suffix }">
  1239. <div class="snippet-grid-settings" style="overflow: auto">
  1240. <table class="table table-condensed margin-top-10 no-border">
  1241. <thead>
  1242. <tr>
  1243. <th width="16">
  1244. <input class="all-meta-checked no-margin-top" type="checkbox" data-bind="enable: !result.isMetaFilterVisible() && result.filteredMeta().length > 0, event: { change: function(){ toggleAllColumns($element, $data); result.clickFilteredMetaCheck() } }, checked: result.filteredMetaChecked" />
  1245. </th>
  1246. <th colspan="2" class="nav-header-like">
  1247. <span class="meta-title pointer" data-bind="click: function(){ result.isMetaFilterVisible(true); }, attr: {title: result.filteredMeta().length }">${_('columns')}</span>
  1248. (<span class="meta-title pointer" data-bind="click: function(){ result.isMetaFilterVisible(true); }, text: result.filteredMeta().length"></span>)
  1249. <span class="inactive-action" href="javascript:void(0)" data-bind="click: function(){ result.isMetaFilterVisible(true); }, css: { 'blue' : result.isMetaFilterVisible }"><i class="pointer fa fa-search" title="${ _('Search') }"></i></span>
  1250. </th>
  1251. </tr>
  1252. <tr data-bind="visible: result.isMetaFilterVisible">
  1253. <td colspan="3"><input class="meta-filter" type="text" data-bind="blurHide: result.isMetaFilterVisible, clearable: result.metaFilter, valueUpdate:'afterkeydown'" placeholder="${ _('Filter columns...') }" title="${ _('Type column:xxx or type:yyy for specific filters.') }" style="width: 257px" /></td>
  1254. </tr>
  1255. </thead>
  1256. <tbody class="unstyled filtered-meta" data-bind="foreach: result.filteredMeta">
  1257. <tr data-bind="visible: name != ''">
  1258. <td><input class="no-margin-top" type="checkbox" data-bind="event: { change: function(){ toggleColumn($element, $data.originalIndex, $parent);} }, checked: $data.checked" /></td>
  1259. <td><a class="pointer" data-bind="click: function(){ scrollToColumn($element, $data.originalIndex); }, attr: { title: $data.name + ' - ' + $data.type}"><span data-bind="text: $data.name"></span></a></td>
  1260. <td><span data-bind="text: $data.type" class="muted margin-left-20"></span></td>
  1261. </tr>
  1262. </tbody>
  1263. <tfoot>
  1264. <tr>
  1265. <td colspan="3">
  1266. <div class="margin-top-10 muted meta-noresults" data-bind="visible: result.filteredMeta().length === 0">
  1267. ${ _('No results found') }
  1268. </div>
  1269. </td>
  1270. </tr>
  1271. </tfoot>
  1272. </table>
  1273. </div>
  1274. </script>
  1275. <script type="text/html" id="snippet-explain${ suffix }">
  1276. <pre class="no-margin-bottom" data-bind="text: result.explanation"></pre>
  1277. </script>
  1278. <script type="text/html" id="snippet-results${ suffix }">
  1279. <div class="snippet-row" data-bind="slideVisible: result.hasSomeResults">
  1280. <div class="snippet-left-bar">
  1281. <!-- ko template: { if: result.type() == 'table' && result.hasSomeResults(), name: 'snippet-result-controls${ suffix }' }--><!-- /ko -->
  1282. </div>
  1283. <div class="result-body">
  1284. <div class="row-fluid" data-bind="visible: result.type() != 'table'" style="display:none; max-height: 400px; margin: 10px 0; overflow-y: auto">
  1285. <!-- ko if: result.data().length != 0 && result.data()[0][1] != "" -->
  1286. <pre data-bind="text: result.data()[0][1]" class="no-margin-bottom"></pre>
  1287. <!-- /ko -->
  1288. <!-- ko ifnot: result.data().length != 0 && result.data()[0][1] != "" -->
  1289. <pre class="no-margin-bottom"><i class="fa fa-check muted"></i> ${ _("Done.") }</pre>
  1290. <!-- /ko -->
  1291. <!-- ko if: result.images().length != 0 -->
  1292. <ul class="unstyled results-images" data-bind="foreach: result.images()">
  1293. <li>
  1294. <img data-bind="attr: {'src': 'data:image/png;base64,' + $data}" class="margin-bottom-10" alt="${ _('Result image') }"/>
  1295. </li>
  1296. </ul>
  1297. <!-- /ko -->
  1298. </div>
  1299. <div class="row-fluid table-results" data-bind="visible: result.type() == 'table'" style="display: none; max-height: 400px; min-height: 290px;">
  1300. <div>
  1301. <div class="column-side" data-bind="visible: isResultSettingsVisible, css:{'span3 result-settings': isResultSettingsVisible, 'hidden': ! isResultSettingsVisible()}" style="position:relative;white-space: nowrap;">
  1302. <!-- ko template: { name: 'snippet-grid-settings${ suffix }', if: showGrid } --><!-- /ko -->
  1303. <!-- ko template: { name: 'snippet-chart-settings${ suffix }', if: showChart } --><!-- /ko -->
  1304. <div class="resize-bar" style="top: 0; right: -10px; cursor: col-resize;"></div>
  1305. </div>
  1306. <div class="grid-side" data-bind="css: {'span9': isResultSettingsVisible, 'span12 nomargin': ! isResultSettingsVisible() }">
  1307. <div data-bind="visible: showGrid, delayedOverflow, css: resultsKlass" style="display: none;">
  1308. <table class="table table-condensed resultTable">
  1309. <thead>
  1310. <tr data-bind="foreach: result.meta">
  1311. <th class="sorting" data-bind="text: ($index() == 0 ? '&nbsp;' : $data.name), css: typeof cssClass != 'undefined' ? cssClass : 'sort-string', attr: {title: $data.type }, style:{'width': $index() == 0 ? '1%' : '', 'height': $index() == 0 ? '32px' : ''}, click: function(obj, e){ $(e.target).parents('table').trigger('sort', obj); }"></th>
  1312. </tr>
  1313. </thead>
  1314. <tbody>
  1315. </tbody>
  1316. </table>
  1317. <div data-bind="visible: status() == 'expired' && result.data() && result.data().length > 99, css: resultsKlass" style="display:none;">
  1318. <pre class="margin-top-10"><i class="fa fa-check muted"></i> ${ _("Results have expired, rerun the query if needed.") }</pre>
  1319. </div>
  1320. </div>
  1321. <div data-bind="visible: showChart" class="chart-container" style="display:none;">
  1322. <h1 class="empty" data-bind="visible: !hasDataForChart()">${ _('Select the chart parameters on the left') }</h1>
  1323. <div data-bind="visible: hasDataForChart">
  1324. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.PIECHART -->
  1325. <div data-bind="attr:{'id': 'pieChart_'+id()}, pieChart: {data: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()}, fqs: ko.observableArray([]),
  1326. transformer: pieChartDataTransformer, maxWidth: 350, parentSelector: '.chart-container' }, visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="chart"></div>
  1327. <!-- /ko -->
  1328. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.BARCHART -->
  1329. <div data-bind="attr:{'id': 'barChart_'+id()}, barChart: {skipWindowResize: true, datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()}, fqs: ko.observableArray([]), hideSelection: true,
  1330. transformer: multiSerieDataTransformer, stacked: false, showLegend: true, isPivot: typeof chartXPivot() !== 'undefined'}, stacked: true, showLegend: true, visible: chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
  1331. <!-- /ko -->
  1332. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.LINECHART -->
  1333. <div data-bind="attr:{'id': 'lineChart_'+id()}, lineChart: {datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()},
  1334. transformer: multiSerieDataTransformer, showControls: false, enableSelection: false }, visible: chartType() == ko.HUE_CHARTS.TYPES.LINECHART" class="chart"></div>
  1335. <!-- /ko -->
  1336. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART -->
  1337. <div data-bind="attr:{'id': 'timelineChart_'+id()}, timelineChart: {type: chartTimelineType, skipWindowResize: true, datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()}, fqs: ko.observableArray([]), hideSelection: true,
  1338. transformer: timelineChartDataTransformer, stacked: false, showLegend: true}, hideSelection: true, visible: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART" class="chart"></div>
  1339. <!-- /ko -->
  1340. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.MAP -->
  1341. <div data-bind="attr:{'id': 'leafletMapChart_'+id()}, leafletMapChart: {datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()},
  1342. transformer: leafletMapChartDataTransformer, showControls: false, height: 380, visible: chartType() == ko.HUE_CHARTS.TYPES.MAP, forceRedraw: true}" class="chart"></div>
  1343. <!-- /ko -->
  1344. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP -->
  1345. <div data-bind="attr:{'id': 'gradientMapChart_'+id()}, mapChart: {data: {counts: result.data, sorting: chartSorting(), snippet: $data, scope: chartScope(), limit: chartLimit()},
  1346. transformer: mapChartDataTransformer, isScale: true, showControls: false, height: 380, maxWidth: 750, parentSelector: '.chart-container', visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP}" class="chart"></div>
  1347. <!-- /ko -->
  1348. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART -->
  1349. <div data-bind="attr:{'id': 'scatterChart_'+id()}, scatterChart: {datum: {counts: result.data, snippet: $data, limit: chartLimit()},
  1350. transformer: scatterChartDataTransformer, maxWidth: 350, y: chartYSingle(), x: chartX(), size: chartScatterSize(), group: chartScatterGroup() }, visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART" class="chart"></div>
  1351. <!-- /ko -->
  1352. </div>
  1353. </div>
  1354. </div>
  1355. </div>
  1356. </div>
  1357. </div>
  1358. </div>
  1359. </script>
  1360. <script type="text/html" id="text-snippet-body${ suffix }">
  1361. <div data-bind="attr:{'id': 'editor_' + id()}, html: statement_raw, value: statement_raw, medium: {}" data-placeHolder="${ _('Type your text here, select some text to format it') }" class="text-snippet"></div>
  1362. </script>
  1363. <script type="text/html" id="markdown-snippet-body${ suffix }">
  1364. <!-- ko ifnot: $root.isPresentationMode() -->
  1365. <div class="row-fluid">
  1366. <div class="span6" data-bind="clickForAceFocus: ace">
  1367. <div class="ace-editor" data-bind="attr: { id: id() }, aceEditor: {
  1368. snippet: $data,
  1369. updateOnInput: true
  1370. }"></div>
  1371. </div>
  1372. <div class="span6">
  1373. <div data-bind="html: renderMarkdown(statement_raw(), id()), attr: {'id': 'liveMD'+id()}"></div>
  1374. </div>
  1375. </div>
  1376. <!-- /ko -->
  1377. <!-- ko if: $root.isPresentationMode() -->
  1378. <div data-bind="html: renderMarkdown(statement_raw(), id())"></div>
  1379. <!-- /ko -->
  1380. </script>
  1381. <script type="text/html" id="executable-snippet-body${ suffix }">
  1382. <div style="padding:10px;">
  1383. <form class="form-horizontal">
  1384. <!-- ko if: type() == 'distcp' -->
  1385. <div class="control-group">
  1386. <label class="control-label">${_('Source')}</label>
  1387. <div class="controls">
  1388. <input type="text" class="input-xxlarge filechooser-input" data-bind="value: properties().source_path, valueUpdate: 'afterkeydown', filechooser: properties().source_path, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true }" placeholder="${ _('Source path to copy, e.g. ${nameNode1}/path/to/input.txt') }"/>
  1389. </div>
  1390. </div>
  1391. <div class="control-group">
  1392. <label class="control-label">${_('Destination')}</label>
  1393. <div class="controls">
  1394. <input type="text" class="input-xxlarge filechooser-input" data-bind="value: properties().destination_path, valueUpdate: 'afterkeydown', filechooser: properties().destination_path, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true }" placeholder="${ _('Destination path, e.g. ${nameNode2}/path/to/output.txt') }"/>
  1395. </div>
  1396. </div>
  1397. <!-- /ko -->
  1398. <!-- ko if: type() == 'shell' -->
  1399. <div class="control-group">
  1400. <label class="control-label">${_('Script path')}</label>
  1401. <div class="controls">
  1402. <input type="text" class="input-xxlarge filechooser-input" data-bind="value: properties().command_path, valueUpdate: 'afterkeydown', filechooser: properties().command_path, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true, selectFolder: false }" placeholder="${ _('Source path to the command') }"/>
  1403. </div>
  1404. </div>
  1405. <div class="control-group">
  1406. <label class="control-label">${_('Variables')}</label>
  1407. <div class="controls">
  1408. <!-- ko template: { if: typeof properties().arguments != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko("Arguments") }', value: properties().arguments, title: '${ _ko("Arguments for the script") }', placeholder: '${ _ko("e.g. MAX=10, PATH=$PATH:/user/path") }' } } --><!-- /ko -->
  1409. <!-- ko template: { if: typeof properties().env_var != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko("Environment") }', value: properties().env_var, title: '${ _ko("Environment variable for the script") }', placeholder: '${ _ko("e.g. CLASSPATH=/path/file.jar") }' } } --><!-- /ko -->
  1410. </div>
  1411. </div>
  1412. <!-- /ko -->
  1413. <!-- ko if: type() == 'mapreduce' -->
  1414. <div class="control-group">
  1415. <label class="control-label">${_('Jar path')}</label>
  1416. <div class="controls">
  1417. <input type="text" class="input-xxlarge filechooser-input" data-bind="value: properties().app_jar, valueUpdate: 'afterkeydown', filechooser: properties().app_jar, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true, selectFolder: false }" placeholder="${ _('Source path to the main MapReduce jar') }"/>
  1418. </div>
  1419. </div>
  1420. <div class="control-group">
  1421. <label class="control-label">${_('Properties')}</label>
  1422. <div class="controls">
  1423. <!-- ko template: { if: typeof properties().hadoopProperties != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko('Hadoop Properties') }', value: properties().hadoopProperties, title: '${ _ko('Name and values of Hadoop properties') }', placeholder: '${ _ko('e.g. mapred.job.queue.name=production, mapred.map.tasks.speculative.execution=false') }'}} --><!-- /ko -->
  1424. </div>
  1425. </div>
  1426. <!-- /ko -->
  1427. <!-- ko if: type() == 'jar' || type() == 'java' -->
  1428. <div class="control-group">
  1429. <label class="control-label">${_('Path')}</label>
  1430. <div class="controls">
  1431. <input type="text" class="input-xxlarge filechooser-input" data-bind="value: properties().app_jar, valueUpdate: 'afterkeydown', filechooser: properties().app_jar, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true, selectFolder: false }" placeholder="${ _('Path to application jar, e.g. hdfs://localhost:8020/user/hue/oozie-examples.jar') }"/>
  1432. </div>
  1433. </div>
  1434. <div class="control-group">
  1435. <label class="control-label">${_('Class')}</label>
  1436. <div class="controls">
  1437. <input type="text" class="input-xxlarge" data-bind="value: properties().class, valueUpdate: 'afterkeydown'" placeholder="${ _('Class name of application, e.g. org.apache.oozie.example.SparkFileCopy') }"/>
  1438. </div>
  1439. </div>
  1440. <div class="control-group">
  1441. <label class="control-label">${_('Variables')}</label>
  1442. <div class="controls">
  1443. <!-- ko template: { if: typeof properties().arguments != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko("Arguments") }', value: properties().arguments, title: '${ _ko("Arguments for the script") }', placeholder: '${ _ko("e.g. MAX=10, PATH=$PATH:/user/path") }' } } --><!-- /ko -->
  1444. </div>
  1445. </div>
  1446. <!-- /ko -->
  1447. <!-- ko if: type() == 'py'-->
  1448. <div class="control-group">
  1449. <label class="control-label">${_('Path')}</label>
  1450. <div class="controls">
  1451. <input type="text" class="input-xxlarge" data-bind="value: properties().py_file, valueUpdate: 'afterkeydown', filechooser: properties().py_file, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true, selectFolder: false }" placeholder="${ _('Path to python file, e.g. script.py') }"/>
  1452. </div>
  1453. </div>
  1454. <!-- /ko -->
  1455. <!-- ko if: type() == 'spark2' -->
  1456. <div class="control-group">
  1457. <!-- ko template: { if: typeof properties().jars != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko('Libs') }', value: properties().jars, title: '${ _ko('Path to jar or python files.') }', placeholder: '${ _ko('e.g. /user/hue/pi.py') }'}} --><!-- /ko -->
  1458. </div>
  1459. <!-- ko if: $.grep(properties().jars(), function(val, index) { return val.toLowerCase().endsWith('.jar'); }).length > 0 -->
  1460. <div class="control-group">
  1461. <label class="control-label">
  1462. ${_('Class')}
  1463. </label>
  1464. <div class="controls">
  1465. <input type="text" class="input-xxlarge" data-bind="value: properties().class, valueUpdate: 'afterkeydown'" placeholder="${ _('Class name of application, e.g. org.apache.oozie.example.SparkFileCopy') }"/>
  1466. </div>
  1467. </div>
  1468. <!-- /ko -->
  1469. <div class="control-group">
  1470. <!-- ko template: { if: typeof properties().spark_arguments != 'undefined', name: 'property', data: { type: 'csv-hdfs-files', label: '${ _ko('Arguments') }', value: properties().spark_arguments, title: '${ _ko('Arguments to the application.') }', placeholder: '${ _ko('e.g. 10, /user/hue/input') }'}} --><!-- /ko -->
  1471. </div>
  1472. <!-- /ko -->
  1473. </form>
  1474. </div>
  1475. </script>
  1476. <script type="text/html" id="snippet-execution-status${ suffix }">
  1477. <div class="snippet-execution-status" data-bind="clickForAceFocus: ace">
  1478. <a class="inactive-action pull-left snippet-logs-btn" href="javascript:void(0)" data-bind="visible: status() === 'running' && errors().length == 0, click: function() { hideFixedHeaders(); $data.showLogs(!$data.showLogs());}, css: {'blue': $data.showLogs}" title="${ _('Toggle Logs') }"><i class="fa fa-fw" data-bind="css: { 'fa-caret-right': !$data.showLogs(), 'fa-caret-down': $data.showLogs() }"></i></a>
  1479. <div class="snippet-progress-container" data-bind="visible: status() != 'canceled' && status() != 'with-optimizer-report'">
  1480. <div class="progress-snippet progress" data-bind="css: {
  1481. 'progress-starting': progress() == 0 && status() == 'running',
  1482. 'progress-warning': progress() > 0 && progress() < 100,
  1483. 'progress-success': progress() == 100,
  1484. 'progress-danger': progress() == 0 && errors().length > 0}" style="background-color: #FFF; width: 100%">
  1485. <div class="bar" data-bind="style: {'width': (errors().length > 0 ? 100 : Math.max(2,progress())) + '%'}"></div>
  1486. </div>
  1487. </div>
  1488. <div class="snippet-error-container alert alert-error" style="margin-bottom: 0" data-bind="visible: errors().length > 0">
  1489. <ul class="unstyled" data-bind="foreach: errors">
  1490. <li data-bind="text: message"></li>
  1491. </ul>
  1492. </div>
  1493. <div class="snippet-error-container alert alert-error" style="margin-bottom: 0" data-bind="visible: aceErrors().length > 0">
  1494. <ul class="unstyled" data-bind="foreach: aceErrors">
  1495. <li data-bind="text: message"></li>
  1496. </ul>
  1497. </div>
  1498. <div class="snippet-error-container alert" style="margin-bottom: 0" data-bind="visible: aceWarnings().length > 0">
  1499. <ul class="unstyled" data-bind="foreach: aceWarnings">
  1500. <li data-bind="text: message"></li>
  1501. </ul>
  1502. </div>
  1503. <div class="snippet-error-container alert alert-error" style="margin-bottom: 0" data-bind="visible: status() == 'canceled', click: function() { status('ready'); }" title="${ _('Click to hide') }">
  1504. <ul class="unstyled">
  1505. <li>${ _("The statement was canceled.") }</li>
  1506. </ul>
  1507. </div>
  1508. </div>
  1509. </script>
  1510. <script type="text/html" id="snippet-code-resizer${ suffix }">
  1511. <div class="snippet-code-resizer" data-bind="aceResizer : { ace: ace, target: '.ace-container-resizable', onStart: hideFixedHeaders, onStop: redrawFixedHeaders }">
  1512. <i class="fa fa-ellipsis-h"></i>
  1513. </div>
  1514. </script>
  1515. <script type="text/html" id="notebook-snippet-type-controls${ suffix }">
  1516. <div class="inactive-action dropdown hover-actions">
  1517. <a class="snippet-side-btn" style="padding-right: 0; padding-left: 2px;" data-toggle="dropdown" href="javascript: void(0);">
  1518. <span data-bind="template: { name: 'snippetIcon${ suffix }', data: $data }"></span>
  1519. </a>
  1520. <a class="inactive-action dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0);">
  1521. <i class="fa fa-caret-down"></i>
  1522. </a>
  1523. <ul class="dropdown-menu" data-bind="foreach: $root.availableSnippets">
  1524. <li><a class="pointer" data-bind="click: function(){ $parent.type($data.type()); }, text: name"></a></li>
  1525. </ul>
  1526. </div>
  1527. </script>
  1528. <script type ="text/html" id="snippet-execution-controls${ suffix }">
  1529. <div class="snippet-actions" style="position: absolute; bottom: 0">
  1530. <!-- ko if: status() == 'loading' -->
  1531. <a class="snippet-side-btn blue" style="cursor: default;" title="${ _('Creating session') }">
  1532. <i class="fa fa-fw fa-spinner fa-spin"></i>
  1533. </a>
  1534. <!-- /ko -->
  1535. <a class="snippet-side-btn" data-bind="click: reexecute, visible: $root.editorMode() && result.handle() && result.handle().has_more_statements, css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }" title="${ _('Restart from the first statement') }">
  1536. <i class="fa fa-fw fa-repeat snippet-side-single"></i>
  1537. </a>
  1538. <div class="label label-info" data-bind="attr: {'title':'${ _ko('Showing results of the statement #')}' + (result.statement_id() + 1)}, visible: $root.editorMode() && result.statements_count() > 1">
  1539. <div class="pull-left" data-bind="text: (result.statement_id() + 1)"></div><div class="pull-left">/</div><div class="pull-left" data-bind="text: result.statements_count()"></div>
  1540. </div>
  1541. <!-- ko if: !isCanceling() -->
  1542. <a class="snippet-side-btn red" data-bind="click: cancel, visible: status() == 'running'" title="${ _('Cancel operation') }">
  1543. <i class="fa fa-fw fa-stop snippet-side-single"></i>
  1544. </a>
  1545. <!-- /ko -->
  1546. <!-- ko if: isCanceling() -->
  1547. <a class="snippet-side-btn" style="cursor: default;" title="${ _('Canceling operation...') }">
  1548. <i class="fa fa-fw fa-spinner snippet-side-single fa-spin"></i>
  1549. </a>
  1550. <!-- /ko -->
  1551. <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }">
  1552. <!-- ko if: isBatchable() && wasBatchExecuted() -->
  1553. <a class="snippet-side-btn" style="padding-right:0; padding-left: 2px" href="javascript: void(0)" title="${ _('Submit all the queries as a background batch job.') }" data-bind="click: function() { wasBatchExecuted(true); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }">
  1554. <i class="fa fa-fw fa-send"></i>
  1555. </a>
  1556. <!-- /ko -->
  1557. <!-- ko if: ! isBatchable() || ! wasBatchExecuted() -->
  1558. <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="attr: {'title': $root.editorMode() && result.statements_count() > 1 ? '${ _ko('Execute next statement')}' : '${ _ko('Execute or CTRL + ENTER') }'}, click: function() { wasBatchExecuted(false); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }, style: {'padding-left': $parent.isBatchable() ? '2px' : '0' }">
  1559. <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : ! $parent.isBatchable() }"></i>
  1560. </a>
  1561. <!-- /ko -->
  1562. % if ENABLE_BATCH_EXECUTE.get():
  1563. <!-- ko if: isBatchable() && status() != 'running' && status() != 'loading' && ! $root.isPresentationMode() -->
  1564. <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'disabled': ! isReady(), 'blue': currentQueryTab() == 'queryExplain' }">
  1565. <i class="fa fa-caret-down"></i>
  1566. </a>
  1567. <ul class="dropdown-menu less-padding">
  1568. <li>
  1569. <a href="javascript:void(0)" data-bind="click: function() { wasBatchExecuted(false); $('.dropdown-toggle').dropdown('toggle'); execute(); }, style: { color: ! isReady() || status() === 'running' || status() === 'loading' ? '#999' : ''}, css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }" title="${ _('Execute interactively the current statement') }">
  1570. <i class="fa fa-fw fa-play"></i> ${_('Execute')}
  1571. </a>
  1572. </li>
  1573. <li>
  1574. <a href="javascript:void(0)" data-bind="click: function() { wasBatchExecuted(true); $('.dropdown-toggle').dropdown('toggle'); execute(); }, css: {'disabled': ! isReady() }" title="${ _('Submit all the queries as a background batch job.') }">
  1575. <i class="fa fa-fw fa-send"></i> ${_('Batch')}
  1576. </a>
  1577. </li>
  1578. </ul>
  1579. <!-- /ko -->
  1580. % endif
  1581. </div>
  1582. <!-- ko if: isSqlDialect && ! $root.isPresentationMode() -->
  1583. <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }">
  1584. <a class="snippet-side-btn" style="padding-right:0; padding-left: 2px;" href="javascript: void(0)" data-bind="click: explain, css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading', 'blue': currentQueryTab() == 'queryExplain' }" title="${ _('Explain the current SQL query') }">
  1585. <i class="fa fa-fw fa-map-o"></i>
  1586. </a>
  1587. <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'disabled': ! isReady(), 'blue': currentQueryTab() == 'queryExplain' }">
  1588. <i class="fa fa-caret-down"></i>
  1589. </a>
  1590. <ul class="dropdown-menu less-padding">
  1591. <li>
  1592. <a href="javascript:void(0)" data-bind="click: explain, style: { color: ! isReady() || status() === 'running' || status() === 'loading' ? '#999' : ''}, css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }" title="${ _('Explain the current SQL query') }">
  1593. <i class="fa fa-fw fa-map-o"></i> ${_('Explain')}
  1594. </a>
  1595. </li>
  1596. <!-- ko if: formatEnabled -->
  1597. <li>
  1598. <a href="javascript:void(0)" data-bind="click: format, css: {'disabled': ! isReady() }" title="${ _('Format the current SQL query') }">
  1599. <i class="fa fa-fw fa-indent"></i> ${_('Format')}
  1600. </a>
  1601. </li>
  1602. <!-- /ko -->
  1603. <li>
  1604. <a href="javascript:void(0)" data-bind="click: clear, css: {'disabled': ! isReady() }" title="${ _('Clear the current editor') }">
  1605. <i class="fa fa-fw fa-eraser"></i> ${_('Clear')}
  1606. </a>
  1607. </li>
  1608. <!-- ko if: HAS_OPTIMIZER -->
  1609. <li class="divider"></li>
  1610. <li>
  1611. <a href="javascript:void(0)" data-bind="click: function() { hasSuggestion(null); compatibilitySourcePlatform(type()); compatibilityTargetPlatform(type() == 'hive' ? 'impala' : 'hive'); queryCompatibility(); }, visible: type() == 'hive' || type() == 'impala'" title="${ _('Get hints on how to port SQL from other databases') }">
  1612. <i class="fa fa-fw fa-random"></i> ${_('Check compatibility')}
  1613. </a>
  1614. </li>
  1615. % if conf.DJANGO_DEBUG_MODE.get() and user.is_superuser:
  1616. <li>
  1617. <a href="javascript:void(0)" data-bind="click: function() { huePubSub.publish('editor.upload.history'); }" title="${ _('Load recent queries in order to improve recommendations') }">
  1618. <i class="fa fa-fw fa-cloud-upload"></i> ${_('Upload history')}
  1619. </a>
  1620. </li>
  1621. % endif
  1622. <!-- /ko -->
  1623. </ul>
  1624. </div>
  1625. <!-- /ko -->
  1626. </div>
  1627. </script>
  1628. <script type="text/html" id="snippet-result-controls${ suffix }">
  1629. <div class="snippet-actions" style="opacity:1">
  1630. <div style="margin-top:25px;">
  1631. <a class="snippet-side-btn" href="javascript: void(0)" data-bind="click: function() { $data.showGrid(true); huePubSub.publish('redraw.fixed.headers'); huePubSub.publish('table.extender.redraw'); }, css: {'active': $data.showGrid}" title="${ _('Grid') }">
  1632. <i class="fa fa-fw fa-th"></i>
  1633. </a>
  1634. </div>
  1635. <div class="dropdown">
  1636. <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="css: {'active': $data.showChart }, click: function() { $data.showChart(true); }" >
  1637. <i class="hcha fa-fw hcha-bar-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.BARCHART" title="${ _('Bars') }"></i>
  1638. <i class="hcha fa-fw hcha-line-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.LINECHART" title="${ _('Lines') }"></i>
  1639. <i class="hcha fa-fw hcha-timeline-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART" title="${ _('Time') }"></i>
  1640. <i class="hcha fa-fw hcha-pie-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" title="${ _('Pie') }"></i>
  1641. <i class="fa fa-fw fa-dot-circle-o" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART" title="${ _('Scatter') }"></i>
  1642. <i class="fa fa-fw fa-map-marker" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" title="${ _('Marker Map') }"></i>
  1643. <i class="hcha fa-fw hcha-map-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" title="${ _('Gradient Map') }"></i>
  1644. </a>
  1645. <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'active': $data.showChart}">
  1646. <i class="fa fa-caret-down"></i>
  1647. </a>
  1648. <ul class="dropdown-menu less-padding">
  1649. <li>
  1650. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.BARCHART}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.BARCHART); }">
  1651. <i class="hcha hcha-bar-chart"></i> ${_('Bars')}
  1652. </a>
  1653. </li>
  1654. <li>
  1655. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.LINECHART}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.LINECHART); }">
  1656. <i class="hcha hcha-line-chart"></i> ${_('Lines')}
  1657. </a>
  1658. </li>
  1659. <li data-bind="visible: result.cleanedDateTimeMeta().length > 0">
  1660. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.TIMELINECHART); }">
  1661. <i class="hcha hcha-timeline-chart"></i> ${_('Time')}
  1662. </a>
  1663. </li>
  1664. <li>
  1665. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.PIECHART}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.PIECHART); }">
  1666. <i class="hcha hcha-pie-chart"></i> ${_('Pie')}
  1667. </a>
  1668. </li>
  1669. <li>
  1670. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.SCATTERCHART); }">
  1671. <i class="fa fa-fw fa-dot-circle-o chart-icon"></i> ${_('Scatter')}
  1672. </a>
  1673. </li>
  1674. <li>
  1675. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.MAP}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.MAP); }">
  1676. <i class="fa fa-fw fa-map-marker chart-icon"></i> ${_('Marker Map')}
  1677. </a>
  1678. </li>
  1679. <li>
  1680. <a href="javascript:void(0)" data-bind="css: {'active': chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP}, click: function(){ $data.showChart(true); chartType(ko.HUE_CHARTS.TYPES.GRADIENTMAP); }">
  1681. <i class="hcha hcha-map-chart"></i> ${_('Gradient Map')}
  1682. </a>
  1683. </li>
  1684. </ul>
  1685. </div>
  1686. <div>
  1687. <a class="snippet-side-btn" href="javascript:void(0)" data-bind="click: function(){ huePubSub.publish('chart.hard.reset'); isResultSettingsVisible(! isResultSettingsVisible()) }, css: { 'blue' : isResultSettingsVisible }" title="${ _('Columns') }">
  1688. <!-- ko if: isResultSettingsVisible() -->
  1689. <i class="fa fa-fw fa-chevron-left"></i>
  1690. <!-- /ko -->
  1691. <!-- ko ifnot: isResultSettingsVisible() -->
  1692. <i class="fa fa-fw fa-columns"></i>
  1693. <!-- /ko -->
  1694. </a>
  1695. </div>
  1696. % if conf.ENABLE_DOWNLOAD.get():
  1697. <div data-bind="component: { name: 'downloadSnippetResults', params: { snippet: $data, notebook: $parent } }" style="display:inline-block;"></div>
  1698. % endif
  1699. </div>
  1700. </script>
  1701. <div class="ace-filechooser" style="display:none;">
  1702. <div class="ace-filechooser-close">
  1703. <a class="pointer" data-bind="click: function(){ $('.ace-filechooser').hide(); }"><i class="fa fa-times"></i></a>
  1704. </div>
  1705. <div class="ace-filechooser-content">
  1706. </div>
  1707. </div>
  1708. <div id="removeSnippetModal${ suffix }" class="modal hide fade">
  1709. <div class="modal-header">
  1710. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1711. <h2 class="modal-title">${_('Confirm Remove')}</h2>
  1712. </div>
  1713. <div class="modal-body">
  1714. <p>${_('Are you sure you want to remove this snippet?')}</p>
  1715. </div>
  1716. <div class="modal-footer" data-bind="with: $root.removeSnippetConfirmation">
  1717. <a class="btn" data-bind="click: function() { $root.removeSnippetConfirmation(null); $('#removeSnippetModal${ suffix }').modal('hide'); }">${_('No')}</a>
  1718. <input type="submit" value="${_('Yes')}" class="btn btn-danger" data-bind="click: function() { notebook.snippets.remove(snippet); redrawFixedHeaders(100); $root.removeSnippetConfirmation(null); $('#removeSnippetModal${ suffix }').modal('hide'); }" />
  1719. </div>
  1720. </div>
  1721. <div class="hoverMsg hide">
  1722. <!-- ko if: $root.editorMode() -->
  1723. <p class="hoverText">${_('Drop a SQL file here')}</p>
  1724. <!-- /ko -->
  1725. <!-- ko ifnot: $root.editorMode() -->
  1726. <p class="hoverText">${_('Drop iPython/Zeppelin notebooks here')}</p>
  1727. <!-- /ko -->
  1728. </div>
  1729. <div id="saveAsModal${ suffix }" class="modal hide fade">
  1730. <div class="modal-header">
  1731. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1732. <!-- ko if: $root.editorMode() -->
  1733. <h2 class="modal-title">${_('Save query as...')}</h2>
  1734. <!-- /ko -->
  1735. <!-- ko ifnot: $root.editorMode() -->
  1736. <h2 class="modal-title">${_('Save notebook as...')}</h2>
  1737. <!-- /ko -->
  1738. </div>
  1739. <!-- ko if: $root.selectedNotebook() -->
  1740. <div class="modal-body">
  1741. <form class="form-horizontal">
  1742. <div class="control-group">
  1743. <label class="control-label">${_('Name')}</label>
  1744. <div class="controls">
  1745. <input type="text" class="input-xlarge" data-bind="value: $root.selectedNotebook().name, valueUpdate:'afterkeydown'"/>
  1746. </div>
  1747. </div>
  1748. <div class="control-group">
  1749. <label class="control-label">${_('Description')}</label>
  1750. <div class="controls">
  1751. <input type="text" class="input-xlarge" data-bind="value: $root.selectedNotebook().description, valueUpdate:'afterkeydown'" placeholder="${ _('(optional)') }"/>
  1752. </div>
  1753. </div>
  1754. </form>
  1755. </div>
  1756. <div class="modal-footer">
  1757. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1758. <input type="button" class="btn btn-primary disable-feedback" value="${_('Save')}" data-dismiss="modal" data-bind="click: saveAsNotebook, enable: $root.selectedNotebook().name().length > 0"/>
  1759. </div>
  1760. <!-- /ko -->
  1761. </div>
  1762. <div id="saveToFileModal${ suffix }" class="modal hide fade">
  1763. <div class="modal-header">
  1764. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1765. <h2 class="modal-title">${_('Are you sure you want to save back to File?')}</h2>
  1766. </div>
  1767. <div class="modal-footer">
  1768. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1769. <input type="button" class="btn btn-primary disable-feedback" value="${_('Save')}" data-dismiss="modal" data-bind="click: function() { huePubSub.publish('save.snippet.to.file'); }"/>
  1770. </div>
  1771. </div>
  1772. <div id="authModal${ suffix }" class="modal hide fade">
  1773. <div class="modal-header">
  1774. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1775. <h2 class="modal-title">${_('Connect to the data source')}</h2>
  1776. </div>
  1777. <div class="modal-body">
  1778. <div class="row-fluid">
  1779. <div class="span6">
  1780. <div class="input-prepend">
  1781. <span class="add-on muted"><i class="fa fa-user"></i></span>
  1782. <input name="username" type="text" data-bind="value: $root.authSessionUsername" placeholder="${ _('Username') }"/>
  1783. </div>
  1784. </div>
  1785. <div class="span6">
  1786. <div class="input-prepend">
  1787. <span class="add-on muted"><i class="fa fa-lock"></i></span>
  1788. <input name="password" type="password" data-bind="value: $root.authSessionPassword" placeholder="${ _('Password') }"/>
  1789. </div>
  1790. </div>
  1791. </div>
  1792. </div>
  1793. <div class="modal-footer">
  1794. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1795. <a class="btn btn-primary disable-feedback" data-dismiss="modal" data-bind="click: function() { $root.selectedNotebook().authSession(); }">${_('Connect')}</a>
  1796. </div>
  1797. </div>
  1798. <div id="clearHistoryModal${ suffix }" class="modal hide fade">
  1799. <div class="modal-header">
  1800. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1801. <h2 class="modal-title">${_('Confirm History Clear')}</h2>
  1802. </div>
  1803. <div class="modal-body">
  1804. <p>${_('Are you sure you want to clear the query history?')}</p>
  1805. </div>
  1806. <div class="modal-footer">
  1807. <a class="btn" data-dismiss="modal">${_('No')}</a>
  1808. <a class="btn btn-danger disable-feedback" data-bind="click: function() { $root.selectedNotebook().clearHistory(); }">${_('Yes')}</a>
  1809. </div>
  1810. </div>
  1811. <!-- ko if: $root.selectedNotebook() -->
  1812. <!-- ko with: $root.selectedNotebook() -->
  1813. <div id="retryModal${ suffix }" class="modal hide fade" data-keyboard="false" data-backdrop="static">
  1814. <div class="modal-header">
  1815. <h2 class="modal-title">${_('Operation timed out')}</h2>
  1816. </div>
  1817. <div class="modal-body">
  1818. <p>${_('The operation timed out. Do you want to retry?')}</p>
  1819. </div>
  1820. <div class="modal-footer">
  1821. <a class="btn" data-bind="click: retryModalCancel">${_('No')}</a>
  1822. <a class="btn btn-primary disable-feedback" data-bind="click: retryModalConfirm">${_('Yes, retry')}</a>
  1823. </div>
  1824. </div>
  1825. <!-- /ko -->
  1826. <!-- /ko -->
  1827. <div class="submit-modal-editor modal hide"></div>
  1828. </%def>
  1829. <%def name="commonJS(is_embeddable=False, bindableElement='editorComponents', suffix='')">
  1830. <script type="text/javascript">
  1831. var HUE_PUB_SUB_EDITOR_ID = (window.location.pathname.indexOf('notebook') > -1) ? 'notebook' : 'editor';
  1832. % if is_embeddable:
  1833. var MAIN_SCROLLABLE = '.page-content';
  1834. % else:
  1835. var MAIN_SCROLLABLE = '.content-panel';
  1836. var shareViewModel = initSharing("#documentShareModal");
  1837. % endif
  1838. var isLeftNavOpen = false;
  1839. huePubSub.subscribe('left.nav.open.toggle', function (val) {
  1840. isLeftNavOpen = val;
  1841. }, HUE_PUB_SUB_EDITOR_ID);
  1842. huePubSub.subscribe('split.panel.resized', function (val) {
  1843. huePubSub.publish('recalculate.name.description.width');
  1844. }, HUE_PUB_SUB_EDITOR_ID);
  1845. var showHoverMsg = function (e) {
  1846. var dt = null;
  1847. if (e) {
  1848. dt = e.dataTransfer;
  1849. }
  1850. if (!isLeftNavOpen && (!dt || (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))))) {
  1851. $('#${ bindableElement }').find(".hoverMsg").removeClass("hide");
  1852. }
  1853. };
  1854. var hideHoverMsg = function (vm) {
  1855. if (vm.editorMode()){
  1856. $('#${ bindableElement }').find(".hoverText").html("${_('Drop a SQL file here')}");
  1857. } else {
  1858. $('#${ bindableElement }').find(".hoverText").html("${_('Drop iPython/Zeppelin notebooks here')}");
  1859. }
  1860. $('#${ bindableElement }').find(".hoverMsg").addClass("hide");
  1861. };
  1862. function renderMarkdown(text, snippetId) {
  1863. text = text.replace(/([^$]*)([$]+[^$]*[$]+)?/g, function (a, text, code) {
  1864. return markdown.toHTML(text).replace(/^<p>|<\/p>$/g, '') + (code ? code : '');
  1865. });
  1866. return text;
  1867. }
  1868. function prepareShareModal () {
  1869. var selectedNotebookUuid = this.selectedNotebook() && this.selectedNotebook().uuid();
  1870. shareViewModel.setDocUuid(this.selectedNotebook().uuid());
  1871. openShareModal();
  1872. };
  1873. function createHueDatatable(el, snippet, vm) {
  1874. var DATATABLES_MAX_HEIGHT = 330;
  1875. var _dt = $(el).hueDataTable({
  1876. i18n: {
  1877. NO_RESULTS: "${_('No results found.')}",
  1878. OF: "${_('of')}"
  1879. },
  1880. fnDrawCallback: function (oSettings) {
  1881. if (vm.editorMode()) {
  1882. $('#queryResults').removeAttr('style');
  1883. DATATABLES_MAX_HEIGHT = $(window).height() - $(el).parent().offset().top - 40;
  1884. $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
  1885. $(el).jHueHorizontalScrollbar();
  1886. $(el).parents('.dataTables_wrapper').jHueScrollLeft();
  1887. }
  1888. else {
  1889. if ($(el).data('fnDraws') === 1) {
  1890. $(el).parents(".dataTables_wrapper").jHueTableScroller({
  1891. maxHeight: DATATABLES_MAX_HEIGHT,
  1892. heightAfterCorrection: 0
  1893. });
  1894. }
  1895. }
  1896. },
  1897. scrollable: vm.editorMode() && !vm.isPresentationMode() ? MAIN_SCROLLABLE : '.dataTables_wrapper',
  1898. contained: !vm.editorMode() || vm.isPresentationMode()
  1899. });
  1900. window.setTimeout(function () {
  1901. if (vm.editorMode()) {
  1902. $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
  1903. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  1904. var bannerTopHeight = 30;
  1905. % else:
  1906. var bannerTopHeight = 0;
  1907. % endif
  1908. $(el).jHueTableExtender2({
  1909. mainScrollable: MAIN_SCROLLABLE,
  1910. fixedFirstColumn: vm.editorMode(),
  1911. % if is_embeddable:
  1912. stickToTopPosition: 48 + bannerTopHeight + ${ conf.CUSTOM.BANNER_TOP_HTML.get() and '0' or '2' },
  1913. % else:
  1914. stickToTopPosition: function() { return vm.isPresentationMode() || vm.isResultFullScreenMode() ? 1 + bannerTopHeight : 76 + bannerTopHeight },
  1915. % endif
  1916. parentId: 'snippet_' + snippet.id(),
  1917. clonedContainerPosition: 'fixed',
  1918. app: 'editor'
  1919. });
  1920. $(el).jHueHorizontalScrollbar();
  1921. } else {
  1922. $(el).jHueTableExtender2({
  1923. mainScrollable: $(el).parents('.dataTables_wrapper')[0],
  1924. fixedFirstColumn: vm.editorMode(),
  1925. parentId: 'snippet_' + snippet.id(),
  1926. clonedContainerPosition: 'absolute',
  1927. app: 'editor'
  1928. });
  1929. }
  1930. }, 0);
  1931. return _dt;
  1932. }
  1933. function createDatatable(el, snippet, vm) {
  1934. var parent = $(el).parent();
  1935. // When executing few columns -> many columns -> few columns we have to clear the style
  1936. $(el).removeAttr('style');
  1937. if ($(el).hasClass('table-huedatatable')) {
  1938. $(el).removeClass('table-huedatatable');
  1939. if (parent.hasClass('dataTables_wrapper')) {
  1940. $(el).unwrap();
  1941. }
  1942. }
  1943. $(el).addClass("dt");
  1944. var _dt = createHueDatatable(el, snippet, vm);
  1945. var dataTableEl = $(el).parents(".dataTables_wrapper");
  1946. if (!vm.editorMode()) {
  1947. dataTableEl.bind('mousewheel DOMMouseScroll wheel', function (e) {
  1948. if ($(el).closest(".results").css("overflow") == "hidden") {
  1949. return;
  1950. }
  1951. var _e = e.originalEvent,
  1952. _deltaX = _e.wheelDeltaX || -_e.deltaX,
  1953. _deltaY = _e.wheelDeltaY || -_e.deltaY;
  1954. this.scrollTop += -_deltaY / 2;
  1955. this.scrollLeft += -_deltaX / 2;
  1956. if (this.scrollTop == 0) {
  1957. $("body")[0].scrollTop += -_deltaY / 3;
  1958. $("html")[0].scrollTop += -_deltaY / 3; // for firefox
  1959. }
  1960. e.preventDefault();
  1961. });
  1962. }
  1963. var _scrollTimeout = -1;
  1964. var scrollElement = dataTableEl;
  1965. if (vm.editorMode()) {
  1966. scrollElement = $(MAIN_SCROLLABLE);
  1967. }
  1968. if (scrollElement.data('scrollFnDtCreation')) {
  1969. scrollElement.off('scroll', scrollElement.data('scrollFnDtCreation'));
  1970. }
  1971. var resultFollowTimeout = -1;
  1972. var dataScroll = function () {
  1973. if (vm.editorMode()) {
  1974. var snippetEl = $('#snippet_' + snippet.id());
  1975. if (snippetEl.find('.dataTables_wrapper').length > 0 && snippet.showGrid()) {
  1976. window.clearTimeout(resultFollowTimeout);
  1977. resultFollowTimeout = window.setTimeout(function () {
  1978. var topCoord = vm.isPresentationMode() || vm.isResultFullScreenMode() ? 50 : 73;
  1979. var offsetTop = 0;
  1980. if (snippetEl.find('.dataTables_wrapper').length > 0 && snippetEl.find('.dataTables_wrapper').offset()){
  1981. offsetTop = (snippetEl.find('.dataTables_wrapper').offset().top - topCoord) * -1;
  1982. }
  1983. var margin = Math.max(offsetTop, 0);
  1984. %if conf.CUSTOM.BANNER_TOP_HTML.get():
  1985. margin += 31;
  1986. %endif
  1987. if (snippet.isResultSettingsVisible()) {
  1988. snippetEl.find('.snippet-grid-settings').css({
  1989. "height": vm.isPresentationMode() || !vm.editorMode() ? '330px' : Math.max(100, Math.ceil($(window).height() - Math.max($('#queryResults').offset().top, topCoord)))+ 'px'
  1990. });
  1991. snippetEl.find('.result-settings').animate({
  1992. 'marginTop': margin
  1993. });
  1994. }
  1995. snippetEl.find('.snippet-actions').animate({
  1996. 'marginTop': margin + 25
  1997. });
  1998. }, 100);
  1999. }
  2000. }
  2001. if (!vm.editorMode() || (vm.editorMode() && snippet.currentQueryTab() === 'queryResults' && snippet.showGrid())) {
  2002. var _lastScrollPosition = scrollElement.data("scrollPosition") != null ? scrollElement.data("scrollPosition") : 0;
  2003. window.clearTimeout(_scrollTimeout);
  2004. scrollElement.data("scrollPosition", scrollElement.scrollTop());
  2005. _scrollTimeout = window.setTimeout(function () {
  2006. if (vm.editorMode()) {
  2007. _lastScrollPosition--; //hack for forcing fetching
  2008. }
  2009. if (_lastScrollPosition != scrollElement.scrollTop() && scrollElement.scrollTop() + scrollElement.outerHeight() + 20 >= scrollElement[0].scrollHeight && _dt && snippet.result.hasMore()) {
  2010. huePubSub.publish('editor.snippet.result.gray', snippet);
  2011. snippet.fetchResult(100, false);
  2012. }
  2013. }, 100);
  2014. }
  2015. };
  2016. scrollElement.data('scrollFnDtCreation', dataScroll);
  2017. scrollElement.on('scroll', dataScroll);
  2018. snippet.isResultSettingsVisible.subscribe(function (newValue) {
  2019. if (newValue) {
  2020. dataScroll();
  2021. }
  2022. });
  2023. huePubSub.subscribeOnce('chart.hard.reset', function(){
  2024. // hard reset once the default opened chart
  2025. var oldChartX = snippet.chartX();
  2026. snippet.chartX(null);
  2027. window.setTimeout(function(){
  2028. snippet.chartX(oldChartX);
  2029. }, 0)
  2030. });
  2031. return _dt;
  2032. }
  2033. function toggleAllColumns(linkElement, snippet) {
  2034. var $t = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  2035. var dt = $t.hueDataTable();
  2036. dt.fnToggleAllCols(linkElement.checked);
  2037. dt.fnDraw();
  2038. }
  2039. function toggleColumn(linkElement, index, snippet) {
  2040. var $t = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  2041. var dt = $t.hueDataTable();
  2042. dt.fnSetColumnVis(index, linkElement.checked);
  2043. }
  2044. function scrollToColumn(linkElement, index) {
  2045. var $resultTable = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  2046. var _text = $.trim($(linkElement).text());
  2047. var _col = $resultTable.find("th").filter(function () {
  2048. return $.trim($(this).text()) == _text;
  2049. });
  2050. $resultTable.find(".columnSelected").removeClass("columnSelected");
  2051. var _colSel = $resultTable.find("tr th:nth-child(" + (_col.index() + 1) + ")");
  2052. if (_colSel.length > 0) {
  2053. $resultTable.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
  2054. $resultTable.parent().animate({
  2055. scrollLeft: _colSel.position().left + $resultTable.parent().scrollLeft() - $resultTable.parent().offset().left - 30
  2056. }, 300, function(){
  2057. $resultTable.data('scrollToCol', _col.index());
  2058. $resultTable.data('scrollToRow', null);
  2059. $resultTable.data('scrollAnimate', true);
  2060. $resultTable.parent().trigger('scroll');
  2061. });
  2062. }
  2063. }
  2064. function isNotNullForCharts(val) {
  2065. return val !== 'NULL' && val !== null;
  2066. }
  2067. function pieChartDataTransformer(rawDatum) {
  2068. var _data = [];
  2069. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2070. var _idxValue = -1;
  2071. var _idxLabel = -1;
  2072. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2073. if (col.name == rawDatum.snippet.chartX()) {
  2074. _idxLabel = idx;
  2075. }
  2076. if (col.name == rawDatum.snippet.chartYSingle()) {
  2077. _idxValue = idx;
  2078. }
  2079. });
  2080. var colors = HueColors.cuiD3Scale();
  2081. $(rawDatum.counts()).each(function (cnt, item) {
  2082. if (isNotNullForCharts(item[_idxValue])) {
  2083. var val = item[_idxValue] * 1;
  2084. if (isNaN(val)) {
  2085. val = 0;
  2086. }
  2087. _data.push({
  2088. label: hueUtils.html2text(item[_idxLabel]),
  2089. value: val,
  2090. color: colors[cnt % colors.length],
  2091. obj: item
  2092. });
  2093. }
  2094. });
  2095. }
  2096. if (rawDatum.sorting == "asc") {
  2097. _data.sort(function (a, b) {
  2098. return a.value - b.value
  2099. });
  2100. }
  2101. if (rawDatum.sorting == "desc") {
  2102. _data.sort(function (a, b) {
  2103. return b.value - a.value
  2104. });
  2105. }
  2106. if (rawDatum.snippet.chartLimit()) {
  2107. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2108. }
  2109. return _data;
  2110. }
  2111. function mapChartDataTransformer(rawDatum) {
  2112. var _data = [];
  2113. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2114. var _idxRegion = -1;
  2115. var _idxValue = -1;
  2116. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2117. if (col.name == rawDatum.snippet.chartX()) {
  2118. _idxRegion = idx;
  2119. }
  2120. if (col.name == rawDatum.snippet.chartYSingle()) {
  2121. _idxValue = idx;
  2122. }
  2123. });
  2124. $(rawDatum.counts()).each(function (cnt, item) {
  2125. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxRegion])) {
  2126. _data.push({
  2127. label: item[_idxRegion],
  2128. value: item[_idxValue],
  2129. obj: item
  2130. });
  2131. }
  2132. });
  2133. }
  2134. if (rawDatum.snippet.chartLimit()) {
  2135. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2136. }
  2137. return _data;
  2138. }
  2139. // The leaflet map can freeze the browser with numbers outside the map
  2140. var MIN_LAT = -90;
  2141. var MAX_LAT = 90;
  2142. var MIN_LNG = -180;
  2143. var MAX_LNG = 180;
  2144. function leafletMapChartDataTransformer(rawDatum) {
  2145. var _data = [];
  2146. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2147. var _idxLat = -1;
  2148. var _idxLng = -1;
  2149. var _idxLabel = -1;
  2150. var _idxHeat = -1;
  2151. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2152. if (col.name == rawDatum.snippet.chartX()) {
  2153. _idxLat = idx;
  2154. }
  2155. if (col.name == rawDatum.snippet.chartYSingle()) {
  2156. _idxLng = idx;
  2157. }
  2158. if (col.name == rawDatum.snippet.chartMapLabel()) {
  2159. _idxLabel = idx;
  2160. }
  2161. if (col.name == rawDatum.snippet.chartMapHeat()) {
  2162. _idxHeat = idx;
  2163. }
  2164. });
  2165. if (rawDatum.snippet.chartMapLabel() != null) {
  2166. $(rawDatum.counts()).each(function (cnt, item) {
  2167. if (isNotNullForCharts(item[_idxLat]) && isNotNullForCharts(item[_idxLng])) {
  2168. _data.push({
  2169. lat: Math.min(Math.max(MIN_LAT, item[_idxLat]), MAX_LAT),
  2170. lng: Math.min(Math.max(MIN_LNG, item[_idxLng]), MAX_LNG),
  2171. label: hueUtils.html2text(item[_idxLabel]),
  2172. isHeat: rawDatum.snippet.chartMapType() === 'heat',
  2173. intensity: _idxHeat > -1 ? (item[_idxHeat]*1 != NaN ? item[_idxHeat]*1 : null) : null,
  2174. obj: item
  2175. });
  2176. }
  2177. });
  2178. } else {
  2179. $(rawDatum.counts()).each(function (cnt, item) {
  2180. if (isNotNullForCharts(item[_idxLat]) && isNotNullForCharts(item[_idxLng])) {
  2181. _data.push({
  2182. lat: Math.min(Math.max(MIN_LAT, item[_idxLat]), MAX_LAT),
  2183. lng: Math.min(Math.max(MIN_LNG, item[_idxLng]), MAX_LNG),
  2184. isHeat: rawDatum.snippet.chartMapType() === 'heat',
  2185. intensity: _idxHeat > -1 ? (item[_idxHeat]*1 != NaN ? item[_idxHeat]*1 : null) : null,
  2186. obj: item
  2187. });
  2188. }
  2189. });
  2190. }
  2191. }
  2192. if (rawDatum.snippet.chartLimit()) {
  2193. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2194. }
  2195. return _data;
  2196. }
  2197. function timelineChartDataTransformer(rawDatum) {
  2198. var _datum = [];
  2199. var _plottedSerie = 0;
  2200. rawDatum.snippet.result.meta().forEach(function (meta) {
  2201. if (rawDatum.snippet.chartYMulti().indexOf(meta.name) > -1) {
  2202. var col = meta.name;
  2203. var _idxValue = -1;
  2204. var _idxLabel = -1;
  2205. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2206. if (icol.name == rawDatum.snippet.chartX()) {
  2207. _idxLabel = idx;
  2208. }
  2209. if (icol.name == col) {
  2210. _idxValue = idx;
  2211. }
  2212. });
  2213. if (_idxValue > -1) {
  2214. var _data = [];
  2215. var colors = HueColors.cuiD3Scale();
  2216. $(rawDatum.counts()).each(function (cnt, item) {
  2217. if (isNotNullForCharts(item[_idxLabel]) && isNotNullForCharts(item[_idxValue])) {
  2218. _data.push({
  2219. series: _plottedSerie,
  2220. x: new Date(moment(hueUtils.html2text(item[_idxLabel])).valueOf()),
  2221. y: item[_idxValue] * 1,
  2222. color: colors[_plottedSerie % colors.length],
  2223. obj: item
  2224. });
  2225. }
  2226. });
  2227. if (rawDatum.sorting == "asc") {
  2228. _data.sort(function (a, b) {
  2229. return a.y - b.y
  2230. });
  2231. }
  2232. if (rawDatum.sorting == "desc") {
  2233. _data.sort(function (a, b) {
  2234. return b.y - a.y
  2235. });
  2236. }
  2237. if (rawDatum.snippet.chartLimit()) {
  2238. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2239. }
  2240. _datum.push({
  2241. key: col,
  2242. values: _data
  2243. });
  2244. _plottedSerie++;
  2245. }
  2246. }
  2247. });
  2248. return _datum;
  2249. }
  2250. function multiSerieDataTransformer(rawDatum) {
  2251. var _datum = [];
  2252. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYMulti().length > 0) {
  2253. var _plottedSerie = 0;
  2254. if (typeof rawDatum.snippet.chartXPivot() !== 'undefined') {
  2255. var _idxValue = -1;
  2256. var _idxLabel = -1;
  2257. var _isXDate = false;
  2258. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2259. if (icol.name == rawDatum.snippet.chartX()) {
  2260. _isXDate = icol.type.toUpperCase().indexOf('DATE') > -1;
  2261. _idxLabel = idx;
  2262. }
  2263. if (icol.name == rawDatum.snippet.chartYSingle()) {
  2264. _idxValue = idx;
  2265. }
  2266. });
  2267. rawDatum.snippet.result.meta().forEach(function (meta, cnt) {
  2268. if (rawDatum.snippet.chartXPivot() === meta.name) {
  2269. var _idxPivot = cnt;
  2270. var colors = HueColors.cuiD3Scale();
  2271. var pivotValues = $.map(rawDatum.counts(), function (p) {
  2272. return p[_idxPivot];
  2273. });
  2274. pivotValues = pivotValues.filter(function (item, pos) {
  2275. return pivotValues.indexOf(item) === pos;
  2276. });
  2277. pivotValues.forEach(function (val, pivotCnt) {
  2278. var _data = [];
  2279. $(rawDatum.counts()).each(function (cnt, item) {
  2280. if (item[_idxPivot] === val) {
  2281. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxLabel])) {
  2282. _data.push({
  2283. x: _isXDate ? moment(item[_idxLabel]) : hueUtils.html2text(item[_idxLabel]),
  2284. y: item[_idxValue] * 1,
  2285. color: colors[pivotCnt % colors.length],
  2286. obj: item
  2287. });
  2288. }
  2289. }
  2290. });
  2291. if (rawDatum.sorting == "asc") {
  2292. _data.sort(function (a, b) {
  2293. return a.y - b.y
  2294. });
  2295. }
  2296. if (rawDatum.sorting == "desc") {
  2297. _data.sort(function (a, b) {
  2298. return b.y - a.y
  2299. });
  2300. }
  2301. _datum.push({
  2302. key: hueUtils.html2text(val),
  2303. values: _data
  2304. });
  2305. });
  2306. }
  2307. });
  2308. // fills in missing values
  2309. var longestSerie = 0;
  2310. _datum.forEach(function (d) {
  2311. if (d.values.length > longestSerie) {
  2312. longestSerie = d.values.length;
  2313. }
  2314. });
  2315. _datum.forEach(function (d) {
  2316. if (d.values.length < longestSerie) {
  2317. var zeroObj = jQuery.extend({}, d.values[0]);
  2318. zeroObj.x = '';
  2319. zeroObj.y = 0;
  2320. for (var i = d.values.length; i < longestSerie; i++) {
  2321. d.values.push(zeroObj)
  2322. }
  2323. }
  2324. });
  2325. if (rawDatum.snippet.chartLimit()) {
  2326. _datum = _datum.slice(1, rawDatum.snippet.chartLimit() + 1);
  2327. }
  2328. }
  2329. else {
  2330. rawDatum.snippet.result.meta().forEach(function (meta) {
  2331. if (rawDatum.snippet.chartYMulti().indexOf(meta.name) > -1) {
  2332. var col = meta.name;
  2333. var _idxValue = -1;
  2334. var _idxLabel = -1;
  2335. var _isXDate = false;
  2336. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2337. if (icol.name == rawDatum.snippet.chartX()) {
  2338. _isXDate = icol.type.toUpperCase().indexOf('DATE') > -1;
  2339. _idxLabel = idx;
  2340. }
  2341. if (icol.name == col) {
  2342. _idxValue = idx;
  2343. }
  2344. });
  2345. if (_idxValue > -1) {
  2346. var _data = [];
  2347. var colors = HueColors.cuiD3Scale();
  2348. $(rawDatum.counts()).each(function (cnt, item) {
  2349. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxLabel])) {
  2350. _data.push({
  2351. series: _plottedSerie,
  2352. x: _isXDate ? moment(item[_idxLabel]) : hueUtils.html2text(item[_idxLabel]),
  2353. y: item[_idxValue] * 1,
  2354. color: colors[cnt % colors.length],
  2355. obj: item
  2356. });
  2357. }
  2358. });
  2359. if (rawDatum.sorting == "asc") {
  2360. _data.sort(function (a, b) {
  2361. return a.y - b.y
  2362. });
  2363. }
  2364. if (rawDatum.sorting == "desc") {
  2365. _data.sort(function (a, b) {
  2366. return b.y - a.y
  2367. });
  2368. }
  2369. if (rawDatum.snippet.chartLimit()) {
  2370. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2371. }
  2372. _datum.push({
  2373. key: col,
  2374. values: _data
  2375. });
  2376. _plottedSerie++;
  2377. }
  2378. }
  2379. });
  2380. }
  2381. }
  2382. return _datum;
  2383. }
  2384. function scatterChartDataTransformer(rawDatum) {
  2385. var _datum = [];
  2386. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2387. function addToDatum(col) {
  2388. var _idxX = -1;
  2389. var _idxY = -1;
  2390. var _idxSize = -1;
  2391. var _idxGroup = -1;
  2392. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2393. if (icol.name == rawDatum.snippet.chartX()) {
  2394. _idxX = idx;
  2395. }
  2396. if (icol.name == rawDatum.snippet.chartYSingle()) {
  2397. _idxY = idx;
  2398. }
  2399. if (icol.name == rawDatum.snippet.chartScatterSize()) {
  2400. _idxSize = idx;
  2401. }
  2402. if (icol.name == rawDatum.snippet.chartScatterGroup()) {
  2403. _idxGroup = idx;
  2404. }
  2405. });
  2406. if (_idxX > -1 && _idxY > -1) {
  2407. var _data = [];
  2408. $(rawDatum.counts()).each(function (cnt, item) {
  2409. if (_idxGroup == -1 || item[_idxGroup] == col) {
  2410. if (isNotNullForCharts(item[_idxX]) && isNotNullForCharts(item[_idxY])) {
  2411. _data.push({
  2412. x: item[_idxX],
  2413. y: item[_idxY],
  2414. shape: 'circle',
  2415. size: _idxSize > -1 ? item[_idxSize] : 100,
  2416. obj: item
  2417. });
  2418. }
  2419. }
  2420. });
  2421. if (rawDatum.snippet.chartLimit()) {
  2422. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2423. }
  2424. _datum.push({
  2425. key: col,
  2426. values: _data
  2427. });
  2428. }
  2429. }
  2430. if (rawDatum.snippet.chartScatterGroup() != null) {
  2431. var _idxGroup = -1;
  2432. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2433. if (icol.name == rawDatum.snippet.chartScatterGroup()) {
  2434. _idxGroup = idx;
  2435. }
  2436. });
  2437. if (_idxGroup > -1) {
  2438. $(rawDatum.counts()).each(function (cnt, item) {
  2439. addToDatum(hueUtils.html2text(item[_idxGroup]));
  2440. });
  2441. }
  2442. } else {
  2443. addToDatum('${ _('Distribution') }');
  2444. }
  2445. }
  2446. return _datum;
  2447. }
  2448. (function () {
  2449. ko.options.deferUpdates = true;
  2450. var VIEW_MODEL_OPTIONS = $.extend(${ options_json | n,unicode,antixss }, {
  2451. huePubSubId: HUE_PUB_SUB_EDITOR_ID,
  2452. user: '${ user.username }',
  2453. userId: ${ user.id },
  2454. suffix: '${ suffix }',
  2455. % if is_embeddable:
  2456. hue4: true,
  2457. % endif
  2458. assistAvailable: true,
  2459. % if conf.USE_NEW_AUTOCOMPLETER.get():
  2460. useNewAutocompleter: true,
  2461. % endif
  2462. autocompleteTimeout: AUTOCOMPLETE_TIMEOUT,
  2463. snippetViewSettings: {
  2464. default: {
  2465. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2466. aceMode: 'ace/mode/sql',
  2467. snippetIcon: 'fa-database',
  2468. sqlDialect: true
  2469. },
  2470. code: {
  2471. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2472. snippetIcon: 'fa-code'
  2473. },
  2474. hive: {
  2475. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2476. aceMode: 'ace/mode/hive',
  2477. snippetImage: '${ static("beeswax/art/icon_beeswax_48.png") }',
  2478. sqlDialect: true
  2479. },
  2480. impala: {
  2481. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2482. aceMode: 'ace/mode/impala',
  2483. snippetImage: '${ static("impala/art/icon_impala_48.png") }',
  2484. sqlDialect: true
  2485. },
  2486. jar : {
  2487. snippetIcon: 'fa-file-archive-o '
  2488. },
  2489. mysql: {
  2490. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2491. aceMode: 'ace/mode/mysql',
  2492. snippetIcon: 'fa-database',
  2493. sqlDialect: true
  2494. },
  2495. mysqljdbc: {
  2496. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2497. aceMode: 'ace/mode/mysql',
  2498. snippetIcon: 'fa-database',
  2499. sqlDialect: true
  2500. },
  2501. oracle: {
  2502. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2503. aceMode: 'ace/mode/oracle',
  2504. snippetIcon: 'fa-database',
  2505. sqlDialect: true
  2506. },
  2507. pig: {
  2508. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2509. aceMode: 'ace/mode/pig',
  2510. snippetImage: '${ static("pig/art/icon_pig_48.png") }'
  2511. },
  2512. postgresql: {
  2513. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2514. aceMode: 'ace/mode/pgsql',
  2515. snippetIcon: 'fa-database',
  2516. sqlDialect: true
  2517. },
  2518. solr: {
  2519. placeHolder: '${ _("Example: SELECT fieldA, FieldB FROM collectionname, or press CTRL + space") }',
  2520. aceMode: 'ace/mode/mysql',
  2521. snippetIcon: 'fa-database',
  2522. sqlDialect: true
  2523. },
  2524. java : {
  2525. snippetIcon: 'fa-file-code-o'
  2526. },
  2527. py : {
  2528. snippetIcon: 'fa-file-code-o'
  2529. },
  2530. pyspark: {
  2531. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2532. aceMode: 'ace/mode/python',
  2533. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2534. },
  2535. r: {
  2536. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2537. aceMode: 'ace/mode/r',
  2538. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2539. },
  2540. scala: {
  2541. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2542. aceMode: 'ace/mode/scala',
  2543. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2544. },
  2545. spark: {
  2546. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2547. aceMode: 'ace/mode/scala',
  2548. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2549. },
  2550. spark2: {
  2551. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2552. },
  2553. mapreduce: {
  2554. snippetIcon: 'fa-file-archive-o'
  2555. },
  2556. shell: {
  2557. snippetIcon: 'fa-terminal'
  2558. },
  2559. sqoop1: {
  2560. placeHolder: '${ _("Example: import --connect jdbc:hsqldb:file:db.hsqldb --table TT --target-dir hdfs://localhost:8020/user/foo -m 1") }',
  2561. snippetImage: '${ static("sqoop/art/icon_sqoop_48.png") }'
  2562. },
  2563. distcp: {
  2564. snippetIcon: 'fa-files-o'
  2565. },
  2566. sqlite: {
  2567. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2568. aceMode: 'ace/mode/sql',
  2569. snippetIcon: 'fa-database',
  2570. sqlDialect: true
  2571. },
  2572. text: {
  2573. placeHolder: '${ _('Type your text here') }',
  2574. aceMode: 'ace/mode/text',
  2575. snippetIcon: 'fa-header'
  2576. },
  2577. markdown: {
  2578. placeHolder: '${ _('Type your markdown here') }',
  2579. aceMode: 'ace/mode/markdown',
  2580. snippetIcon: 'fa-header'
  2581. }
  2582. }
  2583. });
  2584. var viewModel;
  2585. var importExternalNotebook = function (notebook) {
  2586. var currentNotebook = viewModel.selectedNotebook();
  2587. currentNotebook.name(notebook.name);
  2588. currentNotebook.description(notebook.description);
  2589. currentNotebook.selectedSnippet(notebook.selectedSnippet);
  2590. notebook.snippets.forEach(function(snippet){
  2591. var newSnippet = currentNotebook.addSnippet({
  2592. type: snippet.type,
  2593. result: {}
  2594. });
  2595. newSnippet.statement_raw(snippet.statement);
  2596. });
  2597. hideHoverMsg(viewModel);
  2598. };
  2599. window.importExternalNotebook = importExternalNotebook;
  2600. var hideFixedHeaders = function() {
  2601. $('.jHueTableExtenderClonedContainer').hide();
  2602. $('.jHueTableExtenderClonedContainerColumn').hide();
  2603. $('.jHueTableExtenderClonedContainerCell').hide();
  2604. $('.fixed-header-row').hide();
  2605. $('.fixed-first-cell').hide();
  2606. $('.fixed-first-column').hide();
  2607. };
  2608. window.hideFixedHeaders = hideFixedHeaders;
  2609. var redrawTimeout = -1;
  2610. var redrawFixedHeaders = function (timeout) {
  2611. var renderer = function() {
  2612. if (! viewModel.selectedNotebook()) {
  2613. return;
  2614. }
  2615. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  2616. if (snippet.result.meta().length > 0) {
  2617. var tableExtender = $("#snippet_" + snippet.id() + ' .resultTable').data('plugin_jHueTableExtender2');
  2618. if (typeof tableExtender !== 'undefined') {
  2619. tableExtender.repositionHeader();
  2620. tableExtender.drawLockedRows();
  2621. }
  2622. $(MAIN_SCROLLABLE).data('lastScroll', $(MAIN_SCROLLABLE).scrollTop());
  2623. $(MAIN_SCROLLABLE).trigger('scroll');
  2624. }
  2625. });
  2626. $(".jHueTableExtenderClonedContainer").show();
  2627. $(".jHueTableExtenderClonedContainerColumn").show();
  2628. $(".jHueTableExtenderClonedContainerCell").show();
  2629. $('.fixed-header-row').show();
  2630. $('.fixed-first-cell').show();
  2631. $('.fixed-first-column').show();
  2632. };
  2633. if (timeout){
  2634. window.clearTimeout(redrawTimeout);
  2635. redrawTimeout = window.setTimeout(renderer, timeout);
  2636. } else {
  2637. renderer();
  2638. }
  2639. %if not is_embeddable:
  2640. $(MAIN_SCROLLABLE).jHueScrollUp();
  2641. %endif
  2642. };
  2643. var splitDraggableTimeout = -1;
  2644. huePubSub.subscribe('split.draggable.position', function () {
  2645. window.clearTimeout(splitDraggableTimeout);
  2646. splitDraggableTimeout = window.setTimeout(function () {
  2647. redrawFixedHeaders(100);
  2648. }, 200);
  2649. }, HUE_PUB_SUB_EDITOR_ID);
  2650. huePubSub.subscribe('redraw.fixed.headers', function () {
  2651. hideFixedHeaders();
  2652. redrawFixedHeaders(200);
  2653. }, HUE_PUB_SUB_EDITOR_ID);
  2654. huePubSub.subscribe('app.gained.focus', function (app) {
  2655. if (app === 'editor') {
  2656. huePubSub.publish('redraw.fixed.headers');
  2657. huePubSub.publish('hue.scrollleft.show');
  2658. huePubSub.publish('active.snippet.type.changed', viewModel.editorType());
  2659. }
  2660. }, HUE_PUB_SUB_EDITOR_ID);
  2661. huePubSub.subscribe('show.saveToFile.modal', function () {
  2662. $('#saveToFileModal${ suffix }').modal('show');
  2663. }, HUE_PUB_SUB_EDITOR_ID);
  2664. huePubSub.subscribe('tab.switched', function (tab) {
  2665. if (tab !== 'queryResults') {
  2666. $('.hue-datatable-search').hide();
  2667. }
  2668. }, HUE_PUB_SUB_EDITOR_ID);
  2669. huePubSub.subscribe('detach.scrolls', function (snippet) {
  2670. var scrollElement = $('#snippet_' + snippet.id()).find('.dataTables_wrapper');
  2671. if (viewModel.editorMode()) {
  2672. scrollElement = $(MAIN_SCROLLABLE);
  2673. }
  2674. if (scrollElement.data('scrollFnDt')) {
  2675. scrollElement.off('scroll', scrollElement.data('scrollFnDt'));
  2676. }
  2677. }, HUE_PUB_SUB_EDITOR_ID);
  2678. window.redrawFixedHeaders = redrawFixedHeaders;
  2679. function addAce(content, snippetType) {
  2680. var snip = viewModel.selectedNotebook().addSnippet({type: snippetType, result: {}}, true);
  2681. snip.statement_raw(content);
  2682. aceChecks++;
  2683. snip.checkForAce = window.setInterval(function () {
  2684. if (snip.ace()) {
  2685. window.clearInterval(snip.checkForAce);
  2686. aceChecks--;
  2687. if (aceChecks == 0) {
  2688. hideHoverMsg(viewModel);
  2689. redrawFixedHeaders(200);
  2690. }
  2691. }
  2692. }, 100);
  2693. }
  2694. function replaceAce(content) {
  2695. var snip = viewModel.selectedNotebook().snippets()[0];
  2696. if (snip) {
  2697. snip.statement_raw(content);
  2698. snip.result.statements_count(1);
  2699. snip.ace().setValue(content, 1);
  2700. snip.result.statement_range({
  2701. start: {
  2702. row: 0,
  2703. column: 0
  2704. },
  2705. end: {
  2706. row: 0,
  2707. column: 0
  2708. }
  2709. });
  2710. snip.ace()._emit('focus');
  2711. }
  2712. hideHoverMsg(viewModel);
  2713. redrawFixedHeaders(200);
  2714. }
  2715. window.replaceAce = replaceAce;
  2716. function addMarkdown (content) {
  2717. var snip = viewModel.selectedNotebook().addSnippet({type: "markdown", result: {}}, true);
  2718. snip.statement_raw(content);
  2719. }
  2720. function addPySpark (content) {
  2721. addAce(content, "pyspark");
  2722. }
  2723. function addSql (content) {
  2724. addAce(content, "hive");
  2725. }
  2726. function addScala (content) {
  2727. addAce(content, "spark");
  2728. }
  2729. function parseExternalJSON(raw) {
  2730. try {
  2731. if (viewModel.editorMode()){
  2732. replaceAce(raw);
  2733. } else {
  2734. var loaded = typeof raw == "string" ? JSON.parse(raw) : raw;
  2735. if (loaded.nbformat) { //ipython
  2736. var cells = [];
  2737. if (loaded.nbformat == 3) {
  2738. cells = loaded.worksheets[0].cells;
  2739. } else if (loaded.nbformat == 4) {
  2740. cells = loaded.cells;
  2741. }
  2742. cells.forEach(function (cell, cellCnt) {
  2743. window.setTimeout(function () {
  2744. if (cell.cell_type == "code") {
  2745. if (loaded.nbformat == 3) {
  2746. addPySpark($.isArray(cell.input) ? cell.input.join("") : cell.input);
  2747. } else {
  2748. addPySpark($.isArray(cell.source) ? cell.source.join("") : cell.source);
  2749. }
  2750. }
  2751. if (cell.cell_type == "heading") {
  2752. var heading = $.isArray(cell.source) ? cell.source.join("") : cell.source;
  2753. if (cell.level == 1) {
  2754. heading += "\n====================";
  2755. } else if (cell.level == 2) {
  2756. heading += "\n--------------------";
  2757. } else {
  2758. heading = "### " + heading;
  2759. }
  2760. addMarkdown(heading);
  2761. }
  2762. if (cell.cell_type == "markdown") {
  2763. addMarkdown($.isArray(cell.source) ? cell.source.join("") : cell.source);
  2764. }
  2765. if (cellCnt == cells.length - 1 && aceChecks == 0) {
  2766. hideHoverMsg(viewModel);
  2767. }
  2768. }, 10);
  2769. });
  2770. }
  2771. if (loaded.paragraphs) { //zeppelin
  2772. if (loaded.name) {
  2773. viewModel.selectedNotebook().name(loaded.name);
  2774. }
  2775. loaded.paragraphs.forEach(function (paragraph) {
  2776. if (paragraph.text) {
  2777. var content = paragraph.text.split("\n");
  2778. if (content[0].indexOf("%md") > -1) {
  2779. content.shift();
  2780. addMarkdown(content.join("\n"));
  2781. } else if (content[0].indexOf("%sql") > -1 || content[0].indexOf("%hive") > -1) {
  2782. content.shift();
  2783. addSql(content.join("\n"));
  2784. } else if (content[0].indexOf("%pyspark") > -1) {
  2785. content.shift();
  2786. addPySpark(content.join("\n"));
  2787. } else {
  2788. if (content[0].indexOf("%spark") > -1) {
  2789. content.shift();
  2790. }
  2791. addScala(content.join("\n"));
  2792. }
  2793. }
  2794. });
  2795. }
  2796. }
  2797. }
  2798. catch (e) {
  2799. hideHoverMsg(viewModel);
  2800. replaceAce(raw);
  2801. }
  2802. }
  2803. window.parseExternalJSON = parseExternalJSON;
  2804. // Drag and drop iPython / Zeppelin notebooks
  2805. if (window.FileReader) {
  2806. var aceChecks = 0;
  2807. function handleFileSelect (evt) {
  2808. evt.stopPropagation();
  2809. evt.preventDefault();
  2810. var dt = evt.dataTransfer;
  2811. var files = dt.files;
  2812. if (files.length > 0){
  2813. showHoverMsg();
  2814. } else {
  2815. hideHoverMsg(viewModel);
  2816. }
  2817. for (var i = 0, f; f = files[i]; i++) {
  2818. var reader = new FileReader();
  2819. reader.onload = (function (file) {
  2820. return function (e) {
  2821. $(".hoverText").html("<i class='fa fa-spinner fa-spin'></i>");
  2822. parseExternalJSON(e.target.result);
  2823. };
  2824. })(f);
  2825. reader.readAsText(f);
  2826. }
  2827. }
  2828. function handleDragOver (evt) {
  2829. evt.stopPropagation();
  2830. evt.preventDefault();
  2831. evt.dataTransfer.dropEffect = "copy";
  2832. }
  2833. var dropZone = $('#${ bindableElement }')[0];
  2834. dropZone.addEventListener("dragenter", showHoverMsg, false);
  2835. dropZone.addEventListener("dragover", handleDragOver, false);
  2836. dropZone.addEventListener("drop", handleFileSelect, false);
  2837. var isDraggingOverText = false;
  2838. $('#${ bindableElement }').find(".hoverText").on("dragenter", function (e) {
  2839. e.preventDefault();
  2840. e.stopPropagation();
  2841. e.stopImmediatePropagation();
  2842. isDraggingOverText = true;
  2843. });
  2844. $('#${ bindableElement }').find(".hoverText").on("dragleave", function (e) {
  2845. e.preventDefault();
  2846. e.stopPropagation();
  2847. e.stopImmediatePropagation();
  2848. isDraggingOverText = false;
  2849. });
  2850. $('#${ bindableElement }').find(".hoverMsg").on("dragleave", function (e) {
  2851. if (!isDraggingOverText) {
  2852. hideHoverMsg(viewModel);
  2853. }
  2854. });
  2855. }
  2856. $(document).ready(function () {
  2857. % if ENABLE_QUERY_SCHEDULING.get():
  2858. viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS, CoordinatorEditorViewModel, RunningCoordinatorModel);
  2859. % else:
  2860. viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
  2861. % endif
  2862. ko.applyBindings(viewModel, $('#${ bindableElement }')[0]);
  2863. viewModel.init();
  2864. if (viewModel.isOptimizerEnabled()) {
  2865. huePubSub.subscribe('editor.upload.table.stats', function (options) {
  2866. viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
  2867. }, HUE_PUB_SUB_EDITOR_ID);
  2868. huePubSub.subscribe("editor.upload.history", function () {
  2869. viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
  2870. }, HUE_PUB_SUB_EDITOR_ID);
  2871. huePubSub.subscribe("editor.upload.query", function (query_id) {
  2872. viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
  2873. }, HUE_PUB_SUB_EDITOR_ID);
  2874. }
  2875. viewModel.selectedNotebook.subscribe(function (newVal) {
  2876. huePubSub.publish('selected.notebook.changed', newVal);
  2877. });
  2878. huePubSub.subscribe('get.selected.notebook', function () {
  2879. huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
  2880. }, HUE_PUB_SUB_EDITOR_ID);
  2881. huePubSub.subscribe('left.assist.show', function () {
  2882. if (!viewModel.isLeftPanelVisible() && viewModel.assistAvailable()) {
  2883. viewModel.isLeftPanelVisible(true);
  2884. }
  2885. }, HUE_PUB_SUB_EDITOR_ID);
  2886. var wasResultFullScreenMode = false;
  2887. var isAssistAvailable = viewModel.assistAvailable();
  2888. var wasLeftPanelVisible = viewModel.isLeftPanelVisible();
  2889. var wasRightPanelVisible = viewModel.isRightPanelVisible();
  2890. function exitPlayerMode() {
  2891. if (! wasResultFullScreenMode) {
  2892. viewModel.isPresentationMode(false);
  2893. } else {
  2894. viewModel.isResultFullScreenMode(false);
  2895. }
  2896. }
  2897. function togglePresentation(value) {
  2898. viewModel.isEditing(! viewModel.isEditing());
  2899. if (value) {
  2900. $(".jHueNotify").remove();
  2901. isAssistAvailable = viewModel.assistAvailable();
  2902. wasLeftPanelVisible = viewModel.isLeftPanelVisible();
  2903. wasRightPanelVisible = viewModel.isRightPanelVisible();
  2904. huePubSub.publish('side.panels.hide', true);
  2905. viewModel.assistWithoutStorage(true);
  2906. viewModel.assistAvailable(false);
  2907. viewModel.isLeftPanelVisible(false);
  2908. viewModel.isRightPanelVisible(false);
  2909. window.setTimeout(function(){
  2910. viewModel.assistWithoutStorage(false);
  2911. }, 0);
  2912. $(".navigator").hide();
  2913. $(".add-snippet").hide();
  2914. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  2915. $(".main-content").attr("style", "top: 31px!important");
  2916. % else:
  2917. $(".main-content").css("top", "1px");
  2918. % endif
  2919. redrawFixedHeaders(200);
  2920. $(window).bind("keydown", "esc", exitPlayerMode);
  2921. } else {
  2922. huePubSub.publish('side.panels.show', true);
  2923. viewModel.assistWithoutStorage(true);
  2924. viewModel.isLeftPanelVisible(wasLeftPanelVisible);
  2925. viewModel.isRightPanelVisible(wasRightPanelVisible);
  2926. viewModel.assistAvailable(isAssistAvailable);
  2927. window.setTimeout(function(){
  2928. viewModel.assistWithoutStorage(false);
  2929. }, 0);
  2930. $(".navigator").show();
  2931. $(".add-snippet").show();
  2932. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  2933. $(".main-content").css("top", "112px");
  2934. % else:
  2935. $(".main-content").css("top", "74px");
  2936. % endif
  2937. redrawFixedHeaders(200);
  2938. $(window).unbind("keydown", exitPlayerMode);
  2939. }
  2940. }
  2941. viewModel.isResultFullScreenMode.subscribe(function(newValue) {
  2942. wasResultFullScreenMode = true;
  2943. togglePresentation(newValue);
  2944. });
  2945. viewModel.isPresentationMode.subscribe(function(newValue) {
  2946. wasResultFullScreenMode = false;
  2947. if (! newValue) {
  2948. viewModel.selectedNotebook().cancelExecutingAll();
  2949. }
  2950. togglePresentation(newValue);
  2951. viewModel.togglePresentationMode();
  2952. if (newValue) {
  2953. hueAnalytics.convert('editor', 'presentation');
  2954. }
  2955. });
  2956. huePubSub.subscribe('assist.set.manual.visibility', function () {
  2957. wasLeftPanelVisible = viewModel.isLeftPanelVisible();
  2958. wasRightPanelVisible = viewModel.isRightPanelVisible();
  2959. }, HUE_PUB_SUB_EDITOR_ID);
  2960. viewModel.isLeftPanelVisible.subscribe(function (value) {
  2961. redrawFixedHeaders(200);
  2962. });
  2963. $(document).on("updateResultHeaders", function (e) {
  2964. hideFixedHeaders();
  2965. redrawFixedHeaders(200);
  2966. });
  2967. $(document).on("showAuthModal", function (e, data) {
  2968. viewModel.authSessionUsername('${ user.username }');
  2969. viewModel.authSessionPassword('');
  2970. viewModel.authSessionType(data['type']);
  2971. viewModel.authSessionCallback(data['callback']);
  2972. $("#authModal${ suffix }").modal("show");
  2973. });
  2974. $(document).on("hideHistoryModal", function (e) {
  2975. $("#clearHistoryModal${ suffix }").modal("hide");
  2976. });
  2977. huePubSub.subscribe('show.retry.modal', function (data) {
  2978. $('#retryModal${ suffix }').modal('show');
  2979. }, HUE_PUB_SUB_EDITOR_ID);
  2980. huePubSub.subscribe('hide.retry.modal', function (data) {
  2981. $('#retryModal${ suffix }').modal('hide');
  2982. }, HUE_PUB_SUB_EDITOR_ID);
  2983. // Close the notebook snippets when leaving the page
  2984. window.onbeforeunload = function (e) {
  2985. if (!viewModel.selectedNotebook().avoidClosing) {
  2986. viewModel.selectedNotebook().close();
  2987. }
  2988. };
  2989. $(window).data('beforeunload', window.onbeforeunload);
  2990. $(".preview-sample").css("right", (10 + hueUtils.scrollbarWidth()) + "px");
  2991. function saveKeyHandler() {
  2992. if (viewModel.canSave()) {
  2993. viewModel.saveNotebook();
  2994. }
  2995. else {
  2996. $('#saveAsModal${ suffix }').modal('show');
  2997. }
  2998. }
  2999. $(window).bind("keydown", "ctrl+s alt+s meta+s", function (e) {
  3000. e.preventDefault();
  3001. saveKeyHandler();
  3002. return false;
  3003. });
  3004. huePubSub.subscribe('editor.presentation.toggle', function () {
  3005. viewModel.isPresentationMode(!viewModel.isPresentationMode());
  3006. }, HUE_PUB_SUB_EDITOR_ID);
  3007. $(window).bind("keydown", "ctrl+shift+p alt+shift+p meta+shift+p", function (e) {
  3008. e.preventDefault();
  3009. huePubSub.publish('editor.presentation.toggle');
  3010. return false;
  3011. });
  3012. huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
  3013. $(document).bind('keyup', function (e) {
  3014. if (e.keyCode == 191 && e.shiftKey && !$(e.target).is('input') && !$(e.target).is('textarea')) {
  3015. $('#helpModal${ suffix }').modal('show');
  3016. }
  3017. if (e.keyCode == 191 && !e.shiftKey && !$(e.target).is('input') && !$(e.target).is('textarea')) {
  3018. if (viewModel.editorMode() && viewModel.selectedNotebook().snippets()[0].currentQueryTab() == 'queryResults') {
  3019. e.preventDefault();
  3020. var $t = $("#snippet_" + viewModel.selectedNotebook().snippets()[0].id()).find(".resultTable");
  3021. $t.hueDataTable().fnShowSearch();
  3022. return false;
  3023. }
  3024. }
  3025. });
  3026. function newKeyHandler() {
  3027. if (!viewModel.editorMode()) {
  3028. viewModel.selectedNotebook().newSnippet();
  3029. }
  3030. else {
  3031. viewModel.newNotebook(viewModel.editorType(), null, viewModel.selectedNotebook() ? viewModel.selectedNotebook().snippets()[0].currentQueryTab() : null);
  3032. }
  3033. }
  3034. $(window).bind("keydown", "ctrl+e alt+e meta+e", function (e) {
  3035. e.preventDefault();
  3036. newKeyHandler();
  3037. return false;
  3038. });
  3039. huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_EDITOR_ID);
  3040. var initialResizePosition = 100;
  3041. function getDraggableOptions (minY) {
  3042. return {
  3043. axis: "y",
  3044. start: function (e, ui) {
  3045. initialResizePosition = ui.offset.top;
  3046. },
  3047. drag: function (e, ui) {
  3048. draggableHelper($(this), e, ui);
  3049. $(".jHueTableExtenderClonedContainer").hide();
  3050. $(".jHueTableExtenderClonedContainerColumn").hide();
  3051. $(".jHueTableExtenderClonedContainerCell").hide();
  3052. $('.fixed-header-row').hide();
  3053. $('.fixed-first-cell').hide();
  3054. $('.fixed-first-column').hide();
  3055. },
  3056. stop: function (e, ui) {
  3057. $(".jHueTableExtenderClonedContainer").show();
  3058. $(".jHueTableExtenderClonedContainerColum").show();
  3059. $(".jHueTableExtenderClonedContainerCell").show();
  3060. $('.fixed-header-row').show();
  3061. $('.fixed-first-cell').show();
  3062. $('.fixed-first-column').show();
  3063. draggableHelper($(this), e, ui, true);
  3064. redrawFixedHeaders();
  3065. ui.helper.first().removeAttr("style");
  3066. },
  3067. containment: [0, minY, 4000, minY + 400]
  3068. }
  3069. }
  3070. $(".resize-panel a").each(function () {
  3071. $(this).draggable(getDraggableOptions($(this).parents(".snippet").offset().top + 128));
  3072. });
  3073. function draggableHelper (el, e, ui, setSize) {
  3074. var _snippet = ko.dataFor(el.parents(".snippet")[0]);
  3075. var _cm = $("#snippet_" + _snippet.id()).data("editor");
  3076. var _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
  3077. _cm.setSize("99%", _newSize);
  3078. if (setSize) {
  3079. _snippet.aceSize(_newSize);
  3080. }
  3081. }
  3082. function resetResultsResizer(snippet) {
  3083. $("#snippet_" + snippet.id()).find('.table-results .column-side').width(BOOTSTRAP_RATIOS.SPAN3() + '%').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
  3084. if (snippet.isResultSettingsVisible()){
  3085. $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN9()).width(BOOTSTRAP_RATIOS.SPAN9() + '%');
  3086. }
  3087. else {
  3088. $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', 100).width('100%');
  3089. }
  3090. $("#snippet_" + snippet.id()).find('.resize-bar').css('left', '');
  3091. try {
  3092. $("#snippet_" + snippet.id()).find('.resize-bar').draggable('destroy');
  3093. }
  3094. catch (e){}
  3095. var initialPosition = 0;
  3096. $("#snippet_" + snippet.id()).find('.resize-bar').draggable({
  3097. axis: "x",
  3098. containment: $("#snippet_" + snippet.id()).find('.table-results'),
  3099. create: function (event, ui) {
  3100. initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
  3101. $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
  3102. $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
  3103. },
  3104. drag: function (event, ui) {
  3105. if (initialPosition == 0){
  3106. initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
  3107. }
  3108. ui.position.left = Math.max(150, ui.position.left);
  3109. var newSpan3Width = ui.position.left * BOOTSTRAP_RATIOS.SPAN3() / initialPosition;
  3110. var newSpan9Width = 100 - newSpan3Width - BOOTSTRAP_RATIOS.MARGIN();
  3111. $("#snippet_" + snippet.id()).find('.table-results .column-side').width(newSpan3Width + '%').data('newWidth', newSpan3Width);
  3112. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width(newSpan9Width + '%').data('newWidth', newSpan9Width);
  3113. $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
  3114. },
  3115. stop: function () {
  3116. redrawFixedHeaders();
  3117. huePubSub.publish('resize.leaflet.map');
  3118. }
  3119. });
  3120. }
  3121. $(document).on("toggleResultSettings", function (e, snippet) {
  3122. window.setTimeout(function () {
  3123. $('#snippet_' + snippet.id()).find('.chart').trigger("forceUpdate");
  3124. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('update');
  3125. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3126. scrollInertia: 0
  3127. });
  3128. if (snippet.isResultSettingsVisible()){
  3129. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width((100 - $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth') - BOOTSTRAP_RATIOS.MARGIN()) + '%');
  3130. }
  3131. else {
  3132. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width('100%');
  3133. }
  3134. redrawFixedHeaders();
  3135. $(window).trigger('resize');
  3136. }, 10)
  3137. });
  3138. $(document).on("editorSizeChanged", function () {
  3139. window.setTimeout(forceChartDraws, 50);
  3140. });
  3141. $(document).on("redrawResults", function () {
  3142. window.setTimeout(forceChartDraws, 50);
  3143. });
  3144. $(document).on("executeStarted", function (e, options) {
  3145. var $el = $("#snippet_" + options.snippet.id()).find(".resultTable");
  3146. if (options.vm.editorMode()) {
  3147. $('#queryResults').css({
  3148. height: $el.height() + 'px'
  3149. });
  3150. }
  3151. $el.data('scrollToCol', null);
  3152. $el.data('scrollToRow', null);
  3153. $("#snippet_" + options.snippet.id()).find(".progress-snippet").animate({
  3154. height: "3px"
  3155. }, 100);
  3156. if ($el.hasClass("dt")) {
  3157. $el.removeClass("dt");
  3158. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainer").remove();
  3159. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerColumn").remove();
  3160. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerCell").remove();
  3161. if ($el.hueDataTable()) {
  3162. $el.hueDataTable().fnDestroy();
  3163. }
  3164. $el.find("thead tr").empty();
  3165. $el.data('lockedRows', {});
  3166. }
  3167. });
  3168. function resizeToggleResultSettings (snippet, initial) {
  3169. var _dtElement;
  3170. if (snippet.showGrid()) {
  3171. _dtElement = $("#snippet_" + snippet.id()).find(".dataTables_wrapper");
  3172. var topCoord = viewModel.isPresentationMode() || viewModel.isResultFullScreenMode() ? ${ conf.CUSTOM.BANNER_TOP_HTML.get() and '31' or '1' } : 73;
  3173. $("#snippet_" + snippet.id()).find(".snippet-grid-settings").css({
  3174. "height": viewModel.isPresentationMode() || !viewModel.editorMode() ? '330px' : Math.ceil($(window).height() - Math.max($('.result-settings').length > 0 ? $('.result-settings').offset().top : 0, topCoord)) + 'px'
  3175. });
  3176. } else {
  3177. _dtElement = $("#snippet_" + snippet.id()).find(".chart:visible");
  3178. }
  3179. if (_dtElement.length == 0) {
  3180. _dtElement = $("#snippet_" + snippet.id()).find(".table-results");
  3181. }
  3182. _dtElement.parents(".snippet-body").find(".toggle-result-settings").css({
  3183. "height": (_dtElement.height() - 30) + "px",
  3184. "line-height": (_dtElement.height() - 30) + "px"
  3185. });
  3186. if (initial) {
  3187. $('#snippet_' + snippet.id()).find('.result-settings').animate({
  3188. 'marginTop': 0
  3189. });
  3190. $('#snippet_' + snippet.id()).find('.snippet-actions').animate({
  3191. 'marginTop': 0
  3192. });
  3193. huePubSub.publish('resize.leaflet.map');
  3194. }
  3195. }
  3196. huePubSub.subscribe('editor.render.data', function (options) {
  3197. var _el = $("#snippet_" + options.snippet.id()).find(".resultTable");
  3198. if (options.data.length > 0) {
  3199. window.setTimeout(function () {
  3200. var _dt;
  3201. if (options.initial) {
  3202. options.snippet.result.meta.notifySubscribers();
  3203. $("#snippet_" + options.snippet.id()).find("select").trigger("chosen:updated");
  3204. _dt = createDatatable(_el, options.snippet, viewModel);
  3205. resetResultsResizer(options.snippet);
  3206. } else {
  3207. _dt = _el.hueDataTable();
  3208. }
  3209. try {
  3210. _dt.fnAddData(options.data);
  3211. } catch (e) {}
  3212. var _dtElement = $("#snippet_" + options.snippet.id()).find(".dataTables_wrapper");
  3213. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3214. _dtElement.scrollTop(_dtElement.data("scrollPosition"));
  3215. redrawFixedHeaders();
  3216. resizeToggleResultSettings(options.snippet, options.initial);
  3217. }, 300);
  3218. } else {
  3219. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3220. }
  3221. $("#snippet_" + options.snippet.id()).find("select").trigger('chosen:updated');
  3222. $('#snippet_' + options.snippet.id()).find('.snippet-grid-settings').mCustomScrollbar({axis: 'xy', theme: 'minimal-dark', scrollbarPosition: 'outside', mouseWheel:{ preventDefault: true, deltaFactor: 10 }, scrollInertia: 0});
  3223. window.setTimeout(function(){
  3224. $('#snippet_' + options.snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3225. scrollInertia: 0
  3226. });
  3227. }, 200)
  3228. }, HUE_PUB_SUB_EDITOR_ID);
  3229. huePubSub.subscribe('editor.redraw.data', function (options) {
  3230. hueUtils.waitForRendered("#snippet_" + options.snippet.id() + " .resultTable", function (el) {
  3231. return el.is(':visible')
  3232. }, function () {
  3233. var $el = $("#snippet_" + options.snippet.id()).find(".resultTable");
  3234. var dt = createDatatable($el, options.snippet, viewModel);
  3235. dt.fnAddData(options.snippet.result.data());
  3236. });
  3237. }, HUE_PUB_SUB_EDITOR_ID);
  3238. huePubSub.subscribe('editor.snippet.result.gray', function (snippet) {
  3239. var $snippet = $("#snippet_" + snippet.id());
  3240. $snippet.find(".dataTables_wrapper .fixed-first-column").css({opacity: '0'});
  3241. $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '0'});
  3242. $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '0'});
  3243. $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '0.55'});
  3244. }, HUE_PUB_SUB_EDITOR_ID);
  3245. huePubSub.subscribe('editor.snippet.result.normal', function (snippet) {
  3246. var $snippet = $("#snippet_" + snippet.id());
  3247. $snippet.find(".dataTables_wrapper .fixed-first-column").css({opacity: '1'});
  3248. $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '1'});
  3249. $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '1'});
  3250. $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '1'});
  3251. }, HUE_PUB_SUB_EDITOR_ID);
  3252. $(document).on("renderDataError", function (e, options) {
  3253. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3254. });
  3255. $(document).on("progress", function (e, options) {
  3256. if (options.data == 100) {
  3257. window.setTimeout(function () {
  3258. $("#snippet_" + options.snippet.id()).find(".progress-snippet").animate({
  3259. height: "0"
  3260. }, 100, function () {
  3261. options.snippet.progress(0);
  3262. redrawFixedHeaders();
  3263. });
  3264. }, 2000);
  3265. }
  3266. });
  3267. huePubSub.subscribe('render.jqcron', function(){
  3268. if (typeof renderJqCron !== 'undefined'){
  3269. renderJqCron();
  3270. }
  3271. }, HUE_PUB_SUB_EDITOR_ID);
  3272. huePubSub.subscribe('submit.popup.return', function (data) {
  3273. viewModel.selectedNotebook().viewSchedulerId(data.job_id);
  3274. $('.submit-modal-editor').modal('hide');
  3275. huePubSub.publish('show.jobs.panel', data.job_id);
  3276. }, HUE_PUB_SUB_EDITOR_ID);
  3277. huePubSub.subscribe('jobbrowser.data', function (jobs) {
  3278. if (jobs.length > 0) {
  3279. jobs.forEach(function (job) {
  3280. if ($("#" + job.shortId).length > 0) {
  3281. var _job = ko.dataFor($("#" + job.shortId)[0]);
  3282. if (!isNaN(parseInt(job.mapsPercentComplete))) {
  3283. _job.percentJob(parseInt(job.mapsPercentComplete));
  3284. }
  3285. }
  3286. });
  3287. } else {
  3288. if (viewModel.selectedNotebook()) {
  3289. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  3290. snippet.jobs().forEach(function (job) {
  3291. job.percentJob(100);
  3292. });
  3293. });
  3294. }
  3295. }
  3296. }, HUE_PUB_SUB_EDITOR_ID);
  3297. huePubSub.subscribe('editor.get.active.risks', function (callback) {
  3298. var result = {
  3299. editor: undefined,
  3300. risks : {}
  3301. };
  3302. if (viewModel.selectedNotebook()) {
  3303. if (viewModel.selectedNotebook().snippets().length === 1) {
  3304. result.editor = viewModel.selectedNotebook().snippets()[0].ace();
  3305. result.risks = viewModel.selectedNotebook().snippets()[0].complexity() || {};
  3306. } else {
  3307. var notFound = viewModel.selectedNotebook().snippets().every(function (snippet) {
  3308. if (snippet.inFocus()) {
  3309. result.editor = snippet.ace();
  3310. result.risks = snippet.complexity() || {};
  3311. return false;
  3312. }
  3313. return true;
  3314. });
  3315. }
  3316. }
  3317. callback(result);
  3318. }, HUE_PUB_SUB_EDITOR_ID);
  3319. huePubSub.subscribe('editor.grid.shown', function (snippet) {
  3320. hueUtils.waitForRendered('#snippet_' + snippet.id() + ' .dataTables_wrapper', function (el) {
  3321. return el.is(':visible')
  3322. }, function () {
  3323. resizeToggleResultSettings(snippet, true);
  3324. forceChartDraws();
  3325. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar({
  3326. axis: 'xy',
  3327. theme: 'minimal-dark',
  3328. scrollbarPosition: 'outside',
  3329. mouseWheel: {preventDefault: true, deltaFactor: 10},
  3330. scrollInertia: 0
  3331. });
  3332. window.setTimeout(function () {
  3333. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3334. scrollInertia: 0
  3335. });
  3336. }, 200)
  3337. });
  3338. }, HUE_PUB_SUB_EDITOR_ID);
  3339. huePubSub.subscribe('editor.chart.shown', function (snippet) {
  3340. hueUtils.waitForRendered('#snippet_' + snippet.id() + ' .chart:visible', function (el) {
  3341. return el.length > 0
  3342. }, function () {
  3343. resizeToggleResultSettings(snippet, true);
  3344. });
  3345. }, HUE_PUB_SUB_EDITOR_ID);
  3346. $(document).on("forceChartDraw", function (e, snippet) {
  3347. window.setTimeout(function () {
  3348. snippet.chartX.notifySubscribers();
  3349. snippet.chartX.valueHasMutated();
  3350. }, 100);
  3351. });
  3352. var hideTimeout = -1;
  3353. $(document).on("hideAutocomplete", function () {
  3354. window.clearTimeout(hideTimeout);
  3355. hideTimeout = window.setTimeout(function () {
  3356. var $aceAutocomplete = $(".ace_editor.ace_autocomplete");
  3357. if ($aceAutocomplete.is(":visible")) {
  3358. $aceAutocomplete.hide();
  3359. }
  3360. }, 100);
  3361. });
  3362. function forceChartDraws(initial) {
  3363. if (viewModel.selectedNotebook()) {
  3364. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  3365. if (snippet.result.data().length > 0) {
  3366. var _elCheckerInterval = -1;
  3367. var _el = $("#snippet_" + snippet.id());
  3368. _elCheckerInterval = window.setInterval(function () {
  3369. if (_el.find(".resultTable").length > 0) {
  3370. try {
  3371. resizeToggleResultSettings(snippet, initial);
  3372. resetResultsResizer(snippet);
  3373. $(document).trigger("forceChartDraw", snippet);
  3374. } catch (e) { }
  3375. window.clearInterval(_elCheckerInterval);
  3376. }
  3377. }, 200)
  3378. }
  3379. });
  3380. }
  3381. }
  3382. forceChartDraws(true);
  3383. huePubSub.subscribe('recalculate.name.description.width', function () {
  3384. hueUtils.waitForRendered('.editorComponents .hue-title-bar .query-name', function(el){ return el.is(':visible') }, function(){
  3385. var cumulativeWidth = 0;
  3386. $('.editorComponents .hue-title-bar ul li:not(.skip-width-calculation)').each(function(){
  3387. cumulativeWidth += $(this).outerWidth();
  3388. });
  3389. $('.notebook-name-desc').css('max-width', (($('.editorComponents .hue-title-bar').width() - cumulativeWidth - $('.editorComponents .hue-title-bar .pull-right').width() - 120)/2) + 'px');
  3390. });
  3391. }, HUE_PUB_SUB_EDITOR_ID);
  3392. var _resizeTimeout = -1;
  3393. $(window).on("resize", function () {
  3394. huePubSub.publish('recalculate.name.description.width');
  3395. window.clearTimeout(_resizeTimeout);
  3396. _resizeTimeout = window.setTimeout(function () {
  3397. forceChartDraws();
  3398. }, 200);
  3399. });
  3400. });
  3401. })();
  3402. </script>
  3403. </%def>