editor_components.mako 179 KB

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