editor_components.mako 176 KB

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