Explorar el Código

HUE-5304 [indexer] Update name when switching output format

Romain Rigaux hace 8 años
padre
commit
35b89d5

+ 13 - 0
desktop/libs/indexer/src/indexer/solr_api.py

@@ -146,6 +146,19 @@ def create_alias(request):
   return JsonResponse(response)
 
 
+@require_POST
+@api_error_handler
+def list_configs(request):
+  response = {'status': -1}
+
+  client = SolrClient(user=request.user)
+
+  response['configs'] = client.list_configs()
+  response['status'] = 0
+
+  return JsonResponse(response)
+
+
 @require_POST
 @api_error_handler
 def design_schema(request, index):

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

@@ -1337,7 +1337,7 @@ ${ assist.assistPanel() }
       var self = this;
 
       self.name = ko.observable('').extend({throttle: 500});
-      self.name.subscribe(function(name) {
+      self.nameChanged = function(name) {
         var exists = false;
 
         if (name.length == 0) {
@@ -1355,7 +1355,10 @@ ${ assist.assistPanel() }
             $.get("/" + (self.apiHelperType() == 'hive' ? 'beeswax' : self.apiHelperType()) + "/api/autocomplete/" + self.databaseName() + '/' + self.tableName(), function (data) {
               self.isTargetExisting(data.code != 500 && data.code != 404);
               self.isTargetChecking(false);
-            }).fail(function (xhr, textStatus, errorThrown) { self.isTargetExisting(false); self.isTargetChecking(false); });
+            }).fail(function (xhr, textStatus, errorThrown) {
+              self.isTargetExisting(false);
+              self.isTargetChecking(false);
+            });
           }
           else {
             self.isTargetExisting(false);
@@ -1369,7 +1372,10 @@ ${ assist.assistPanel() }
             $.get("/" + (self.apiHelperType() == 'hive' ? 'beeswax' : self.apiHelperType()) + "/api/autocomplete/" + self.databaseName(), function (data) {
               self.isTargetExisting(data.tables_meta && data.tables_meta.length > 0);
               self.isTargetChecking(false);
-            }).fail(function (xhr, textStatus, errorThrown) { self.isTargetExisting(false); self.isTargetChecking(false); });
+            }).fail(function (xhr, textStatus, errorThrown) {
+              self.isTargetExisting(false);
+              self.isTargetChecking(false);
+            });
           }
           else {
             self.isTargetExisting(false);
@@ -1383,11 +1389,21 @@ ${ assist.assistPanel() }
           }, function (data) {
             self.isTargetExisting(data.status == 0);
             self.isTargetChecking(false);
-            // Fetch indexerConfigSets
-          }).fail(function (xhr, textStatus, errorThrown) { self.isTargetExisting(false); self.isTargetChecking(false); });
+          }).fail(function (xhr, textStatus, errorThrown) {
+            self.isTargetExisting(false);
+            self.isTargetChecking(false);
+          });
+          $.post("/indexer/api/configs/list/", function (data) {
+            if (data.status == 0) {
+              self.indexerConfigSets(data.configs);
+            } else {
+              $(document).trigger("error", data.message);
+            }
+          });
         }
         resizeElements();
-      });
+      };
+      self.name.subscribe(self.nameChanged);
 
       self.apiHelperType = ko.observable('${ sourceType }');
 
@@ -1395,6 +1411,7 @@ ${ assist.assistPanel() }
       self.outputFormat = ko.observable(wizard.prefill.target_type() || 'table');
       self.outputFormat.subscribe(function (newValue) {
         if (newValue && newValue != 'database' && ((newValue == 'table' || newValue == 'index') && wizard.source.path().length > 0)) {
+          self.nameChanged(self.name());
           wizard.guessFieldTypes();
           resizeElements();
         }

+ 1 - 0
desktop/libs/indexer/src/indexer/urls.py

@@ -47,6 +47,7 @@ urlpatterns += patterns('indexer.api',
 urlpatterns += patterns('indexer.solr_api',
   # V2
   url(r'^api/aliases/create/$', 'create_alias', name='create_alias'),
+  url(r'^api/configs/list/$', 'list_configs', name='list_configs'),
   url(r'^api/indexes/list/$', 'list_indexes', name='list_indexes'),
   url(r'^api/indexes/create/$', 'create_index', name='create_index'),
   url(r'^api/indexes/delete/$', 'delete_indexes', name='delete_indexes'),