Explorar el Código

HUE-4826 [fb] Allow to edit the path in the file chooser

Enrico Berti hace 9 años
padre
commit
c4690b9

+ 0 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -575,7 +575,6 @@ from django.utils.translation import ugettext as _
     </tr>
   </script>
 
-  <script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
   <script src="${ static('desktop/js/jquery.hdfstree.js') }" type="text/javascript" charset="utf-8"></script>
   <script src="${ static('desktop/ext/js/knockout.min.js') }" type="text/javascript" charset="utf-8"></script>
   <script src="${ static('desktop/ext/js/knockout-mapping.min.js') }" type="text/javascript" charset="utf-8"></script>

+ 0 - 1
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -527,7 +527,6 @@ ${ commonshare() | n,unicode }
 <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/select2.full.patched.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/share2.vm.js') }"></script>
-<script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
 
 ${ dashboard.import_bindings() }
 

+ 0 - 1
apps/security/src/security/templates/hdfs.mako

@@ -294,7 +294,6 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
 
 <script src="${ static('desktop/js/ko.hue-bindings.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('security/js/hdfs.ko.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
 
 <script type="text/javascript">
 

+ 0 - 1
apps/sqoop/src/sqoop/templates/app.mako

@@ -686,7 +686,6 @@ ${ commonheader(None, "sqoop", user) | n,unicode }
 <script src="${ static('desktop/ext/js/knockout-mapping.min.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }"></script>
 <script src="${ static('desktop/js/ko.editable.js') }"></script>
-<script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('sqoop/js/cclass.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('sqoop/js/koify.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('sqoop/js/sqoop.autocomplete.js') }" type="text/javascript" charset="utf-8"></script>

+ 25 - 0
desktop/core/src/desktop/static/desktop/css/hue3.css

@@ -922,6 +922,31 @@ div.box {
   border-radius: 0 3px 3px 0 !important;
 }
 
+.filechooser-tree .editable-breadcrumbs {
+  cursor: text;
+}
+
+.filechooser-tree .editable-breadcrumbs:hover {
+  background-color: #F0F0F0;
+}
+
+.filechooser-tree .editable-breadcrumb-input {
+  margin-left: 10px;
+  margin-bottom: 0;
+  border-radius: 2px;
+  border: 1px solid #EEE;
+  -webkit-box-shadow: none;
+  -moz-box-shadow: none;
+  box-shadow: none;
+  width: 370px;
+  height: 20px;
+  line-height: 20px;
+  min-height: 20px;
+  font-size: 1.25em;
+  padding-left: 10px!important;
+}
+
+
 /*
  * jHueSelector
  */

+ 35 - 2
desktop/core/src/desktop/static/desktop/js/jquery.filechooser.js

@@ -256,14 +256,14 @@
           'white-space': 'nowrap'
         });
 
