editor_components.mako 179 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589
  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)">
  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").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()">
  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').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').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)">
  334. <div id="helpModal" 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" 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" 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'}">
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. <script type="text/html" id="notebook">
  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',
  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', data: $root }"></div>
  491. </div>
  492. </div>
  493. </div>
  494. </div>
  495. </script>
  496. <script type="text/html" id="notebook-session-config-template">
  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">
  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">
  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().length == 0" class="logs logs-bigger">${ _('No logs available at this moment.') }</pre>
  564. <pre data-bind="visible: 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">
  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" 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' } --><!-- /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' } --><!-- /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">
  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">
  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">
  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' } --><!-- /ko -->
  789. <!-- ko template: { name: 'longer-operation' } --><!-- /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' } --><!-- /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">
  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' } --><!-- /ko -->
  801. <!-- ko template: { name: 'longer-operation' } --><!-- /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' } --><!-- /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"><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">
  814. % if ENABLE_EXTERNAL_STATEMENT.get():
  815. <!-- ko if: isSqlDialect() -->
  816. <div class="margin-left-10" data-bind="component: { name: 'hue-drop-down', params: { value: statementType, entries: statementTypes, linkTitle: '${ _ko('Statement type') }' } }" style="display: inline-block"></div>
  817. <!-- /ko -->
  818. % endif
  819. </script>
  820. <script type="text/html" id="snippet">
  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' } --><!-- /ko -->
  828. <!-- ko template: { if: ['text', 'markdown'].indexOf(type()) == -1, name: 'snippet-execution-controls' } --><!-- /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' } --><!-- /ko -->
  834. <!-- ko template: { if: ! $root.editorMode(), name: 'notebook-snippet-header' } --><!-- /ko -->
  835. </h2>
  836. <!-- ko template: { if: ['text', 'jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce', 'py', 'markdown'].indexOf(type()) == -1, name: 'code-editor-snippet-body' } --><!-- /ko -->
  837. <!-- ko template: { if: type() == 'text', name: 'text-snippet-body' } --><!-- /ko -->
  838. <!-- ko template: { if: type() == 'markdown', name: 'markdown-snippet-body' } --><!-- /ko -->
  839. <!-- ko template: { if: ['java', 'distcp', 'shell', 'mapreduce', 'jar', 'py', 'spark2'].indexOf(type()) != -1, name: 'executable-snippet-body' } --><!-- /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' --><!-- /ko -->
  843. </div>
  844. </div>
  845. <!-- ko template: { if: ['text', 'markdown'].indexOf(type()) == -1, name: 'snippet-execution-status' } --><!-- /ko -->
  846. <!-- ko template: { if: $root.editorMode() && ['jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce'].indexOf(type()) == -1, name: 'snippet-code-resizer' } --><!-- /ko -->
  847. <!-- ko if: $root.editorMode() -->
  848. <!-- ko template: 'snippet-log' --><!-- /ko -->
  849. <!-- ko template: 'query-tabs' --><!-- /ko -->
  850. <!-- /ko -->
  851. <!-- ko ifnot: $root.editorMode() -->
  852. <!-- ko template: 'snippet-log' --><!-- /ko -->
  853. <!-- ko template: { if: ['text', 'jar', 'java', 'distcp', 'shell', 'mapreduce', 'py', 'markdown'].indexOf(type()) == -1, name: 'snippet-results' } --><!-- /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">
  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">
  886. <!-- ko if: HAS_OPTIMIZER && (type() == 'impala' || type() == 'hive') -->
  887. <div 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. <!-- ko if: hasSuggestion() == 'error' -->
  985. <div class="round-icon idle" data-bind="click: function(){ showOptimizer(! showOptimizer()) }, attr: { 'title': showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
  986. <i class="fa"></i>
  987. </div>
  988. <!-- ko if: showOptimizer -->
  989. <span class="optimizer-explanation alert-neutral">${ _('Not validated.') }</span>
  990. <!-- /ko -->
  991. <!-- /ko -->
  992. </div>
  993. <!-- /ko -->
  994. <div class="row-fluid" style="margin-bottom: 5px">
  995. <div class="editor span12" data-bind="css: {'single-snippet-editor ace-container-resizable' : $root.editorMode() }, clickForAceFocus: ace">
  996. <!-- ko if: statementType() == 'file' -->
  997. <div class="margin-top-10">
  998. <label class="pull-left" style="margin-top: 6px;margin-right: 10px;">${_('Query File')}</label>
  999. <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') }"/>
  1000. <!-- ko if: statementPath() -->
  1001. <div class="inline-block" style="margin-top: 4px">
  1002. <a data-bind="hueLink: '/filebrowser/view=' + statementPath()" target="_blank" title="${ _('Open in new tab') }">
  1003. <i class="fa fa-external-link-square"></i>
  1004. </a>
  1005. </div>
  1006. <a class="btn" data-bind="click: function() { getExternalStatement(); }"><i class="fa fa-lg fa-refresh"></i></a>
  1007. <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>
  1008. <!-- /ko -->
  1009. </div>
  1010. <div class="clearfix margin-bottom-20"></div>
  1011. <!-- /ko -->
  1012. <!-- ko if: statementType() == 'document' -->
  1013. <div class="margin-top-10">
  1014. <!-- ko if: associatedDocumentLoading -->
  1015. <i class="fa fa-spinner fa-spin muted"></i>
  1016. <!-- /ko -->
  1017. <label class="pull-left" style="margin-top: 6px;margin-right: 10px;" data-bind="visible: !associatedDocumentLoading()">${_('Document')}</label>
  1018. <div class="selectize-wrapper" style="width: 300px;" data-bind="visible: !associatedDocumentLoading()">
  1019. <select placeholder="${ _('Search your documents...') }" data-bind="documentChooser: { loading: associatedDocumentLoading, value: associatedDocumentUuid, document: associatedDocument }"></select>
  1020. </div>
  1021. <!-- ko if: associatedDocument() -->
  1022. <div class="pull-left" style="margin-top: 4px">
  1023. <a data-bind="hueLink: href: associatedDocument().absoluteUrl" target="_blank" title="${ _('Open in new tab') }">
  1024. <i class="fa fa-external-link-square"></i>
  1025. </a>
  1026. <span data-bind='text: associatedDocument().description' style="padding: 3px; margin-top: 2px" class="muted"></span>
  1027. </div>
  1028. <!-- /ko -->
  1029. </div>
  1030. <div class="clearfix margin-bottom-20"></div>
  1031. <!-- /ko -->
  1032. <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: {
  1033. snippet: $data,
  1034. contextTooltip: '${ _ko("Right-click for details") }',
  1035. expandStar: '${ _ko("Right-click to expand with columns") }',
  1036. onBlur: saveTemporarySnippet,
  1037. highlightedRange: result.statement_range,
  1038. useNewAutocompleter: $root.useNewAutocompleter,
  1039. aceOptions: {
  1040. showLineNumbers: $root.editorMode(),
  1041. showGutter: $root.editorMode(),
  1042. maxLines: $root.editorMode() ? null : 25,
  1043. minLines: $root.editorMode() ? null : 3
  1044. }
  1045. }, style: {opacity: statementType() !== 'text' ? '0.75' : '1', 'top': $root.editorMode() && statementType() !== 'text' ? '60px' : '0'}"></div>
  1046. % if conf.USE_NEW_AUTOCOMPLETER.get():
  1047. <!-- ko component: { name: 'hueAceAutocompleter', params: { editor: ace, snippet: $data } } --><!-- /ko -->
  1048. % endif
  1049. <ul class="table-drop-menu hue-context-menu">
  1050. <li class="editor-drop-value"><a href="javascript:void(0);">"<span class="editor-drop-identifier"></span>"</a></li>
  1051. <li class="divider"></li>
  1052. <li class="editor-drop-select"><a href="javascript:void(0);">SELECT FROM <span class="editor-drop-identifier"></span>...</a></li>
  1053. <li class="editor-drop-insert"><a href="javascript:void(0);">INSERT INTO <span class="editor-drop-identifier"></span>...</a></li>
  1054. <li class="editor-drop-update"><a href="javascript:void(0);">UPDATE <span class="editor-drop-identifier"></span>...</a></li>
  1055. <li class="editor-drop-drop"><a href="javascript:void(0);">DROP TABLE <span class="editor-drop-identifier"></span>...</a></li>
  1056. </ul>
  1057. </div>
  1058. <div class="clearfix"></div>
  1059. <ul data-bind="foreach: variables" class="unstyled inline">
  1060. <li>
  1061. <div class="input-prepend margin-top-10">
  1062. <span class="muted add-on" data-bind="text: name"></span>
  1063. <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; } }">
  1064. </div>
  1065. </li>
  1066. </ul>
  1067. </div>
  1068. <div class="clearfix"></div>
  1069. </script>
  1070. <script type="text/html" id="snippet-chart-settings">
  1071. <div>
  1072. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART -->
  1073. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1074. <li class="nav-header">${_('type')}</li>
  1075. </ul>
  1076. <div data-bind="visible: chartType() != ''">
  1077. <select data-bind="selectedOptions: chartTimelineType, optionsCaption: '${_ko('Choose a type...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a type...") }', update: chartTimelineType, dropdownAutoWidth: true}">
  1078. <option value="bar">${ _("Bars") }</option>
  1079. <option value="line">${ _("Lines") }</option>
  1080. </select>
  1081. </div>
  1082. <!-- /ko -->
  1083. <!-- ko if: chartType() != '' && chartType() === ko.HUE_CHARTS.TYPES.PIECHART -->
  1084. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1085. <li class="nav-header">${_('value')}</li>
  1086. </ul>
  1087. <div>
  1088. <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>
  1089. </div>
  1090. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1091. <li class="nav-header">${_('legend')}</li>
  1092. </ul>
  1093. <div>
  1094. <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>
  1095. </div>
  1096. <!-- /ko -->
  1097. <!-- ko if: chartType() != '' && chartType() !== ko.HUE_CHARTS.TYPES.PIECHART -->
  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">${_('x-axis')}</li>
  1100. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('region')}</li>
  1101. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('latitude')}</li>
  1102. </ul>
  1103. <div>
  1104. <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>
  1105. </div>
  1106. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != ''">
  1107. <li data-bind="visible: [ko.HUE_CHARTS.TYPES.MAP, ko.HUE_CHARTS.TYPES.GRADIENTMAP].indexOf(chartType()) == -1" class="nav-header">${_('y-axis')}</li>
  1108. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" class="nav-header">${_('value')}</li>
  1109. <li data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" class="nav-header">${_('longitude')}</li>
  1110. </ul>
  1111. <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)">
  1112. <ul class="unstyled" data-bind="foreach: result.cleanedNumericMeta" style="margin-bottom: 0">
  1113. <li><label class="checkbox"><input type="checkbox" data-bind="checkedValue: name, checked: $parent.chartYMulti" /> <span data-bind="text: $data.name"></span></label></li>
  1114. </ul>
  1115. </div>
  1116. <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">
  1117. <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>
  1118. </div>
  1119. <!-- /ko -->
  1120. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() === ko.HUE_CHARTS.TYPES.BARCHART">
  1121. <li class="nav-header">${_('group')}</li>
  1122. </ul>
  1123. <div data-bind="visible: chartType() === ko.HUE_CHARTS.TYPES.BARCHART">
  1124. <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>
  1125. </div>
  1126. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1127. <li class="nav-header">${_('limit')}</li>
  1128. </ul>
  1129. <div>
  1130. <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>
  1131. </div>
  1132. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.MAP -->
  1133. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1134. <li class="nav-header">${_('type')}</li>
  1135. </ul>
  1136. <div data-bind="visible: chartType() != ''">
  1137. <select data-bind="selectedOptions: chartMapType, optionsCaption: '${_ko('Choose a type...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a type...") }', update: chartMapType, dropdownAutoWidth: true}">
  1138. <option value="marker">${ _("Markers") }</option>
  1139. <option value="heat">${ _("Heatmap") }</option>
  1140. </select>
  1141. </div>
  1142. <!-- ko if: chartMapType() == 'marker' -->
  1143. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1144. <li class="nav-header">${_('label')}</li>
  1145. </ul>
  1146. <div>
  1147. <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>
  1148. </div>
  1149. <!-- /ko -->
  1150. <!-- ko if: chartMapType() == 'heat' -->
  1151. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1152. <li class="nav-header">${_('intensity')}</li>
  1153. </ul>
  1154. <div>
  1155. <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>
  1156. </div>
  1157. <!-- /ko -->
  1158. <!-- /ko -->
  1159. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1160. <li class="nav-header">${_('scatter size')}</li>
  1161. </ul>
  1162. <div data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1163. <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>
  1164. </div>
  1165. <ul class="nav nav-list" style="border: none; background-color: #FFF" data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1166. <li class="nav-header">${_('scatter group')}</li>
  1167. </ul>
  1168. <div data-bind="visible: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART">
  1169. <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>
  1170. </div>
  1171. <!-- ko if: chartType() != '' && chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP -->
  1172. <ul class="nav nav-list" style="border: none; background-color: #FFF">
  1173. <li class="nav-header">${_('scope')}</li>
  1174. </ul>
  1175. <div data-bind="visible: chartType() != ''">
  1176. <select data-bind="selectedOptions: chartScope, optionsCaption: '${_ko('Choose a scope...')}', select2: { width: '100%', placeholder: '${ _ko("Choose a scope...") }', update: chartScope, dropdownAutoWidth: true}">
  1177. <option value="world">${ _("World") }</option>
  1178. <option value="europe">${ _("Europe") }</option>
  1179. <option value="aus">${ _("Australia") }</option>
  1180. <option value="bra">${ _("Brazil") }</option>
  1181. <option value="can">${ _("Canada") }</option>
  1182. <option value="chn">${ _("China") }</option>
  1183. <option value="fra">${ _("France") }</option>
  1184. <option value="deu">${ _("Germany") }</option>
  1185. <option value="ita">${ _("Italy") }</option>
  1186. <option value="jpn">${ _("Japan") }</option>
  1187. <option value="gbr">${ _("UK") }</option>
  1188. <option value="usa">${ _("USA") }</option>
  1189. </select>
  1190. </div>
  1191. <!-- /ko -->
  1192. <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">
  1193. <li class="nav-header">${_('sorting')}</li>
  1194. </ul>
  1195. <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">
  1196. <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>
  1197. <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>
  1198. <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>
  1199. </div>
  1200. </div>
  1201. </script>
  1202. <script type="text/html" id="snippet-grid-settings">
  1203. <div class="snippet-grid-settings" style="overflow: auto">
  1204. <table class="table table-condensed margin-top-10">
  1205. <thead>
  1206. <tr>
  1207. <th width="16">
  1208. <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" />
  1209. </th>
  1210. <th colspan="2" class="nav-header-like">
  1211. <span class="meta-title pointer" data-bind="click: function(){ result.isMetaFilterVisible(true); }, attr: {title: result.filteredMeta().length }">${_('columns')}</span>
  1212. (<span class="meta-title pointer" data-bind="click: function(){ result.isMetaFilterVisible(true); }, text: result.filteredMeta().length"></span>)
  1213. <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>
  1214. </th>
  1215. </tr>
  1216. <tr data-bind="visible: result.isMetaFilterVisible">
  1217. <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>
  1218. </tr>
  1219. </thead>
  1220. <tbody class="unstyled filtered-meta" data-bind="foreach: result.filteredMeta">
  1221. <tr data-bind="visible: name != ''">
  1222. <td><input class="no-margin-top" type="checkbox" data-bind="event: { change: function(){ toggleColumn($element, $data.originalIndex, $parent);} }, checked: $data.checked" /></td>
  1223. <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>
  1224. <td><span data-bind="text: $data.type" class="muted margin-left-20"></span></td>
  1225. </tr>
  1226. </tbody>
  1227. <tfoot>
  1228. <tr>
  1229. <td colspan="3">
  1230. <div class="margin-top-10 muted meta-noresults" data-bind="visible: result.filteredMeta().length === 0">
  1231. ${ _('No results found') }
  1232. </div>
  1233. </td>
  1234. </tr>
  1235. </tfoot>
  1236. </table>
  1237. </div>
  1238. </script>
  1239. <script type="text/html" id="snippet-explain">
  1240. <pre class="no-margin-bottom" data-bind="text: result.explanation"></pre>
  1241. </script>
  1242. <script type="text/html" id="snippet-results">
  1243. <div class="snippet-row" data-bind="slideVisible: result.hasSomeResults">
  1244. <div class="snippet-left-bar">
  1245. <!-- ko template: { if: result.type() == 'table' && result.hasSomeResults(), name: 'snippet-result-controls' }--><!-- /ko -->
  1246. </div>
  1247. <div class="result-body">
  1248. <div class="row-fluid" data-bind="visible: result.type() != 'table'" style="display:none; max-height: 400px; margin: 10px 0; overflow-y: auto">
  1249. <!-- ko if: result.data().length != 0 && result.data()[0][1] != "" -->
  1250. <pre data-bind="text: result.data()[0][1]" class="no-margin-bottom"></pre>
  1251. <!-- /ko -->
  1252. <!-- ko ifnot: result.data().length != 0 && result.data()[0][1] != "" -->
  1253. <pre class="no-margin-bottom"><i class="fa fa-check muted"></i> ${ _("Done.") }</pre>
  1254. <!-- /ko -->
  1255. <!-- ko if: result.images().length != 0 -->
  1256. <ul class="unstyled results-images" data-bind="foreach: result.images()">
  1257. <li>
  1258. <img data-bind="attr: {'src': 'data:image/png;base64,' + $data}" class="margin-bottom-10" alt="${ _('Result image') }"/>
  1259. </li>
  1260. </ul>
  1261. <!-- /ko -->
  1262. </div>
  1263. <div class="row-fluid table-results" data-bind="visible: result.type() == 'table'" style="display: none; max-height: 400px; min-height: 260px;">
  1264. <div>
  1265. <div class="column-side" data-bind="visible: isResultSettingsVisible, css:{'span3 result-settings': isResultSettingsVisible, 'hidden': ! isResultSettingsVisible()}" style="position:relative;white-space: nowrap;">
  1266. <!-- ko template: { name: 'snippet-grid-settings', if: showGrid } --><!-- /ko -->
  1267. <!-- ko template: { name: 'snippet-chart-settings', if: showChart } --><!-- /ko -->
  1268. <div class="resize-bar" style="top: 0; right: -10px; cursor: col-resize;"></div>
  1269. </div>
  1270. <div class="grid-side" data-bind="css: {'span9': isResultSettingsVisible, 'span12 nomargin': ! isResultSettingsVisible() }">
  1271. <div data-bind="visible: showGrid, delayedOverflow, css: resultsKlass" style="display: none;">
  1272. <table class="table table-condensed resultTable">
  1273. <thead>
  1274. <tr data-bind="foreach: result.meta">
  1275. <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>
  1276. </tr>
  1277. </thead>
  1278. <tbody>
  1279. </tbody>
  1280. </table>
  1281. <div data-bind="visible: status() == 'expired' && result.data() && result.data().length > 99, css: resultsKlass" style="display:none;">
  1282. <pre class="margin-top-10"><i class="fa fa-check muted"></i> ${ _("Results have expired, rerun the query if needed.") }</pre>
  1283. </div>
  1284. </div>
  1285. <div data-bind="visible: showChart" class="chart-container" style="display:none;">
  1286. <h1 class="empty" data-bind="visible: !hasDataForChart()">${ _('Select the chart parameters on the left') }</h1>
  1287. <div data-bind="visible: hasDataForChart">
  1288. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.PIECHART -->
  1289. <div data-bind="attr:{'id': 'pieChart_'+id()}, pieChart: {data: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()}, fqs: ko.observableArray([]),
  1290. transformer: pieChartDataTransformer, maxWidth: 350, parentSelector: '.chart-container' }, visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" class="chart"></div>
  1291. <!-- /ko -->
  1292. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.BARCHART -->
  1293. <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,
  1294. transformer: multiSerieDataTransformer, stacked: false, showLegend: true, isPivot: typeof chartXPivot() !== 'undefined'}, stacked: true, showLegend: true, visible: chartType() == ko.HUE_CHARTS.TYPES.BARCHART" class="chart"></div>
  1295. <!-- /ko -->
  1296. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.LINECHART -->
  1297. <div data-bind="attr:{'id': 'lineChart_'+id()}, lineChart: {datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()},
  1298. transformer: multiSerieDataTransformer, showControls: false, enableSelection: false }, visible: chartType() == ko.HUE_CHARTS.TYPES.LINECHART" class="chart"></div>
  1299. <!-- /ko -->
  1300. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART -->
  1301. <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,
  1302. transformer: timelineChartDataTransformer, stacked: false, showLegend: true}, hideSelection: true, visible: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART" class="chart"></div>
  1303. <!-- /ko -->
  1304. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.MAP -->
  1305. <div data-bind="attr:{'id': 'leafletMapChart_'+id()}, leafletMapChart: {datum: {counts: result.data, sorting: chartSorting(), snippet: $data, limit: chartLimit()},
  1306. transformer: leafletMapChartDataTransformer, showControls: false, height: 380, visible: chartType() == ko.HUE_CHARTS.TYPES.MAP, forceRedraw: true}" class="chart"></div>
  1307. <!-- /ko -->
  1308. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP -->
  1309. <div data-bind="attr:{'id': 'gradientMapChart_'+id()}, mapChart: {data: {counts: result.data, sorting: chartSorting(), snippet: $data, scope: chartScope(), limit: chartLimit()},
  1310. transformer: mapChartDataTransformer, isScale: true, showControls: false, height: 380, maxWidth: 750, parentSelector: '.chart-container', visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP}" class="chart"></div>
  1311. <!-- /ko -->
  1312. <!-- ko if: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART -->
  1313. <div data-bind="attr:{'id': 'scatterChart_'+id()}, scatterChart: {datum: {counts: result.data, snippet: $data, limit: chartLimit()},
  1314. transformer: scatterChartDataTransformer, maxWidth: 350, y: chartYSingle(), x: chartX(), size: chartScatterSize(), group: chartScatterGroup() }, visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART" class="chart"></div>
  1315. <!-- /ko -->
  1316. </div>
  1317. </div>
  1318. </div>
  1319. </div>
  1320. </div>
  1321. </div>
  1322. </div>
  1323. </script>
  1324. <script type="text/html" id="text-snippet-body">
  1325. <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>
  1326. </script>
  1327. <script type="text/html" id="markdown-snippet-body">
  1328. <!-- ko ifnot: $root.isPlayerMode() -->
  1329. <div class="row-fluid">
  1330. <div class="span6" data-bind="clickForAceFocus: ace">
  1331. <div class="ace-editor" data-bind="attr: { id: id() }, aceEditor: {
  1332. snippet: $data,
  1333. updateOnInput: true
  1334. }"></div>
  1335. </div>
  1336. <div class="span6">
  1337. <div data-bind="html: renderMarkdown(statement_raw(), id()), attr: {'id': 'liveMD'+id()}"></div>
  1338. </div>
  1339. </div>
  1340. <!-- /ko -->
  1341. <!-- ko if: $root.isPlayerMode() -->
  1342. <div data-bind="html: renderMarkdown(statement_raw(), id())"></div>
  1343. <!-- /ko -->
  1344. </script>
  1345. <script type="text/html" id="executable-snippet-body">
  1346. <div style="padding:10px;">
  1347. <form class="form-horizontal">
  1348. <!-- ko if: type() == 'distcp' -->
  1349. <div class="control-group">
  1350. <label class="control-label">${_('Source')}</label>
  1351. <div class="controls">
  1352. <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') }"/>
  1353. </div>
  1354. </div>
  1355. <div class="control-group">
  1356. <label class="control-label">${_('Destination')}</label>
  1357. <div class="controls">
  1358. <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') }"/>
  1359. </div>
  1360. </div>
  1361. <!-- /ko -->
  1362. <!-- ko if: type() == 'shell' -->
  1363. <div class="control-group">
  1364. <label class="control-label">${_('Script path')}</label>
  1365. <div class="controls">
  1366. <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') }"/>
  1367. </div>
  1368. </div>
  1369. <div class="control-group">
  1370. <label class="control-label">${_('Variables')}</label>
  1371. <div class="controls">
  1372. <!-- 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 -->
  1373. <!-- 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 -->
  1374. </div>
  1375. </div>
  1376. <!-- /ko -->
  1377. <!-- ko if: type() == 'mapreduce' -->
  1378. <div class="control-group">
  1379. <label class="control-label">${_('Jar path')}</label>
  1380. <div class="controls">
  1381. <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') }"/>
  1382. </div>
  1383. </div>
  1384. <div class="control-group">
  1385. <label class="control-label">${_('Properties')}</label>
  1386. <div class="controls">
  1387. <!-- 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 -->
  1388. </div>
  1389. </div>
  1390. <!-- /ko -->
  1391. <!-- ko if: type() == 'jar' || type() == 'java' -->
  1392. <div class="control-group">
  1393. <label class="control-label">${_('Path')}</label>
  1394. <div class="controls">
  1395. <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') }"/>
  1396. </div>
  1397. </div>
  1398. <div class="control-group">
  1399. <label class="control-label">${_('Class')}</label>
  1400. <div class="controls">
  1401. <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') }"/>
  1402. </div>
  1403. </div>
  1404. <div class="control-group">
  1405. <label class="control-label">${_('Variables')}</label>
  1406. <div class="controls">
  1407. <!-- 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 -->
  1408. </div>
  1409. </div>
  1410. <!-- /ko -->
  1411. <!-- ko if: type() == 'py'-->
  1412. <div class="control-group">
  1413. <label class="control-label">${_('Path')}</label>
  1414. <div class="controls">
  1415. <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') }"/>
  1416. </div>
  1417. </div>
  1418. <!-- /ko -->
  1419. <!-- ko if: type() == 'spark2' -->
  1420. <div class="control-group">
  1421. <!-- 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 -->
  1422. </div>
  1423. <!-- ko if: $.grep(properties().jars(), function(val, index) { return val.toLowerCase().endsWith('.jar'); }).length > 0 -->
  1424. <div class="control-group">
  1425. <label class="control-label">
  1426. ${_('Class')}
  1427. </label>
  1428. <div class="controls">
  1429. <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') }"/>
  1430. </div>
  1431. </div>
  1432. <!-- /ko -->
  1433. <div class="control-group">
  1434. <!-- 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 -->
  1435. </div>
  1436. <!-- /ko -->
  1437. </form>
  1438. </div>
  1439. </script>
  1440. <script type="text/html" id="snippet-execution-status">
  1441. <div class="snippet-execution-status" data-bind="clickForAceFocus: ace">
  1442. <div class="snippet-progress-container" data-bind="visible: status() != 'canceled' && status() != 'with-optimizer-report'">
  1443. <div class="progress-snippet progress" data-bind="css: {
  1444. 'progress-starting': progress() == 0 && status() == 'running',
  1445. 'progress-warning': progress() > 0 && progress() < 100,
  1446. 'progress-success': progress() == 100,
  1447. 'progress-danger': progress() == 0 && errors().length > 0}" style="background-color: #FFF; width: 100%">
  1448. <div class="bar" data-bind="style: {'width': (errors().length > 0 ? 100 : Math.max(2,progress())) + '%'}"></div>
  1449. </div>
  1450. </div>
  1451. <div class="snippet-error-container alert alert-error" style="margin-bottom: 0" data-bind="visible: errors().length > 0">
  1452. <ul class="unstyled" data-bind="foreach: errors">
  1453. <li data-bind="text: message"></li>
  1454. </ul>
  1455. </div>
  1456. <div class="snippet-error-container alert alert-error" style="margin-bottom: 0" data-bind="visible: aceErrors().length > 0">
  1457. <ul class="unstyled" data-bind="foreach: aceErrors">
  1458. <li data-bind="text: message"></li>
  1459. </ul>
  1460. </div>
  1461. <div class="snippet-error-container alert" style="margin-bottom: 0" data-bind="visible: aceWarnings().length > 0">
  1462. <ul class="unstyled" data-bind="foreach: aceWarnings">
  1463. <li data-bind="text: message"></li>
  1464. </ul>
  1465. </div>
  1466. <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') }">
  1467. <ul class="unstyled">
  1468. <li>${ _("The statement was canceled.") }</li>
  1469. </ul>
  1470. </div>
  1471. </div>
  1472. </script>
  1473. <script type="text/html" id="snippet-code-resizer">
  1474. <div class="snippet-code-resizer" data-bind="aceResizer : { ace: ace, target: '.ace-container-resizable', onStart: hideFixedHeaders, onStop: redrawFixedHeaders }">
  1475. <i class="fa fa-ellipsis-h"></i>
  1476. </div>
  1477. </script>
  1478. <script type="text/html" id="notebook-snippet-type-controls">
  1479. <div class="inactive-action dropdown hover-actions">
  1480. <a class="snippet-side-btn" style="padding-right: 0; padding-left: 2px;" data-toggle="dropdown" href="javascript: void(0);">
  1481. <span data-bind="template: { name: 'snippetIcon', data: $data }"></span>
  1482. </a>
  1483. <a class="inactive-action dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0);">
  1484. <i class="fa fa-caret-down"></i>
  1485. </a>
  1486. <ul class="dropdown-menu" data-bind="foreach: $root.availableSnippets">
  1487. <li><a class="pointer" data-bind="click: function(){ $parent.type($data.type()); }, text: name"></a></li>
  1488. </ul>
  1489. </div>
  1490. </script>
  1491. <script type ="text/html" id="snippet-execution-controls">
  1492. <div class="snippet-actions" style="position: absolute; bottom: 0">
  1493. <!-- ko if: status() == 'loading' -->
  1494. <a class="snippet-side-btn blue" style="cursor: default;" title="${ _('Creating session') }">
  1495. <i class="fa fa-fw fa-spinner fa-spin"></i>
  1496. </a>
  1497. <!-- /ko -->
  1498. <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') }">
  1499. <i class="fa fa-fw fa-repeat snippet-side-single"></i>
  1500. </a>
  1501. <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">
  1502. <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>
  1503. </div>
  1504. <!-- ko if: !isCanceling() -->
  1505. <a class="snippet-side-btn red" data-bind="click: cancel, visible: status() == 'running'" title="${ _('Cancel operation') }">
  1506. <i class="fa fa-fw fa-stop snippet-side-single"></i>
  1507. </a>
  1508. <!-- /ko -->
  1509. <!-- ko if: isCanceling() -->
  1510. <a class="snippet-side-btn" style="cursor: default;" title="${ _('Canceling operation...') }">
  1511. <i class="fa fa-fw fa-spinner snippet-side-single fa-spin"></i>
  1512. </a>
  1513. <!-- /ko -->
  1514. <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }">
  1515. <!-- ko if: isBatchable() && wasBatchExecuted() -->
  1516. <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() }">
  1517. <i class="fa fa-fw fa-send"></i>
  1518. </a>
  1519. <!-- /ko -->
  1520. <!-- ko if: ! isBatchable() || ! wasBatchExecuted() -->
  1521. <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' }">
  1522. <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : ! $parent.isBatchable() }"></i>
  1523. </a>
  1524. <!-- /ko -->
  1525. % if ENABLE_BATCH_EXECUTE.get():
  1526. <!-- ko if: isBatchable() && status() != 'running' && status() != 'loading' -->
  1527. <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' }">
  1528. <i class="fa fa-caret-down"></i>
  1529. </a>
  1530. <ul class="dropdown-menu less-padding">
  1531. <li>
  1532. <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') }">
  1533. <i class="fa fa-fw fa-play"></i> ${_('Execute')}
  1534. </a>
  1535. </li>
  1536. <li>
  1537. <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.') }">
  1538. <i class="fa fa-fw fa-send"></i> ${_('Batch')}
  1539. </a>
  1540. </li>
  1541. </ul>
  1542. <!-- /ko -->
  1543. % endif
  1544. </div>
  1545. <!-- ko if: isSqlDialect -->
  1546. <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': ! isReady() || status() === 'running' || status() === 'loading' }">
  1547. <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') }">
  1548. <i class="fa fa-fw fa-map-o"></i>
  1549. </a>
  1550. <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' }">
  1551. <i class="fa fa-caret-down"></i>
  1552. </a>
  1553. <ul class="dropdown-menu less-padding">
  1554. <li>
  1555. <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') }">
  1556. <i class="fa fa-fw fa-map-o"></i> ${_('Explain')}
  1557. </a>
  1558. </li>
  1559. <!-- ko if: formatEnabled -->
  1560. <li>
  1561. <a href="javascript:void(0)" data-bind="click: format, css: {'disabled': ! isReady() }" title="${ _('Format the current SQL query') }">
  1562. <i class="fa fa-fw fa-indent"></i> ${_('Format')}
  1563. </a>
  1564. </li>
  1565. <!-- /ko -->
  1566. <li>
  1567. <a href="javascript:void(0)" data-bind="click: clear, css: {'disabled': ! isReady() }" title="${ _('Clear the current editor') }">
  1568. <i class="fa fa-fw fa-eraser"></i> ${_('Clear')}
  1569. </a>
  1570. </li>
  1571. <!-- ko if: HAS_OPTIMIZER -->
  1572. <li class="divider"></li>
  1573. <li>
  1574. <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') }">
  1575. <i class="fa fa-fw fa-random"></i> ${_('Check compatibility')}
  1576. </a>
  1577. </li>
  1578. % if conf.DJANGO_DEBUG_MODE.get() and user.is_superuser:
  1579. <li>
  1580. <a href="javascript:void(0)" data-bind="click: function() { huePubSub.publish('editor.upload.history'); }" title="${ _('Load recent queries in order to improve recommendations') }">
  1581. <i class="fa fa-fw fa-cloud-upload"></i> ${_('Upload history')}
  1582. </a>
  1583. </li>
  1584. % endif
  1585. <!-- /ko -->
  1586. </ul>
  1587. </div>
  1588. <!-- /ko -->
  1589. </div>
  1590. </script>
  1591. <script type="text/html" id="snippet-result-controls">
  1592. <div class="snippet-actions" style="opacity:1">
  1593. <div style="margin-top:25px;">
  1594. <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') }">
  1595. <i class="fa fa-fw fa-th"></i>
  1596. </a>
  1597. </div>
  1598. <div class="dropdown">
  1599. <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="css: {'active': $data.showChart }, click: function() { $data.showChart(true); }" >
  1600. <i class="hcha fa-fw hcha-bar-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.BARCHART" title="${ _('Bars') }"></i>
  1601. <i class="hcha fa-fw hcha-line-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.LINECHART" title="${ _('Lines') }"></i>
  1602. <i class="hcha fa-fw hcha-timeline-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.TIMELINECHART" title="${ _('Time') }"></i>
  1603. <i class="hcha fa-fw hcha-pie-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.PIECHART" title="${ _('Pie') }"></i>
  1604. <i class="fa fa-fw fa-dot-circle-o" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.SCATTERCHART" title="${ _('Scatter') }"></i>
  1605. <i class="fa fa-fw fa-map-marker" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.MAP" title="${ _('Marker Map') }"></i>
  1606. <i class="hcha fa-fw hcha-map-chart" data-bind="visible: chartType() == ko.HUE_CHARTS.TYPES.GRADIENTMAP" title="${ _('Gradient Map') }"></i>
  1607. </a>
  1608. <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'active': $data.showChart}">
  1609. <i class="fa fa-caret-down"></i>
  1610. </a>
  1611. <ul class="dropdown-menu less-padding">
  1612. <li>
  1613. <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); }">
  1614. <i class="hcha hcha-bar-chart"></i> ${_('Bars')}
  1615. </a>
  1616. </li>
  1617. <li>
  1618. <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); }">
  1619. <i class="hcha hcha-line-chart"></i> ${_('Lines')}
  1620. </a>
  1621. </li>
  1622. <li data-bind="visible: result.cleanedDateTimeMeta().length > 0">
  1623. <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); }">
  1624. <i class="hcha hcha-timeline-chart"></i> ${_('Time')}
  1625. </a>
  1626. </li>
  1627. <li>
  1628. <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); }">
  1629. <i class="hcha hcha-pie-chart"></i> ${_('Pie')}
  1630. </a>
  1631. </li>
  1632. <li>
  1633. <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); }">
  1634. <i class="fa fa-fw fa-dot-circle-o chart-icon"></i> ${_('Scatter')}
  1635. </a>
  1636. </li>
  1637. <li>
  1638. <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); }">
  1639. <i class="fa fa-fw fa-map-marker chart-icon"></i> ${_('Marker Map')}
  1640. </a>
  1641. </li>
  1642. <li>
  1643. <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); }">
  1644. <i class="hcha hcha-map-chart"></i> ${_('Gradient Map')}
  1645. </a>
  1646. </li>
  1647. </ul>
  1648. </div>
  1649. <div>
  1650. <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') }">
  1651. <!-- ko if: isResultSettingsVisible() -->
  1652. <i class="fa fa-fw fa-chevron-left"></i>
  1653. <!-- /ko -->
  1654. <!-- ko ifnot: isResultSettingsVisible() -->
  1655. <i class="fa fa-fw fa-columns"></i>
  1656. <!-- /ko -->
  1657. </a>
  1658. </div>
  1659. <div data-bind="component: { name: 'downloadSnippetResults', params: { snippet: $data, notebook: $parent } }" style="display:inline-block;"></div>
  1660. </div>
  1661. </script>
  1662. <div class="ace-filechooser" style="display:none;">
  1663. <div class="ace-filechooser-close">
  1664. <a class="pointer" data-bind="click: function(){ $('.ace-filechooser').hide(); }"><i class="fa fa-times"></i></a>
  1665. </div>
  1666. <div class="ace-filechooser-content">
  1667. </div>
  1668. </div>
  1669. <div id="removeSnippetModal" class="modal hide fade">
  1670. <div class="modal-header">
  1671. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1672. <h2 class="modal-title">${_('Confirm Remove')}</h2>
  1673. </div>
  1674. <div class="modal-body">
  1675. <p>${_('Are you sure you want to remove this snippet?')}</p>
  1676. </div>
  1677. <div class="modal-footer" data-bind="with: $root.removeSnippetConfirmation">
  1678. <a class="btn" data-bind="click: function() { $root.removeSnippetConfirmation(null); $('#removeSnippetModal').modal('hide'); }">${_('No')}</a>
  1679. <input type="submit" value="${_('Yes')}" class="btn btn-danger" data-bind="click: function() { notebook.snippets.remove(snippet); redrawFixedHeaders(100); $root.removeSnippetConfirmation(null); $('#removeSnippetModal').modal('hide'); }" />
  1680. </div>
  1681. </div>
  1682. <div class="hoverMsg hide">
  1683. <!-- ko if: $root.editorMode() -->
  1684. <p class="hoverText">${_('Drop a SQL file here')}</p>
  1685. <!-- /ko -->
  1686. <!-- ko ifnot: $root.editorMode() -->
  1687. <p class="hoverText">${_('Drop iPython/Zeppelin notebooks here')}</p>
  1688. <!-- /ko -->
  1689. </div>
  1690. <div id="saveAsModal" class="modal hide fade">
  1691. <div class="modal-header">
  1692. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1693. <!-- ko if: $root.editorMode() -->
  1694. <h2 class="modal-title">${_('Save query as...')}</h2>
  1695. <!-- /ko -->
  1696. <!-- ko ifnot: $root.editorMode() -->
  1697. <h2 class="modal-title">${_('Save notebook as...')}</h2>
  1698. <!-- /ko -->
  1699. </div>
  1700. <!-- ko if: $root.selectedNotebook() -->
  1701. <div class="modal-body">
  1702. <form class="form-horizontal">
  1703. <div class="control-group">
  1704. <label class="control-label">${_('Name')}</label>
  1705. <div class="controls">
  1706. <input type="text" class="input-xlarge" data-bind="value: $root.selectedNotebook().name, valueUpdate:'afterkeydown'"/>
  1707. </div>
  1708. </div>
  1709. <div class="control-group">
  1710. <label class="control-label">${_('Description')}</label>
  1711. <div class="controls">
  1712. <input type="text" class="input-xlarge" data-bind="value: $root.selectedNotebook().description, valueUpdate:'afterkeydown'" placeholder="${ _('(optional)') }"/>
  1713. </div>
  1714. </div>
  1715. </form>
  1716. </div>
  1717. <div class="modal-footer">
  1718. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1719. <input type="button" class="btn btn-primary disable-feedback" value="${_('Save')}" data-dismiss="modal" data-bind="click: saveAsNotebook, enable: $root.selectedNotebook().name().length > 0"/>
  1720. </div>
  1721. <!-- /ko -->
  1722. </div>
  1723. <div id="saveToFileModal" class="modal hide fade">
  1724. <div class="modal-header">
  1725. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1726. <h2 class="modal-title">${_('Are you sure you want to save back to File?')}</h2>
  1727. </div>
  1728. <div class="modal-footer">
  1729. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1730. <input type="button" class="btn btn-primary disable-feedback" value="${_('Save')}" data-dismiss="modal" data-bind="click: function() { huePubSub.publish('save.snippet.to.file'); }"/>
  1731. </div>
  1732. </div>
  1733. <div id="authModal" class="modal hide fade">
  1734. <div class="modal-header">
  1735. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1736. <h2 class="modal-title">${_('Connect to the data source')}</h2>
  1737. </div>
  1738. <div class="modal-body">
  1739. <div class="row-fluid">
  1740. <div class="span6">
  1741. <div class="input-prepend">
  1742. <span class="add-on muted"><i class="fa fa-user"></i></span>
  1743. <input name="username" type="text" data-bind="value: $root.authSessionUsername" placeholder="${ _('Username') }"/>
  1744. </div>
  1745. </div>
  1746. <div class="span6">
  1747. <div class="input-prepend">
  1748. <span class="add-on muted"><i class="fa fa-lock"></i></span>
  1749. <input name="password" type="password" data-bind="value: $root.authSessionPassword" placeholder="${ _('Password') }"/>
  1750. </div>
  1751. </div>
  1752. </div>
  1753. </div>
  1754. <div class="modal-footer">
  1755. <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
  1756. <a class="btn btn-primary disable-feedback" data-dismiss="modal" data-bind="click: function() { $root.selectedNotebook().authSession(); }">${_('Connect')}</a>
  1757. </div>
  1758. </div>
  1759. <div id="clearHistoryModal" class="modal hide fade">
  1760. <div class="modal-header">
  1761. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1762. <h2 class="modal-title">${_('Confirm History Clear')}</h2>
  1763. </div>
  1764. <div class="modal-body">
  1765. <p>${_('Are you sure you want to clear the query history?')}</p>
  1766. </div>
  1767. <div class="modal-footer">
  1768. <a class="btn" data-dismiss="modal">${_('No')}</a>
  1769. <a class="btn btn-danger disable-feedback" data-bind="click: function() { $root.selectedNotebook().clearHistory(); }">${_('Yes')}</a>
  1770. </div>
  1771. </div>
  1772. <!-- ko if: $root.selectedNotebook() -->
  1773. <!-- ko with: $root.selectedNotebook() -->
  1774. <div id="retryModal" class="modal hide fade" data-keyboard="false" data-backdrop="static">
  1775. <div class="modal-header">
  1776. <h2 class="modal-title">${_('Operation timed out')}</h2>
  1777. </div>
  1778. <div class="modal-body">
  1779. <p>${_('The operation timed out. Do you want to retry?')}</p>
  1780. </div>
  1781. <div class="modal-footer">
  1782. <a class="btn" data-bind="click: retryModalCancel">${_('No')}</a>
  1783. <a class="btn btn-primary disable-feedback" data-bind="click: retryModalConfirm">${_('Yes, retry')}</a>
  1784. </div>
  1785. </div>
  1786. <!-- /ko -->
  1787. <!-- /ko -->
  1788. <div class="submit-modal modal hide"></div>
  1789. </%def>
  1790. <%def name="commonJS(is_embeddable=False, bindableElement='editorComponents')">
  1791. <script type="text/javascript">
  1792. % if is_embeddable:
  1793. var MAIN_SCROLLABLE = '.page-content';
  1794. var HUE_PUB_SUB_AFFIX = (window.location.getParameter('type') ? '-' + window.location.getParameter('type') : '');
  1795. % else:
  1796. var MAIN_SCROLLABLE = '.content-panel';
  1797. var HUE_PUB_SUB_AFFIX = '';
  1798. % endif
  1799. var HUE_PUB_SUB_APP = 'editor' + HUE_PUB_SUB_AFFIX;
  1800. var isLeftNavOpen = false;
  1801. huePubSub.subscribe('left.nav.open.toggle', function(val) {
  1802. isLeftNavOpen = val;
  1803. }, HUE_PUB_SUB_APP);
  1804. var showHoverMsg = function (e) {
  1805. var dt = null;
  1806. if (e) {
  1807. dt = e.dataTransfer;
  1808. }
  1809. if (!isLeftNavOpen && (!dt || (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))))) {
  1810. $(".hoverMsg").removeClass("hide");
  1811. }
  1812. };
  1813. var hideHoverMsg = function (vm) {
  1814. if (vm.editorMode()){
  1815. $(".hoverText").html("${_('Drop a SQL file here')}");
  1816. } else {
  1817. $(".hoverText").html("${_('Drop iPython/Zeppelin notebooks here')}");
  1818. }
  1819. $(".hoverMsg").addClass("hide");
  1820. };
  1821. function renderMarkdown(text, snippetId) {
  1822. text = text.replace(/([^$]*)([$]+[^$]*[$]+)?/g, function (a, text, code) {
  1823. return markdown.toHTML(text).replace(/^<p>|<\/p>$/g, '') + (code ? code : '');
  1824. });
  1825. return text;
  1826. }
  1827. function createHueDatatable(el, snippet, vm) {
  1828. var DATATABLES_MAX_HEIGHT = 330;
  1829. var _dt = $(el).hueDataTable({
  1830. i18n: {
  1831. NO_RESULTS: "${_('No results found.')}",
  1832. OF: "${_('of')}"
  1833. },
  1834. fnDrawCallback: function (oSettings) {
  1835. if (vm.editorMode()) {
  1836. $('#queryResults').removeAttr('style');
  1837. DATATABLES_MAX_HEIGHT = $(window).height() - $(el).parent().offset().top - 40;
  1838. $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
  1839. $(el).jHueHorizontalScrollbar();
  1840. $(el).parents('.dataTables_wrapper').jHueScrollLeft();
  1841. }
  1842. else {
  1843. if ($(el).data('fnDraws') === 1) {
  1844. $(el).parents(".dataTables_wrapper").jHueTableScroller({
  1845. maxHeight: DATATABLES_MAX_HEIGHT,
  1846. heightAfterCorrection: 0
  1847. });
  1848. }
  1849. }
  1850. },
  1851. scrollable: vm.editorMode() ? MAIN_SCROLLABLE : '.dataTables_wrapper',
  1852. contained: !vm.editorMode()
  1853. });
  1854. window.setTimeout(function () {
  1855. if (vm.editorMode()) {
  1856. $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
  1857. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  1858. var bannerTopHeight = 30;
  1859. % else:
  1860. var bannerTopHeight = 0;
  1861. % endif
  1862. $(el).jHueTableExtender2({
  1863. mainScrollable: MAIN_SCROLLABLE,
  1864. fixedFirstColumn: vm.editorMode(),
  1865. % if is_embeddable:
  1866. stickToTopPosition: function() { return vm.isPlayerMode() ? 47 + bannerTopHeight : 50 + bannerTopHeight },
  1867. % else:
  1868. stickToTopPosition: function() { return vm.isPlayerMode() ? 1 + bannerTopHeight : 73 + bannerTopHeight },
  1869. % endif
  1870. parentId: 'snippet_' + snippet.id(),
  1871. clonedContainerPosition: 'fixed',
  1872. app: 'editor'
  1873. });
  1874. $(el).jHueHorizontalScrollbar();
  1875. } else {
  1876. $(el).jHueTableExtender2({
  1877. mainScrollable: $(el).parents('.dataTables_wrapper')[0],
  1878. fixedFirstColumn: vm.editorMode(),
  1879. parentId: 'snippet_' + snippet.id(),
  1880. clonedContainerPosition: 'absolute',
  1881. app: 'editor'
  1882. });
  1883. }
  1884. }, 0);
  1885. return _dt;
  1886. }
  1887. function createDatatable(el, snippet, vm) {
  1888. var parent = $(el).parent();
  1889. // When executing few columns -> many columns -> few columns we have to clear the style
  1890. $(el).removeAttr('style');
  1891. if ($(el).hasClass('table-huedatatable')) {
  1892. $(el).removeClass('table-huedatatable');
  1893. if (parent.hasClass('dataTables_wrapper')) {
  1894. $(el).unwrap();
  1895. }
  1896. }
  1897. $(el).addClass("dt");
  1898. var _dt = createHueDatatable(el, snippet, vm);
  1899. var dataTableEl = $(el).parents(".dataTables_wrapper");
  1900. if (!vm.editorMode()) {
  1901. dataTableEl.bind('mousewheel DOMMouseScroll wheel', function (e) {
  1902. if ($(el).closest(".results").css("overflow") == "hidden") {
  1903. return;
  1904. }
  1905. var _e = e.originalEvent,
  1906. _deltaX = _e.wheelDeltaX || -_e.deltaX,
  1907. _deltaY = _e.wheelDeltaY || -_e.deltaY;
  1908. this.scrollTop += -_deltaY / 2;
  1909. this.scrollLeft += -_deltaX / 2;
  1910. if (this.scrollTop == 0) {
  1911. $("body")[0].scrollTop += -_deltaY / 3;
  1912. $("html")[0].scrollTop += -_deltaY / 3; // for firefox
  1913. }
  1914. e.preventDefault();
  1915. });
  1916. }
  1917. var _scrollTimeout = -1;
  1918. var scrollElement = dataTableEl;
  1919. if (vm.editorMode()) {
  1920. scrollElement = $(MAIN_SCROLLABLE);
  1921. }
  1922. if (scrollElement.data('scrollFnDtCreation')) {
  1923. scrollElement.off('scroll', scrollElement.data('scrollFnDtCreation'));
  1924. }
  1925. var resultFollowTimeout = -1;
  1926. var dataScroll = function () {
  1927. if (vm.editorMode()) {
  1928. var snippetEl = $('#snippet_' + snippet.id());
  1929. if (snippetEl.find('.dataTables_wrapper').length > 0 && snippet.showGrid()) {
  1930. window.clearTimeout(resultFollowTimeout);
  1931. resultFollowTimeout = window.setTimeout(function () {
  1932. var topCoord = vm.isPlayerMode() ? 1 : 73;
  1933. var offsetTop = 0;
  1934. if (snippetEl.find('.dataTables_wrapper').length > 0 && snippetEl.find('.dataTables_wrapper').offset()){
  1935. offsetTop = (snippetEl.find('.dataTables_wrapper').offset().top - topCoord) * -1;
  1936. }
  1937. var margin = Math.max(offsetTop, 0);
  1938. if (snippet.isResultSettingsVisible()) {
  1939. snippetEl.find('.snippet-grid-settings').css({
  1940. "height": Math.ceil($(window).height() - Math.max($('#queryResults').offset().top, topCoord)) + 'px'
  1941. });
  1942. snippetEl.find('.result-settings').animate({
  1943. 'marginTop': margin
  1944. });
  1945. }
  1946. snippetEl.find('.snippet-actions').animate({
  1947. 'marginTop': margin + 25
  1948. });
  1949. }, 100);
  1950. }
  1951. }
  1952. if (!vm.editorMode() || (vm.editorMode() && snippet.currentQueryTab() === 'queryResults' && snippet.showGrid())) {
  1953. var _lastScrollPosition = scrollElement.data("scrollPosition") != null ? scrollElement.data("scrollPosition") : 0;
  1954. window.clearTimeout(_scrollTimeout);
  1955. scrollElement.data("scrollPosition", scrollElement.scrollTop());
  1956. _scrollTimeout = window.setTimeout(function () {
  1957. if (vm.editorMode()) {
  1958. _lastScrollPosition--; //hack for forcing fetching
  1959. }
  1960. if (_lastScrollPosition != scrollElement.scrollTop() && scrollElement.scrollTop() + scrollElement.outerHeight() + 20 >= scrollElement[0].scrollHeight && _dt && snippet.result.hasMore()) {
  1961. huePubSub.publish('editor.snippet.result.gray', snippet);
  1962. snippet.fetchResult(100, false);
  1963. }
  1964. }, 100);
  1965. }
  1966. };
  1967. scrollElement.data('scrollFnDtCreation', dataScroll);
  1968. scrollElement.on('scroll', dataScroll);
  1969. snippet.isResultSettingsVisible.subscribe(function (newValue) {
  1970. if (newValue) {
  1971. dataScroll();
  1972. }
  1973. });
  1974. huePubSub.subscribeOnce('chart.hard.reset', function(){
  1975. // hard reset once the default opened chart
  1976. var oldChartX = snippet.chartX();
  1977. snippet.chartX(null);
  1978. window.setTimeout(function(){
  1979. snippet.chartX(oldChartX);
  1980. }, 0)
  1981. });
  1982. return _dt;
  1983. }
  1984. function toggleAllColumns(linkElement, snippet) {
  1985. var $t = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  1986. var dt = $t.hueDataTable();
  1987. dt.fnToggleAllCols(linkElement.checked);
  1988. dt.fnDraw();
  1989. }
  1990. function toggleColumn(linkElement, index, snippet) {
  1991. var $t = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  1992. var dt = $t.hueDataTable();
  1993. dt.fnSetColumnVis(index, linkElement.checked);
  1994. }
  1995. function scrollToColumn(linkElement, index) {
  1996. var $resultTable = $(linkElement).parents(".snippet").find("table.resultTable:eq(0)");
  1997. var _text = $.trim($(linkElement).text().split(" ")[0]);
  1998. var _col = $resultTable.find("th").filter(function () {
  1999. return $.trim($(this).text()) == _text;
  2000. });
  2001. $resultTable.find(".columnSelected").removeClass("columnSelected");
  2002. var _colSel = $resultTable.find("tr th:nth-child(" + (_col.index() + 1) + ")");
  2003. if (_colSel.length > 0) {
  2004. $resultTable.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
  2005. $resultTable.parent().animate({
  2006. scrollLeft: _colSel.position().left + $resultTable.parent().scrollLeft() - $resultTable.parent().offset().left - 30
  2007. }, 300, function(){
  2008. $resultTable.data('scrollToCol', _col.index());
  2009. $resultTable.data('scrollToRow', null);
  2010. $resultTable.data('scrollAnimate', true);
  2011. $resultTable.parent().trigger('scroll');
  2012. });
  2013. }
  2014. }
  2015. function isNotNullForCharts(val) {
  2016. return val !== 'NULL' && val !== null;
  2017. }
  2018. function pieChartDataTransformer(rawDatum) {
  2019. var _data = [];
  2020. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2021. var _idxValue = -1;
  2022. var _idxLabel = -1;
  2023. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2024. if (col.name == rawDatum.snippet.chartX()) {
  2025. _idxLabel = idx;
  2026. }
  2027. if (col.name == rawDatum.snippet.chartYSingle()) {
  2028. _idxValue = idx;
  2029. }
  2030. });
  2031. var colors = HueColors.cuiD3Scale();
  2032. $(rawDatum.counts()).each(function (cnt, item) {
  2033. if (isNotNullForCharts(item[_idxValue])) {
  2034. var val = item[_idxValue] * 1;
  2035. if (isNaN(val)) {
  2036. val = 0;
  2037. }
  2038. _data.push({
  2039. label: hueUtils.html2text(item[_idxLabel]),
  2040. value: val,
  2041. color: colors[cnt % colors.length],
  2042. obj: item
  2043. });
  2044. }
  2045. });
  2046. }
  2047. if (rawDatum.sorting == "asc") {
  2048. _data.sort(function (a, b) {
  2049. return a.value - b.value
  2050. });
  2051. }
  2052. if (rawDatum.sorting == "desc") {
  2053. _data.sort(function (a, b) {
  2054. return b.value - a.value
  2055. });
  2056. }
  2057. if (rawDatum.snippet.chartLimit()) {
  2058. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2059. }
  2060. return _data;
  2061. }
  2062. function mapChartDataTransformer(rawDatum) {
  2063. var _data = [];
  2064. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2065. var _idxRegion = -1;
  2066. var _idxValue = -1;
  2067. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2068. if (col.name == rawDatum.snippet.chartX()) {
  2069. _idxRegion = idx;
  2070. }
  2071. if (col.name == rawDatum.snippet.chartYSingle()) {
  2072. _idxValue = idx;
  2073. }
  2074. });
  2075. $(rawDatum.counts()).each(function (cnt, item) {
  2076. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxRegion])) {
  2077. _data.push({
  2078. label: item[_idxRegion],
  2079. value: item[_idxValue],
  2080. obj: item
  2081. });
  2082. }
  2083. });
  2084. }
  2085. if (rawDatum.snippet.chartLimit()) {
  2086. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2087. }
  2088. return _data;
  2089. }
  2090. // The leaflet map can freeze the browser with numbers outside the map
  2091. var MIN_LAT = -90;
  2092. var MAX_LAT = 90;
  2093. var MIN_LNG = -180;
  2094. var MAX_LNG = 180;
  2095. function leafletMapChartDataTransformer(rawDatum) {
  2096. var _data = [];
  2097. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2098. var _idxLat = -1;
  2099. var _idxLng = -1;
  2100. var _idxLabel = -1;
  2101. var _idxHeat = -1;
  2102. rawDatum.snippet.result.meta().forEach(function (col, idx) {
  2103. if (col.name == rawDatum.snippet.chartX()) {
  2104. _idxLat = idx;
  2105. }
  2106. if (col.name == rawDatum.snippet.chartYSingle()) {
  2107. _idxLng = idx;
  2108. }
  2109. if (col.name == rawDatum.snippet.chartMapLabel()) {
  2110. _idxLabel = idx;
  2111. }
  2112. if (col.name == rawDatum.snippet.chartMapHeat()) {
  2113. _idxHeat = idx;
  2114. }
  2115. });
  2116. if (rawDatum.snippet.chartMapLabel() != null) {
  2117. $(rawDatum.counts()).each(function (cnt, item) {
  2118. if (isNotNullForCharts(item[_idxLat]) && isNotNullForCharts(item[_idxLng])) {
  2119. _data.push({
  2120. lat: Math.min(Math.max(MIN_LAT, item[_idxLat]), MAX_LAT),
  2121. lng: Math.min(Math.max(MIN_LNG, item[_idxLng]), MAX_LNG),
  2122. label: hueUtils.html2text(item[_idxLabel]),
  2123. isHeat: rawDatum.snippet.chartMapType() === 'heat',
  2124. intensity: _idxHeat > -1 ? (item[_idxHeat]*1 != NaN ? item[_idxHeat]*1 : null) : null,
  2125. obj: item
  2126. });
  2127. }
  2128. });
  2129. } else {
  2130. $(rawDatum.counts()).each(function (cnt, item) {
  2131. if (isNotNullForCharts(item[_idxLat]) && isNotNullForCharts(item[_idxLng])) {
  2132. _data.push({
  2133. lat: Math.min(Math.max(MIN_LAT, item[_idxLat]), MAX_LAT),
  2134. lng: Math.min(Math.max(MIN_LNG, item[_idxLng]), MAX_LNG),
  2135. isHeat: rawDatum.snippet.chartMapType() === 'heat',
  2136. intensity: _idxHeat > -1 ? (item[_idxHeat]*1 != NaN ? item[_idxHeat]*1 : null) : null,
  2137. obj: item
  2138. });
  2139. }
  2140. });
  2141. }
  2142. }
  2143. if (rawDatum.snippet.chartLimit()) {
  2144. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2145. }
  2146. return _data;
  2147. }
  2148. function timelineChartDataTransformer(rawDatum) {
  2149. var _datum = [];
  2150. var _plottedSerie = 0;
  2151. rawDatum.snippet.result.meta().forEach(function (meta) {
  2152. if (rawDatum.snippet.chartYMulti().indexOf(meta.name) > -1) {
  2153. var col = meta.name;
  2154. var _idxValue = -1;
  2155. var _idxLabel = -1;
  2156. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2157. if (icol.name == rawDatum.snippet.chartX()) {
  2158. _idxLabel = idx;
  2159. }
  2160. if (icol.name == col) {
  2161. _idxValue = idx;
  2162. }
  2163. });
  2164. if (_idxValue > -1) {
  2165. var _data = [];
  2166. var colors = HueColors.cuiD3Scale();
  2167. $(rawDatum.counts()).each(function (cnt, item) {
  2168. if (isNotNullForCharts(item[_idxLabel]) && isNotNullForCharts(item[_idxValue])) {
  2169. _data.push({
  2170. series: _plottedSerie,
  2171. x: new Date(moment(hueUtils.html2text(item[_idxLabel])).valueOf()),
  2172. y: item[_idxValue] * 1,
  2173. color: colors[_plottedSerie % colors.length],
  2174. obj: item
  2175. });
  2176. }
  2177. });
  2178. if (rawDatum.sorting == "asc") {
  2179. _data.sort(function (a, b) {
  2180. return a.y - b.y
  2181. });
  2182. }
  2183. if (rawDatum.sorting == "desc") {
  2184. _data.sort(function (a, b) {
  2185. return b.y - a.y
  2186. });
  2187. }
  2188. if (rawDatum.snippet.chartLimit()) {
  2189. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2190. }
  2191. _datum.push({
  2192. key: col,
  2193. values: _data
  2194. });
  2195. _plottedSerie++;
  2196. }
  2197. }
  2198. });
  2199. return _datum;
  2200. }
  2201. function multiSerieDataTransformer(rawDatum) {
  2202. var _datum = [];
  2203. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYMulti().length > 0) {
  2204. var _plottedSerie = 0;
  2205. if (typeof rawDatum.snippet.chartXPivot() !== 'undefined') {
  2206. var _idxValue = -1;
  2207. var _idxLabel = -1;
  2208. var _isXDate = false;
  2209. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2210. if (icol.name == rawDatum.snippet.chartX()) {
  2211. _isXDate = icol.type.toUpperCase().indexOf('DATE') > -1;
  2212. _idxLabel = idx;
  2213. }
  2214. if (icol.name == rawDatum.snippet.chartYSingle()) {
  2215. _idxValue = idx;
  2216. }
  2217. });
  2218. rawDatum.snippet.result.meta().forEach(function (meta, cnt) {
  2219. if (rawDatum.snippet.chartXPivot() === meta.name) {
  2220. var _idxPivot = cnt;
  2221. var colors = HueColors.cuiD3Scale();
  2222. var pivotValues = $.map(rawDatum.counts(), function (p) {
  2223. return p[_idxPivot];
  2224. });
  2225. pivotValues = pivotValues.filter(function (item, pos) {
  2226. return pivotValues.indexOf(item) === pos;
  2227. });
  2228. pivotValues.forEach(function (val, pivotCnt) {
  2229. var _data = [];
  2230. $(rawDatum.counts()).each(function (cnt, item) {
  2231. if (item[_idxPivot] === val) {
  2232. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxLabel])) {
  2233. _data.push({
  2234. x: _isXDate ? moment(item[_idxLabel]) : hueUtils.html2text(item[_idxLabel]),
  2235. y: item[_idxValue] * 1,
  2236. color: colors[pivotCnt % colors.length],
  2237. obj: item
  2238. });
  2239. }
  2240. }
  2241. });
  2242. if (rawDatum.sorting == "asc") {
  2243. _data.sort(function (a, b) {
  2244. return a.y - b.y
  2245. });
  2246. }
  2247. if (rawDatum.sorting == "desc") {
  2248. _data.sort(function (a, b) {
  2249. return b.y - a.y
  2250. });
  2251. }
  2252. _datum.push({
  2253. key: hueUtils.html2text(val),
  2254. values: _data
  2255. });
  2256. });
  2257. }
  2258. });
  2259. // fills in missing values
  2260. var longestSerie = 0;
  2261. _datum.forEach(function (d) {
  2262. if (d.values.length > longestSerie) {
  2263. longestSerie = d.values.length;
  2264. }
  2265. });
  2266. _datum.forEach(function (d) {
  2267. if (d.values.length < longestSerie) {
  2268. var zeroObj = jQuery.extend({}, d.values[0]);
  2269. zeroObj.x = '';
  2270. zeroObj.y = 0;
  2271. for (var i = d.values.length; i < longestSerie; i++) {
  2272. d.values.push(zeroObj)
  2273. }
  2274. }
  2275. });
  2276. if (rawDatum.snippet.chartLimit()) {
  2277. _datum = _datum.slice(1, rawDatum.snippet.chartLimit() + 1);
  2278. }
  2279. }
  2280. else {
  2281. rawDatum.snippet.result.meta().forEach(function (meta) {
  2282. if (rawDatum.snippet.chartYMulti().indexOf(meta.name) > -1) {
  2283. var col = meta.name;
  2284. var _idxValue = -1;
  2285. var _idxLabel = -1;
  2286. var _isXDate = false;
  2287. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2288. if (icol.name == rawDatum.snippet.chartX()) {
  2289. _isXDate = icol.type.toUpperCase().indexOf('DATE') > -1;
  2290. _idxLabel = idx;
  2291. }
  2292. if (icol.name == col) {
  2293. _idxValue = idx;
  2294. }
  2295. });
  2296. if (_idxValue > -1) {
  2297. var _data = [];
  2298. var colors = HueColors.cuiD3Scale();
  2299. $(rawDatum.counts()).each(function (cnt, item) {
  2300. if (isNotNullForCharts(item[_idxValue]) && isNotNullForCharts(item[_idxLabel])) {
  2301. _data.push({
  2302. series: _plottedSerie,
  2303. x: _isXDate ? moment(item[_idxLabel]) : hueUtils.html2text(item[_idxLabel]),
  2304. y: item[_idxValue] * 1,
  2305. color: colors[cnt % colors.length],
  2306. obj: item
  2307. });
  2308. }
  2309. });
  2310. if (rawDatum.sorting == "asc") {
  2311. _data.sort(function (a, b) {
  2312. return a.y - b.y
  2313. });
  2314. }
  2315. if (rawDatum.sorting == "desc") {
  2316. _data.sort(function (a, b) {
  2317. return b.y - a.y
  2318. });
  2319. }
  2320. if (rawDatum.snippet.chartLimit()) {
  2321. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2322. }
  2323. _datum.push({
  2324. key: col,
  2325. values: _data
  2326. });
  2327. _plottedSerie++;
  2328. }
  2329. }
  2330. });
  2331. }
  2332. }
  2333. return _datum;
  2334. }
  2335. function scatterChartDataTransformer(rawDatum) {
  2336. var _datum = [];
  2337. if (rawDatum.snippet.chartX() != null && rawDatum.snippet.chartYSingle() != null) {
  2338. function addToDatum(col) {
  2339. var _idxX = -1;
  2340. var _idxY = -1;
  2341. var _idxSize = -1;
  2342. var _idxGroup = -1;
  2343. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2344. if (icol.name == rawDatum.snippet.chartX()) {
  2345. _idxX = idx;
  2346. }
  2347. if (icol.name == rawDatum.snippet.chartYSingle()) {
  2348. _idxY = idx;
  2349. }
  2350. if (icol.name == rawDatum.snippet.chartScatterSize()) {
  2351. _idxSize = idx;
  2352. }
  2353. if (icol.name == rawDatum.snippet.chartScatterGroup()) {
  2354. _idxGroup = idx;
  2355. }
  2356. });
  2357. if (_idxX > -1 && _idxY > -1) {
  2358. var _data = [];
  2359. $(rawDatum.counts()).each(function (cnt, item) {
  2360. if (_idxGroup == -1 || item[_idxGroup] == col) {
  2361. if (isNotNullForCharts(item[_idxX]) && isNotNullForCharts(item[_idxY])) {
  2362. _data.push({
  2363. x: item[_idxX],
  2364. y: item[_idxY],
  2365. shape: 'circle',
  2366. size: _idxSize > -1 ? item[_idxSize] : 100,
  2367. obj: item
  2368. });
  2369. }
  2370. }
  2371. });
  2372. if (rawDatum.snippet.chartLimit()) {
  2373. _data = _data.slice(1, rawDatum.snippet.chartLimit() + 1);
  2374. }
  2375. _datum.push({
  2376. key: col,
  2377. values: _data
  2378. });
  2379. }
  2380. }
  2381. if (rawDatum.snippet.chartScatterGroup() != null) {
  2382. var _idxGroup = -1;
  2383. rawDatum.snippet.result.meta().forEach(function (icol, idx) {
  2384. if (icol.name == rawDatum.snippet.chartScatterGroup()) {
  2385. _idxGroup = idx;
  2386. }
  2387. });
  2388. if (_idxGroup > -1) {
  2389. $(rawDatum.counts()).each(function (cnt, item) {
  2390. addToDatum(hueUtils.html2text(item[_idxGroup]));
  2391. });
  2392. }
  2393. } else {
  2394. addToDatum('${ _('Distribution') }');
  2395. }
  2396. }
  2397. return _datum;
  2398. }
  2399. function saveTemporarySnippet($element, value) {
  2400. if ($element.data('last-active-editor')) {
  2401. try {
  2402. if (viewModel.editorType() != 'notebook') {
  2403. $.totalStorage('hue.notebook.lastWrittenSnippet.${user}.' + viewModel.editorType(), value);
  2404. }
  2405. }
  2406. catch (e){} // storage quota exceeded with enormous editor content
  2407. }
  2408. }
  2409. (function () {
  2410. ko.options.deferUpdates = true;
  2411. var VIEW_MODEL_OPTIONS = $.extend(${ options_json | n,unicode,antixss }, {
  2412. user: '${ user.username }',
  2413. userId: ${ user.id },
  2414. % if is_embeddable:
  2415. hue4: true,
  2416. % endif
  2417. assistAvailable: true,
  2418. % if conf.USE_NEW_AUTOCOMPLETER.get():
  2419. useNewAutocompleter: true,
  2420. % endif
  2421. autocompleteTimeout: AUTOCOMPLETE_TIMEOUT,
  2422. snippetViewSettings: {
  2423. default: {
  2424. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2425. aceMode: 'ace/mode/sql',
  2426. snippetIcon: 'fa-database',
  2427. sqlDialect: true
  2428. },
  2429. code: {
  2430. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2431. snippetIcon: 'fa-code'
  2432. },
  2433. hive: {
  2434. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2435. aceMode: 'ace/mode/hive',
  2436. snippetImage: '${ static("beeswax/art/icon_beeswax_48.png") }',
  2437. sqlDialect: true
  2438. },
  2439. impala: {
  2440. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2441. aceMode: 'ace/mode/impala',
  2442. snippetImage: '${ static("impala/art/icon_impala_48.png") }',
  2443. sqlDialect: true
  2444. },
  2445. jar : {
  2446. snippetIcon: 'fa-file-archive-o '
  2447. },
  2448. mysql: {
  2449. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2450. aceMode: 'ace/mode/mysql',
  2451. snippetIcon: 'fa-database',
  2452. sqlDialect: true
  2453. },
  2454. mysqljdbc: {
  2455. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2456. aceMode: 'ace/mode/mysql',
  2457. snippetIcon: 'fa-database',
  2458. sqlDialect: true
  2459. },
  2460. oracle: {
  2461. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2462. aceMode: 'ace/mode/oracle',
  2463. snippetIcon: 'fa-database',
  2464. sqlDialect: true
  2465. },
  2466. pig: {
  2467. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2468. aceMode: 'ace/mode/pig',
  2469. snippetImage: '${ static("pig/art/icon_pig_48.png") }'
  2470. },
  2471. postgresql: {
  2472. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2473. aceMode: 'ace/mode/pgsql',
  2474. snippetIcon: 'fa-database',
  2475. sqlDialect: true
  2476. },
  2477. solr: {
  2478. placeHolder: '${ _("Example: SELECT fieldA, FieldB FROM collectionname, or press CTRL + space") }',
  2479. aceMode: 'ace/mode/mysql',
  2480. snippetIcon: 'fa-database',
  2481. sqlDialect: true
  2482. },
  2483. java : {
  2484. snippetIcon: 'fa-file-code-o'
  2485. },
  2486. py : {
  2487. snippetIcon: 'fa-file-code-o'
  2488. },
  2489. pyspark: {
  2490. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2491. aceMode: 'ace/mode/python',
  2492. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2493. },
  2494. r: {
  2495. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2496. aceMode: 'ace/mode/r',
  2497. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2498. },
  2499. scala: {
  2500. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2501. aceMode: 'ace/mode/scala',
  2502. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2503. },
  2504. spark: {
  2505. placeHolder: '${ _("Example: 1 + 1, or press CTRL + space") }',
  2506. aceMode: 'ace/mode/scala',
  2507. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2508. },
  2509. spark2: {
  2510. snippetImage: '${ static("spark/art/icon_spark_48.png") }'
  2511. },
  2512. mapreduce: {
  2513. snippetIcon: 'fa-file-archive-o'
  2514. },
  2515. shell: {
  2516. snippetIcon: 'fa-terminal'
  2517. },
  2518. sqoop1: {
  2519. placeHolder: '${ _("Example: import --connect jdbc:hsqldb:file:db.hsqldb --table TT --target-dir hdfs://localhost:8020/user/foo -m 1") }',
  2520. snippetImage: '${ static("sqoop/art/icon_sqoop_48.png") }'
  2521. },
  2522. distcp: {
  2523. snippetIcon: 'fa-files-o'
  2524. },
  2525. sqlite: {
  2526. placeHolder: '${ _("Example: SELECT * FROM tablename, or press CTRL + space") }',
  2527. aceMode: 'ace/mode/sql',
  2528. snippetIcon: 'fa-database',
  2529. sqlDialect: true
  2530. },
  2531. text: {
  2532. placeHolder: '${ _('Type your text here') }',
  2533. aceMode: 'ace/mode/text',
  2534. snippetIcon: 'fa-header'
  2535. },
  2536. markdown: {
  2537. placeHolder: '${ _('Type your markdown here') }',
  2538. aceMode: 'ace/mode/markdown',
  2539. snippetIcon: 'fa-header'
  2540. }
  2541. }
  2542. });
  2543. var viewModel;
  2544. var importExternalNotebook = function (notebook) {
  2545. var currentNotebook = viewModel.selectedNotebook();
  2546. currentNotebook.name(notebook.name);
  2547. currentNotebook.description(notebook.description);
  2548. currentNotebook.selectedSnippet(notebook.selectedSnippet);
  2549. notebook.snippets.forEach(function(snippet){
  2550. var newSnippet = currentNotebook.addSnippet({
  2551. type: snippet.type,
  2552. result: {}
  2553. });
  2554. newSnippet.statement_raw(snippet.statement);
  2555. });
  2556. hideHoverMsg(viewModel);
  2557. };
  2558. window.importExternalNotebook = importExternalNotebook;
  2559. var hideFixedHeaders = function() {
  2560. $('.jHueTableExtenderClonedContainer').hide();
  2561. $('.jHueTableExtenderClonedContainerColumn').hide();
  2562. $('.jHueTableExtenderClonedContainerCell').hide();
  2563. $('.fixed-header-row').hide();
  2564. $('.fixed-first-cell').hide();
  2565. $('.fixed-first-column').hide();
  2566. };
  2567. window.hideFixedHeaders = hideFixedHeaders;
  2568. var redrawTimeout = -1;
  2569. var redrawFixedHeaders = function (timeout) {
  2570. var renderer = function() {
  2571. if (! viewModel.selectedNotebook()) {
  2572. return;
  2573. }
  2574. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  2575. if (snippet.result.meta().length > 0) {
  2576. var tableExtender = $("#snippet_" + snippet.id() + ' .resultTable').data('plugin_jHueTableExtender2');
  2577. if (typeof tableExtender !== 'undefined') {
  2578. tableExtender.repositionHeader();
  2579. tableExtender.drawLockedRows();
  2580. }
  2581. $(MAIN_SCROLLABLE).data('lastScroll', $(MAIN_SCROLLABLE).scrollTop());
  2582. $(MAIN_SCROLLABLE).trigger('scroll');
  2583. }
  2584. });
  2585. $(".jHueTableExtenderClonedContainer").show();
  2586. $(".jHueTableExtenderClonedContainerColumn").show();
  2587. $(".jHueTableExtenderClonedContainerCell").show();
  2588. $('.fixed-header-row').show();
  2589. $('.fixed-first-cell').show();
  2590. $('.fixed-first-column').show();
  2591. };
  2592. if (timeout){
  2593. window.clearTimeout(redrawTimeout);
  2594. redrawTimeout = window.setTimeout(renderer, timeout);
  2595. } else {
  2596. renderer();
  2597. }
  2598. %if not is_embeddable:
  2599. $(MAIN_SCROLLABLE).jHueScrollUp();
  2600. %endif
  2601. };
  2602. var splitDraggableTimeout = -1;
  2603. huePubSub.subscribe('split.draggable.position', function () {
  2604. window.clearTimeout(splitDraggableTimeout);
  2605. splitDraggableTimeout = window.setTimeout(function () {
  2606. redrawFixedHeaders(100);
  2607. }, 200);
  2608. }, HUE_PUB_SUB_APP);
  2609. huePubSub.subscribe('redraw.fixed.headers', function () {
  2610. hideFixedHeaders();
  2611. redrawFixedHeaders(200);
  2612. }, HUE_PUB_SUB_APP);
  2613. huePubSub.subscribe('app.gained.focus', function (app) {
  2614. if (app === 'editor') {
  2615. huePubSub.publish('redraw.fixed.headers');
  2616. }
  2617. }, HUE_PUB_SUB_APP);
  2618. huePubSub.subscribe('show.saveToFile.modal', function () {
  2619. $('#saveToFileModal').modal('show');
  2620. }, HUE_PUB_SUB_APP);
  2621. huePubSub.subscribe('tab.switched', function (tab) {
  2622. if (tab !== 'queryResults') {
  2623. $('.hue-datatable-search').hide();
  2624. }
  2625. }, HUE_PUB_SUB_APP);
  2626. huePubSub.subscribe('detach.scrolls', function (snippet) {
  2627. var scrollElement = $('#snippet_' + snippet.id()).find('.dataTables_wrapper');
  2628. if (viewModel.editorMode()) {
  2629. scrollElement = $(MAIN_SCROLLABLE);
  2630. }
  2631. if (scrollElement.data('scrollFnDt')) {
  2632. scrollElement.off('scroll', scrollElement.data('scrollFnDt'));
  2633. }
  2634. }, HUE_PUB_SUB_APP);
  2635. window.redrawFixedHeaders = redrawFixedHeaders;
  2636. function addAce(content, snippetType) {
  2637. var snip = viewModel.selectedNotebook().addSnippet({type: snippetType, result: {}}, true);
  2638. snip.statement_raw(content);
  2639. aceChecks++;
  2640. snip.checkForAce = window.setInterval(function () {
  2641. if (snip.ace()) {
  2642. window.clearInterval(snip.checkForAce);
  2643. aceChecks--;
  2644. if (aceChecks == 0) {
  2645. hideHoverMsg(viewModel);
  2646. redrawFixedHeaders(200);
  2647. }
  2648. }
  2649. }, 100);
  2650. }
  2651. function replaceAce(content) {
  2652. var snip = viewModel.selectedNotebook().snippets()[0];
  2653. if (snip) {
  2654. snip.statement_raw(content);
  2655. snip.result.statements_count(1);
  2656. snip.ace().setValue(content, 1);
  2657. snip.result.statement_range({
  2658. start: {
  2659. row: 0,
  2660. column: 0
  2661. },
  2662. end: {
  2663. row: 0,
  2664. column: 0
  2665. }
  2666. });
  2667. snip.ace()._emit('focus');
  2668. }
  2669. hideHoverMsg(viewModel);
  2670. redrawFixedHeaders(200);
  2671. }
  2672. window.replaceAce = replaceAce;
  2673. function addMarkdown (content) {
  2674. var snip = viewModel.selectedNotebook().addSnippet({type: "markdown", result: {}}, true);
  2675. snip.statement_raw(content);
  2676. }
  2677. function addPySpark (content) {
  2678. addAce(content, "pyspark");
  2679. }
  2680. function addSql (content) {
  2681. addAce(content, "hive");
  2682. }
  2683. function addScala (content) {
  2684. addAce(content, "spark");
  2685. }
  2686. function parseExternalJSON(raw) {
  2687. try {
  2688. if (viewModel.editorMode()){
  2689. replaceAce(raw);
  2690. } else {
  2691. var loaded = typeof raw == "string" ? JSON.parse(raw) : raw;
  2692. if (loaded.nbformat) { //ipython
  2693. var cells = [];
  2694. if (loaded.nbformat == 3) {
  2695. cells = loaded.worksheets[0].cells;
  2696. } else if (loaded.nbformat == 4) {
  2697. cells = loaded.cells;
  2698. }
  2699. cells.forEach(function (cell, cellCnt) {
  2700. window.setTimeout(function () {
  2701. if (cell.cell_type == "code") {
  2702. if (loaded.nbformat == 3) {
  2703. addPySpark($.isArray(cell.input) ? cell.input.join("") : cell.input);
  2704. } else {
  2705. addPySpark($.isArray(cell.source) ? cell.source.join("") : cell.source);
  2706. }
  2707. }
  2708. if (cell.cell_type == "heading") {
  2709. var heading = $.isArray(cell.source) ? cell.source.join("") : cell.source;
  2710. if (cell.level == 1) {
  2711. heading += "\n====================";
  2712. } else if (cell.level == 2) {
  2713. heading += "\n--------------------";
  2714. } else {
  2715. heading = "### " + heading;
  2716. }
  2717. addMarkdown(heading);
  2718. }
  2719. if (cell.cell_type == "markdown") {
  2720. addMarkdown($.isArray(cell.source) ? cell.source.join("") : cell.source);
  2721. }
  2722. if (cellCnt == cells.length - 1 && aceChecks == 0) {
  2723. hideHoverMsg(viewModel);
  2724. }
  2725. }, 10);
  2726. });
  2727. }
  2728. if (loaded.paragraphs) { //zeppelin
  2729. if (loaded.name) {
  2730. viewModel.selectedNotebook().name(loaded.name);
  2731. }
  2732. loaded.paragraphs.forEach(function (paragraph) {
  2733. if (paragraph.text) {
  2734. var content = paragraph.text.split("\n");
  2735. if (content[0].indexOf("%md") > -1) {
  2736. content.shift();
  2737. addMarkdown(content.join("\n"));
  2738. } else if (content[0].indexOf("%sql") > -1 || content[0].indexOf("%hive") > -1) {
  2739. content.shift();
  2740. addSql(content.join("\n"));
  2741. } else if (content[0].indexOf("%pyspark") > -1) {
  2742. content.shift();
  2743. addPySpark(content.join("\n"));
  2744. } else {
  2745. if (content[0].indexOf("%spark") > -1) {
  2746. content.shift();
  2747. }
  2748. addScala(content.join("\n"));
  2749. }
  2750. }
  2751. });
  2752. }
  2753. }
  2754. }
  2755. catch (e) {
  2756. hideHoverMsg(viewModel);
  2757. replaceAce(raw);
  2758. }
  2759. }
  2760. window.parseExternalJSON = parseExternalJSON;
  2761. // Drag and drop iPython / Zeppelin notebooks
  2762. if (window.FileReader) {
  2763. var aceChecks = 0;
  2764. function handleFileSelect (evt) {
  2765. evt.stopPropagation();
  2766. evt.preventDefault();
  2767. var dt = evt.dataTransfer;
  2768. var files = dt.files;
  2769. if (files.length > 0){
  2770. showHoverMsg();
  2771. } else {
  2772. hideHoverMsg(viewModel);
  2773. }
  2774. for (var i = 0, f; f = files[i]; i++) {
  2775. var reader = new FileReader();
  2776. reader.onload = (function (file) {
  2777. return function (e) {
  2778. $(".hoverText").html("<i class='fa fa-spinner fa-spin'></i>");
  2779. parseExternalJSON(e.target.result);
  2780. };
  2781. })(f);
  2782. reader.readAsText(f);
  2783. }
  2784. }
  2785. function handleDragOver (evt) {
  2786. evt.stopPropagation();
  2787. evt.preventDefault();
  2788. evt.dataTransfer.dropEffect = "copy";
  2789. }
  2790. var dropZone = $('#${ bindableElement }')[0];
  2791. dropZone.addEventListener("dragenter", showHoverMsg, false);
  2792. dropZone.addEventListener("dragover", handleDragOver, false);
  2793. dropZone.addEventListener("drop", handleFileSelect, false);
  2794. var isDraggingOverText = false;
  2795. $(".hoverText").on("dragenter", function (e) {
  2796. e.preventDefault();
  2797. e.stopPropagation();
  2798. e.stopImmediatePropagation();
  2799. isDraggingOverText = true;
  2800. });
  2801. $(".hoverText").on("dragleave", function (e) {
  2802. e.preventDefault();
  2803. e.stopPropagation();
  2804. e.stopImmediatePropagation();
  2805. isDraggingOverText = false;
  2806. });
  2807. $(".hoverMsg").on("dragleave", function (e) {
  2808. if (!isDraggingOverText) {
  2809. hideHoverMsg(viewModel);
  2810. }
  2811. });
  2812. }
  2813. $(document).ready(function () {
  2814. % if ENABLE_QUERY_SCHEDULING.get():
  2815. viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS, CoordinatorEditorViewModel, RunningCoordinatorModel);
  2816. % else:
  2817. viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
  2818. % endif
  2819. ko.applyBindings(viewModel, $('#${ bindableElement }')[0]);
  2820. viewModel.init();
  2821. huePubSub.subscribe('editor.upload.table.stats', function (options) {
  2822. viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
  2823. }, HUE_PUB_SUB_APP);
  2824. huePubSub.subscribe("editor.upload.history", function () {
  2825. viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
  2826. }, HUE_PUB_SUB_APP);
  2827. huePubSub.subscribe("editor.upload.query", function (query_id) {
  2828. viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
  2829. }, HUE_PUB_SUB_APP);
  2830. huePubSub.subscribe('editor.active.statement.changed', function (statementDetails) {
  2831. var foundSnippet = viewModel.selectedNotebook().snippets().filter(function (snippet) {
  2832. return snippet.ace() && snippet.ace().container.id === statementDetails.id;
  2833. });
  2834. if (foundSnippet.length == 1) {
  2835. if (statementDetails.activeStatement) {
  2836. foundSnippet[0].positionStatement(statementDetails.activeStatement.statement);
  2837. } else {
  2838. foundSnippet[0].positionStatement('');
  2839. }
  2840. }
  2841. }, HUE_PUB_SUB_APP);
  2842. viewModel.selectedNotebook.subscribe(function (newVal) {
  2843. huePubSub.publish('selected.notebook.changed', newVal);
  2844. });
  2845. huePubSub.subscribe('get.selected.notebook', function () {
  2846. huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
  2847. }, HUE_PUB_SUB_APP);
  2848. var isAssistAvailable = viewModel.assistAvailable();
  2849. var wasLeftPanelVisible = viewModel.isLeftPanelVisible();
  2850. var wasRightPanelVisible = viewModel.isRightPanelVisible();
  2851. function exitPlayerMode() {
  2852. viewModel.isPlayerMode(false);
  2853. viewModel.isFullscreenMode(false);
  2854. }
  2855. viewModel.isPlayerMode.subscribe(function (value) {
  2856. if (value){
  2857. $(".jHueNotify").hide();
  2858. huePubSub.publish('side.panels.hide');
  2859. viewModel.assistAvailable(false);
  2860. viewModel.isLeftPanelVisible(false);
  2861. viewModel.isRightPanelVisible(false);
  2862. $(".navigator").hide();
  2863. $(".add-snippet").hide();
  2864. if (viewModel.isFullscreenMode()){
  2865. $(".main-content").css("top", "50px");
  2866. } else {
  2867. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  2868. $(".main-content").attr("style", "top: 31px!important");
  2869. % else:
  2870. $(".main-content").css("top", "1px");
  2871. % endif
  2872. }
  2873. redrawFixedHeaders(200);
  2874. $(window).bind("keydown", "esc", exitPlayerMode);
  2875. } else {
  2876. huePubSub.publish('side.panels.show');
  2877. viewModel.isLeftPanelVisible(wasLeftPanelVisible);
  2878. viewModel.isRightPanelVisible(wasRightPanelVisible);
  2879. viewModel.assistAvailable(isAssistAvailable);
  2880. $(".navigator").show();
  2881. $(".add-snippet").show();
  2882. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  2883. $(".main-content").css("top", "112px");
  2884. % else:
  2885. $(".main-content").css("top", "74px");
  2886. % endif
  2887. redrawFixedHeaders(200);
  2888. $(window).unbind("keydown", exitPlayerMode);
  2889. }
  2890. });
  2891. huePubSub.subscribe('assist.set.manual.visibility', function () {
  2892. wasLeftPanelVisible = viewModel.isLeftPanelVisible();
  2893. wasRightPanelVisible = viewModel.isRightPanelVisible();
  2894. }, HUE_PUB_SUB_APP);
  2895. viewModel.isLeftPanelVisible.subscribe(function (value) {
  2896. redrawFixedHeaders(200);
  2897. });
  2898. $(document).on("updateResultHeaders", function (e) {
  2899. hideFixedHeaders();
  2900. redrawFixedHeaders(200);
  2901. });
  2902. $(document).on("showAuthModal", function (e, data) {
  2903. viewModel.authSessionUsername('${ user.username }');
  2904. viewModel.authSessionPassword('');
  2905. viewModel.authSessionType(data['type']);
  2906. viewModel.authSessionCallback(data['callback']);
  2907. $("#authModal").modal("show");
  2908. });
  2909. $(document).on("hideHistoryModal", function (e) {
  2910. $("#clearHistoryModal").modal("hide");
  2911. });
  2912. huePubSub.subscribe('show.retry.modal', function (data) {
  2913. $('#retryModal').modal('show');
  2914. }, HUE_PUB_SUB_APP);
  2915. huePubSub.subscribe('hide.retry.modal', function (data) {
  2916. $('#retryModal').modal('hide');
  2917. }, HUE_PUB_SUB_APP);
  2918. // Close the notebook snippets when leaving the page
  2919. window.onbeforeunload = function (e) {
  2920. if (!viewModel.selectedNotebook().avoidClosing) {
  2921. viewModel.selectedNotebook().close();
  2922. }
  2923. };
  2924. $(window).data('beforeunload', window.onbeforeunload);
  2925. $(".preview-sample").css("right", (10 + hueUtils.scrollbarWidth()) + "px");
  2926. function saveKeyHandler() {
  2927. if (viewModel.canSave()) {
  2928. viewModel.saveNotebook();
  2929. }
  2930. else {
  2931. $('#saveAsModal').modal('show');
  2932. }
  2933. }
  2934. $(window).bind("keydown", "ctrl+s alt+s meta+s", function (e) {
  2935. e.preventDefault();
  2936. saveKeyHandler();
  2937. return false;
  2938. });
  2939. huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_APP);
  2940. $(document).bind('keyup', function (e) {
  2941. if (e.keyCode == 191 && e.shiftKey && !$(e.target).is('input') && !$(e.target).is('textarea')) {
  2942. $('#helpModal').modal('show');
  2943. }
  2944. if (e.keyCode == 191 && !e.shiftKey && !$(e.target).is('input') && !$(e.target).is('textarea')) {
  2945. if (viewModel.editorMode() && viewModel.selectedNotebook().snippets()[0].currentQueryTab() == 'queryResults') {
  2946. e.preventDefault();
  2947. var $t = $("#snippet_" + viewModel.selectedNotebook().snippets()[0].id()).find(".resultTable");
  2948. $t.hueDataTable().fnShowSearch();
  2949. return false;
  2950. }
  2951. }
  2952. });
  2953. function newKeyHandler() {
  2954. if (!viewModel.editorMode()) {
  2955. viewModel.selectedNotebook().newSnippet();
  2956. }
  2957. else {
  2958. viewModel.newNotebook(viewModel.editorType(), null, viewModel.selectedNotebook() ? viewModel.selectedNotebook().snippets()[0].currentQueryTab() : null);
  2959. }
  2960. }
  2961. $(window).bind("keydown", "ctrl+e alt+e meta+e", function (e) {
  2962. e.preventDefault();
  2963. newKeyHandler();
  2964. return false;
  2965. });
  2966. huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_APP);
  2967. var initialResizePosition = 100;
  2968. function getDraggableOptions (minY) {
  2969. return {
  2970. axis: "y",
  2971. start: function (e, ui) {
  2972. initialResizePosition = ui.offset.top;
  2973. },
  2974. drag: function (e, ui) {
  2975. draggableHelper($(this), e, ui);
  2976. $(".jHueTableExtenderClonedContainer").hide();
  2977. $(".jHueTableExtenderClonedContainerColumn").hide();
  2978. $(".jHueTableExtenderClonedContainerCell").hide();
  2979. $('.fixed-header-row').hide();
  2980. $('.fixed-first-cell').hide();
  2981. $('.fixed-first-column').hide();
  2982. },
  2983. stop: function (e, ui) {
  2984. $(".jHueTableExtenderClonedContainer").show();
  2985. $(".jHueTableExtenderClonedContainerColum").show();
  2986. $(".jHueTableExtenderClonedContainerCell").show();
  2987. $('.fixed-header-row').show();
  2988. $('.fixed-first-cell').show();
  2989. $('.fixed-first-column').show();
  2990. draggableHelper($(this), e, ui, true);
  2991. redrawFixedHeaders();
  2992. ui.helper.first().removeAttr("style");
  2993. },
  2994. containment: [0, minY, 4000, minY + 400]
  2995. }
  2996. }
  2997. $(".resize-panel a").each(function () {
  2998. $(this).draggable(getDraggableOptions($(this).parents(".snippet").offset().top + 128));
  2999. });
  3000. function draggableHelper (el, e, ui, setSize) {
  3001. var _snippet = ko.dataFor(el.parents(".snippet")[0]);
  3002. var _cm = $("#snippet_" + _snippet.id()).data("editor");
  3003. var _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
  3004. _cm.setSize("99%", _newSize);
  3005. if (setSize) {
  3006. _snippet.aceSize(_newSize);
  3007. }
  3008. }
  3009. function resetResultsResizer(snippet) {
  3010. $("#snippet_" + snippet.id()).find('.table-results .column-side').width(BOOTSTRAP_RATIOS.SPAN3() + '%').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
  3011. if (snippet.isResultSettingsVisible()){
  3012. $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN9()).width(BOOTSTRAP_RATIOS.SPAN9() + '%');
  3013. }
  3014. else {
  3015. $("#snippet_" + snippet.id()).find('.table-results .grid-side').data('newWidth', 100).width('100%');
  3016. }
  3017. $("#snippet_" + snippet.id()).find('.resize-bar').css('left', '');
  3018. try {
  3019. $("#snippet_" + snippet.id()).find('.resize-bar').draggable('destroy');
  3020. }
  3021. catch (e){}
  3022. var initialPosition = 0;
  3023. $("#snippet_" + snippet.id()).find('.resize-bar').draggable({
  3024. axis: "x",
  3025. containment: $("#snippet_" + snippet.id()).find('.table-results'),
  3026. create: function (event, ui) {
  3027. initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
  3028. $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth', BOOTSTRAP_RATIOS.SPAN3());
  3029. $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
  3030. },
  3031. drag: function (event, ui) {
  3032. if (initialPosition == 0){
  3033. initialPosition = $("#snippet_" + snippet.id()).find('.resize-bar').position().left;
  3034. }
  3035. ui.position.left = Math.max(150, ui.position.left);
  3036. var newSpan3Width = ui.position.left * BOOTSTRAP_RATIOS.SPAN3() / initialPosition;
  3037. var newSpan9Width = 100 - newSpan3Width - BOOTSTRAP_RATIOS.MARGIN();
  3038. $("#snippet_" + snippet.id()).find('.table-results .column-side').width(newSpan3Width + '%').data('newWidth', newSpan3Width);
  3039. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width(newSpan9Width + '%').data('newWidth', newSpan9Width);
  3040. $("#snippet_" + snippet.id()).find('.meta-filter').width($("#snippet_" + snippet.id()).find('.table-results .column-side').width() - 28)
  3041. },
  3042. stop: function () {
  3043. redrawFixedHeaders();
  3044. huePubSub.publish('resize.leaflet.map');
  3045. }
  3046. });
  3047. }
  3048. $(document).on("toggleResultSettings", function (e, snippet) {
  3049. window.setTimeout(function () {
  3050. $('#snippet_' + snippet.id()).find('.chart').trigger("forceUpdate");
  3051. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('update');
  3052. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3053. scrollInertia: 0
  3054. });
  3055. if (snippet.isResultSettingsVisible()){
  3056. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width((100 - $("#snippet_" + snippet.id()).find('.table-results .column-side').data('newWidth') - BOOTSTRAP_RATIOS.MARGIN()) + '%');
  3057. }
  3058. else {
  3059. $("#snippet_" + snippet.id()).find('.table-results .grid-side').width('100%');
  3060. }
  3061. redrawFixedHeaders();
  3062. $(window).trigger('resize');
  3063. }, 10)
  3064. });
  3065. $(document).on("editorSizeChanged", function () {
  3066. window.setTimeout(forceChartDraws, 50);
  3067. });
  3068. $(document).on("redrawResults", function () {
  3069. window.setTimeout(forceChartDraws, 50);
  3070. });
  3071. $(document).on("executeStarted", function (e, options) {
  3072. var $el = $("#snippet_" + options.snippet.id()).find(".resultTable");
  3073. if (options.vm.editorMode()) {
  3074. $('#queryResults').css({
  3075. height: $el.height() + 'px'
  3076. });
  3077. }
  3078. $el.data('scrollToCol', null);
  3079. $el.data('scrollToRow', null);
  3080. $("#snippet_" + options.snippet.id()).find(".progress-snippet").animate({
  3081. height: "3px"
  3082. }, 100);
  3083. if ($el.hasClass("dt")) {
  3084. $el.removeClass("dt");
  3085. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainer").remove();
  3086. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerColumn").remove();
  3087. $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerCell").remove();
  3088. if ($el.hueDataTable()) {
  3089. $el.hueDataTable().fnDestroy();
  3090. }
  3091. $el.find("thead tr").empty();
  3092. $el.data('lockedRows', {});
  3093. }
  3094. });
  3095. function resizeToggleResultSettings (snippet, initial) {
  3096. var _dtElement;
  3097. if (snippet.showGrid()) {
  3098. _dtElement = $("#snippet_" + snippet.id()).find(".dataTables_wrapper");
  3099. var topCoord = viewModel.isPlayerMode() ? ${ conf.CUSTOM.BANNER_TOP_HTML.get() and '31' or '1' } : 73;
  3100. $("#snippet_" + snippet.id()).find(".snippet-grid-settings").css({
  3101. "height": Math.ceil($(window).height() - Math.max($('.result-settings').length > 0 ? $('.result-settings').offset().top : 0, topCoord)) + 'px'
  3102. });
  3103. } else {
  3104. _dtElement = $("#snippet_" + snippet.id()).find(".chart:visible");
  3105. }
  3106. if (_dtElement.length == 0) {
  3107. _dtElement = $("#snippet_" + snippet.id()).find(".table-results");
  3108. }
  3109. _dtElement.parents(".snippet-body").find(".toggle-result-settings").css({
  3110. "height": (_dtElement.height() - 30) + "px",
  3111. "line-height": (_dtElement.height() - 30) + "px"
  3112. });
  3113. if (initial) {
  3114. $('#snippet_' + snippet.id()).find('.result-settings').animate({
  3115. 'marginTop': 0
  3116. });
  3117. $('#snippet_' + snippet.id()).find('.snippet-actions').animate({
  3118. 'marginTop': 0
  3119. });
  3120. huePubSub.publish('resize.leaflet.map');
  3121. }
  3122. }
  3123. $(document).on("renderData", function (e, options) {
  3124. var _el = $("#snippet_" + options.snippet.id()).find(".resultTable");
  3125. if (options.data.length > 0) {
  3126. window.setTimeout(function () {
  3127. var _dt;
  3128. if (options.initial) {
  3129. options.snippet.result.meta.notifySubscribers();
  3130. $("#snippet_" + options.snippet.id()).find("select").trigger("chosen:updated");
  3131. _dt = createDatatable(_el, options.snippet, viewModel);
  3132. resetResultsResizer(options.snippet);
  3133. }
  3134. else {
  3135. _dt = _el.hueDataTable();
  3136. }
  3137. try {
  3138. _dt.fnAddData(options.data);
  3139. }
  3140. catch (e) {}
  3141. var _dtElement = $("#snippet_" + options.snippet.id()).find(".dataTables_wrapper");
  3142. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3143. _dtElement.scrollTop(_dtElement.data("scrollPosition"));
  3144. redrawFixedHeaders();
  3145. resizeToggleResultSettings(options.snippet, options.initial);
  3146. }, 300);
  3147. } else {
  3148. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3149. }
  3150. $("#snippet_" + options.snippet.id()).find("select").trigger('chosen:updated');
  3151. $('#snippet_' + options.snippet.id()).find('.snippet-grid-settings').mCustomScrollbar({axis: 'xy', theme: 'minimal-dark', scrollbarPosition: 'outside', mouseWheel:{ preventDefault: true, deltaFactor: 10 }, scrollInertia: 0});
  3152. window.setTimeout(function(){
  3153. $('#snippet_' + options.snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3154. scrollInertia: 0
  3155. });
  3156. }, 200)
  3157. });
  3158. huePubSub.subscribe('editor.snippet.result.gray', function (snippet) {
  3159. var $snippet = $("#snippet_" + snippet.id());
  3160. $snippet.find(".dataTables_wrapper .fixed-first-column").css({opacity: '0'});
  3161. $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '0'});
  3162. $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '0'});
  3163. $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '0.55'});
  3164. }, HUE_PUB_SUB_APP);
  3165. huePubSub.subscribe('editor.snippet.result.normal', function (snippet) {
  3166. var $snippet = $("#snippet_" + snippet.id());
  3167. $snippet.find(".dataTables_wrapper .fixed-first-column").css({opacity: '1'});
  3168. $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '1'});
  3169. $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '1'});
  3170. $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '1'});
  3171. }, HUE_PUB_SUB_APP);
  3172. $(document).on("renderDataError", function (e, options) {
  3173. huePubSub.publish('editor.snippet.result.normal', options.snippet);
  3174. });
  3175. $(document).on("progress", function (e, options) {
  3176. if (options.data == 100) {
  3177. window.setTimeout(function () {
  3178. $("#snippet_" + options.snippet.id()).find(".progress-snippet").animate({
  3179. height: "0"
  3180. }, 100, function () {
  3181. options.snippet.progress(0);
  3182. redrawFixedHeaders();
  3183. });
  3184. }, 2000);
  3185. }
  3186. });
  3187. huePubSub.subscribe('render.jqcron', function(){
  3188. if (typeof renderJqCron !== 'undefined'){
  3189. renderJqCron();
  3190. }
  3191. }, HUE_PUB_SUB_APP);
  3192. huePubSub.subscribe('submit.popup.return', function (data) {
  3193. viewModel.selectedNotebook().viewSchedulerId(data.job_id);
  3194. $.jHueNotify.info('${_('Coordinator submitted.')}');
  3195. $('.submit-modal').modal('hide');
  3196. $('a[href=\'#scheduledJobsTab\']').click();
  3197. }, HUE_PUB_SUB_APP);
  3198. huePubSub.subscribe('jobbrowser.data', function (jobs) {
  3199. if (jobs.length > 0) {
  3200. jobs.forEach(function (job) {
  3201. if ($("#" + job.shortId).length > 0) {
  3202. var _job = ko.dataFor($("#" + job.shortId)[0]);
  3203. if (!isNaN(parseInt(job.mapsPercentComplete))) {
  3204. _job.percentJob(parseInt(job.mapsPercentComplete));
  3205. }
  3206. }
  3207. });
  3208. }
  3209. else {
  3210. if (viewModel.selectedNotebook()) {
  3211. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  3212. snippet.jobs().forEach(function (job) {
  3213. job.percentJob(100);
  3214. });
  3215. });
  3216. }
  3217. }
  3218. }, HUE_PUB_SUB_APP);
  3219. $(document).on("gridShown", function (e, snippet) {
  3220. window.setTimeout(function () {
  3221. resizeToggleResultSettings(snippet, true);
  3222. forceChartDraws();
  3223. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar({axis: 'xy', theme: 'minimal-dark', scrollbarPosition: 'outside', mouseWheel:{ preventDefault: true, deltaFactor: 10 }, scrollInertia: 0});
  3224. window.setTimeout(function(){
  3225. $('#snippet_' + snippet.id()).find('.snippet-grid-settings').mCustomScrollbar('scrollTo', 'left', {
  3226. scrollInertia: 0
  3227. });
  3228. }, 200)
  3229. }, 50);
  3230. });
  3231. $(document).on("chartShown", function (e, snippet) {
  3232. window.setTimeout(function () {
  3233. resizeToggleResultSettings(snippet, true);
  3234. }, 50);
  3235. });
  3236. $(document).on("forceChartDraw", function (e, snippet) {
  3237. window.setTimeout(function () {
  3238. snippet.chartX.notifySubscribers();
  3239. snippet.chartX.valueHasMutated();
  3240. }, 100);
  3241. });
  3242. var hideTimeout = -1;
  3243. $(document).on("hideAutocomplete", function () {
  3244. window.clearTimeout(hideTimeout);
  3245. hideTimeout = window.setTimeout(function () {
  3246. var $aceAutocomplete = $(".ace_editor.ace_autocomplete");
  3247. if ($aceAutocomplete.is(":visible")) {
  3248. $aceAutocomplete.hide();
  3249. }
  3250. }, 100);
  3251. });
  3252. function forceChartDraws(initial) {
  3253. if (viewModel.selectedNotebook()) {
  3254. viewModel.selectedNotebook().snippets().forEach(function (snippet) {
  3255. if (snippet.result.data().length > 0) {
  3256. var _elCheckerInterval = -1;
  3257. var _el = $("#snippet_" + snippet.id());
  3258. _elCheckerInterval = window.setInterval(function () {
  3259. if (_el.find(".resultTable").length > 0) {
  3260. try {
  3261. resizeToggleResultSettings(snippet, initial);
  3262. resetResultsResizer(snippet);
  3263. $(document).trigger("forceChartDraw", snippet);
  3264. } catch (e) { }
  3265. window.clearInterval(_elCheckerInterval);
  3266. }
  3267. }, 200)
  3268. }
  3269. });
  3270. }
  3271. }
  3272. forceChartDraws(true);
  3273. var _resizeTimeout = -1;
  3274. $(window).on("resize", function () {
  3275. $('.notebook-name-desc').css('max-width', ($('.snippet-container').width()/4) + 'px');
  3276. window.clearTimeout(_resizeTimeout);
  3277. _resizeTimeout = window.setTimeout(function () {
  3278. forceChartDraws();
  3279. }, 200);
  3280. });
  3281. });
  3282. })();
  3283. </script>
  3284. </%def>