Skip to content

Commit

Permalink
[importer] improvements in direct upload
Browse files Browse the repository at this point in the history
  • Loading branch information
agl29 committed Apr 21, 2021
1 parent eea5c7a commit 1d496d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion desktop/libs/indexer/src/indexer/api3.py
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion desktop/libs/indexer/src/indexer/indexers/sql.py
Expand Up @@ -308,7 +308,7 @@ def create_table_from_local_file(self, source, destination, start_time=-1):
'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)
Expand Down
12 changes: 6 additions & 6 deletions desktop/libs/indexer/src/indexer/templates/importer.mako
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
Expand All @@ -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'},
Expand All @@ -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([
Expand Down
4 changes: 2 additions & 2 deletions desktop/libs/indexer/src/indexer/tests.py
Expand Up @@ -71,12 +71,12 @@ def test_input_formats_no_fs(self):
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):
Expand Down

0 comments on commit 1d496d7

Please sign in to comment.