-        var $scrollingBreadcrumbs = $("<ul>").addClass("hueBreadcrumb").css({
+        var $scrollingBreadcrumbs = $("<ul>").addClass("hueBreadcrumb editable-breadcrumbs").css({
           'padding': '0',
           'marginLeft': '10px',
           'marginBottom': '0',
+          'paddingLeft': '10px',
           'paddingRight': '10px',
           'float': 'left',
           'width': '370px',
-          'height': '30px',
           'overflow-x': 'scroll',
           'overflow-y': 'hidden',
           'white-space': 'nowrap'
@@ -290,6 +290,19 @@
           _extraHome.appendTo($scrollingBreadcrumbs);
         }
 
+        var $hdfsAutocomplete = $('<input type="text">').addClass('editable-breadcrumb-input').val(path).hide();
+
+        $scrollingBreadcrumbs.click(function (e) {
+          if ($(e.target).is('ul') || $(e.target).is('i')) {
+            $(this).hide();
+            $hdfsAutocomplete.show().focus();
+          }
+        });
+
+        var $editBreadcrumbs = $("<li>").css('marginRight', '10px');
+        var $crumbLink = $("<a>").addClass('inactive-action');
+        $crumbLink.attr("href", "javascript:void(0)").html('<i class="fa fa-pencil"></i>').appendTo($editBreadcrumbs);
+        $editBreadcrumbs.appendTo($scrollingBreadcrumbs);
         if (typeof data.breadcrumbs != "undefined" && data.breadcrumbs != null) {
           var _bLength = data.breadcrumbs.length;
           $(data.breadcrumbs).each(function (cnt, crumb) {
@@ -318,6 +331,26 @@
         $scrollingBreadcrumbs.animate({
           'scrollLeft': $scrollingBreadcrumbs.width()
         });
+
+        $hdfsAutocomplete.appendTo($(_parent.element).find('.filechooser-tree'));
+
+        $hdfsAutocomplete.jHueHdfsAutocomplete({
+          home: "/user/" + _parent.options.user + "/",
+          skipEnter: true,
+          skipKeydownEvents: true,
+          onEnter: function (el) {
+            var _url = el.val();
+            _parent.options.onFolderChange(_url);
+            _parent.navigateTo(_url);
+            $("#jHueHdfsAutocomplete").hide();
+          },
+          onBlur: function () {
+            $hdfsAutocomplete.hide();
+            $scrollingBreadcrumbs.show();
+          },
+          smartTooltip: _parent.options.labels.SMART_TOOLTIP
+        });
+
         $('<div>').addClass('clearfix').appendTo($(_parent.element).find('.filechooser-tree'));
 
         if (typeof $.nicescroll !== 'undefined') {

+ 6 - 0
desktop/core/src/desktop/static/desktop/js/jquery.hdfsautocomplete.js

@@ -32,6 +32,7 @@
         smartTooltipThreshold: 10, // needs 10 up/down or click actions and no tab to activate the smart tooltip
         showOnFocus: false,
         skipKeydownEvents: false,
+        skipEnter: false,
         skipScrollEvent: false,
         zIndex: 33000,
         isS3: false
@@ -133,6 +134,11 @@
       if (e.keyCode == 32 && e.ctrlKey) {
         e.preventDefault();
       }
+      if (_this.options.skipEnter && e.keyCode === 13){
+        e.preventDefault();
+        e.stopPropagation();
+        e.stopImmediatePropagation();
+      }
     });
 
 

+ 1 - 0
desktop/core/src/desktop/templates/common_header.mako

@@ -191,6 +191,7 @@ if USE_NEW_EDITOR.get():
   <script src="${ static('desktop/js/hue.utils.js') }"></script>
   <script src="${ static('desktop/ext/js/jquery/jquery-2.1.1.min.js') }"></script>
   <script src="${ static('desktop/js/jquery.migration.js') }"></script>
+  <script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
   <script src="${ static('desktop/js/jquery.filechooser.js') }"></script>
   <script src="${ static('desktop/js/jquery.selector.js') }"></script>
   <script src="${ static('desktop/js/jquery.delayedinput.js') }"></script>

+ 0 - 1
desktop/libs/indexer/src/indexer/templates/indexer.mako

@@ -26,7 +26,6 @@
 ${ commonheader(_("Solr Indexes"), "search", user, "60px") | n,unicode }
 
 <script src="${ static('desktop/js/jquery.hiveautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
 <script src="${ static('desktop/js/jquery.huedatatable.js') }"></script>
 <script src="${ static('desktop/ext/js/d3.v3.js') }" type="text/javascript" charset="utf-8"></script>

+ 0 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -173,7 +173,6 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('desktop/js/ace.extended.js') }"></script>
 
 <script src="${ static('desktop/js/jquery.hiveautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/jquery.hdfsautocomplete.js') }" type="text/javascript" charset="utf-8"></script>
 
 <script type="text/x-mathjax-config">
   MathJax.Hub.Config({