listdir.mako 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.template.defaultfilters import urlencode
  18. from desktop.views import commonheader, commonfooter
  19. from django.utils.translation import ugettext as _
  20. from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
  21. %>
  22. <%namespace name="actionbar" file="actionbar.mako" />
  23. <%namespace name="dir" file="listdir_components.mako" />
  24. <%namespace name="fb_components" file="fb_components.mako" />
  25. %if not is_embeddable:
  26. ${ commonheader(None, 'filebrowser', user, request) | n,unicode }
  27. %endif
  28. ${ fb_components.menubar() }
  29. <style type="text/css">
  30. .tooltip.left {
  31. margin-left: -10px;
  32. }
  33. %if is_embeddable:
  34. .filebrowser .pagination {
  35. position: inherit;
  36. }
  37. %endif
  38. </style>
  39. <div id="${ path.startswith('S3A://') and 'filebrowser_s3Components' or 'filebrowserComponents' }" class="container-fluid filebrowser">
  40. <div class="card card-small">
  41. <div class="actionbar">
  42. <%actionbar:render>
  43. <%def name="search()">
  44. <input type="text" class="input-large search-query" placeholder="${_('Search for file name')}" data-bind="clearable: searchQuery, valueUpdateDelay: 500">
  45. </%def>
  46. <%def name="actions()">
  47. <div class="btn-toolbar" style="display: inline; vertical-align: middle">
  48. <div id="ch-dropdown" class="btn-group" style="vertical-align: middle">
  49. <button class="btn dropdown-toggle" title="${_('Actions')}" data-toggle="dropdown"
  50. data-bind="visible: !inTrash(), enable: selectedFiles().length > 0 && (!isS3() || (isS3() && !isS3Root()))">
  51. <i class="fa fa-cog"></i> ${_('Actions')}
  52. <span class="caret" style="line-height: 15px"></span>
  53. </button>
  54. <ul class="dropdown-menu" style="top: auto">
  55. <li><a href="javascript: void(0)" title="${_('Rename')}" data-bind="visible: !inTrash() && selectedFiles().length == 1, click: renameFile,
  56. enable: selectedFiles().length == 1 && isCurrentDirSelected().length == 0"><i class="fa fa-fw fa-font"></i>
  57. ${_('Rename')}</a></li>
  58. <li><a href="javascript: void(0)" title="${_('Move')}" data-bind="click: move, enable: selectedFiles().length > 0 &&
  59. isCurrentDirSelected().length == 0"><i class="fa fa-fw fa-random"></i> ${_('Move')}</a></li>
  60. <li><a href="javascript: void(0)" title="${_('Copy')}" data-bind="click: copy, enable: selectedFiles().length > 0 &&
  61. isCurrentDirSelected().length == 0"><i class="fa fa-fw fa-files-o"></i> ${_('Copy')}</a></li>
  62. % if show_download_button:
  63. <li>
  64. <a href="javascript: void(0)" title="${_('Download')}" data-bind="visible: !inTrash() && selectedFiles().length == 1 && selectedFile().type == 'file', click: downloadFile">
  65. <i class="fa fa-fw fa-arrow-circle-o-down"></i> ${_('Download')}
  66. </a>
  67. </li>
  68. % endif
  69. <li class="divider" data-bind="visible: !isS3()"></li>
  70. % if is_fs_superuser:
  71. <li data-bind="css: {'disabled': isCurrentDirSentryManaged() || selectedSentryFiles().length > 0 }">
  72. <a href="javascript: void(0)" data-bind="visible: ! inTrash(), click: changeOwner, enable: selectedFiles().length > 0">
  73. <i class="fa fa-fw fa-user"></i> ${_('Change owner / group')}
  74. </a>
  75. </li>
  76. % endif
  77. <li data-bind="css: {'disabled': isCurrentDirSentryManaged() || selectedSentryFiles().length > 0 }, visible: !isS3()">
  78. <a href="javascript: void(0)" data-bind="visible: ! inTrash(), click: changePermissions, enable: selectedFiles().length > 0">
  79. <i class="fa fa-fw fa-list-alt"></i> ${_('Change permissions')}
  80. </a>
  81. </li>
  82. <li class="divider" data-bind="visible: !isS3()"></li>
  83. <li data-bind="css: {'disabled': inTrash() || selectedFiles().length > 1 }, visible: !isS3()">
  84. <a class="pointer" data-bind="click: function(){ selectedFiles().length == 1 ? showSummary(): void(0)}">
  85. <i class="fa fa-fw fa-pie-chart"></i> ${_('Summary')}
  86. </a>
  87. </li>
  88. <li>
  89. <a href="javascript: void(0)" title="${_('Set Replication')}" data-bind="visible: !inTrash() && !isS3() && selectedFiles().length == 1 && selectedFile().type == 'file', click: setReplicationFactor">
  90. <i class="fa fa-fw fa-hdd-o"></i> ${_('Set replication')}
  91. </a>
  92. </li>
  93. % if ENABLE_EXTRACT_UPLOADED_ARCHIVE.get() and 'oozie' in apps:
  94. <li><a href="javascript: void(0)" title="${_('Compress selection into a single archive')}" data-bind="click: function() { setCompressArchiveDefault(); confirmCompressFiles();}, visible: showCompressButton">
  95. <i class="fa fa-fw fa-file-archive-o"></i> ${_('Compress')}</a>
  96. </li>
  97. <li><a href="javascript: void(0)" title="${_('Extract selected archive')}" data-bind="visible: selectedFiles().length == 1 && isArchive(selectedFile().name) && !isS3(), click: confirmExtractArchive">
  98. <i class="fa fa-fw fa-file-archive-o"></i> ${_('Extract')}</a>
  99. </li>
  100. % endif
  101. </ul>
  102. </div>
  103. <button class="btn fileToolbarBtn" title="${_('Restore from trash')}" data-bind="visible: inRestorableTrash(), click: restoreTrashSelected, enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0"><i class="fa fa-cloud-upload"></i> ${_('Restore')}</button>
  104. <!-- ko ifnot: inTrash -->
  105. <!-- ko if: $root.isS3 -->
  106. <button class="btn fileToolbarBtn delete-link" title="${_('Delete forever')}" data-bind="enable: selectedFiles().length > 0, click: deleteSelected"><i class="fa fa-bolt"></i> ${_('Delete forever')}</button>
  107. <!-- /ko -->
  108. <!-- ko ifnot: $root.isS3 -->
  109. <div id="delete-dropdown" class="btn-group" style="vertical-align: middle">
  110. <button id="trash-btn" class="btn toolbarBtn" data-bind="enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0, click: trashSelected"><i class="fa fa-times"></i> ${_('Move to trash')}</button>
  111. <button id="trash-btn-caret" class="btn toolbarBtn dropdown-toggle" data-toggle="dropdown" data-bind="enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0">
  112. <span class="caret"></span>
  113. </button>
  114. <ul class="dropdown-menu">
  115. <li><a href="javascript: void(0)" class="delete-link" title="${_('Delete forever')}" data-bind="enable: selectedFiles().length > 0, click: deleteSelected"><i class="fa fa-bolt"></i> ${_('Delete forever')}</a></li>
  116. </ul>
  117. </div>
  118. <!-- /ko -->
  119. <!-- /ko -->
  120. % if 'oozie' in apps:
  121. <button class="btn fileToolbarBtn" title="${_('Submit')}"
  122. data-bind="visible: selectedFiles().length == 1 && $.inArray(selectedFile().name, ['workflow.xml', 'coordinator.xml', 'bundle.xml']) > -1, click: submitSelected">
  123. <i class="fa fa-fw fa-play"></i> ${_('Submit')}
  124. </button>
  125. % if ENABLE_EXTRACT_UPLOADED_ARCHIVE.get():
  126. <button class="btn extractArchiveBtn" title="${_('Extract')}"
  127. data-bind="visible: selectedFiles().length == 1 && isArchive(selectedFile().name) && !isS3(), click: confirmExtractArchive">
  128. <i class="fa fa-fw fa-file-archive-o"></i> ${_('Extract')}
  129. </button>
  130. % endif
  131. % endif
  132. % if 'beeswax' in apps:
  133. <a class="btn" title="${_('Open in Editor')}"
  134. data-bind="visible: selectedFiles().length == 1 && isSelectedFileSql(), click: openFileInEditor">
  135. ${_('Open in Editor')}
  136. </a>
  137. % endif
  138. </div>
  139. </%def>
  140. <%def name="creation()">
  141. <button class="btn fileToolbarBtn" title="${_('Empty trash')}" data-bind="visible: inTrash(), click: purgeTrash"><i class="fa fa-fire"></i> ${_('Empty trash')}</button>
  142. <div class="btn-toolbar" style="display: inline; vertical-align: middle">
  143. % if show_upload_button:
  144. <!-- ko if: isS3 -->
  145. <a class="btn fileToolbarBtn" title="${_('Upload files')}" data-bind="visible: !inTrash(), css: {'disabled': isS3Root()}, click: function(){ if (!isS3Root()) { uploadFile() }}"><i class="fa fa-arrow-circle-o-up"></i> ${_('Upload')}</a>
  146. <!-- /ko -->
  147. <!-- ko ifnot: isS3 -->
  148. <div id="upload-dropdown" class="btn-group" style="vertical-align: middle">
  149. <a href="javascript: void(0)" class="btn upload-link dropdown-toggle" title="${_('Upload')}" data-bind="click: uploadFile, visible: !inTrash(), css: {'disabled': isS3() && isS3Root()}">
  150. <i class="fa fa-arrow-circle-o-up"></i> ${_('Upload')}
  151. </a>
  152. </div>
  153. <!-- /ko -->
  154. % endif
  155. <div class="btn-group" style="vertical-align: middle">
  156. <a href="javascript: void(0)" data-toggle="dropdown" class="btn dropdown-toggle" data-bind="visible: !inTrash()">
  157. <i class="fa fa-plus-circle"></i> ${_('New')}
  158. <span class="caret"></span>
  159. </a>
  160. <ul class="dropdown-menu pull-right" style="top: auto">
  161. <li data-bind="visible: !isS3() || isS3() && !isS3Root()"><a href="javascript: void(0)" class="create-file-link" title="${_('File')}"><i class="fa fa-file-o"></i> ${_('File')}</a></li>
  162. <li><a href="javascript: void(0)" class="create-directory-link" title="${_('Directory')}"><i class="fa fa-folder"></i> <span data-bind="visible: !isS3() || isS3() && !isS3Root()">${_('Directory')}</span><span data-bind="visible: isS3() && isS3Root()">${_('Bucket')}</span></a></li>
  163. </ul>
  164. </div>
  165. </div>
  166. </%def>
  167. </%actionbar:render>
  168. </div>
  169. <div class="actionbarGhost hide"></div>
  170. <div class="scrollable">
  171. <div class="alert alert-warn" data-bind="visible: inTrash">
  172. ${ _("This is Hadoop trash. Files will be under a checkpoint, or timestamp named, directory.") }
  173. </div>
  174. <div class="alert alert-warn" data-bind="visible: isCurrentDirSentryManaged">
  175. ${ _('The permissions for this folder are managed by the Sentry Namenode plugin.') }
  176. </div>
  177. <div class="alert alert-warn" data-bind="visible: ! isCurrentDirSentryManaged() && selectedSentryFiles().length > 0">
  178. ${ _('The permissions of some of the selected files are managed by the Sentry Namenode plugin.') }
  179. </div>
  180. % if breadcrumbs:
  181. ${fb_components.breadcrumbs(path, breadcrumbs, True)}
  182. %endif
  183. <div style="padding-left: 6px">
  184. ${dir.list_table_browser(files, path_enc, current_request_path, show_download_button, cwd_set)}
  185. </div>
  186. </div>
  187. </div>
  188. <div class="hoverMsg hide">
  189. <p class="hoverText"></p>
  190. </div>
  191. </div>
  192. %if not is_embeddable:
  193. ${ commonfooter(request, messages) | n,unicode }
  194. %endif