Преглед на файлове

HUE-956 [beeswax] Load data into a table should redirect to the table

Filechooser can select a directory too.
Oozie action properties can select a file or directory (not perfect
yet but better than just a file)
Romain Rigaux преди 12 години
родител
ревизия
b95b881

+ 15 - 6
apps/beeswax/src/beeswax/templates/describe_table.mako

@@ -166,11 +166,11 @@ ${layout.menubar(section='tables')}
                 ${comps.bootstrapLabel(load_form["path"])}
                 <div class="controls">
                     ${comps.field(load_form["path"],
-                    placeholder="/user/user_name/data_dir/file",
-                    klass="pathChooser input-xlarge",
-                    file_chooser=True,
-                    show_errors=False
-                    )}
+                                  placeholder="/user/user_name/data_dir/file",
+                                  klass="pathChooser input-xlarge",
+                                  file_chooser=True,
+                                  show_errors=False)
+                     }
                 </div>
             </div>
 
@@ -239,7 +239,16 @@ ${layout.menubar(section='tables')}
            $("input[name='"+_destination+"']").val(filePath);
            $("#filechooser").slideUp();
          },
-         createFolder: false
+         onFolderChange: function (filePath) {
+           $("input[name='"+_destination+"']").val(filePath);
+         },
+         onFolderChoose: function (filePath) {
+           $("input[name='"+_destination+"']").val(filePath);
+           $("#filechooser").slideUp();
+         },
+         createFolder: false,
+         selectFolder: true,
+         uploadFile: true
        });
        $("#filechooser").slideDown();
      });

+ 0 - 56
apps/beeswax/src/beeswax/templates/load_table.mako

@@ -1,56 +0,0 @@
-## 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 desktop.views import commonheader, commonfooter
-from django.utils.translation import ugettext as _
-%>
-
-<%namespace name="layout" file="layout.mako" />
-<%namespace name="util" file="util.mako" />
-
-${ commonheader(_('Load Data into %(table)s') % {'table': table}, app_name, user, '100px') | n,unicode }
-
-${layout.menubar()}
-
-<div class="container-fluid">
-  <h1>${_('Load Data into %(table)s') % {'table': table}}</h1>
-
-  <div class="prompt_popup">
-    <form action="${action}" method="POST">
-      <dl>
-        ${util.render_field(form["path"])}
-        <a class="hue-chooseFile" data-filters="ArtButton" data-icon-styles="{'width': 16, 'height': 16, 'top': 6, 'left': 6 }" data-chooseFor="path">
-          ${_('Open File Chooser')}
-        </a>
-        ## Path (on HDFS) of files to load.
-        ${util.render_field(form["overwrite"])}
-        ## Any existing data will be erased!
-        % for pf in form.partition_columns:
-          ${util.render_field(form[pf])}
-        % endfor
-        ## This table is partitioned.  Therefore,
-        ## you must specify what partition
-        ## this data corresponds to.
-      </dl>
-      <p>
-          ${_("Note that loading data will move data from its location into the table's storage location.")}
-      </p>
-      <input type="submit">
-    </form>
-  </div>
-</div>
-
-${ commonfooter(messages) | n,unicode }

+ 6 - 3
apps/beeswax/src/beeswax/views.py

@@ -396,10 +396,13 @@ def load_table(request, database, table):
         hql += ")"
 
       on_success_url = reverse(get_app_name(request) + ':describe_table', kwargs={'database': database, 'table': table})
-      return confirm_query(request, hql, on_success_url)
+      query = hql_query(hql, database=database)
+      try:
+        return execute_directly(request, query, on_success_url=on_success_url)
+      except Exception, e:
+        raise PopupException(_("Can't load the data"), detail=e)
   else:
-    form = beeswax.forms.LoadDataForm(table_obj)
-    return render("load_table.mako", request, {'form': form, 'table': table, 'action': request.get_full_path()})
+    raise PopupException(_('Requires a POST'), detail=e)
 
 
 def describe_partitions(request, database, table):

+ 1 - 1
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -735,7 +735,7 @@ $('#workflow').on('click', '.import-jobsub-node-link', function(e) {
 ko.bindingHandlers.fileChooser = {
   init: function(element, valueAccessor, allBindings, model) {
     var self = $(element);
-    self.after(getFileBrowseButton(self));
+    self.after(getFileBrowseButton(self, true));
   }
 };