| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275 |
- ## Licensed to Cloudera, Inc. under one
- ## or more contributor license agreements. See the NOTICE file
- ## distributed with this work for additional information
- ## regarding copyright ownership. Cloudera, Inc. licenses this file
- ## to you under the Apache License, Version 2.0 (the
- ## "License"); you may not use this file except in compliance
- ## with the License. You may obtain a copy of the License at
- ##
- ## http://www.apache.org/licenses/LICENSE-2.0
- ##
- ## Unless required by applicable law or agreed to in writing, software
- ## distributed under the License is distributed on an "AS IS" BASIS,
- ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ## See the License for the specific language governing permissions and
- ## limitations under the License.
- <%!
- from django.utils.html import escape
- from django.utils.translation import ugettext as _
- from desktop import conf
- from desktop.conf import USE_NEW_EDITOR, IS_EMBEDDED
- from desktop.lib.i18n import smart_unicode
- from desktop.views import commonheader, commonfooter, _ko
- from beeswax.conf import LIST_PARTITIONS_LIMIT
- from metastore.conf import ENABLE_NEW_CREATE_TABLE
- %>
- <%namespace name="actionbar" file="actionbar.mako" />
- <%namespace name="assist" file="/assist.mako" />
- <%namespace name="components" file="components.mako" />
- <%
- MAIN_SCROLLABLE = is_embeddable and ".page-content" or ".content-panel"
- if conf.CUSTOM.BANNER_TOP_HTML.get():
- TOP_SNAP = is_embeddable and "82px" or "108px"
- else:
- TOP_SNAP = is_embeddable and "52px" or "78px"
- %>
- % if not is_embeddable:
- ${ commonheader(_("Metastore"), app_name, user, request) | n,unicode }
- <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
- <script src="${ static('desktop/ext/js/jquery/plugins/jquery.mousewheel.min.js') }"></script>
- <script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
- <script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
- <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }"></script>
- <script src="${ static('desktop/js/ko.editable.js') }"></script>
- ${ assist.assistJSModels() }
- <link rel="stylesheet" href="${ static('notebook/css/notebook-layout.css') }">
- <style type="text/css">
- % if conf.CUSTOM.BANNER_TOP_HTML.get():
- .show-assist {
- top: 110px!important;
- }
- .main-content {
- top: 112px!important;
- }
- % endif
- </style>
- ${ assist.assistPanel() }
- % endif
- <script src="${ static('desktop/ext/js/wysihtml5-0.3.0.min.js') }"></script>
- <script src="${ static('desktop/js/bootstrap-wysihtml5-0.0.2.js') }"></script>
- <script src="${ static('desktop/ext/js/bootstrap-editable.wysihtml5.js') }"></script>
- <script src="${ static('beeswax/js/stats.utils.js') }"></script>
- <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-editable.css') }">
- <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-wysihtml5-0.0.2.css') }">
- <link rel="stylesheet" href="${ static('notebook/css/notebook.css') }">
- <span class="notebook">
- ${ components.menubar(is_embeddable) }
- <script src="${ static('metastore/js/metastore.ko.js') }"></script>
- <link rel="stylesheet" href="${ static('metastore/css/metastore.css') }" type="text/css">
- <script type="text/html" id="metastore-breadcrumbs">
- <div style="font-size: 14px; margin: 0 12px; line-height: 27px;">
- <div data-bind="component: { name: 'hue-drop-down', params: { value: source, entries: sources, onChanged: sourceChanged, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Source') }' } }" style="display: inline-block"></div>
- <!-- ko with: source -->
- <!-- ko if: namespaces().length > 1 || namespaceRefreshEnabled() -->
- <div class="margin-left-10" data-bind="component: { name: 'hue-drop-down', params: { value: namespace, entries: namespaces, onChanged: namespaceChanged, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Namespace') }' } }" style="display: inline-block"></div>
- <!-- /ko -->
- <!-- /ko -->
- </div>
- <ul style="padding-top: 0" class="nav nav-pills hue-breadcrumbs-bar" id="breadcrumbs">
- <!-- ko with: source -->
- <!-- ko with: namespace -->
- <li>
- <a href="javascript:void(0);" data-bind="click: $root.databasesBreadcrumb">${_('Databases')}
- <!-- ko if: database -->
- <span class="divider">></span>
- <!-- /ko -->
- </a>
- </li>
- <!-- ko with: database -->
- <li>
- <a href="javascript:void(0);" data-bind="click: $root.tablesBreadcrumb">
- <span data-bind="text: catalogEntry.name"></span>
- <!-- ko with: table -->
- <span class="divider">></span>
- <!-- /ko -->
- </a>
- </li>
- <!-- ko with: table -->
- <li class="editable-breadcrumbs" title="${_('Edit path')}" data-bind="click: function(){ $parent.editingTable(true); }, visible: !$parent.editingTable()">
- <a href="javascript:void(0)" data-bind="text: catalogEntry.name"></a>
- </li>
- <!-- /ko -->
- <!-- ko if: editingTable -->
- <!-- ko with: table -->
- <li class="editable-breadcrumb-input">
- <input type="text" data-bind="hivechooser: { data: catalogEntry.name, database: $parent.catalogEntry.name, namespace: $parent.catalogEntry.namespace, compute: $parent.catalogEntry.compute, skipColumns: true, searchEverywhere: true, onChange: function(val) { $parent.setTableByName(val); $parent.editingTable(false); }, apiHelperUser: '${ user }', apiHelperType: $root.source().type }" autocomplete="off" />
- </li>
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- </ul>
- </script>
- <script type="text/html" id="metastore-partition-columns-table">
- <div style="overflow-x: auto; overflow-y: hidden">
- <table class="table table-condensed table-nowrap metastore-table">
- <thead>
- <tr>
- <th style="width: 1%"> </th>
- <th>${_('Name')}</th>
- <th>${_('Type')}</th>
- </tr>
- </thead>
- <tbody>
- <!-- ko foreach: detailedKeys -->
- <tr>
- <td data-bind="text: $index() + 1"></td>
- <td data-bind="text: $data.name"></td>
- <td data-bind="text: $data.type"></td>
- </tr>
- <!-- /ko -->
- </tbody>
- </table>
- </div>
- </script>
- <script type="text/html" id="metastore-partition-values-table">
- <div style="overflow-x: auto; overflow-y: hidden">
- <table id="partitionsTable" class="table table-condensed table-nowrap metastore-table">
- <thead>
- <tr>
- <th style="width: 1%" class="vertical-align-middle">
- <!-- ko ifnot: $data.withDrop -->
-
- <!-- /ko -->
- <!-- ko if: $data.withDrop -->
- <div class="hue-checkbox fa" data-bind="hueCheckAll: { allValues: $data.values, selectedValues: $data.selectedValues }"></div>
- <!-- /ko -->
- </th>
- <th>${_('Values')}</th>
- <th>${_('Spec')}</th>
- <th data-bind="visible: $root.source().type !== 'impala'">${_('Browse')}</th>
- </tr>
- </thead>
- <tbody>
- <!-- ko foreach: $data.values -->
- <tr>
- <td>
- <!-- ko ifnot: $parent.withDrop -->
- <span data-bind="text: $index() + 1"></span>
- <!-- /ko -->
- <!-- ko if: $parent.withDrop -->
- <div class="hue-checkbox fa" data-bind="multiCheck: '#partitionsTable', value: $data, hueChecked: $parent.selectedValues"></div>
- <!-- /ko -->
- </td>
- <td title="${_('Query partition data')}">
- <!-- ko if: IS_HUE_4 -->
- <a data-bind="click: function() { queryAndWatch(notebookUrl, $root.source().type); }, text: '[\'' + columns.join('\',\'') + '\']'" href="javascript:void(0)"></a>
- <!-- /ko -->
- <!-- ko if: ! IS_HUE_4 -->
- <a data-bind="attr: { 'href': readUrl }, text: '[\'' + columns.join('\',\'') + '\']'"></a>
- <!-- /ko -->
- </td>
- <td data-bind="text: partitionSpec"></td>
- <td data-bind="visible: $root.source().type != 'impala'">
- <!-- ko if: IS_HUE_4 -->
- <a data-bind="click: function () { browsePartitionFolder(browseUrl); }" href="javascript:void(0)" title="${_('Browse partition files')}">
- ${_('Files')}
- </a>
- <!-- /ko -->
- <!-- ko if: ! IS_HUE_4 -->
- <a data-bind="attr: { 'href': browseUrl }" title="${_('Browse partition files')}">${_('Files')}</a>
- <!-- /ko -->
- </td>
- </tr>
- <!-- /ko -->
- </tbody>
- </table>
- </div>
- </script>
- <script type="text/html" id="metastore-samples-table">
- <div data-bind="delayedOverflow">
- <table id="sampleTable" class="table table-condensed table-nowrap sample-table old-datatable metastore-table">
- <thead>
- <tr>
- <th style="width: 1%"> </th>
- <!-- ko foreach: headers -->
- <th data-bind="text: $data"></th>
- <!-- /ko -->
- </tr>
- </thead>
- <tbody>
- <!-- ko foreach: rows -->
- <tr>
- <td data-bind="text: $index() + 1"></td>
- <!-- ko foreach: $data -->
- <td data-bind="html: $data"></td>
- <!-- /ko -->
- </tr>
- <!-- /ko -->
- </tbody>
- </table>
- </div>
- <div id="jumpToColumnAlert" class="alert hide" style="margin-top: 12px;">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <strong>${_('Did you know?')}</strong>
- <ul>
- <li>${ _('If the sample contains a large number of columns, click a row to select a column to jump to') }</li>
- </ul>
- </div>
- </script>
- <script type="text/html" id="metastore-table-properties">
- <!-- ko with: tableDetails -->
- <h4>${ _('Properties') } <i data-bind="visible: $parent.loadingDetails()" class="fa fa-spinner fa-spin" style="display: none;"></i></h4>
- <div class="row-fluid">
- <div class="metastore-property">
- <!-- ko if: is_view -->
- ${ _('View') }
- <!-- /ko -->
- <!-- ko ifnot: is_view -->
- <span data-bind="visible: partition_keys.length" style="display: none;">
- <a class="pointer" data-bind="click: function() { $root.currentTab('partitions'); $('.page-content').scrollTop(0); }">
- ${ _("Partitioned") }
- </a>
- </span>
- ${ _('Table') }
- <!-- /ko -->
- </div>
- <!-- ko ifnot: is_view -->
- <div class="metastore-property">
- <!-- ko if: details.properties.table_type == 'MANAGED_TABLE' -->
- ${_('Managed')}
- <!-- /ko -->
- <!-- ko if: details.properties.table_type == 'EXTERNAL_TABLE' -->
- ${_('External')}
- <!-- /ko -->
- ${_('and stored in')}
- <!-- ko if: details.properties.format === 'kudu' -->
- <div>${_('Kudu')}</div>
- <!-- /ko -->
- <!-- ko if: details.properties.format !== 'kudu' -->
- <div>
- % if IS_EMBEDDED.get():
- <span data-bind="attr: {'title': path_location}">${_('location')}</span>
- % else:
- <a href="javascript: void(0);" data-bind="storageContextPopover: { path: hdfs_link.replace('/filebrowser/view=', ''), offset: { left: 5 } }"> ${_('location')}</a>
- % endif
- </div>
- <!-- /ko -->
- </div>
- <!-- /ko -->
- <div class="metastore-property">
- ${ _('Created by') }
- <span data-bind="text: details.properties.owner"></span>
- ${ _('on') }
- <span data-bind="text: localeFormat(details.properties.create_time) != 'Invalid Date' ? localeFormat(details.properties.create_time) : details.properties.create_time"></span>
- </div>
- </div>
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-table-stats">
- <!-- ko if: tableDetails() && ! tableDetails().is_view -->
- <!-- ko with: tableDetails -->
- <h4>${ _('Stats') }
- <!-- ko ifnot: partition_keys.length -->
- % if has_write_access:
- <!-- ko if: $parent.refreshingTableStats -->
- <i class="fa fa-refresh fa-spin"></i>
- <!-- /ko -->
- <!-- ko ifnot: $parent.refreshingTableStats() || is_view -->
- <a class="pointer" href="javascript: void(0);" data-bind="click: $parent.refreshTableStats"><i class="fa fa-refresh"></i></a>
- <!-- /ko -->
- % endif
- <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>
- <!-- /ko -->
- </h4>
- <div class="row-fluid">
- <!-- ko with: $parent.tableStats -->
- <!-- ko if: typeof numFiles !== 'undefined' && typeof last_modified_by === 'undefined' -->
- <span class="metastore-property">
- <div>${ _('Files') }</div>
- <div data-bind="text: numFiles"></div>
- </span>
- <!-- /ko -->
- <!-- ko if: typeof numRows !== 'undefined' -->
- <span class="metastore-property">
- <div>${ _('Rows') }</div>
- <div data-bind="text: numRows"></div>
- </span>
- <!-- /ko -->
- <!-- ko if: typeof totalSize !== 'undefined' && typeof last_modified_by === 'undefined' -->
- <span class="metastore-property">
- <div>${ _('Total size') }</div>
- <div data-bind="text: filesize(totalSize)"></div>
- </span>
- <!-- /ko -->
- <!-- ko if: typeof transient_lastDdlTime !== 'undefined' -->
- <div class="metastore-property">
- ${ _('Data last updated on') }
- <span data-bind="text: localeFormat(transient_lastDdlTime * 1000)"></span>
- </div>
- <!-- /ko -->
- <!-- ko if: typeof last_modified_time !== 'undefined' -->
- <div class="metastore-property">
- ${ _('Schema last modified on') }
- <span data-bind="text: localeFormat(last_modified_time*1000)"></span>
- ${ _('by') }
- <span data-bind="text: last_modified_by"></span>
- </div>
- <!-- /ko -->
- <!-- /ko -->
- </div>
- <!-- /ko -->
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-databases">
- <div class="entries-table-container">
- <div class="actionbar-actions">
- % if has_write_access:
- <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>
- <div id="dropDatabase" class="modal hide fade">
- % if is_embeddable:
- <form action="/metastore/databases/drop" data-bind="submit: dropAndWatch" method="POST">
- <input type="hidden" name="is_embeddable" value="true"/>
- <input type="hidden" name="start_time" value=""/>
- <input type="hidden" name="source_type" data-bind="value: $root.source().type"/>
- % else:
- <form id="dropDatabaseForm" action="/metastore/databases/drop" method="POST">
- % endif
- ${ csrf_token(request) | n,unicode }
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">×</span></button>
- <h2 id="dropDatabaseMessage" class="modal-title">${ _('Do you really want to delete the following database(s)?') }</h2>
- </div>
- <div class="modal-body">
- <ul data-bind="foreach: selectedDatabases">
- <li>
- <span data-bind="text: catalogEntry.name"></span>
- </li>
- </ul>
- </div>
- <div class="modal-footer">
- <div class="label label-important margin-top-5 pull-left">${ _('Warning: This will drop all tables and objects within the database.') }</div>
- <input type="button" class="btn" data-dismiss="modal" value="${_('No')}">
- <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
- </div>
- <!-- ko foreach: selectedDatabases -->
- <input type="hidden" name="database_selection" data-bind="value: catalogEntry.name" />
- <!-- /ko -->
- </form>
- </div>
- % if is_embeddable:
- <button href="javascript: void(0);" class="btn btn-default" data-bind="publish: { 'open.link': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' + '/?sourceType=' + catalogEntry.getSourceType() + '&namespace=' + catalogEntry.namespace.id + '&compute=' + catalogEntry.compute.id }" title="${_('Create a new database')}"><i class="fa fa-plus"></i> ${_('New')}</button>
- % elif ENABLE_NEW_CREATE_TABLE.get():
- <button class="btn btn-default" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' + '/?sourceType=' + catalogEntry.getSourceType() + '&namespace=' + catalogEntry.namespace.id + '&compute=' + catalogEntry.compute.id }" title="${_('Create a new database')}"><i class="fa fa-plus"></i> ${_('New')}</button>
- % else:
- <button href="${ url('beeswax:create_database') }" class="btn btn-default" title="${_('Create a new database')}"><i class="fa fa-plus"></i> ${_('New')}</button>
- % endif
- % endif
- </div>
- <div class="entries-table-no-header">
- <!-- ko if: catalogEntry() -->
- <!-- ko component: { name: 'catalog-entries-list', params: { catalogEntry: catalogEntry(), contextPopoverEnabled: true, onClick: onDatabaseClick.bind($data), selectedEntries: selectedDatabases, editableDescriptions: /true/i.test('${ has_write_access }') } } --><!-- /ko -->
- <!-- /ko -->
- </div>
- </div>
- </script>
- <script type="text/html" id="metastore-td-description">
- % if has_write_access:
- <div data-bind="visibleOnHover: { selector: '.editable-inline-action' }">
- <div data-bind="editable: comment, editableOptions: {
- mode: 'inline',
- enabled: true,
- type: 'textarea',
- showbuttons: 'bottom',
- inputclass: 'hue-table-browser-desc-input',
- toggle: 'manual',
- toggleElement: '.toggle-editable',
- placeholder: '${ _ko('Add a description...') }',
- emptytext: '${ _ko('Add a description...') }',
- inputclass: 'hue-table-browser-desc-input',
- rows: 6,
- inlineEditAction: { editClass: 'toggle-editable editable-inline-action' },
- multiLineEllipsis: { overflowHeight: '40px', expandable: true, expandActionClass: 'editable-inline-action' }
- }">
- ${ _('Add a description...') }</div>
- </div>
- % else:
- <span style="white-space: pre;" data-bind="text: comment"></span>
- % endif
- </script>
- <script type="text/html" id="metastore-main-description">
- % if has_write_access:
- <!-- ko if: $root.navigatorEnabled() -->
- <div class="hue-table-browser-desc-container" data-bind="visibleOnHover: { selector: '.editable-inline-action' }">
- <div class="hue-table-browser-desc">
- <div data-bind="editable: comment, editableOptions: {
- mode: 'inline',
- enabled: true,
- type: 'textarea',
- showbuttons: 'bottom',
- inputclass: 'hue-table-browser-desc-input',
- toggle: 'manual',
- toggleElement: '.toggle-editable',
- placeholder: '${ _ko('Add a description...') }',
- emptytext: '${ _ko('No description available') }',
- rows: 8,
- inlineEditAction: { editClass: 'toggle-editable editable-inline-action' },
- multiLineEllipsis: { overflowHeight: '120px', expandable: true, expandActionClass: 'editable-inline-action', inlineEditAction: true },
- }" class="inline-block">
- ${ _('Add a description...') }
- </div>
- </div>
- </div>
- <!-- /ko -->
- <!-- ko ifnot: $root.navigatorEnabled() -->
- <div data-bind="text: comment, attr: { title: comment }" class="table-description"></div>
- <!-- /ko -->
- % else:
- <div data-bind="text: comment, attr: { title: comment }" class="table-description"></div>
- %endif
- </script>
- <script type="text/html" id="metastore-nav-tags">
- <!-- ko if: $root.navigatorEnabled() -->
- <div class="metastore-nav-tags" data-bind="component: { name: 'nav-tags', params: { catalogEntry: catalogEntry }}"></div>
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-nav-properties">
- <!-- ko if: $root.navigatorEnabled() -->
- <div data-bind="component: { name: 'nav-properties', params: { catalogEntry: catalogEntry }}"></div>
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-tables">
- <div class="row-fluid">
- <!-- ko if: $root.navigatorEnabled() -->
- <!-- ko template: 'metastore-main-description' --><!-- /ko -->
- <!-- ko template: 'metastore-nav-tags' --><!-- /ko -->
- <!-- ko template: 'metastore-nav-properties' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko with: stats -->
- <div class="span12 tile" style="margin: 5px 10px;">
- <div class="span6 tile">
- <h4>${ _('Properties') }</h4>
- <div>
- <div class="metastore-property">
- <div>${ _('Owner') }</div>
- <div><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></div>
- </div>
- <div class="metastore-property">
- <div>${ _('Location') }</div>
- <div>
- % if IS_EMBEDDED.get():
- <span data-bind="attr: { 'title': location }"> ${_('Location')}</span>
- % else:
- <a href="javascript: void(0);" data-bind="storageContextPopover: { path: hdfs_link.replace('/filebrowser/view=', ''), offset: { left: 5 } }"> ${_('Location')}</a>
- % endif
- </div>
- </div>
- </div>
- </div>
- <!-- ko with: parameters -->
- <div class="row-fluid">
- <div class="span12">
- <div title="${ _('Parameters') }">
- <!-- ko template: { name: 'metastore-databases-parameters', data: hueUtils.parseHivePseudoJson($data) }--><!-- /ko -->
- </div>
- </div>
- </div>
- <!-- /ko -->
- </div>
- <!-- /ko -->
- </div>
- <div class="row-fluid">
- <div class="span12 tile entries-table-container">
- <h4 class="entries-table-header">${ _('Tables') }</h4>
- <div class="actionbar-actions" data-bind="visible: tables().length > 0">
- <button class="btn toolbarBtn margin-left-20" title="${_('Browse the selected table')}" data-bind="click: function () { onTableClick(selectedTables()[0].catalogEntry); selectedTables([]); }, disable: selectedTables().length !== 1"><i class="fa fa-eye"></i> ${_('View')}</button>
- <button class="btn toolbarBtn" title="${_('Query the selected table')}" data-bind="click: function () { IS_HUE_4 ? queryAndWatch('/notebook/browse/' + selectedTables()[0].catalogEntry.path.join('/') + '/', $root.source().type) : location.href = '/notebook/browse/' + selectedTables()[0].catalogEntry.path.join('/'); }, disable: selectedTables().length !== 1">
- <i class="fa fa-play fa-fw"></i> ${_('Query')}
- </button>
- % if has_write_access:
- <button id="dropBtn" class="btn toolbarBtn" title="${_('Drop the selected tables')}" data-bind="click: function () { $('#dropTable').modal('show'); }, disable: selectedTables().length === 0"><i class="fa fa-times"></i> ${_('Drop')}</button>
- % if is_embeddable:
- <button href="javascript: void(0);" class="btn btn-default" data-bind="publish: { 'open.link': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + catalogEntry.name + '/?sourceType=' + catalogEntry.getSourceType() + '&namespace=' + catalogEntry.namespace.id + '&compute=' + catalogEntry.compute.id }" title="${_('Create a new table')}"><i class="fa fa-plus"></i> ${_('New')}</button>
- % elif ENABLE_NEW_CREATE_TABLE.get():
- <button class="btn btn-default" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + catalogEntry.name + '/?sourceType=' + catalogEntry.getSourceType() + '&namespace=' + catalogEntry.namespace.id + '&compute=' + catalogEntry.compute.id }" title="${_('Create a new table')}"><i class="fa fa-plus"></i> ${_('New')}</button>
- % else:
- <button class="btn btn-default" data-bind="attr: { 'href': '/beeswax/create/import_wizard/' + catalogEntry.name }" title="${_('Create a new table from a file')}"><i class="fa fa-stack"></i> ${_('New from file')}</button>
- <button class="btn btn-default" data-bind="attr: { 'href': '/beeswax/create/create_table/' + catalogEntry.name }" title="${_('Create a new table manually')}"><i class="fa fa-plus"></i> ${_('New manually')}</button>
- % endif
- % endif
- </div>
- <!-- ko component: { name: 'catalog-entries-list', params: { catalogEntry: catalogEntry, contextPopoverEnabled: true, onClick: onTableClick.bind($data), selectedEntries: selectedTables, editableDescriptions: /true/i.test('${ has_write_access }') } } --><!-- /ko -->
- </div>
- </div>
- % if has_write_access:
- <div id="dropTable" class="modal hide fade">
- % if is_embeddable:
- <form data-bind="attr: { 'action': '/metastore/tables/drop/' + catalogEntry.name }, submit: dropAndWatch" method="POST">
- <input type="hidden" name="is_embeddable" value="true"/>
- <input type="hidden" name="start_time" value=""/>
- <input type="hidden" name="source_type" data-bind="value: $root.source().type"/>
- % else:
- <form data-bind="attr: { 'action': '/metastore/tables/drop/' +catalogEntry. name }" method="POST">
- % endif
- ${ csrf_token(request) | n,unicode }
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">×</span></button>
- <h2 id="dropTableMessage" class="modal-title">${_('Do you really want to drop the selected table(s)?')}</h2>
- </div>
- <div class="modal-body">
- <ul data-bind="foreach: selectedTables">
- <!-- ko if: $index() <= 9 -->
- <li>
- <span data-bind="text: catalogEntry.name"></span>
- </li>
- <!-- /ko -->
- </ul>
- <!-- ko if: selectedTables().length > 10 -->
- ${_('and')} <span data-bind="text: selectedTables().length - 10"></span> ${_('others')}.<br>
- <!-- /ko -->
- <label class="checkbox" style="display: inline-block; margin-top: 5px">
- <input type="checkbox" name="skip_trash" /> ${ _('Skip the trash') }
- </label>
- </div>
- <div class="modal-footer">
- <input type="button" class="btn" data-dismiss="modal" value="${_('No')}" />
- <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
- </div>
- <!-- ko foreach: selectedTables -->
- <input type="hidden" name="table_selection" data-bind="value: catalogEntry.name" />
- <!-- /ko -->
- </form>
- </div>
- % endif
- </script>
- <script type="text/html" id="metastore-databases-parameters">
- <div data-bind="toggleOverflow: {height: 24}" style="word-break: break-all">
- <div class="inline margin-right-20"><i class="fa fa-fw fa-cog muted"></i></div>
- <!-- ko foreach: Object.keys($data) -->
- <div class="inline margin-right-20"><strong data-bind="text: $data"></strong>: <span data-bind="text: $parent[$data]"></span></div>
- <!-- /ko -->
- </div>
- </script>
- <script type="text/html" id="metastore-overview-tab">
- <div class="row-fluid margin-top-10">
- <div class="span4 tile">
- <!-- ko template: 'metastore-table-properties' --><!-- /ko -->
- </div>
- <div class="span4 tile">
- <!-- ko template: 'metastore-table-stats' --><!-- /ko -->
- </div>
- </div>
- <div class="tile">
- <h4 style="margin-bottom: 5px;">${ _('Schema') } <i data-bind="visible: loadingColumns" class="fa fa-spinner fa-spin" style="display: none;"></i></h4>
- <!-- ko component: { name: 'catalog-entries-list', params: { catalogEntry: catalogEntry, contextPopoverEnabled: true, editableDescriptions: /true/i.test('${ has_write_access }') } } --><!-- /ko -->
- </div>
- </script>
- <script type="text/html" id="metastore-partitions-tab">
- <!-- ko with: partitions -->
- <div class="tile" data-bind="visible: true" style="display: none;">
- <h4>${ _('Columns') }</h4>
- <!-- ko template: 'metastore-partition-columns-table' --><!-- /ko -->
- </div>
- <div class="tile" data-bind="visible: true" style="display: none;">
- <h4>${ _('Partitions') } <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i></h4>
- <!-- ko if: loaded -->
- <div class="row-fluid">
- <div class="span10">
- <div data-bind="visible: filters().length > 0">
- <div data-bind="foreach: filters">
- <div class="filter-box">
- <a href="javascript:void(0)" class="pull-right" data-bind="click: $parent.removeFilter">
- <i class="fa fa-times"></i>
- </a>
- <select class="input-small" data-bind="options: $parent.keys, value: column"></select>
-
- <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...') }" />
- </div>
- </div>
- <div class="pull-left" style="margin-top: 4px; margin-bottom: 10px">
- <a class="add-filter" href="javascript: void(0)" data-bind="click: addFilter">
- <i class="fa fa-plus"></i> ${ _('Add') }
- </a>
- <label class="checkbox inline pulled">${ _('Sort Desc') } <input type="checkbox" data-bind="checked: sortDesc" /></label>
- <button class="btn" data-bind="click: filter"><i class="fa fa-filter"></i> ${ _('Filter') }</button>
- </div>
- </div>
- <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">
- <i class="fa fa-plus"></i> ${ _('Add a filter') }
- </a>
- <div class="clearfix"></div>
- </div>
- <div class="span2">
- % if has_write_access:
- <div class="pull-right">
- <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>
- </div>
- % endif
- </div>
- </div>
- <!-- ko template: { if: values().length, name: 'metastore-partition-values-table', data: { values: values, selectedValues: selectedValues, withDrop: true } } --><!-- /ko -->
- <span data-bind="visible: !values().length" style="display: none;">${ _('The partition does not contain any values') }</span>
- <!-- /ko -->
- </div>
- % if has_write_access:
- <div id="dropPartition" class="modal hide fade">
- % if is_embeddable:
- <form data-bind="attr: { 'action': '/metastore/table/' + $parent.catalogEntry.path.join('/') + '/partitions/drop' }, submit: dropAndWatch" method="POST">
- <input type="hidden" name="is_embeddable" value="true"/>
- <input type="hidden" name="format" value="json"/>
- <input type="hidden" name="start_time" value=""/>
- <input type="hidden" name="source_type" data-bind="value: $root.source().type"/>
- % else:
- <form data-bind="attr: { 'action': '/metastore/table/' + $parent.catalogEntry.path.join('/')+ '/partitions/drop' }" method="POST">
- % endif
- ${ csrf_token(request) | n,unicode }
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">×</span></button>
- <h2 id="dropPartitionMessage" class="modal-title">${_('Confirm action')}</h2>
- </div>
- <div class="modal-footer">
- <input type="button" class="btn" data-dismiss="modal" value="${_('Cancel')}" />
- <input type="submit" class="btn btn-danger" value="${_('Yes')}"/>
- </div>
- <select class="hide" name="partition_selection" data-bind="options: valuesFlat, selectedOptions: selectedValuesFlat" size="5" multiple="true"></select>
- </form>
- </div>
- % endif
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-sample-tab">
- <!-- ko with: samples -->
- <!-- ko if: loading -->
- <div class="empty-message">
- <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i>
- </div>
- <!-- /ko -->
- <!-- ko if: loaded() && !hasErrors() -->
- <!-- ko template: { if: rows().length, name: 'metastore-samples-table' } --><!-- /ko -->
- <div data-bind="visible: !rows().length && metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The view does not contain any data.') }</div>
- <div data-bind="visible: !rows().length && !metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The table does not contain any data.') }</div>
- <!-- /ko -->
- <!-- ko if: hasErrors() -->
- <div class="empty-message alert" data-bind="text: errorMessage() || '${ _ko('Could not load the sample, see the server log for details.') }'"></div>
- <!-- /ko -->
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-permissions-tab">
- <div class="acl-panel-content" style="height: 988px;">
- <div class="pull-right">
- <input class="input-medium no-margin" type="text" placeholder="Search privileges...">
- <a class="btn pointer">
- <i class="fa fa-plus-circle"></i> Add role
- </a>
- </div>
- <h4 style="margin-top: 4px;">Privileges </h4>
- <div class="acl-block-title">
- <i class="fa fa-cube muted"></i> <a class="pointer"><span>customerFraud</span></a>
- </div>
- <div>
- <div class="acl-block acl-block-airy">
- <span class="muted" title="3 months ago">TABLE</span>
- <span>
- <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
- </span>
- <br>
- server=<span>server1</span>
- <span>
- <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().catalogEntry.name"></span></a>
- </span>
- <span>
- <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: catalogEntry.name"></span></a>
- </span>
- <span style="display: none;">
- <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
- </span>
- <i class="fa fa-long-arrow-right"></i> action=INSERT
- </div>
- <div class="acl-block acl-block-airy">
- <span class="muted" title="3 months ago">TABLE</span>
- <span>
- <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
- </span>
- <br>
- server=server1
- <span>
- <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().catalogEntry.name"></span></a>
- </span>
- <span>
- <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: catalogEntry.name"></span></a>
- </span>
- <span style="display: none;">
- <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
- </span>
- <i class="fa fa-long-arrow-right"></i> action=<span>SELECT</span>
- </div>
- </div>
- <div class="acl-block acl-actions">
- <span class="pointer" title="Show 50 more..." style="display: none;"><i class="fa fa-ellipsis-h"></i></span>
- <span class="pointer" title="Add privilege"><i class="fa fa-plus"></i></span>
- <span class="pointer" title="Undo" style="display: none;"> <i class="fa fa-undo"></i></span>
- <span class="pointer" title="Save" style="display: none;"> <i class="fa fa-save"></i></span>
- </div>
- <div class="acl-block-title">
- <i class="fa fa-cube muted"></i> <a class="pointer"><span>customerAccess</span></a>
- </div>
- <div>
- <div class="acl-block acl-block-airy">
- <span class="muted" title="3 months ago">TABLE</span>
- <span>
- <a class="muted" style="margin-left: 4px" title="Open in Sentry" href="/security/hive"><i class="fa fa-external-link"></i></a>
- </span>
- <br>
- server=server1
- <span>
- <i class="fa fa-long-arrow-right"></i> db=<a class="pointer" title="Browse db privileges"><span data-bind="text: $root.database().catalogEntry.name"></span></a>
- </span>
- <span>
- <i class="fa fa-long-arrow-right"></i> table=<a class="pointer" title="Browse table privileges"><span data-bind="text: catalogEntry.name"></span></a>
- </span>
- <span style="display: none;">
- <i class="fa fa-long-arrow-right"></i> column=<a class="pointer" title="Browse column privileges"><span></span></a>
- </span>
- <i class="fa fa-long-arrow-right"></i> action=<span>ALL</span>
- </div>
- <div class="acl-block acl-actions">
- <span class="pointer" title="Show 50 more..." style="display: none;"><i class="fa fa-ellipsis-h"></i></span>
- <span class="pointer" title="Add privilege"><i class="fa fa-plus"></i></span>
- <span class="pointer" title="Undo" style="display: none;"> <i class="fa fa-undo"></i></span>
- <span class="pointer" title="Save" style="display: none;"> <i class="fa fa-save"></i></span>
- </div>
- </div>
- </div>
- </script>
- <script type="text/html" id="metastore-queries-tab">
- <br/>
- <i class="fa fa-spinner fa-spin" data-bind="visible: $root.loadingQueries"></i>
- <table data-bind="visible: ! loadingQueries() && $data.optimizerDetails().queryList().length > 0" class="table table-condensed">
- <thead>
- <tr>
- <th width="10%">${ _('Id') }</th>
- <th width="10%">${ _('Popularity') }</th>
- <th>${ _('Character') }</th>
- <th>${ _('Query') }</th>
- <th width="20%">${ _('Complexity') }</th>
- <th width="10%">${ _('Hive Compatible') }</th>
- <th width="10%">${ _('Impala Compatible') }</th>
- </tr>
- </thead>
- <tbody data-bind="hueach: { data: $data.optimizerDetails().queryList(), itemHeight: 32, scrollable: '${ MAIN_SCROLLABLE }', scrollableOffset: 200 }">
- <tr>
- <td data-bind="text: qid"></td>
- <td style="height: 10px; width: 70px; margin-top:5px;" data-bind="attr: {'title': queryCount()}">
- <div class="progress bar" style="background-color: #0B7FAD" data-bind="style: { 'width' : Math.round(queryCount() / $parent.optimizerDetails().queryCount() * 100) + '%' }"></div>
- </td>
- <td><code data-bind="text: queryChar"></code></td>
- <td><code data-bind="text: query().substring(0, 100) + '...'"></code></td>
- <td data-bind="text: complexity, css: {'alert-success': complexity() == 'Low', 'alert-warning': complexity() == 'Medium', 'alert-danger': complexity() == 'High'}" class="alert"></td>
- <td data-bind="text: hiveCompatible"></td>
- <td data-bind="text: impalaCompatible"></td>
- </tr>
- </tbody>
- </table>
- <div data-bind="visible: ! loadingQueries() && $data.optimizerDetails().queryList().length == 0" class="empty-message">
- ${ _('No queries found for the current table.') }
- </div>
- </script>
- <script type="text/html" id="metastore-view-sql-tab">
- <div style="padding: 5px 15px">
- <!-- ko hueSpinner: { spin: loadingViewSql, inline: true } --><!-- /ko -->
- <!-- ko ifnot: loadingViewSql -->
- <div data-bind="highlight: { value: viewSql, formatted: true, dialect: catalogEntry.getSourceType() }"></div>
- <!-- /ko -->
- </div>
- </script>
- <script type="text/html" id="metastore-details-tab">
- <!-- ko with: tableDetails -->
- <table class="properties-table">
- <tbody data-bind="foreach: properties">
- <!-- ko if: col_name.indexOf('#') === 0 -->
- <tr>
- <td colspan="3"><h4 data-bind="text: col_name.substring(1)"></h4></td>
- </tr>
- <!-- /ko -->
- <!-- ko ifnot: col_name.indexOf('#') === 0 -->
- <tr>
- <td class="property-name" data-bind="text: col_name || ' '"></td>
- <td data-bind="text: data_type || ' '"></td>
- <td data-bind="text: comment || ' '"></td>
- </tr>
- <!-- /ko -->
- </tbody>
- </table>
- <!-- /ko -->
- </script>
- <script type="text/html" id="metastore-relationships-tab">
- <!-- ko hueSpinner: { spin: loadingTopJoins, inline: true } --><!-- /ko -->
- <table data-bind="visible: !loadingTopJoins()" class="table table-condensed">
- <thead>
- <tr>
- <th>${ _('Table') }</th>
- <th>${ _('Foreign keys') }</th>
- </tr>
- </thead>
- <tbody>
- <!-- ko if: topJoins().length === 0 -->
- <tr>
- <td colspan="2" style="font-style: italic;">${ _('No related tables found.') }</td>
- </tr>
- <!-- /ko -->
- <!-- ko foreach: topJoins -->
- <tr>
- <td><a href="javascript:void(0);" data-bind="text: tableName, sqlContextPopover: { sourceType: $parents[1].catalogEntry.getSourceType(), namespace: parents[1].catalogEntry.namespace, compute: parents[1].catalogEntry.compute, path: tablePath, offset: { top: -3, left: 3 }}"></a></td>
- <td>
- <table class="metastore-join-column-table">
- <tbody data-bind="foreach: joinCols">
- <tr>
- <td><a href="javascript:void(0);" data-bind="text: target, sqlContextPopover: { sourceType: $parents[2].catalogEntry.getSourceType(), namespace: $parents[2].catalogEntry.namespace, compute: parents[2].catalogEntry.compute, path: targetPath, offset: { top: -3, left: 3 }}"></a></td>
- <td class="metastore-join-arrow"><i class="fa fa-arrows-h"></i></td>
- <td><a href="javascript:void(0);" data-bind="text: source, sqlContextPopover: { sourceType: $parents[2].catalogEntry.getSourceType(), namespace: $parents[2].catalogEntry.namespace, compute: parents[2].catalogEntry.compute, path: sourcePath, offset: { top: -3, left: 3 }}"></a></td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- <!-- /ko -->
- </tbody>
- </table>
- </script>
- <script type="text/html" id="metastore-describe-table">
- <div class="clearfix"></div>
- <!-- ko template: 'metastore-main-description' --><!-- /ko -->
- <!-- ko if: $root.navigatorEnabled() -->
- <!-- ko template: 'metastore-nav-tags' --><!-- /ko -->
- <!-- ko template: 'metastore-nav-properties' --><!-- /ko -->
- <!-- /ko -->
- <ul class="nav nav-tabs nav-tabs-border margin-top-10">
- <li data-bind="css: { 'active': $root.currentTab() === 'overview' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('overview'); }">${_('Overview')}</a></li>
- <!-- ko if: $root.optimizerEnabled() -->
- <li data-bind="css: { 'active': $root.currentTab() === 'relationships' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('relationships'); }">${_('Relationships')} (<span data-bind="text: topJoins().length"></span>)</a></li>
- ## <!-- ko if: $root.database().table().optimizerDetails() -->
- ## <li data-bind="css: { 'active': $root.currentTab() === 'permissions' }"><a href="javascript: void(0);" data-bind="click: function(){ $root.currentTab('permissions'); }">${_('Permissions')}</a></li>
- ## <li data-bind="css: { 'active': $root.currentTab() === 'queries' }"><a href="javascript: void(0);" data-bind="click: function(){ $root.currentTab('queries'); }">${_('Queries')} (<span data-bind="text: $root.database().table().optimizerDetails().queryCount"></span>)</a></li>
- ## <li data-bind="css: { 'active': $root.currentTab() === 'joins' }"><a href="javascript: void(0);" data-bind="click: function(){ $root.currentTab('joins'); }">${_('Joins')} (<span data-bind="text: $root.database().table().optimizerDetails().joinCount"></span>)</a></li>
- ## <!-- /ko -->
- ## <!-- ko if: $root.database().table().relationshipsDetails() -->
- ## <!-- /ko -->
- <!-- /ko -->
- <!-- ko if: tableDetails() && tableDetails().partition_keys.length -->
- <li data-bind="css: { 'active': $root.currentTab() === 'partitions' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('partitions'); }">${_('Partitions')} (<span data-bind="text: partitionsCountLabel"></span>)</a></li>
- <!-- /ko -->
- <li data-bind="css: { 'active': $root.currentTab() === 'sample' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('sample'); }">${_('Sample')} (<span data-bind="text: samples.rows().length"></span>)</a></li>
- <!-- ko if: catalogEntry.isView() -->
- <li data-bind="css: { 'active' : $root.currentTab() === 'viewSql' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('viewSql'); }">${ _('View SQL') }</a></li>
- <!-- /ko -->
- <li data-bind="css: { 'active' : $root.currentTab() === 'details' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('details'); }">${ _('Details') }</a></li>
- <li data-bind="css: { 'active' : $root.currentTab() === 'privileges' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('privileges'); }">${ _('Privileges') }</a></li>
- </ul>
- <div class="tab-content margin-top-10" style="border: none; overflow: hidden">
- <div>
- <!-- ko if: $root.currentTab() === 'overview' -->
- <!-- ko template: 'metastore-overview-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'relationships' -->
- <!-- ko template: { name: 'metastore-relationships-tab' } --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'partitions' -->
- <!-- ko template: 'metastore-partitions-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'sample' -->
- <!-- ko template: 'metastore-sample-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'permissions' -->
- <!-- ko template: 'metastore-permissions-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.optimizerEnabled() && $root.currentTab() === 'queries' -->
- <!-- ko template: { name: 'metastore-queries-tab', data: $root.database().table() } --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'viewSql' -->
- <!-- ko template: 'metastore-view-sql-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'details' -->
- <!-- ko template: 'metastore-details-tab' --><!-- /ko -->
- <!-- /ko -->
- <!-- ko if: $root.currentTab() === 'privileges' -->
- <div data-bind="component: { name: 'hue-sentry-privileges', params: { isSentryAdmin: false, readOnly: true, server: 'server1', path: catalogEntry.path.join('.')}}"></div>
- <!-- /ko -->
- </div>
- </div>
- </script>
- <span id="metastoreComponents">
- % if not is_embeddable:
- <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function () { $root.isLeftPanelVisible(true); }">
- <i class="fa fa-chevron-right"></i>
- </a>
- % endif
- <div class="main-content">
- <div class="vertical-full container-fluid" data-bind="style: { 'padding-left' : $root.isLeftPanelVisible() ? '0' : '20px' }">
- <div class="vertical-full row-fluid panel-container">
- % if not is_embeddable:
- <div class="assist-container left-panel" data-bind="visible: $root.isLeftPanelVisible() && $root.assistAvailable()">
- <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { $root.isLeftPanelVisible(false) }">
- <i class="fa fa-chevron-left"></i>
- </a>
- <div class="assist" data-bind="component: {
- name: 'assist-panel',
- params: {
- user: '${user.username}',
- sql: {
- navigationSettings: {
- openItem: true,
- showStats: true
- }
- },
- visibleAssistPanels: ['sql']
- }
- }"></div>
- </div>
- <div class="resizer" data-bind="visible: $root.isLeftPanelVisible() && $root.assistAvailable(), splitDraggable : { appName: 'notebook', leftPanelVisible: $root.isLeftPanelVisible }"><div class="resize-bar"> </div></div>
- % endif
- <div class="content-panel">
- <div class="metastore-main">
- <!-- ko hueSpinner: { spin: loading, center: true, size: 'xlarge' } --><!-- /ko -->
- <!-- ko ifnot: loading -->
- <h1>
- <div class="inline-block pull-right">
- <!-- ko with: source -->
- <!-- ko with: namespace -->
- <!-- ko with: database -->
- <!-- ko with: table -->
- % if USE_NEW_EDITOR.get():
- <!-- ko if: IS_HUE_4 -->
- <a href="javascript: void(0);" class="btn btn-default" data-bind="click: function() { queryAndWatch('/notebook/browse/' + catalogEntry.path.join('/') + '/', $root.source().type); }" title="${_('Query')}"><i class="fa fa-play fa-fw"></i> ${_('Query')}</a>
- <!-- /ko -->
- <!-- ko if: ! IS_HUE_4 -->
- <a class="btn btn-default" data-bind="attr: { 'href': '/notebook/browse/' + catalogEntry.path.join('/') }" title="${_('Query')}"><i class="fa fa-play fa-fw"></i> ${_('Query')}</a>
- <!-- /ko -->
- % else:
- <a class="btn btn-default" data-bind="attr: { 'href': '/metastore/table/'+ catalogEntry.path.join('/') + '/read' }" title="${_('Browse Data')}"><i class="fa fa-play fa-fw"></i> ${_('Browse Data')}</a>
- % endif
- % if has_write_access:
- <a href="javascript: void(0);" class="btn btn-default" data-bind="click: showImportData, visible: tableDetails() && !tableDetails().is_view" title="${_('Import Data')}"><i class="fa fa-upload fa-fw"></i> ${_('Import')}</a>
- % endif
- % if has_write_access:
- <a href="#dropSingleTable" data-toggle="modal" class="btn btn-default" data-bind="attr: { 'title' : tableDetails() && tableDetails().is_view ? '${_('Drop View')}' : '${_('Drop Table')}' }"><i class="fa fa-times fa-fw"></i> ${_('Drop')}</a>
- % endif
- <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh the table')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : refreshing }"></i> ${_('Refresh')}</a>
- <!-- /ko -->
- <!-- ko if: !table() -->
- <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh the database')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : refreshing }"></i> ${_('Refresh')}</a>
- <!-- /ko -->
- <!-- /ko -->
- <!-- ko if: !database() -->
- <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }"></i> ${_('Refresh')}</a>
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- </div>
- <!-- ko template: 'metastore-breadcrumbs' --><!-- /ko -->
- </h1>
- <!-- ko with: source -->
- <!-- ko with: namespace -->
- <!-- ko template: { if: !loading() && !database(), name: 'metastore-databases' } --><!-- /ko -->
- <!-- ko with: database -->
- <i data-bind="visible: loading" class="fa fa-spinner fa-spin fa-2x margin-left-10" style="color: #999; display: none;"></i>
- <!-- ko template: { if: !loading() && !table(), name: 'metastore-tables' } --><!-- /ko -->
- <!-- ko with: table -->
- <!-- ko template: 'metastore-describe-table' --><!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- <!-- /ko -->
- </div>
- </div>
- </div>
- </div>
- <!-- ko with: source -->
- <!-- ko with: namespace -->
- <div id="dropSingleTable" class="modal hide fade">
- % if is_embeddable:
- <form data-bind="submit: dropAndWatch" method="POST">
- <input type="hidden" name="is_embeddable" value="true"/>
- <input type="hidden" name="start_time" value=""/>
- <input type="hidden" name="source_type" data-bind="value: $root.source().type"/>
- % else:
- <form method="POST">
- % endif
- ${ csrf_token(request) | n,unicode }
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">×</span></button>
- <h2 class="modal-title">${_('Drop Table')}</h2>
- </div>
- <div class="modal-body">
- <div>${_('Do you really want to drop the table')} <span style="font-weight: bold;" data-bind="text: database() && database().table() ? database().table().catalogEntry.name : ''"></span>?</div>
- </div>
- <div class="modal-footer">
- <input type="hidden" name="table_selection" data-bind="value: database() && database().table() ? database().table().catalogEntry.name : ''" />
- <input type="button" class="btn" data-dismiss="modal" value="${_('No')}"/>
- <input type="submit" data-bind="click: function (vm, e) { var $form = $(e.target).parents('form'); $form.attr('action', '/metastore/tables/drop/' + vm.database().catalogEntry.name); return true; }" class="btn btn-danger" value="${_('Yes, drop this table')}"/>
- </div>
- </form>
- </div>
- <!-- /ko -->
- <!-- /ko -->
- <div id="import-data-modal" class="modal hide fade" style="display: block;width: 680px;margin-left: -340px!important;"></div>
- </div>
- </span>
- <script type="text/javascript">
- function dropAndWatch(formElement) {
- $(formElement).find('input[name=start_time]').val(ko.mapping.toJSON(new Date().getTime()));
- $(formElement).ajaxSubmit({
- dataType: 'json',
- success: function(resp) {
- if (resp.history_uuid) {
- huePubSub.publish('notebook.task.submitted', resp.history_uuid);
- huePubSub.publish('metastore.clear.selection');
- } else if (resp && resp.message) {
- $(document).trigger("error", resp.message);
- }
- $("#dropTable").modal('hide');
- $("#dropSingleTable").modal('hide');
- $("#dropDatabase").modal('hide');
- $("#dropPartition").modal('hide');
- },
- error: function (xhr) {
- $(document).trigger("error", xhr.responseText);
- }
- });
- }
- function browsePartitionFolder(url) {
- $.get(url, {
- format: "json"
- },function(resp) {
- if (resp.uri_path) {
- huePubSub.publish('open.link', resp.uri_path);
- } else if (resp.message) {
- $(document).trigger("error", resp.message);
- }
- }).fail(function (xhr) {
- $(document).trigger("error", xhr.responseText);
- });
- }
- function queryAndWatch(url, sourceType) {
- $.post(url, {
- format: "json",
- sourceType: sourceType
- },function(resp) {
- if (resp.history_uuid) {
- huePubSub.publish('open.editor.query', resp.history_uuid);
- } else if (resp.message) {
- $(document).trigger("error", resp.message);
- }
- }).fail(function (xhr) {
- $(document).trigger("error", xhr.responseText);
- });
- }
- (function () {
- if (ko.options) {
- ko.options.deferUpdates = true;
- }
- $(document).ready(function () {
- var options = {
- user: '${ user.username }',
- % if is_embeddable:
- hue4: true,
- % endif
- optimizerEnabled: '${ is_optimizer_enabled }' === 'True',
- navigatorEnabled: '${ is_navigator_enabled }' === 'True',
- optimizerUrl: '${ optimizer_url }',
- navigatorUrl: '${ navigator_url }',
- sourceType: '${ source_type }'
- };
- var viewModel = new MetastoreViewModel(options);
- huePubSub.subscribe('metastore.scroll.to.top', function () {
- $('${ MAIN_SCROLLABLE }').scrollTop(0);
- });
- huePubSub.subscribe('metastore.clear.selection', function () {
- viewModel.selectedDatabases.removeAll();
- if (viewModel.database()) {
- viewModel.database().selectedTables.removeAll();
- }
- }, 'metastore');
- viewModel.currentTab.subscribe(function(tab){
- if (tab === 'relationships') {
- // viewModel.database().table().getRelationships();
- } else if (tab === 'sample') {
- var selector = 'samplesTable';
- % if conf.CUSTOM.BANNER_TOP_HTML.get():
- var bannerTopHeight = 30;
- % else:
- var bannerTopHeight = 0;
- % endif
- if ($(selector).parents('.dataTables_wrapper').length == 0){
- hueUtils.waitForRendered(selector, function(el){ return el.find('td').length > 0 }, function(){
- $(selector).dataTable({
- "bPaginate": false,
- "bLengthChange": false,
- "bInfo": false,
- "bDestroy": true,
- "bFilter": false,
- "bAutoWidth": false,
- "oLanguage": {
- "sEmptyTable": "${_('No data available')}",
- "sZeroRecords": "${_('No matching records')}"
- },
- "fnDrawCallback": function (oSettings) {
- $(selector).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
- $(selector).jHueTableExtender2({
- fixedHeader: true,
- fixedFirstColumn: true,
- includeNavigator: false,
- lockSelectedRow: false,
- parentId: 'sample',
- classToRemove: 'sample-table',
- mainScrollable: '${ MAIN_SCROLLABLE }',
- % if is_embeddable:
- stickToTopPosition: 51 + bannerTopHeight,
- % else:
- stickToTopPosition: 76 + bannerTopHeight,
- % endif
- clonedContainerPosition: 'fixed',
- app: 'metastore'
- });
- $(selector).jHueHorizontalScrollbar();
- },
- "aoColumnDefs": [
- {
- "sType": "numeric",
- "aTargets": [ "sort-numeric" ]
- },
- {
- "sType": "string",
- "aTargets": [ "sort-string" ]
- },
- {
- "sType": "date",
- "aTargets": [ "sort-date" ]
- }
- ]
- });
- });
- }
- }
- });
- viewModel.scrollToColumn = function (col) {
- if (!col.table.samples.loading()) {
- $('.page-content').scrollTop(0);
- viewModel.currentTab('sample');
- hueUtils.waitForRendered('#sampleTable', function (el) {
- return el.parent().hasClass('dataTables_wrapper')
- }, function () {
- var sampleTable = $('#sampleTable');
- var sampleCol = sampleTable.find('th').filter(function () {
- return $.trim($(this).text()).indexOf(col.catalogEntry.name) > -1;
- });
- sampleTable.find('.columnSelected').removeClass('columnSelected');
- sampleTable.find('tr td:nth-child(' + (sampleCol.index() + 1) + ')').addClass('columnSelected');
- var scrollLeft = 0;
- sampleTable.find('th:lt(' + sampleCol.index() + ')').each(function () {
- scrollLeft += $(this).outerWidth();
- });
- scrollLeft = Math.max(0, scrollLeft - 40);
- sampleTable.parent().scrollLeft(scrollLeft);
- sampleTable.parent().trigger('scroll_update');
- });
- }
- };
- ko.applyBindings(viewModel, $('#metastoreComponents')[0]);
- if (location.getParameter('refresh') === 'true') {
- DataCatalog.getEntry({ namespace: viewModel.source().namespace().namespace, compute: viewModel.source().namespace().compute, sourceType: viewModel.source().type, path: [], definition: { type: 'source' }}).done(function (entry) {
- entry.clearCache({ invalidate: viewMode.source().type === 'impala' ? 'invalidate' : 'cache', silenceErrors: true });
- hueUtils.replaceURL('?');
- });
- }
- });
- })();
- </script>
- </span>
- % if not is_embeddable:
- ${ commonfooter(request, messages) | n,unicode }
- % endif
|