Selaa lähdekoodia

[indexer] Remove schema generator

Conflicts:
	desktop/libs/indexer/static/js/collections.js
Abraham Elmahrek 11 vuotta sitten
vanhempi
commit
21e4b243e6

+ 0 - 18
desktop/libs/indexer/src/indexer/api.py

@@ -87,24 +87,6 @@ def parse_fields(request):
   return HttpResponse(json.dumps(result), mimetype="application/json")
 
 
-def example_schema(request):
-  if request.method != 'POST':
-    raise PopupException(_('POST request required.'))
-
-  result = {'status': -1}
-
-  collection = json.loads(request.POST.get('collection', '{}'))
-
-  if not collection:
-    result['message'] = _('Collection missing.')
-
-  if result.get('message', None) is None:
-    result['example'] = example_schema_xml_with_fields_and_unique_key(collection.get('fields', []), collection.get('uniqueKeyField', 'id'))
-    result['status'] = 0
-
-  return HttpResponse(json.dumps(result), mimetype="application/json")
-
-
 def collections(request):
   searcher = CollectionManagerController(request.user)
   solr_collections = searcher.get_collections()

+ 32 - 35
desktop/libs/indexer/src/indexer/templates/collections.mako

@@ -266,41 +266,38 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
 </script>
 
 <script type="text/html" id="collection-fields">
-  <div class="span6">
-    <table class="table table-bordered fields-table">
-      <thead>
-        <tr>
-          <th width="30%">${_('Name')}</th>
-          <th width="15%">${_('Type')}</th>
-          <th width="10%">${_('Required')}</th>
-          <th width="10%">${_('Indexed')}</th>
-          <th width="10%">${_('Stored')}</th>
-          <th width="10%">${_('Unique Key')}</th>
-          <th width="15%"></th>
-        </tr>
-      </thead>
-      <tbody data-bind="sortable: collection.fields">
-        <tr data-bind="css: {'error': name.errors().length > 0}" class="ko_container editable">
-          <td data-bind="editableText: name">
-            <span class="pull-left fa fa-pencil"></span>
-          </td>
-          <td><select data-bind="options: $parent.fieldTypes, value: type" name="type"></select></td>
-          <td><input data-bind="checked: required" type="checkbox"></td>
-          <td><input data-bind="checked: indexed" type="checkbox"></td>
-          <td><input data-bind="checked: stored" type="checkbox"></td>
-          <td><input data-bind="checked: uniqueKeyField" name="unique-key" type="checkbox" /></td>
-          <td>
-            <a data-bind="click: remove, visible: editable" href="javascript:void(0)" class="btn btn-danger"><i class="fa fa-minus"></i>&nbsp;${_("Remove")}</a>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-
-    <br style="clear: both" />
-    <br />
-    <a data-bind="click: collection.newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add field")}</a>
-  </div>
-  <pre data-bind="text: exampleSchema" class="span6 examples"></pre>
+  <table class="table table-bordered fields-table">
+    <thead>
+      <tr>
+        <th width="30%">${_('Name')}</th>
+        <th width="15%">${_('Type')}</th>
+        <th width="10%">${_('Required')}</th>
+        <th width="10%">${_('Indexed')}</th>
+        <th width="10%">${_('Stored')}</th>
+        <th width="10%">${_('Unique Key')}</th>
+        <th width="15%"></th>
+      </tr>
+    </thead>
+    <tbody data-bind="sortable: collection.fields">
+      <tr data-bind="css: {'error': name.errors().length > 0}" class="ko_container editable">
+        <td data-bind="editableText: name">
+          <span class="pull-left fa fa-pencil"></span>
+        </td>
+        <td><select data-bind="options: $parent.fieldTypes, value: type" name="type"></select></td>
+        <td><input data-bind="checked: required" type="checkbox"></td>
+        <td><input data-bind="checked: indexed" type="checkbox"></td>
+        <td><input data-bind="checked: stored" type="checkbox"></td>
+        <td><input data-bind="checked: uniqueKeyField" name="unique-key" type="checkbox" /></td>
+        <td>
+          <a data-bind="click: remove, visible: editable" href="javascript:void(0)" class="btn btn-danger"><i class="fa fa-minus"></i>&nbsp;${_("Remove")}</a>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+
+  <br style="clear: both" />
+  <br />
+  <a data-bind="click: collection.newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add field")}</a>
 </script>
 <!--/ Wizard -->
 

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

@@ -23,7 +23,6 @@ urlpatterns = patterns('indexer.views',
 
 urlpatterns += patterns('indexer.api',
   url(r'^api/fields/parse/$', 'parse_fields', name='api_parse_fields'),
-  url(r'^api/schema/example/$', 'example_schema', name='api_example_schema'),
   url(r'^api/collections/$', 'collections', name='api_collections'),
   url(r'^api/collections/create/$', 'collections_create', name='api_collections_create'),
   url(r'^api/collections/import/$', 'collections_import', name='api_collections_import'),

+ 1 - 31
desktop/libs/indexer/static/js/collections.js

@@ -203,7 +203,6 @@ var CreateCollectionViewModel = function() {
   self.hive = new HiveViewModel();
   self.hbase = new HBaseViewModel();
   self.wizard = new Wizard();
-  self.exampleSchema = ko.observable();
   self.isLoading = ko.observable();
   self.sources = ko.mapping.fromJS(SOURCES);
   self.fieldTypes = ko.mapping.fromJS(FIELD_TYPES);
@@ -211,14 +210,6 @@ var CreateCollectionViewModel = function() {
   self.fieldQuoteCharacters = ko.mapping.fromJS(FIELD_QUOTE_CHARACTERS);
   self.sourceTypes = ko.mapping.fromJS(SOURCE_TYPES);
 
-  self.allCollectionChanges = ko.computed(function() {
-    ko.toJS(self.collection.fields);
-
-    if ('fetchExampleSchema' in self) {
-      self.fetchExampleSchema();
-    }
-  });
-
   self.parseFields = function() {
     if (self.source() == 'file') {
       self.isLoading(true);
@@ -249,8 +240,6 @@ var CreateCollectionViewModel = function() {
           } else if (first) {
             self.collection.uniqueKeyField(first.name());
           }
-
-          self.fetchExampleSchema();
         } else {
           $(document).trigger("error", data.message);
         }
@@ -262,25 +251,6 @@ var CreateCollectionViewModel = function() {
     }
   };
 
-  self.fetchExampleSchema = function() {
-    self.isLoading(true);
-    var collection = ko.mapping.toJS(self.collection);
-    return $.post("/indexer/api/schema/example/", {
-      'collection': ko.mapping.toJSON(collection)
-    }).done(function(data) {
-      if (data.status == 0) {
-        self.exampleSchema(data.example);
-      } else {
-        $(document).trigger("error", data.message);
-      }
-      self.isLoading(false);
-    })
-    .fail(function (xhr, textStatus, errorThrown) {
-      $(document).trigger("error", xhr.responseText);
-      self.isLoading(false);
-    });
-  };
-
   self.save = function() {
     if (self.wizard.currentPage().validate()) {
       self.isLoading(true);
@@ -300,9 +270,9 @@ var CreateCollectionViewModel = function() {
           if (data.status == 0) {
             window.location.href = '/indexer';
           } else {
+            self.isLoading(false);
             $(document).trigger("error", data.message);
           }
-          self.isLoading(false);
         })
         .fail(function (xhr, textStatus, errorThrown) {
           $(document).trigger("error", xhr.responseText);