editor_components.mako 186 KB

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