metastore.mako 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  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.html import escape
  18. from django.utils.translation import ugettext as _
  19. from desktop import conf
  20. from desktop.conf import USE_NEW_EDITOR
  21. from desktop.lib.i18n import smart_unicode
  22. from desktop.views import commonheader, commonfooter, _ko
  23. from beeswax.conf import LIST_PARTITIONS_LIMIT
  24. from metastore.conf import ENABLE_NEW_CREATE_TABLE
  25. %>
  26. <%namespace name="actionbar" file="actionbar.mako" />
  27. <%namespace name="assist" file="/assist.mako" />
  28. <%namespace name="components" file="components.mako" />
  29. <%
  30. MAIN_SCROLLABLE = is_embeddable and ".page-content" or ".content-panel"
  31. if conf.CUSTOM.BANNER_TOP_HTML.get():
  32. TOP_SNAP = is_embeddable and "82px" or "108px"
  33. else:
  34. TOP_SNAP = is_embeddable and "52px" or "78px"
  35. %>
  36. % if not is_embeddable:
  37. ${ commonheader(_("Metastore"), app_name, user, request) | n,unicode }
  38. <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
  39. <script src="${ static('desktop/ext/js/jquery/plugins/jquery.mousewheel.min.js') }"></script>
  40. <script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
  41. <script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
  42. <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }"></script>
  43. <script src="${ static('desktop/js/ko.editable.js') }"></script>
  44. ${ assist.assistJSModels() }
  45. <link rel="stylesheet" href="${ static('notebook/css/notebook-layout.css') }">
  46. <style type="text/css">
  47. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  48. .show-assist {
  49. top: 110px!important;
  50. }
  51. .main-content {
  52. top: 112px!important;
  53. }
  54. % endif
  55. </style>
  56. ${ assist.assistPanel() }
  57. % endif
  58. <script src="${ static('desktop/ext/js/wysihtml5-0.3.0.min.js') }"></script>
  59. <script src="${ static('desktop/js/bootstrap-wysihtml5-0.0.2.js') }"></script>
  60. <script src="${ static('desktop/ext/js/bootstrap-editable.wysihtml5.js') }"></script>
  61. <script src="${ static('beeswax/js/stats.utils.js') }"></script>
  62. <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-editable.css') }">
  63. <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-wysihtml5-0.0.2.css') }">
  64. <link rel="stylesheet" href="${ static('notebook/css/notebook.css') }">
  65. <span class="notebook">
  66. ${ components.menubar(is_embeddable) }
  67. <script src="${ static('metastore/js/metastore.ko.js') }"></script>
  68. <link rel="stylesheet" href="${ static('metastore/css/metastore.css') }" type="text/css">
  69. <script type="text/html" id="metastore-breadcrumbs">
  70. <ul class="nav nav-pills hue-breadcrumbs-bar" id="breadcrumbs">
  71. <li>
  72. <a href="javascript:void(0);" data-bind="click: databasesBreadcrumb">${_('Databases')}
  73. <!-- ko if: database -->
  74. <span class="divider">&gt;</span>
  75. <!-- /ko -->
  76. </a>
  77. </li>
  78. <!-- ko with: database -->
  79. <li>
  80. <a href="javascript:void(0);" data-bind="click: $root.tablesBreadcrumb">
  81. <span data-bind="text: name"></span>
  82. <!-- ko with: table -->
  83. <span class="divider">&gt;</span>
  84. <!-- /ko -->
  85. </a>
  86. </li>
  87. <!-- ko with: table -->
  88. <li class="editable-breadcrumbs" title="${_('Edit path')}" data-bind="click: function(){ $parent.editingTable(true); }, visible: !$parent.editingTable()">
  89. <a href="javascript:void(0)" data-bind="text: name"></a>
  90. </li>
  91. <!-- /ko -->
  92. <!-- ko if: editingTable -->
  93. <!-- ko with: table -->
  94. <li class="editable-breadcrumb-input">
  95. <input type="text" data-bind="hivechooser: {data: name, database: $parent.name, skipColumns: true, searchEverywhere: true, onChange: function(val){ $parent.setTableByName(val); $parent.editingTable(false); }, apiHelperUser: '${ user }', apiHelperType: $root.sourceType()}" autocomplete="off" />
  96. </li>
  97. <!-- /ko -->
  98. <!-- /ko -->
  99. <!-- /ko -->
  100. </ul>
  101. </script>
  102. <script type="text/html" id="metastore-columns-table">
  103. <div style="overflow-x: auto; overflow-y: hidden">
  104. <table class="table table-condensed table-nowrap">
  105. <thead>
  106. <tr>
  107. <th width="2%">&nbsp;</th>
  108. <th width="2%" class="no-sort">&nbsp;</th>
  109. <th width="17%">${_('Name')}</th>
  110. <th width="15%">${_('Type')}</th>
  111. <!-- ko if: $root.optimizerEnabled -->
  112. <th width="15%">${_('Popularity')}</th>
  113. <!-- /ko -->
  114. <th width="50%">${_('Comment')}</th>
  115. </tr>
  116. </thead>
  117. <tbody data-bind="hueach: {data: $data, itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 200, disableHueEachRowCount: 5, scrollUp: true}">
  118. <tr>
  119. <td data-bind="text: $index() + $indexOffset() + 1"></td>
  120. <td><a class="blue" href="javascript:void(0)" data-bind="click: showContextPopover"><i class="fa fa-fw fa-info" title="${_('Show details')}"></i></a></td>
  121. <td title="${ _("Scroll to the column") }">
  122. <!-- ko if: $root.database() && $root.database().table() && $root.database().table().samples && $root.database().table().samples.loading() -->
  123. <span data-bind="text: name"></span> <i class="fa fa-key" data-bind="visible: typeof primary_key !== 'undefined' && primary_key() == 'true'"></i>
  124. <!-- /ko -->
  125. <!-- ko ifnot: $root.database() && $root.database().table() && $root.database().table().samples && $root.database().table().samples.loading() -->
  126. <a href="javascript:void(0)" class="column-selector" data-bind="click: $root.scrollToColumn"><span data-bind="text: name"></span> <i class="fa fa-key" data-bind="visible: typeof primary_key !== 'undefined' && primary_key() == 'true'"></i></a>
  127. <!-- /ko -->
  128. </td>
  129. <td data-bind="text: type"></td>
  130. <!-- ko if: $root.optimizerEnabled -->
  131. <td>
  132. <div class="progress" style="height: 10px; width: 70px; margin-top:5px;" data-bind="attr: { 'title': popularity() }">
  133. <div class="bar" style="background-color: #0B7FAD" data-bind="style: { 'width' : popularity() + '%' }"></div>
  134. </div>
  135. </td>
  136. <!-- /ko -->
  137. <td>
  138. % if has_write_access:
  139. <!-- ko ifnot: table.isView() -->
  140. <div class="show-inactive-on-hover">
  141. <a class="inactive-action pointer toggle-editable" title="${ _('Edit the comment') }"><i class="fa fa-pencil"></i></a>
  142. <span data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'wysihtml5', toggle: 'manual', skipNewLines: true, toggleElement: '.toggle-editable', placement: 'left', placeholder: '${ _ko('Add a comment...') }', emptytext: '${ _ko('Add a comment...') }', inputclass: 'input-xlarge'}">
  143. ${ _('Add a comment...') }</span>
  144. </div>
  145. <!-- /ko -->
  146. <!-- ko if: table.isView() -->
  147. <span data-bind="text: comment"></span>
  148. <!-- /ko -->
  149. % else:
  150. <span data-bind="text: comment"></span>
  151. % endif
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. </div>
  157. </script>
  158. <script type="text/html" id="metastore-partition-columns-table">
  159. <div style="overflow-x: auto; overflow-y: hidden">
  160. <table class="table table-condensed table-nowrap">
  161. <thead>
  162. <tr>
  163. <th style="width: 1%">&nbsp;</th>
  164. <th>${_('Name')}</th>
  165. <th>${_('Type')}</th>
  166. </tr>
  167. </thead>
  168. <tbody>
  169. <!-- ko foreach: detailedKeys -->
  170. <tr>
  171. <td data-bind="text: $index() + 1"></td>
  172. <td data-bind="text: $data.name"></td>
  173. <td data-bind="text: $data.type"></td>
  174. </tr>
  175. <!-- /ko -->
  176. </tbody>
  177. </table>
  178. </div>
  179. </script>
  180. <script type="text/html" id="metastore-partition-values-table">
  181. <div style="overflow-x: auto; overflow-y: hidden">
  182. <table id="partitionsTable" class="table table-condensed table-nowrap">
  183. <thead>
  184. <tr>
  185. <th style="width: 1%" class="vertical-align-middle">
  186. <!-- ko ifnot: $data.withDrop -->
  187. &nbsp;
  188. <!-- /ko -->
  189. <!-- ko if: $data.withDrop -->
  190. <div class="hueCheckbox fa" data-bind="hueCheckAll: { allValues: $data.values, selectedValues: $data.selectedValues }"></div>
  191. <!-- /ko -->
  192. </th>
  193. <th>${_('Values')}</th>
  194. <th>${_('Spec')}</th>
  195. <th data-bind="visible: $root.sourceType() != 'impala'">${_('Browse')}</th>
  196. </tr>
  197. </thead>
  198. <tbody>
  199. <!-- ko foreach: $data.values -->
  200. <tr>
  201. <td>
  202. <!-- ko ifnot: $parent.withDrop -->
  203. <span data-bind="text: $index() + 1"></span>
  204. <!-- /ko -->
  205. <!-- ko if: $parent.withDrop -->
  206. <div class="hueCheckbox fa" data-bind="multiCheck: '#partitionsTable', value: $data, hueChecked: $parent.selectedValues"></div>
  207. <!-- /ko -->
  208. </td>
  209. <td title="${_('Query partition data')}">
  210. <!-- ko if: IS_HUE_4 -->
  211. <a data-bind="click: function() { queryAndWatch(notebookUrl, $root.sourceType()); }, text: '[\'' + columns.join('\',\'') + '\']'" href="javascript:void(0)"></a>
  212. <!-- /ko -->
  213. <!-- ko if: ! IS_HUE_4 -->
  214. <a data-bind="attr: {'href': readUrl }, text: '[\'' + columns.join('\',\'') + '\']'"></a>
  215. <!-- /ko -->
  216. </td>
  217. <td data-bind="text: partitionSpec"></td>
  218. <td data-bind="visible: $root.sourceType() != 'impala'">
  219. <!-- ko if: IS_HUE_4 -->
  220. <a data-bind="click: function () { browsePartitionFolder(browseUrl); }" href="javascript:void(0)" title="${_('Browse partition files')}">
  221. ${_('Files')}
  222. </a>
  223. <!-- /ko -->
  224. <!-- ko if: ! IS_HUE_4 -->
  225. <a data-bind="attr: {'href': browseUrl }" title="${_('Browse partition files')}">${_('Files')}</a>
  226. <!-- /ko -->
  227. </td>
  228. </tr>
  229. <!-- /ko -->
  230. </tbody>
  231. </table>
  232. </div>
  233. </script>
  234. <script type="text/html" id="metastore-samples-table">
  235. <table class="table table-condensed table-nowrap sample-table old-datatable">
  236. <thead>
  237. <tr>
  238. <th style="width: 1%">&nbsp;</th>
  239. <!-- ko foreach: headers -->
  240. <th data-bind="text: $data"></th>
  241. <!-- /ko -->
  242. </tr>
  243. </thead>
  244. <tbody>
  245. <!-- ko foreach: rows -->
  246. <tr>
  247. <td data-bind="text: $index() + 1"></td>
  248. <!-- ko foreach: $data -->
  249. <td data-bind="text: $data"></td>
  250. <!-- /ko -->
  251. </tr>
  252. <!-- /ko -->
  253. </tbody>
  254. </table>
  255. <div id="jumpToColumnAlert" class="alert hide" style="margin-top: 12px;">
  256. <button type="button" class="close" data-dismiss="alert">&times;</button>
  257. <strong>${_('Did you know?')}</strong>
  258. <ul>
  259. <li>${ _('If the sample contains a large number of columns, click a row to select a column to jump to') }</li>
  260. </ul>
  261. </div>
  262. </script>
  263. <script type="text/html" id="metastore-table-properties">
  264. <i data-bind="visible: loadingDetails" class="fa fa-spinner fa-spin fa-2x muted" style="display: none;"></i>
  265. <!-- ko with: tableDetails -->
  266. <h4>${ _('Properties') }</h4>
  267. <div class="row-fluid">
  268. <div title="${ _('Type') }">
  269. <!-- ko if: is_view -->
  270. <i class="fa fa-fw fa-eye muted"></i> ${ _('View') }
  271. <!-- /ko -->
  272. <!-- ko ifnot: is_view -->
  273. <i class="fa fa-fw fa-table muted"></i> ${ _('Table') }
  274. <!-- /ko -->
  275. </div>
  276. <div title="${ _('Owner') }">
  277. <i class="fa fa-fw fa-user muted"></i> <span data-bind="text: details.properties.owner"></span>
  278. </div>
  279. <div title="${ _('Created') }"><i class="fa fa-fw fa-clock-o muted"></i> <span data-bind="text: localeFormat(details.properties.create_time) != 'Invalid Date' ? localeFormat(details.properties.create_time) : details.properties.create_time"></span></div>
  280. <div title="${ _('Format') }">
  281. <i class="fa fa-fw fa-file-o muted"></i> <span data-bind="text: details.properties.format"></span>
  282. <i class="fa fa-fw fa-archive muted"></i>
  283. <span data-bind="visible: details.properties.table_type == 'MANAGED_TABLE'" style="display: none;">${_('Managed')}</span>
  284. <span data-bind="visible: details.properties.table_type == 'EXTERNAL_TABLE'" style="display: none;">${_('External')}</span>
  285. </div>
  286. </div>
  287. <!-- /ko -->
  288. </script>
  289. <script type="text/html" id="metastore-table-stats">
  290. <!-- ko if: tableDetails() && ! tableDetails().is_view -->
  291. <!-- ko with: tableDetails -->
  292. <h4>${ _('Stats') }
  293. <!-- ko ifnot: partition_keys.length -->
  294. % if has_write_access:
  295. <!-- ko if: $parent.refreshingTableStats -->
  296. <i class="fa fa-refresh fa-spin"></i>
  297. <!-- /ko -->
  298. <!-- ko ifnot: $parent.refreshingTableStats() || is_view -->
  299. <a class="pointer" href="javascript: void(0);" data-bind="click: $parent.refreshTableStats"><i class="fa fa-refresh"></i></a>
  300. <!-- /ko -->
  301. % endif
  302. <span data-bind="visible: details.stats.COLUMN_STATS_ACCURATE == 'false' && ! is_view" rel="tooltip" data-placement="top" title="${ _('The column stats for this table are not accurate') }"><i class="fa fa-exclamation-triangle"></i></span>
  303. <!-- /ko -->
  304. </h4>
  305. <div class="row-fluid">
  306. <div>
  307. <i class="fa fa-fw fa-hdd-o muted"></i>
  308. <!-- ko if: details.properties.format == 'kudu' -->
  309. ${_('Stored in')} Kudu
  310. <!-- /ko -->
  311. <!-- ko if: details.properties.format != 'kudu' -->
  312. <a data-bind="hueLink: hdfs_link, attr: {'rel': path_location}" title="${_('Open data location')}">${_('Location')}</a>
  313. <!-- /ko -->
  314. </div>
  315. <!-- ko with: $parent.tableStats -->
  316. <!-- ko if: typeof transient_lastDdlTime !== 'undefined' -->
  317. <span title="${ _('Last data update') }"><i class="fa fa-fw fa-clock-o muted"></i> <span data-bind="text: localeFormat(transient_lastDdlTime * 1000)"></span></span>
  318. <!-- /ko -->
  319. <!-- ko if: typeof last_modified_by !== 'undefined' || typeof last_modified_time !== 'undefined' -->
  320. <div>
  321. <!-- ko if: typeof last_modified_time !== 'undefined' -->
  322. <span title="${ _('Last DDL modified time') }"><i class="fa fa-fw fa-clock-o muted"></i> <span data-bind="text: localeFormat(last_modified_time*1000)"></span></span>
  323. <!-- /ko -->
  324. <!-- ko if: typeof last_modified_by !== 'undefined' -->
  325. <span title="${ _('Last DDL modified by') }"><i class="fa fa-fw fa-user muted"></i> <span data-bind="text: last_modified_by"></span></span>
  326. <!-- /ko -->
  327. </div>
  328. <!-- /ko -->
  329. <!-- ko if: typeof numFiles !== 'undefined' && typeof last_modified_by === 'undefined' -->
  330. <div title="${ _('Number of files') }"><i class="fa fa-fw fa-files-o muted"></i> <span data-bind="text: numFiles"></span> ${ _('files') }</div>
  331. <!-- /ko -->
  332. <!-- ko if: typeof numRows !== 'undefined' -->
  333. <div title="${ _('Number of rows') }"><i class="fa fa-fw fa-list muted"></i> <span data-bind="text: numRows"></span> ${ _('rows') }</div>
  334. <!-- /ko -->
  335. <!-- ko if: typeof totalSize !== 'undefined' && typeof last_modified_by === 'undefined' -->
  336. <div title="${ _('Total size') }"><i class="fa fa-fw fa-tasks muted"></i> <span data-bind="text: filesize(totalSize)"></span></div>
  337. <!-- /ko -->
  338. <!-- /ko -->
  339. </div>
  340. <!-- /ko -->
  341. <!-- /ko -->
  342. </script>
  343. <script type="text/html" id="metastore-databases">
  344. <div class="actionbar-actions" data-bind="dockable: { scrollable: '${ MAIN_SCROLLABLE }', nicescroll: true, jumpCorrection: 5, topSnap: '${ TOP_SNAP }' }">
  345. <input class="input-xlarge search-query margin-left-10" type="text" placeholder="${ _('Search for a database...') }" data-bind="clearable: databaseQuery, value: databaseQuery, valueUpdate: 'afterkeydown'"/>
  346. % if has_write_access:
  347. <button class="btn toolbarBtn margin-left-20" title="${_('Drop the selected databases')}" data-bind="click: function () { $('#dropDatabase').modal('show'); }, disable: selectedDatabases().length === 0"><i class="fa fa-times"></i> ${_('Drop')}</button>
  348. <div id="dropDatabase" class="modal hide fade">
  349. % if is_embeddable:
  350. <form action="/metastore/databases/drop" data-bind="submit: dropAndWatch" method="POST">
  351. <input type="hidden" name="is_embeddable" value="true"/>
  352. <input type="hidden" name="start_time" value=""/>
  353. <input type="hidden" name="source_type" data-bind="value: $root.sourceType"/>
  354. % else:
  355. <form id="dropDatabaseForm" action="/metastore/databases/drop" method="POST">
  356. % endif
  357. ${ csrf_token(request) | n,unicode }
  358. <div class="modal-header">
  359. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  360. <h2 id="dropDatabaseMessage" class="modal-title">${ _('Do you really want to delete the following database(s)?') }</h2>
  361. </div>
  362. <div class="modal-body">
  363. <ul data-bind="foreach: selectedDatabases">
  364. <li>
  365. <span data-bind="text: name"></span>
  366. <!-- ko if: $data.tables().length > 0 -->
  367. (<span data-bind="text: $data.tables().length"></span> tables)
  368. <!-- /ko -->
  369. </li>
  370. </ul>
  371. </div>
  372. <div class="modal-footer">
  373. <div class="label label-important margin-top-5 pull-left">${ _('Warning: This will drop all tables and objects within the database.') }</div>
  374. <input type="button" class="btn" data-dismiss="modal" value="${_('No')}">
  375. <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
  376. </div>
  377. <!-- ko foreach: selectedDatabases -->
  378. <input type="hidden" name="database_selection" data-bind="value: name" />
  379. <!-- /ko -->
  380. </form>
  381. </div>
  382. % endif
  383. </div>
  384. <table id="databasesTable" class="table table-condensed datatables" style="margin-bottom: 10px" data-bind="visible: filteredDatabases().length > 0">
  385. <thead>
  386. <tr>
  387. <th width="1%" style="text-align: center" class="vertical-align-middle"><div class="hueCheckbox fa" data-bind="hueCheckAll: { allValues: filteredDatabases, selectedValues: selectedDatabases }"></div></th>
  388. <th>${ _('Database Name') }</th>
  389. </tr>
  390. </thead>
  391. <tbody data-bind="hueach: {data: filteredDatabases, itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 145, scrollUp: true}">
  392. <tr>
  393. <td width="1%" style="text-align: center">
  394. <div class="hueCheckbox fa" data-bind="multiCheck: '#databasesTable', value: $data, hueChecked: $parent.selectedDatabases"></div>
  395. </td>
  396. <td>
  397. <a href="javascript: void(0);" data-bind="text: name, click: function () { $parent.setDatabase($data, function(){ huePubSub.publish('metastore.url.change'); }) }"></a>
  398. </td>
  399. </tr>
  400. </tbody>
  401. </table>
  402. <span class="margin-left-10" data-bind="visible: filteredDatabases().length === 0" style="font-style: italic; display: none;">${_('No databases found')}</span>
  403. </script>
  404. <script type="text/html" id="metastore-tables">
  405. <div class="row-fluid">
  406. <!-- ko with: stats -->
  407. <div class="
  408. %if is_optimizer_enabled:
  409. span8
  410. %else:
  411. span12
  412. %endif
  413. tile">
  414. <div class="span6 tile">
  415. <h4>${ _('Properties') }</h4>
  416. <div title="${ _('Comment') }"><i class="fa fa-fw fa-comment muted"></i>
  417. <!-- ko if: comment -->
  418. <span data-bind="text: comment"></span>
  419. <!-- /ko -->
  420. <!-- ko ifnot: comment -->
  421. <i>${_('No comment.')}</i>
  422. <!-- /ko -->
  423. <div title="${ _('Owner') }">
  424. <i class="fa fa-fw fa-user muted"></i>
  425. <span data-bind="text: owner_name ? owner_name : '${ _ko('None') }'"></span> <span data-bind="visible: owner_type">(<span data-bind="text: owner_type"></span>)</span>
  426. <br/>
  427. <i class="fa fa-fw fa-hdd-o muted"></i> <a data-bind="attr: {'href': hdfs_link, 'rel': location }"> ${_('Location')}</a>
  428. </div>
  429. </div>
  430. </div>
  431. <div class="span6 tile">
  432. <!-- ko if: $root.navigatorEnabled() -->
  433. <h4>${ _('Tags') }</h4>
  434. <div style="margin-top: 5px" data-bind="component: { name: 'nav-tags', params: {
  435. sourceType: $root.sourceType(),
  436. database: db_name
  437. } }"></div>
  438. <!-- /ko -->
  439. </div>
  440. <!-- ko with: parameters -->
  441. <div class="row-fluid">
  442. <div class="span12">
  443. <div title="${ _('Parameters') }">
  444. <!-- ko template: { name: 'metastore-databases-parameters', data: hueUtils.parseHivePseudoJson($data) }--><!-- /ko -->
  445. </div>
  446. </div>
  447. </div>
  448. <!-- /ko -->
  449. </div>
  450. <!-- /ko -->
  451. </div>
  452. <div class="row-fluid">
  453. <div class="span12 tile">
  454. <h4>${ _('Tables') }</h4>
  455. <div class="actionbar-actions" data-bind="visible: tables().length > 0, dockable: { scrollable: '${ MAIN_SCROLLABLE }', nicescroll: true, jumpCorrection: 5, topSnap: '${ TOP_SNAP }' }">
  456. <input class="input-xlarge search-query margin-left-10" type="text" placeholder="${ _('Search for a table...') }" data-bind="clearable: tableQuery, value: tableQuery, valueUpdate: 'afterkeydown'"/>
  457. <button class="btn toolbarBtn margin-left-20" title="${_('Browse the selected table')}" data-bind="click: function () { setTable(selectedTables()[0]); selectedTables([]); }, disable: selectedTables().length !== 1"><i class="fa fa-eye"></i> ${_('View')}</button>
  458. <button class="btn toolbarBtn" title="${_('Query the selected table')}" data-bind="click: function () { IS_HUE_4 ? queryAndWatch('/notebook/browse/' + name + '/' + selectedTables()[0].name + '/', $root.sourceType()) : location.href = '/notebook/browse/' + name + '/' + selectedTables()[0].name; }, disable: selectedTables().length !== 1">
  459. <i class="fa fa-play fa-fw"></i> ${_('Query')}
  460. </button>
  461. % if has_write_access:
  462. <button id="dropBtn" class="btn toolbarBtn" title="${_('Delete the selected tables')}" data-bind="click: function () { $('#dropTable').modal('show'); }, disable: selectedTables().length === 0"><i class="fa fa-times"></i> ${_('Drop')}</button>
  463. % endif
  464. </div>
  465. <table id="tablesTable" class="table table-condensed table-nowrap" style="margin-bottom: 10px; width: 100%" data-bind="visible: filteredTables().length > 0">
  466. <thead>
  467. <tr>
  468. <th width="1%" style="text-align: center" class="vertical-align-middle"><div class="hueCheckbox fa" data-bind="hueCheckAll: { allValues: filteredTables, selectedValues: selectedTables }"></div></th>
  469. <th>&nbsp;</th>
  470. <th width="30%">${ _('Table Name') }</th>
  471. <th width="48%">${ _('Comment') }</th>
  472. <!-- ko if: $root.optimizerEnabled -->
  473. <th width="10%">${ _('Popularity') }</th>
  474. <th width="10%">${ _('Columns') }</th>
  475. <!-- /ko -->
  476. <th width="1%">${ _('Type') }</th>
  477. </tr>
  478. </thead>
  479. <tbody data-bind="hueach: {data: filteredTables, itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 277, scrollUp: true}">
  480. <tr>
  481. <td width="1%" style="text-align: center">
  482. <div class="hueCheckbox fa" data-bind="multiCheck: '#tablesTable', value: $data, hueChecked: $parent.selectedTables"></div>
  483. </td>
  484. <td width="1%"><a class="blue" href="javascript:void(0)" data-bind="click: showContextPopover"><i class="fa fa-fw fa-info" title="${_('Show details')}"></i></a></td>
  485. <td>
  486. <a class="tableLink" href="javascript:void(0);" data-bind="text: name, click: function() { $parent.setTable($data, function(){ huePubSub.publish('metastore.url.change'); }) }"></a>
  487. </td>
  488. <td style="text-overflow: ellipsis; overflow: hidden; max-width: 0" data-bind="html: commentWithoutNewLines, attr: {title: hueUtils.html2text(commentWithoutNewLines())}"></td>
  489. <!-- ko if: $root.optimizerEnabled -->
  490. <!-- ko if: optimizerStats() -->
  491. <td>
  492. <div class="progress" style="height: 10px; width: 70px; margin-top:5px;" data-bind="attr: {'title': optimizerStats().popularity}">
  493. <div class="bar" style="background-color: #0B7FAD" data-bind="style: { 'width' : optimizerStats().popularity + '%' }"></div>
  494. </div>
  495. </td>
  496. <td data-bind="text: optimizerStats().column_count"></td>
  497. <!-- /ko -->
  498. <!-- ko ifnot: optimizerStats() -->
  499. <td></td>
  500. <td></td>
  501. <!-- /ko -->
  502. <!-- /ko -->
  503. <td class="center">
  504. <!-- ko ifnot: $root.optimizerEnabled && optimizerStats() -->
  505. <!-- ko if: type == 'Table' -->
  506. <i class="fa fa-fw fa-table muted" title="${ _('Table') }"></i>
  507. <!-- /ko -->
  508. <!-- ko if: type == 'View' -->
  509. <i class="fa fa-fw fa-eye muted" title="${ _('View') }"></i>
  510. <!-- /ko -->
  511. <!-- /ko -->
  512. <!-- ko if: $root.optimizerEnabled && optimizerStats() -->
  513. <!-- ko if: optimizerStats().is_fact -->
  514. <i class="fa fa-fw muted fa-database" title="${ _('Fact table') }"></i>
  515. <!-- /ko -->
  516. <!-- ko ifnot: optimizerStats().is_fact -->
  517. <i class="fa fa-fw muted fa-calendar" title="${ _('Dimension table') }"></i>
  518. <!-- /ko -->
  519. <!-- /ko -->
  520. </td>
  521. </tr>
  522. </tbody>
  523. </table>
  524. <span data-bind="visible: filteredTables().length === 0, css: {'margin-left-10': tables().length > 0}" style="font-style: italic; display: none;">${_('No tables found.')}</span>
  525. </div>
  526. </div>
  527. % if has_write_access:
  528. <div id="dropTable" class="modal hide fade">
  529. % if is_embeddable:
  530. <form data-bind="attr: { 'action': '/metastore/tables/drop/' + name }, submit: dropAndWatch" method="POST">
  531. <input type="hidden" name="is_embeddable" value="true"/>
  532. <input type="hidden" name="start_time" value=""/>
  533. <input type="hidden" name="source_type" data-bind="value: $root.sourceType"/>
  534. % else:
  535. <form data-bind="attr: { 'action': '/metastore/tables/drop/' + name }" method="POST">
  536. % endif
  537. ${ csrf_token(request) | n,unicode }
  538. <div class="modal-header">
  539. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  540. <h2 id="dropTableMessage" class="modal-title">${_('Do you really want to drop the selected table(s)?')}</h2>
  541. </div>
  542. <div class="modal-body">
  543. <ul data-bind="foreach: selectedTables">
  544. <!-- ko if: $index() <= 9 -->
  545. <li>
  546. <span data-bind="text: name"></span>
  547. </li>
  548. <!-- /ko -->
  549. </ul>
  550. <!-- ko if: selectedTables().length > 10 -->
  551. ${_('and')} <span data-bind="text: selectedTables().length - 10"></span> ${_('others')}.<br>
  552. <!-- /ko -->
  553. <label class="checkbox" style="display: inline-block; margin-top: 5px">
  554. <input type="checkbox" name="skip_trash" /> ${ _('Skip the trash') }
  555. </label>
  556. </div>
  557. <div class="modal-footer">
  558. <input type="button" class="btn" data-dismiss="modal" value="${_('No')}" />
  559. <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
  560. </div>
  561. <!-- ko foreach: selectedTables -->
  562. <input type="hidden" name="table_selection" data-bind="value: name" />
  563. <!-- /ko -->
  564. </form>
  565. </div>
  566. % endif
  567. </script>
  568. <script type="text/html" id="metastore-databases-parameters">
  569. <div data-bind="toggleOverflow: {height: 24}">
  570. <div class="inline margin-right-20"><i class="fa fa-fw fa-cog muted"></i></div>
  571. <!-- ko foreach: Object.keys($data) -->
  572. <div class="inline margin-right-20"><strong data-bind="text: $data"></strong>: <span data-bind="text: $parent[$data]"></span></div>
  573. <!-- /ko -->
  574. </div>
  575. </script>
  576. <script type="text/html" id="metastore-databases-actions">
  577. <div class="inline-block pull-right">
  578. <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceTypes: [sourceType()] }); }">
  579. <i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }" title="${_('Refresh')}"></i>
  580. </a>
  581. % if has_write_access:
  582. % if is_embeddable:
  583. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }'); }" title="${_('Create a new database')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
  584. % elif ENABLE_NEW_CREATE_TABLE.get():
  585. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' }" title="${_('Create a new database')}"><i class="fa fa-plus"></i></a>
  586. % else:
  587. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }" href="${ url('beeswax:create_database') }" title="${_('Create a new database')}"><i class="fa fa-plus"></i></a>
  588. % endif
  589. % endif
  590. </div>
  591. </script>
  592. <script type="text/html" id="metastore-tables-actions">
  593. <div class="inline-block pull-right">
  594. <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: refresh" title="${_('Refresh')}"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
  595. % if has_write_access:
  596. % if is_embeddable:
  597. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + database().name ); }" title="${_('Create a new table')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
  598. % elif ENABLE_NEW_CREATE_TABLE.get():
  599. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + database().name }" title="${_('Create a new table')}"><i class="fa fa-plus"></i></a>
  600. % else:
  601. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '/beeswax/create/import_wizard/' + database().name }" title="${_('Create a new table from a file')}"><span class="fa-stack fa-fw" style="width: 1.28571429em"><i class="fa fa-file-o fa-stack-1x"></i><i class="fa fa-plus-circle fa-stack-1x" style="font-size: 14px; margin-left: 5px; margin-top: 6px;"></i></span></a>
  602. <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '/beeswax/create/create_table/' + database().name }" title="${_('Create a new table manually')}"><i class="fa fa-plus"></i></a>
  603. % endif
  604. % endif
  605. </div>
  606. </script>
  607. <script type="text/html" id="metastore-describe-table-actions">
  608. <div class="inline-block pull-right">
  609. <!-- ko with: database -->
  610. <!-- ko with: table -->
  611. % if USE_NEW_EDITOR.get():
  612. <!-- ko if: IS_HUE_4 -->
  613. <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function() { queryAndWatch('/notebook/browse/' + database.name + '/' + name + '/', $root.sourceType()); }" title="${_('Query the table')}" href="javascript:void(0)"><i class="fa fa-play fa-fw"></i></a>
  614. <!-- /ko -->
  615. <!-- ko if: ! IS_HUE_4 -->
  616. <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '/notebook/browse/' + database.name + '/' + name }" title="${_('Query the table')}"><i class="fa fa-play fa-fw"></i></a>
  617. <!-- /ko -->
  618. % else:
  619. <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '/metastore/table/'+ database.name + '/' + name + '/read' }" title="${_('Browse Data')}"><i class="fa fa-play fa-fw"></i></a>
  620. % endif
  621. <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceTypes: [$root.sourceType()] }); }" title="${_('Refresh')}" href="javascript:void(0)"><i class="pointer fa fa-refresh fa-fw" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
  622. % if has_write_access:
  623. <a class="inactive-action" href="#" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: showImportData, visible: tableDetails() && ! tableDetails().is_view" title="${_('Import Data')}"><i class="fa fa-upload fa-fw"></i></a>
  624. % endif
  625. % if has_write_access:
  626. <a class="inactive-action" href="#dropSingleTable" data-toggle="modal" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'title' : tableDetails() && tableDetails().is_view ? '${_('Drop View')}' : '${_('Drop Table')}' }"><i class="fa fa-times fa-fw"></i></a>
  627. % endif
  628. <!-- /ko -->
  629. <!-- /ko -->
  630. </div>
  631. </script>
  632. <script type="text/html" id="metastore-overview-tab">
  633. <div class="row-fluid margin-top-10">
  634. <div class="span3 tile">
  635. <!-- ko template: 'metastore-table-properties' --><!-- /ko -->
  636. </div>
  637. <div class="span3 tile">
  638. <!-- ko template: 'metastore-table-stats' --><!-- /ko -->
  639. </div>
  640. <!-- ko if: $root.navigatorEnabled() && navigatorStats() -->
  641. <div class="span6 tile">
  642. <h4>${ _('Tags') }</h4>
  643. <div style="margin-top: 5px" data-bind="component: { name: 'nav-tags', params: {
  644. sourceType: $root.sourceType(),
  645. database: database.name,
  646. table: name
  647. } }"></div>
  648. </div>
  649. <!-- /ko -->
  650. </div>
  651. <div class="tile">
  652. <h4>${ _('Columns') } (<span data-bind="text: columns().length"></span>) <i data-bind="visible: loadingColumns" class="fa fa-spinner fa-spin" style="display: none;"></i></h4>
  653. <!-- ko with: favouriteColumns -->
  654. <!-- ko template: "metastore-columns-table" --><!-- /ko -->
  655. <!-- /ko -->
  656. <a class="pointer" data-bind="visible: columns().length > favouriteColumns().length, click: function() { $('li a[href=\'#columns\']').click(); }">
  657. ${_('View more...')}
  658. </a>
  659. </div>
  660. <div class="tile">
  661. <h4>${ _('Sample') } <i data-bind="visible: samples.loading" class='fa fa-spinner fa-spin' style="display: none;"></i></h4>
  662. <!-- ko with: samples -->
  663. <!-- ko if: loaded() && !hasErrors() -->
  664. <!-- ko with: preview -->
  665. <!-- ko template: { if: rows().length, name: 'metastore-samples-table' } --><!-- /ko -->
  666. <a class="pointer" data-bind="visible: rows().length >= 3, click: function() { $('li a[href=\'#sample\']').click(); }" style="display: none;">
  667. ${_('View more...')}
  668. </a>
  669. <!-- /ko -->
  670. <div data-bind="visible: !rows().length && metastoreTable.tableDetails().is_view" style="display: none;">${ _('The view does not contain any data.') }</div>
  671. <div data-bind="visible: !rows().length && !metastoreTable.tableDetails().is_view" style="display: none;">${ _('The table does not contain any data.') }</div>
  672. <!-- /ko -->
  673. <!-- ko if: hasErrors() -->
  674. <div>${ _('Could not load the sample, see the server log for details.') }</div>
  675. <!-- /ko -->
  676. <!-- /ko -->
  677. </div>
  678. <div class="tile" data-bind="visible: tableDetails() && tableDetails().partition_keys.length" style="display: none;">
  679. <!-- ko with: partitions -->
  680. <h4>${ _('Partitions') } <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i></h4>
  681. <!-- ko if: loaded -->
  682. <!-- ko with: preview -->
  683. <!-- ko template: { if: values().length, name: 'metastore-partition-values-table', data: { values: values, withDrop: false } } --><!-- /ko -->
  684. <a class="pointer" data-bind="visible: values().length >= 3, click: function() { $('li a[href=\'#partitions\']').click(); }" style="display: none;">
  685. ${_('View more...')}
  686. </a>
  687. <!-- /ko -->
  688. <span data-bind="visible: !values().length" style="display: none;">${ _('The partition does not contain any values') }</span>
  689. <!-- /ko -->
  690. <!-- /ko -->
  691. </div>
  692. </script>
  693. <script type="text/html" id="metastore-columns-tab">
  694. <!-- ko with: filteredColumns -->
  695. <!-- ko template: "metastore-columns-table" --><!-- /ko -->
  696. <!-- /ko -->
  697. </script>
  698. <script type="text/html" id="metastore-partitions-tab">
  699. <!-- ko with: partitions -->
  700. <div class="tile" data-bind="visible: true" style="display: none;">
  701. <h4>${ _('Columns') }</h4>
  702. <!-- ko template: 'metastore-partition-columns-table' --><!-- /ko -->
  703. </div>
  704. <div class="tile" data-bind="visible: true" style="display: none;">
  705. <h4>${ _('Partitions') } <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i></h4>
  706. <!-- ko if: loaded -->
  707. <div class="row-fluid">
  708. <div class="span10">
  709. <div data-bind="visible: filters().length > 0">
  710. <div data-bind="foreach: filters">
  711. <div class="filter-box">
  712. <a href="javascript:void(0)" class="pull-right" data-bind="click: $parent.removeFilter">
  713. <i class="fa fa-times"></i>
  714. </a>
  715. <select class="input-small" data-bind="options: $parent.keys, value: column"></select>
  716. &nbsp;
  717. <input class="input-small" type="text" data-bind="value: value, typeahead: { target: value, source: $parent.typeaheadValues(column), triggerOnFocus: true, forceUpdateSource: true}" placeholder="${ _('Value to filter...') }" />
  718. </div>
  719. </div>
  720. <div class="pull-left" style="margin-top: 4px; margin-bottom: 10px">
  721. <a class="add-filter" href="javascript: void(0)" data-bind="click: addFilter">
  722. <i class="fa fa-plus"></i> ${ _('Add') }
  723. </a>
  724. <label class="checkbox inline pulled">${ _('Sort Desc') } <input type="checkbox" data-bind="checked: sortDesc" /></label>
  725. <button class="btn" data-bind="click: filter"><i class="fa fa-filter"></i> ${ _('Filter') }</button>
  726. </div>
  727. </div>
  728. <a class="add-filter" href="javascript: void(0)" data-bind="click: addFilter, visible: values().length > 0 && filters().length == 0" style="margin-bottom: 20px; margin-left: 14px">
  729. <i class="fa fa-plus"></i> ${ _('Add a filter') }
  730. </a>
  731. <div class="clearfix"></div>
  732. </div>
  733. <div class="span2">
  734. % if has_write_access:
  735. <div class="pull-right">
  736. <button class="btn" title="${_('Delete the selected partitions')}" data-bind="click: function () { $('#dropPartition').modal('show'); }, disable: selectedValues().length === 0"><i class="fa fa-trash-o"></i> ${_('Drop partition(s)')}</button>
  737. </div>
  738. % endif
  739. </div>
  740. </div>
  741. <!-- ko template: { if: values().length, name: 'metastore-partition-values-table', data: { values: values, selectedValues: selectedValues, withDrop: true } } --><!-- /ko -->
  742. <span data-bind="visible: !values().length" style="display: none;">${ _('The partition does not contain any values') }</span>
  743. <!-- /ko -->
  744. </div>
  745. % if has_write_access:
  746. <div id="dropPartition" class="modal hide fade">
  747. % if is_embeddable:
  748. <form data-bind="attr: { 'action': '/metastore/table/' + $parent.database.name + '/' + $parent.name + '/partitions/drop' }, submit: dropAndWatch" method="POST">
  749. <input type="hidden" name="is_embeddable" value="true"/>
  750. <input type="hidden" name="format" value="json"/>
  751. <input type="hidden" name="start_time" value=""/>
  752. <input type="hidden" name="source_type" data-bind="value: $root.sourceType"/>
  753. % else:
  754. <form data-bind="attr: { 'action': '/metastore/table/' + $parent.database.name + '/' + $parent.name + '/partitions/drop' }" method="POST">
  755. % endif
  756. ${ csrf_token(request) | n,unicode }
  757. <div class="modal-header">
  758. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  759. <h2 id="dropPartitionMessage" class="modal-title">${_('Confirm action')}</h2>
  760. </div>
  761. <div class="modal-footer">
  762. <input type="button" class="btn" data-dismiss="modal" value="${_('Cancel')}" />
  763. <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
  764. </div>
  765. <select class="hide" name="partition_selection" data-bind="options: valuesFlat, selectedOptions: selectedValuesFlat" size="5" multiple="true"></select>
  766. </form>
  767. </div>
  768. % endif
  769. <!-- /ko -->
  770. </script>
  771. <script type="text/html" id="metastore-sample-tab">
  772. <!-- ko with: samples -->
  773. <!-- ko if: loading -->
  774. <div class="empty-message">
  775. <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i>
  776. </div>
  777. <!-- /ko -->
  778. <!-- ko if: loaded() && !hasErrors() -->
  779. <!-- ko template: { if: rows().length, name: 'metastore-samples-table' } --><!-- /ko -->
  780. <div data-bind="visible: !rows().length && metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The view does not contain any data.') }</div>
  781. <div data-bind="visible: !rows().length && !metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The table does not contain any data.') }</div>
  782. <!-- /ko -->
  783. <!-- ko if: hasErrors() -->
  784. <div class="empty-message">${ _('Could not load the sample, see the server log for details.') }</div>
  785. <!-- /ko -->
  786. <!-- /ko -->
  787. </script>
  788. <script type="text/html" id="metastore-queries-tab">
  789. <br/>
  790. <i class="fa fa-spinner fa-spin" data-bind="visible: $root.loadingQueries"></i>
  791. <table data-bind="visible: ! loadingQueries() && $data.optimizerDetails().queryList().length > 0" class="table table-condensed">
  792. <thead>
  793. <tr>
  794. <th width="10%">${ _('Id') }</th>
  795. <th width="10%">${ _('Popularity') }</th>
  796. <th>${ _('Character') }</th>
  797. <th>${ _('Query') }</th>
  798. <th width="20%">${ _('Complexity') }</th>
  799. <th width="10%">${ _('Hive Compatible') }</th>
  800. <th width="10%">${ _('Impala Compatible') }</th>
  801. </tr>
  802. </thead>
  803. <tbody data-bind="hueach: {data: $data.optimizerDetails().queryList(), itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 200}">
  804. <tr>
  805. <td data-bind="text: qid"></td>
  806. <td style="height: 10px; width: 70px; margin-top:5px;" data-bind="attr: {'title': queryCount()}">
  807. <div class="progress bar" style="background-color: #0B7FAD" data-bind="style: { 'width' : Math.round(queryCount() / $parent.optimizerDetails().queryCount() * 100) + '%' }"></div>
  808. </td>
  809. <td><code data-bind="text: queryChar"></code></td>
  810. <td><code data-bind="text: query().substring(0, 100) + '...'"></code></td>
  811. <td data-bind="text: complexity, css: {'alert-success': complexity() == 'Low', 'alert-warning': complexity() == 'Medium', 'alert-danger': complexity() == 'High'}" class="alert"></td>
  812. <td data-bind="text: hiveCompatible"></td>
  813. <td data-bind="text: impalaCompatible"></td>
  814. </tr>
  815. </tbody>
  816. </table>
  817. <div data-bind="visible: ! loadingQueries() && $data.optimizerDetails().queryList().length == 0" class="empty-message">
  818. ${ _('No queries found for the current table.') }
  819. </div>
  820. </script>
  821. <script type="text/html" id="metastore-details-tab">
  822. <!-- ko with: tableDetails -->
  823. <table class="properties-table">
  824. <tbody data-bind="foreach: properties">
  825. <!-- ko if: col_name.indexOf('#') === 0 -->
  826. <tr>
  827. <td colspan="3"><h4 data-bind="text: col_name.substring(1)"></h4></td>
  828. </tr>
  829. <!-- /ko -->
  830. <!-- ko ifnot: col_name.indexOf('#') === 0 -->
  831. <tr>
  832. <td class="property-name" data-bind="text: col_name || '&nbsp;'"></td>
  833. <td data-bind="text: data_type || '&nbsp;'"></td>
  834. <td data-bind="text: comment || '&nbsp;'"></td>
  835. </tr>
  836. <!-- /ko -->
  837. </tbody>
  838. </table>
  839. <!-- /ko -->
  840. </script>
  841. <script type="text/html" id="metastore-describe-table">
  842. <div class="clearfix"></div>
  843. % if has_write_access:
  844. <div style="position: relative;" class="show-inactive-on-hover">
  845. <div style="position:absolute; left: 10px; top: 2px;"><a class="inactive-action pointer toggle-editable" title="${ _('Edit the description') }"><i class="fa fa-pencil vertical-align-top"></i></a></div>
  846. <div style="margin-left: 25px;" data-bind="toggleOverflow: { height: 24 }">
  847. <div style="height: inherit" data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'wysihtml5', toggle: 'manual', toggleElement: '.toggle-editable', placement: 'bottom', forcePlacement: true, placeholder: '${ _ko('Add a description...') }', emptytext: '${ _ko('No description available') }', inputclass:'input-xlarge', rows: 10 }" class="inline-block">
  848. ${ _('Add a description...') }
  849. </div>
  850. </div>
  851. </div>
  852. % else:
  853. <div data-bind="html: comment, attr:{ title: comment }" class="table-description"></div>
  854. %endif
  855. <ul class="nav nav-tabs nav-tabs-border margin-top-30">
  856. <li><a href="#overview" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-overview'); }">${_('Overview')}</a></li>
  857. <li><a href="#columns" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-columns'); }">${_('Columns')} (<span data-bind="text: columns().length"></span>)</a></li>
  858. <!-- ko if: tableDetails() && tableDetails().partition_keys.length -->
  859. <li><a href="#partitions" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-partitions'); }">${_('Partitions')} (<span data-bind="text: partitionsCountLabel"></span>)</a></li>
  860. <!-- /ko -->
  861. <li><a href="#sample" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-sample'); }">${_('Sample')}</a></li>
  862. <!-- ko if: $root.optimizerEnabled() -->
  863. <!-- ko if: $root.database().table().optimizerDetails() -->
  864. ##<li><a href="#permissions" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-permissions'); }">${_('Permissions')}</a></li>
  865. ##<li><a href="#queries" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-queries'); }">${_('Queries')} (<span data-bind="text: $root.database().table().optimizerDetails().queryCount"></span>)</a></li>
  866. ##<li><a href="#joins" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-joins'); }">${_('Joins')} (<span data-bind="text: $root.database().table().optimizerDetails().joinCount"></span>)</a></li>
  867. <!-- /ko -->
  868. ##<!-- ko if: $root.database().table().relationshipsDetails() -->
  869. ##<li><a href="#relationships" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-relationships'); }">${_('Relationships')} (<span data-bind="text: $root.database().table().relationshipsDetails().inputs().length + $root.database().table().relationshipsDetails().targets().length"></span>)</a></li>
  870. ##<!-- /ko -->
  871. <!-- /ko -->
  872. <li><a href="#details" data-toggle="tab" data-bind="click: function(){ $root.currentTab('table-details'); }">${ _('Details') }</a></li>
  873. </ul>
  874. <div class="tab-content margin-top-10" style="border: none; overflow: hidden">
  875. <div class="tab-pane" id="overview">
  876. <!-- ko if: $root.currentTab() == 'table-overview' -->
  877. <!-- ko template: 'metastore-overview-tab' --><!-- /ko -->
  878. <!-- /ko -->
  879. </div>
  880. <div class="tab-pane" id="columns">
  881. <!-- ko if: $root.currentTab() == 'table-columns' -->
  882. <input class="input-xlarge search-query margin-left-10" type="text" placeholder="${ _('Search for a column...') }" data-bind="clearable: columnQuery, value: columnQuery, valueUpdate: 'afterkeydown'"/>
  883. <div class="margin-top-10">
  884. <!-- ko template: 'metastore-columns-tab' --><!-- /ko -->
  885. </div>
  886. <!-- /ko -->
  887. </div>
  888. <div class="tab-pane" id="partitions">
  889. <!-- ko if: $root.currentTab() == 'table-partitions' -->
  890. <!-- ko template: 'metastore-partitions-tab' --><!-- /ko -->
  891. <!-- /ko -->
  892. </div>
  893. <div class="tab-pane" id="sample">
  894. <!-- ko if: $root.currentTab() == 'table-sample' -->
  895. <!-- ko template: 'metastore-sample-tab' --><!-- /ko -->
  896. <!-- /ko -->
  897. </div>
  898. <div class="tab-pane" id="permissions">
  899. <div class="acl-panel-content" style="height: 988px;">
  900. <div class="pull-right">
  901. <input class="input-medium no-margin" type="text" placeholder="Search privileges..."> &nbsp;
  902. <a class="btn pointer">
  903. <i class="fa fa-plus-circle"></i> Add role
  904. </a>
  905. </div>
  906. <h4 style="margin-top: 4px;">Privileges &nbsp;</h4>
  907. <div class="acl-block-title">
  908. <i class="fa fa-cube muted"></i> <a class="pointer"><span>customerFraud</span></a>
  909. </div>
  910. <div>
  911. <div class="acl-block acl-block-airy">
  912. <span class="muted" title="3 months ago">TABLE</span>
  913. <span>
  914. <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
  915. </span>
  916. <br>
  917. server=<span>server1</span>
  918. <span>
  919. <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().name"></span></a>
  920. </span>
  921. <span>
  922. <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: name"></span></a>
  923. </span>
  924. <span style="display: none;">
  925. <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
  926. </span>
  927. <i class="fa fa-long-arrow-right"></i> action=INSERT
  928. </div>
  929. <div class="acl-block acl-block-airy">
  930. <span class="muted" title="3 months ago">TABLE</span>
  931. <span>
  932. <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
  933. </span>
  934. <br>
  935. server=server1
  936. <span>
  937. <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().name"></span></a>
  938. </span>
  939. <span>
  940. <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: name"></span></a>
  941. </span>
  942. <span style="display: none;">
  943. <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
  944. </span>
  945. <i class="fa fa-long-arrow-right"></i> action=<span>SELECT</span>
  946. </div>
  947. </div>
  948. <div class="acl-block acl-actions">
  949. <span class="pointer" title="Show 50 more..." style="display: none;"><i class="fa fa-ellipsis-h"></i></span>
  950. <span class="pointer" title="Add privilege"><i class="fa fa-plus"></i></span>
  951. <span class="pointer" title="Undo" style="display: none;"> &nbsp; <i class="fa fa-undo"></i></span>
  952. <span class="pointer" title="Save" style="display: none;"> &nbsp; <i class="fa fa-save"></i></span>
  953. </div>
  954. <div class="acl-block-title">
  955. <i class="fa fa-cube muted"></i> <a class="pointer"><span>customerAccess</span></a>
  956. </div>
  957. <div>
  958. <div class="acl-block acl-block-airy">
  959. <span class="muted" title="3 months ago">TABLE</span>
  960. <span>
  961. <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
  962. </span>
  963. <br>
  964. server=server1
  965. <span>
  966. <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().name"></span></a>
  967. </span>
  968. <span>
  969. <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: name"></span></a>
  970. </span>
  971. <span style="display: none;">
  972. <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
  973. </span>
  974. <i class="fa fa-long-arrow-right"></i> action=<span>ALL</span>
  975. </div>
  976. <div class="acl-block acl-actions">
  977. <span class="pointer" title="Show 50 more..." style="display: none;"><i class="fa fa-ellipsis-h"></i></span>
  978. <span class="pointer" title="Add privilege"><i class="fa fa-plus"></i></span>
  979. <span class="pointer" title="Undo" style="display: none;"> &nbsp; <i class="fa fa-undo"></i></span>
  980. <span class="pointer" title="Save" style="display: none;"> &nbsp; <i class="fa fa-save"></i></span>
  981. </div>
  982. </div>
  983. </div>
  984. </div>
  985. <div class="tab-pane" id="queries">
  986. <!-- ko if: $root.optimizerEnabled() && $root.currentTab() == 'table-queries' -->
  987. <!-- ko template: {name: 'metastore-queries-tab', data: $root.database().table()} --><!-- /ko -->
  988. <!-- /ko -->
  989. </div>
  990. <div class="tab-pane" id="joins">
  991. <!-- ko if: $root.optimizerEnabled() && $root.database().table().optimizerDetails() -->
  992. <!-- ko with: $root.database().table().optimizerDetails().joinTables -->
  993. <table data-bind="visible: $data.length > 0" class="table table-condensed">
  994. <thead>
  995. <tr>
  996. <th width="10%">${ _('Id') }</th>
  997. <th width="10%">${ _('Popularity') }</th>
  998. <th width="30%">${ _('Table Name') }</th>
  999. <th>${ _('Join Column') }</th>
  1000. <th width="10%">${ _('Join counts') }</th>
  1001. </tr>
  1002. </thead>
  1003. <tbody data-bind="hueach: {data: $data, itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 200}">
  1004. <tr>
  1005. <td data-bind="text: tableEid"></td>
  1006. <td style="height: 10px; width: 70px; margin-top:5px;" data-bind="attr: {'title': joinpercent()}">
  1007. <div class="progress bar" style="background-color: #0B7FAD" data-bind="style: { 'width' : joinpercent() + '%' }"></div>
  1008. </td>
  1009. <td><a data-bind="text: tableName, attr: { href: '/metastore/table/' + $root.database().name + '/' + tableName() }"></a></td>
  1010. <td class="pointer"><code data-bind="text: joinColumns, click: $root.scrollToColumn"></code></td>
  1011. <td data-bind="text: numJoins"></td>
  1012. </tr>
  1013. </tbody>
  1014. </table>
  1015. <!-- /ko -->
  1016. <!-- /ko -->
  1017. </div>
  1018. <div class="tab-pane" id="relationships">
  1019. <!-- ko if: $root.currentTab() == 'table-relationships' && $root.database().table().relationshipsDetails() -->
  1020. <!-- ko with: $root.database().table().relationshipsDetails() -->
  1021. <h4>${ _('Inputs') }</h4>
  1022. <div class="row-fluid">
  1023. <!-- ko foreach: inputs -->
  1024. <div data-bind="text: $data"></div>
  1025. <!-- /ko -->
  1026. <!-- ko if: inputs().length == 0 -->
  1027. ${ _('Not inputs') }
  1028. <!-- /ko -->
  1029. </div>
  1030. <br/>
  1031. <h4>${ _('Targets') }</h4>
  1032. <div class="row-fluid">
  1033. <!-- ko foreach: targets -->
  1034. <div data-bind="text: $data"></div>
  1035. <!-- /ko -->
  1036. <!-- ko if: targets().length == 0 -->
  1037. ${ _('Not targets') }
  1038. <!-- /ko -->
  1039. </div>
  1040. <br/>
  1041. <h4>${ _('Source query') }</h4>
  1042. <div class="row-fluid">
  1043. <!-- ko if: source_query().length > 0 -->
  1044. <code data-bind="text: source_query"></code>
  1045. <!-- /ko -->
  1046. <!-- ko if: source_query().length == 0 -->
  1047. ${ _('No source query') }
  1048. <!-- /ko -->
  1049. </div>
  1050. <br/>
  1051. <h4>${ _('Target queries') }</h4>
  1052. <div class="row-fluid">
  1053. <!-- ko foreach: target_queries -->
  1054. <div>
  1055. <code data-bind="text: $data"></code>
  1056. </div>
  1057. <!-- /ko -->
  1058. <!-- ko if: target_queries().length == 0 -->
  1059. ${ _('Not target queries') }
  1060. <!-- /ko -->
  1061. </div>
  1062. <br/>
  1063. <h4>${ _('Lineage') }</h4>
  1064. <div class="row-fluid">
  1065. <button class="btn toolbarBtn" title="${_('Open in Navigator ')}" data-bind="click: function () { window.open($root.navigatorUrl() + '?view=detailsView&id=' + id() + '&b=rFlCX&tab=lineage', '_blank'); }">
  1066. <i class="fa fa-skyatlas"></i> ${_('View in Navigator')}
  1067. </button>
  1068. </div>
  1069. <!-- /ko -->
  1070. <!-- /ko -->
  1071. </div>
  1072. <div class="tab-pane" id="details">
  1073. <!-- ko if: $root.currentTab() == 'table-details' -->
  1074. <!-- ko template: 'metastore-details-tab' --><!-- /ko -->
  1075. <!-- /ko -->
  1076. </div>
  1077. </div>
  1078. </script>
  1079. <span id="metastoreComponents">
  1080. % if not is_embeddable:
  1081. <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function () { $root.isLeftPanelVisible(true); }">
  1082. <i class="fa fa-chevron-right"></i>
  1083. </a>
  1084. % endif
  1085. <div class="main-content">
  1086. <div class="vertical-full container-fluid" data-bind="style: { 'padding-left' : $root.isLeftPanelVisible() ? '0' : '20px' }">
  1087. <div class="vertical-full row-fluid panel-container">
  1088. % if not is_embeddable:
  1089. <div class="assist-container left-panel" data-bind="visible: $root.isLeftPanelVisible() && $root.assistAvailable()">
  1090. <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { $root.isLeftPanelVisible(false) }">
  1091. <i class="fa fa-chevron-left"></i>
  1092. </a>
  1093. <div class="assist" data-bind="component: {
  1094. name: 'assist-panel',
  1095. params: {
  1096. user: '${user.username}',
  1097. sql: {
  1098. navigationSettings: {
  1099. openItem: true,
  1100. showStats: true
  1101. }
  1102. },
  1103. visibleAssistPanels: ['sql']
  1104. }
  1105. }"></div>
  1106. </div>
  1107. <div class="resizer" data-bind="visible: $root.isLeftPanelVisible() && $root.assistAvailable(), splitDraggable : { appName: 'notebook', leftPanelVisible: $root.isLeftPanelVisible }"><div class="resize-bar">&nbsp;</div></div>
  1108. % endif
  1109. <div class="content-panel" ${ not is_embeddable and 'data-bind="niceScroll"' or ''}>
  1110. <div class="metastore-main">
  1111. <!-- ko hueSpinner: { spin: loading, center: true, size: 'xlarge' } --><!-- /ko -->
  1112. <!-- ko ifnot: loading -->
  1113. <h1>
  1114. <!-- ko template: { if: database() !== null && database().table() !== null, name: 'metastore-describe-table-actions' }--><!-- /ko -->
  1115. <!-- ko template: { if: database() !== null && database().table() === null, name: 'metastore-tables-actions' }--><!-- /ko -->
  1116. <!-- ko template: { if: database() === null, name: 'metastore-databases-actions' }--><!-- /ko -->
  1117. <!-- ko template: 'metastore-breadcrumbs' --><!-- /ko -->
  1118. </h1>
  1119. <!-- ko template: { if: !loading() && database() === null, name: 'metastore-databases' } --><!-- /ko -->
  1120. <!-- ko with: database -->
  1121. <i data-bind="visible: loading" class="fa fa-spinner fa-spin fa-2x margin-left-10" style="color: #999; display: none;"></i>
  1122. <!-- ko template: { if: !loading() && table() === null, name: 'metastore-tables' } --><!-- /ko -->
  1123. <!-- ko with: table -->
  1124. <!-- ko template: 'metastore-describe-table' --><!-- /ko -->
  1125. <!-- /ko -->
  1126. <!-- /ko -->
  1127. <!-- /ko -->
  1128. </div>
  1129. </div>
  1130. </div>
  1131. </div>
  1132. <div id="dropSingleTable" class="modal hide fade">
  1133. % if is_embeddable:
  1134. <form data-bind="submit: dropAndWatch" method="POST">
  1135. <input type="hidden" name="is_embeddable" value="true"/>
  1136. <input type="hidden" name="start_time" value=""/>
  1137. <input type="hidden" name="source_type" data-bind="value: $root.sourceType"/>
  1138. % else:
  1139. <form method="POST">
  1140. % endif
  1141. ${ csrf_token(request) | n,unicode }
  1142. <div class="modal-header">
  1143. <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
  1144. <h2 class="modal-title">${_('Drop Table')}</h2>
  1145. </div>
  1146. <div class="modal-body">
  1147. <div>${_('Do you really want to drop the table')} <span style="font-weight: bold;" data-bind="text: database() && database().table() ? database().table().name : ''"></span>?</div>
  1148. </div>
  1149. <div class="modal-footer">
  1150. <input type="hidden" name="table_selection" data-bind="value: database() && database().table() ? database().table().name : ''" />
  1151. <input type="button" class="btn" data-dismiss="modal" value="${_('No')}"/>
  1152. <input type="submit" data-bind="click: function (vm, e) { var $form = $(e.target).parents('form'); $form.attr('action', '/metastore/tables/drop/' + vm.database().name); return true; }" class="btn btn-danger" value="${_('Yes, drop this table')}"/>
  1153. </div>
  1154. </form>
  1155. </div>
  1156. <div id="import-data-modal" class="modal hide fade" style="display: block;width: 680px;margin-left: -340px!important;"></div>
  1157. </div>
  1158. </span>
  1159. <script type="text/javascript">
  1160. function dropAndWatch(formElement) {
  1161. $(formElement).find('input[name=start_time]').val(ko.mapping.toJSON(new Date().getTime()));
  1162. $(formElement).ajaxSubmit({
  1163. dataType: 'json',
  1164. success: function(resp) {
  1165. if (resp.history_uuid) {
  1166. huePubSub.publish('notebook.task.submitted', resp.history_uuid);
  1167. huePubSub.publish('metastore.clear.selection');
  1168. } else if (resp && resp.message) {
  1169. $(document).trigger("error", resp.message);
  1170. }
  1171. $("#dropTable").modal('hide');
  1172. $("#dropSingleTable").modal('hide');
  1173. $("#dropDatabase").modal('hide');
  1174. $("#dropPartition").modal('hide');
  1175. },
  1176. error: function (xhr, textStatus, errorThrown) {
  1177. $(document).trigger("error", xhr.responseText);
  1178. }
  1179. });
  1180. }
  1181. function browsePartitionFolder(url) {
  1182. $.get(url, {
  1183. format: "json"
  1184. },function(resp) {
  1185. if (resp.uri_path) {
  1186. huePubSub.publish('open.link', resp.uri_path);
  1187. } else if (resp.message) {
  1188. $(document).trigger("error", resp.message);
  1189. }
  1190. }).fail(function (xhr) {
  1191. $(document).trigger("error", xhr.responseText);
  1192. });
  1193. }
  1194. function queryAndWatch(url, sourceType) {
  1195. $.post(url, {
  1196. format: "json",
  1197. sourceType: sourceType
  1198. },function(resp) {
  1199. if (resp.history_uuid) {
  1200. huePubSub.publish('open.editor.query', resp.history_uuid);
  1201. } else if (resp.message) {
  1202. $(document).trigger("error", resp.message);
  1203. }
  1204. }).fail(function (xhr) {
  1205. $(document).trigger("error", xhr.responseText);
  1206. });
  1207. }
  1208. (function () {
  1209. ko.options.deferUpdates = true;
  1210. $(document).ready(function () {
  1211. var options = {
  1212. user: '${ user.username }',
  1213. % if is_embeddable:
  1214. hue4: true,
  1215. % endif
  1216. optimizerEnabled: '${ is_optimizer_enabled }' === 'True',
  1217. navigatorEnabled: '${ is_navigator_enabled }' === 'True',
  1218. optimizerUrl: '${ optimizer_url }',
  1219. navigatorUrl: '${ navigator_url }',
  1220. sourceType: '${ source_type }'
  1221. };
  1222. var viewModel = new MetastoreViewModel(options);
  1223. huePubSub.subscribe('metastore.scroll.to.top', function () {
  1224. $('${ MAIN_SCROLLABLE }').scrollTop(0);
  1225. $('${ MAIN_SCROLLABLE }').getNiceScroll().resize();
  1226. });
  1227. huePubSub.subscribe('metastore.clear.selection', function () {
  1228. viewModel.selectedDatabases.removeAll();
  1229. if (viewModel.database()) {
  1230. viewModel.database().selectedTables.removeAll();
  1231. }
  1232. }, 'metastore');
  1233. viewModel.currentTab.subscribe(function(tab){
  1234. if (tab == 'table-relationships') {
  1235. // viewModel.database().table().getRelationships();
  1236. } else if (tab == 'table-sample') {
  1237. var selector = '#sample .sample-table';
  1238. % if conf.CUSTOM.BANNER_TOP_HTML.get():
  1239. var bannerTopHeight = 30;
  1240. % else:
  1241. var bannerTopHeight = 0;
  1242. % endif
  1243. if ($(selector).parents('.dataTables_wrapper').length == 0){
  1244. hueUtils.waitForRendered(selector, function(el){ return el.find('td').length > 0 }, function(){
  1245. $(selector).dataTable({
  1246. "bPaginate": false,
  1247. "bLengthChange": false,
  1248. "bInfo": false,
  1249. "bDestroy": true,
  1250. "bFilter": false,
  1251. "bAutoWidth": false,
  1252. "oLanguage": {
  1253. "sEmptyTable": "${_('No data available')}",
  1254. "sZeroRecords": "${_('No matching records')}"
  1255. },
  1256. "fnDrawCallback": function (oSettings) {
  1257. $(selector).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
  1258. $(selector).jHueTableExtender2({
  1259. fixedHeader: true,
  1260. fixedFirstColumn: true,
  1261. includeNavigator: false,
  1262. lockSelectedRow: false,
  1263. parentId: 'sample',
  1264. classToRemove: 'sample-table',
  1265. mainScrollable: '${ MAIN_SCROLLABLE }',
  1266. % if is_embeddable:
  1267. stickToTopPosition: 51 + bannerTopHeight,
  1268. % else:
  1269. stickToTopPosition: 76 + bannerTopHeight,
  1270. % endif
  1271. clonedContainerPosition: 'fixed',
  1272. app: 'metastore'
  1273. });
  1274. $(selector).jHueHorizontalScrollbar();
  1275. },
  1276. "aoColumnDefs": [
  1277. {
  1278. "sType": "numeric",
  1279. "aTargets": [ "sort-numeric" ]
  1280. },
  1281. {
  1282. "sType": "string",
  1283. "aTargets": [ "sort-string" ]
  1284. },
  1285. {
  1286. "sType": "date",
  1287. "aTargets": [ "sort-date" ]
  1288. }
  1289. ]
  1290. });
  1291. });
  1292. }
  1293. }
  1294. $('${ MAIN_SCROLLABLE }').getNiceScroll().resize();
  1295. });
  1296. viewModel.scrollToColumn = function (col) {
  1297. if (!col.table.samples.loading()) {
  1298. $('a[href="#sample"]').click();
  1299. hueUtils.waitForRendered('#sample .sample-table', function (el) {
  1300. return el.parent().hasClass('dataTables_wrapper')
  1301. }, function () {
  1302. var sampleTable = $('#sample .sample-table');
  1303. var sampleCol = sampleTable.find('th').filter(function () {
  1304. return $.trim($(this).text()).indexOf(col.name()) > -1;
  1305. });
  1306. sampleTable.find('.columnSelected').removeClass('columnSelected');
  1307. sampleTable.find('tr td:nth-child(' + (sampleCol.index() + 1) + ')').addClass('columnSelected');
  1308. var scrollLeft = 0;
  1309. sampleTable.find('th:lt(' + sampleCol.index() + ')').each(function () {
  1310. scrollLeft += $(this).outerWidth();
  1311. });
  1312. scrollLeft = Math.max(0, scrollLeft - 40);
  1313. sampleTable.parent().scrollLeft(scrollLeft);
  1314. sampleTable.parent().trigger('scroll_update');
  1315. });
  1316. }
  1317. }
  1318. ko.applyBindings(viewModel, $('#metastoreComponents')[0]);
  1319. if (location.getParameter('refresh') === 'true') {
  1320. huePubSub.publish('assist.db.refresh', { sourceTypes: [viewModel.sourceType()] });
  1321. hueUtils.replaceURL('?');
  1322. }
  1323. });
  1324. })();
  1325. </script>
  1326. </span>
  1327. % if not is_embeddable:
  1328. ${ commonfooter(request, messages) | n,unicode }
  1329. % endif