metastore.mako 64 KB

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