ソースを参照

HUE-1753 [beeswax] Setting and files inputs in the editor are not user friendly

Improved a bit adding a tooltip on the field
Ajax stat on files doesn't try to download certain mimetypes anymore
Fixed layout problem of the file field on Chrome
Enrico Berti 12 年 前
コミット
5dc2eed

+ 39 - 3
apps/beeswax/src/beeswax/templates/execute.mako

@@ -50,7 +50,7 @@ ${layout.menubar(section='query')}
 
             <div class="control-group">
               <label>${_('Value')}</label>
-              <input data-bind="value: value" type="text" class="span8" placeholder="1"/>
+              <input data-bind="value: value" type="text" class="settingValuesField span8" placeholder="1"/>
             </div>
           </div>
           <!-- /ko -->
@@ -87,7 +87,7 @@ ${layout.menubar(section='query')}
 
             <div class="control-group">
               <label>${_('Path')}</label>
-              <input data-bind="value: path" type="text" class="span8 pathChooser" placeholder="/user/foo/udf.jar"/>
+              <input data-bind="value: path" type="text" class="filesField span7 pathChooser" placeholder="/user/foo/udf.jar"/>
             </div>
           </div>
           <!-- /ko -->
@@ -120,7 +120,7 @@ ${layout.menubar(section='query')}
 
             <div class="control-group">
               <label>${_('Class name')}</label>
-              <input data-bind="value: class_name" type="text" class="span8" placeholder="com.acme.example"/>
+              <input data-bind="value: class_name" type="text" class="classNamesField span8" placeholder="com.acme.example"/>
             </div>
           </div>
           <!-- /ko -->
@@ -1594,6 +1594,15 @@ $(document).on('cancelled.query', function (e) {
   $(document).trigger("info", "${ _('Query canceled!') }")
 });
 
+function updateSidebarTooltips(selector) {
+  $(selector).each(function(){
+    $(this).tooltip({
+      placement: "right",
+      title: $(this).val()
+    }).attr('data-original-title', $(this).val()).tooltip('fixTitle');
+  });
+}
+
 $(document).ready(function () {
   $(".pathChooser:not(:has(~ button))").after(getFileBrowseButton($(".pathChooser:not(:has(~ button))")));
 
@@ -1621,6 +1630,33 @@ $(document).ready(function () {
     'html': true
   });
 
+  $(document).on("change", ".settingsField", function(){
+    updateSidebarTooltips(".settingsField");
+  });
+
+  $(document).on("change", ".settingValuesField", function(){
+    updateSidebarTooltips(".settingValuesField");
+  });
+
+  $(document).on("change", ".filesField", function(){
+    updateSidebarTooltips(".filesField");
+  });
+
+  $(document).on("change", ".functionsField", function(){
+    updateSidebarTooltips(".functionsField");
+  });
+
+  $(document).on("change", ".classNamesField", function(){
+    updateSidebarTooltips(".classNamesField");
+  });
+
+  // loads default
+  updateSidebarTooltips(".settingsField");
+  updateSidebarTooltips(".settingValuesField");
+  updateSidebarTooltips(".filesField");
+  updateSidebarTooltips(".functionsField");
+  updateSidebarTooltips(".classNamesField");
+
   % if app_name == 'impala':
     $("#downloadQuery").click(function () {
       $("<input>").attr("type", "hidden").attr("name", "button-submit").attr("value", "Execute").appendTo($("#advancedSettingsForm"));

+ 1 - 0
apps/beeswax/static/js/beeswax.vm.js

@@ -577,6 +577,7 @@ function getFileBrowseButton(inputElement) {
       initialPath: inputElement.val(),
       onFileChoose: function (filePath) {
         inputElement.val(filePath);
+        inputElement.trigger("change");
         $("#chooseFile").modal("hide");
       },
       createFolder: false

+ 6 - 4
apps/filebrowser/src/filebrowser/views.py

@@ -496,11 +496,13 @@ def display(request, path):
     if not request.fs.isfile(path):
         raise PopupException(_("Not a file: '%(path)s'") % {'path': path})
 
-    mimetype = mimetypes.guess_type(path)[0]
+    # display inline files just if it's not an ajax request
+    if not request.is_ajax():
+      mimetype = mimetypes.guess_type(path)[0]
 
-    if mimetype is not None and INLINE_DISPLAY_MIMETYPE.search(mimetype):
-      path_enc = urlencode(path)
-      return redirect(reverse('filebrowser.views.download', args=[path_enc]) + '?disposition=inline')
+      if mimetype is not None and INLINE_DISPLAY_MIMETYPE.search(mimetype):
+        path_enc = urlencode(path)
+        return redirect(reverse('filebrowser.views.download', args=[path_enc]) + '?disposition=inline')
 
     stats = request.fs.stats(path)
     encoding = request.GET.get('encoding') or i18n.get_site_encoding()