|
@@ -203,7 +203,6 @@ var CreateCollectionViewModel = function() {
|
|
|
self.hive = new HiveViewModel();
|
|
self.hive = new HiveViewModel();
|
|
|
self.hbase = new HBaseViewModel();
|
|
self.hbase = new HBaseViewModel();
|
|
|
self.wizard = new Wizard();
|
|
self.wizard = new Wizard();
|
|
|
- self.exampleSchema = ko.observable();
|
|
|
|
|
self.isLoading = ko.observable();
|
|
self.isLoading = ko.observable();
|
|
|
self.sources = ko.mapping.fromJS(SOURCES);
|
|
self.sources = ko.mapping.fromJS(SOURCES);
|
|
|
self.fieldTypes = ko.mapping.fromJS(FIELD_TYPES);
|
|
self.fieldTypes = ko.mapping.fromJS(FIELD_TYPES);
|
|
@@ -211,14 +210,6 @@ var CreateCollectionViewModel = function() {
|
|
|
self.fieldQuoteCharacters = ko.mapping.fromJS(FIELD_QUOTE_CHARACTERS);
|
|
self.fieldQuoteCharacters = ko.mapping.fromJS(FIELD_QUOTE_CHARACTERS);
|
|
|
self.sourceTypes = ko.mapping.fromJS(SOURCE_TYPES);
|
|
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() {
|
|
self.parseFields = function() {
|
|
|
if (self.source() == 'file') {
|
|
if (self.source() == 'file') {
|
|
|
self.isLoading(true);
|
|
self.isLoading(true);
|
|
@@ -249,8 +240,6 @@ var CreateCollectionViewModel = function() {
|
|
|
} else if (first) {
|
|
} else if (first) {
|
|
|
self.collection.uniqueKeyField(first.name());
|
|
self.collection.uniqueKeyField(first.name());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- self.fetchExampleSchema();
|
|
|
|
|
} else {
|
|
} else {
|
|
|
$(document).trigger("error", data.message);
|
|
$(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() {
|
|
self.save = function() {
|
|
|
if (self.wizard.currentPage().validate()) {
|
|
if (self.wizard.currentPage().validate()) {
|
|
|
self.isLoading(true);
|
|
self.isLoading(true);
|
|
@@ -300,9 +270,9 @@ var CreateCollectionViewModel = function() {
|
|
|
if (data.status == 0) {
|
|
if (data.status == 0) {
|
|
|
window.location.href = '/indexer';
|
|
window.location.href = '/indexer';
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ self.isLoading(false);
|
|
|
$(document).trigger("error", data.message);
|
|
$(document).trigger("error", data.message);
|
|
|
}
|
|
}
|
|
|
- self.isLoading(false);
|
|
|
|
|
})
|
|
})
|
|
|
.fail(function (xhr, textStatus, errorThrown) {
|
|
.fail(function (xhr, textStatus, errorThrown) {
|
|
|
$(document).trigger("error", xhr.responseText);
|
|
$(document).trigger("error", xhr.responseText);
|