Переглянути джерело

[importer] improvements in direct upload

ayush.goyal 4 роки тому
батько
коміт
1d496d77a3

+ 1 - 1
desktop/libs/indexer/src/indexer/api3.py

@@ -229,7 +229,7 @@ def guess_field_types(request):
   file_format = json.loads(request.POST.get('fileFormat', '{}'))
 
   if file_format['inputFormat'] == 'localfile':
-    path = file_format['path']
+    path = urllib_unquote(file_format['path'])
 
     with open(BASE_DIR + path, 'r') as local_file:
 

+ 1 - 1
desktop/libs/indexer/src/indexer/indexers/sql.py

@@ -308,7 +308,7 @@ class SQLIndexer(object):
           'primary_keys': ', '.join(destination.get('indexerPrimaryKey'))
       }
 
-    path = source['path']
+    path = urllib_unquote(source['path'])
     if path:
       with open(BASE_DIR + path, 'r') as local_file:
         reader = csv.reader(local_file)

+ 6 - 6
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -237,7 +237,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
           <div data-bind="visible: createWizard.source.inputFormat() == 'localfile'">
               <form method="post" action="" enctype="multipart/form-data" id="uploadform">
                 <div >
-                    <input type="file" id="inputfile" name="inputfile" accept=".csv">
+                    <input type="file" id="inputfile" name="inputfile" style="margin-left: 130px" accept=".csv">
                 </div>
             </form>
           </div>
@@ -1726,7 +1726,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
 
 
       self.sampleCols.subscribe(refreshTemporaryTable);
-      self.inputFormat = ko.observable(wizard.prefill.source_type() ? wizard.prefill.source_type() : 'file');
+      self.inputFormat = ko.observable(wizard.prefill.source_type() ? wizard.prefill.source_type() : 'localfile');
 
       self.inputFormat.subscribe(function(val) {
         wizard.destination.columns.removeAll();
@@ -1749,8 +1749,11 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
         }
       });
       self.inputFormatsAll = ko.observableArray([
+          % if ENABLE_DIRECT_UPLOAD.get():
+          {'value': 'localfile', 'name': 'Small Local File'},
+          % endif
           % if request.fs:
-          {'value': 'file', 'name': 'File'},
+          {'value': 'file', 'name': 'Remote File'},
           % endif
           % if ENABLE_SQOOP.get():
           {'value': 'rdbms', 'name': 'External Database'},
@@ -1769,9 +1772,6 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
           {'value': 'connector', 'name': 'Connectors'},
           % endif
           {'value': 'manual', 'name': 'Manually'},
-          % if ENABLE_DIRECT_UPLOAD.get():
-          {'value': 'localfile', 'name': 'LocalFile'}
-          % endif
           ##{'value': 'text', 'name': 'Paste Text'},
       ]);
       self.inputFormatsManual = ko.observableArray([

+ 2 - 2
desktop/libs/indexer/src/indexer/tests.py

@@ -71,12 +71,12 @@ class TestImporter(object):
       get_filesystem.return_value = Mock()
 
       resp = self.client.get(reverse('indexer:importer'))
-      assert_true(b"{'value': 'file', 'name': 'File'}" in resp.content)
+      assert_true(b"{'value': 'file', 'name': 'Remote File'}" in resp.content)
 
       get_filesystem.return_value = None
 
       resp = self.client.get(reverse('indexer:importer'))
-      assert_false(b"{'value': 'file', 'name': 'File'}" in resp.content)
+      assert_false(b"{'value': 'file', 'name': 'Remote File'}" in resp.content)
 
 
 class TestIndexerWithSolr(object):