Commit 3b4ccb7f by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1545 : UI updates for recent changes in TypesREST

parent 9e7e5f05
......@@ -32,7 +32,7 @@ define(['require',
initialize: function() {
this.modelName = 'VEntity';
this.modelAttrName = '';
this.modelAttrName = 'entityDefs';
},
parseRecords: function(resp, options) {
try {
......@@ -50,22 +50,6 @@ define(['require',
} else {
return resp
}
// if (this.modelAttrName && this.modelAttrName === "createEntity") {
// var arr = [];
// arr.push({
// attributes: resp.attributes,
// classifications: resp.classifications,
// guid: resp.guid,
// typeName: resp.typeName
// });
// return arr;
// } else {
// if (resp[this.modelAttrName]) {
// return resp[this.modelAttrName];
// } else {
// return resp
// }
// }
} catch (e) {
console.log(e);
......
......@@ -30,30 +30,19 @@ define(['require',
model: VTag,
initialize: function() {
this.modelName = 'VTag';
this.modelAttrName = 'list';
this.modelAttrName = 'classificationDefs';
},
parseRecords: function(resp, options) {
try {
if (!this.modelAttrName) {
throw new Error("this.modelAttrName not defined for " + this);
}
if (this.modelAttrName === "list") {
if (resp[this.modelAttrName]) {
return resp[this.modelAttrName];
} else {
return resp
}
} else {
var arr = [];
resp[this.modelAttrName].forEach(function(d) {
arr.push({
tags: d
});
});
return arr;
}
} catch (e) {
console.log(e);
}
......
......@@ -169,8 +169,7 @@ require(['App',
var that = this;
this.asyncFetchCounter = 2;
this.entityDefCollection = new VEntityList();
that.entityDefCollection.url = UrlLinks.entitiesDefApiUrl()
that.entityDefCollection.modelAttrName = 'list';
that.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
App.appRouter = new Router({
entityDefCollection: this.entityDefCollection
......
......@@ -49,7 +49,7 @@ define(['require',
return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
},
saveTagAttribute: function(guid, options) {
var url = UrlLinks.typesClassicationApiUrl(null, guid);
var url = UrlLinks.typesClassicationApiUrl();
options = _.extend({
contentType: 'application/json',
dataType: 'json'
......
......@@ -22,6 +22,12 @@ define(['require', 'utils/Enums'], function(require, Enums) {
var UrlLinks = {
baseUrl: '/api/atlas',
baseUrlV2: '/api/atlas/v2',
typedefsUrl: function() {
return {
defs: this.baseUrlV2 + '/types/typedefs',
def: this.baseUrlV2 + '/types/typedef'
};
},
taxonomiesApiUrl: function() {
return this.baseUrl + '/v1/taxonomies';
},
......@@ -39,11 +45,11 @@ define(['require', 'utils/Enums'], function(require, Enums) {
}
},
entitiesDefApiUrl: function(name) {
var entitieDefUrl = this.baseUrlV2 + '/types/entitydef';
var entitieDefUrl = this.typedefsUrl();
if (name) {
return entitieDefUrl + '/name/' + name;
return entitieDefUrl.def + '/name/' + name + '?type=entity';
} else {
return entitieDefUrl;
return entitieDefUrl.defs + '?type=entity';
}
},
entitiesTraitsApiUrl: function(token) {
......@@ -59,17 +65,17 @@ define(['require', 'utils/Enums'], function(require, Enums) {
return this.baseUrl + '/entities/' + guid + '/audit';
},
typesClassicationApiUrl: function(name, guid) {
var typeUrl = this.baseUrlV2 + '/types/classificationdef'
var typeUrl = this.typedefsUrl();
if (name) {
return typeUrl + '/name/' + name;
return typeUrl.def + '/name/' + name + '?type=classification';
} else if (guid) {
return typeUrl + '/guid/' + guid;
return typeUrl.def + '/guid/' + guid + '?type=classification';
} else {
return typeUrl;
return typeUrl.defs + '?type=classification';
}
},
typesApiUrl: function() {
return this.baseUrlV2 + '/types/typedefs/headers'
return this.typedefsUrl().defs + '/headers'
},
lineageApiUrl: function(guid) {
var lineageUrl = this.baseUrlV2 + '/lineage';
......
......@@ -70,7 +70,7 @@ define(['require',
} else {
this.$('.fontLoader').hide();
Utils.notifyError({
content: 'Something went wrong'
content: 'Tag Not Found'
});
}
}, this);
......@@ -106,7 +106,7 @@ define(['require',
if (this.model.get("description")) {
this.ui.description.text(this.model.get("description"));
}
if (this.model.get("attributeDefs")) {
if (attributeDefs) {
if (!_.isArray(attributeDefs)) {
attributeDefs = [attributeDefs];
}
......@@ -138,10 +138,19 @@ define(['require',
});
return;
}
this.model.saveTagAttribute(this.model.get('guid'), {
data: JSON.stringify(saveObject),
data: JSON.stringify({
classificationDefs: [saveObject],
entityDefs: [],
enumDefs: [],
structDefs: []
}),
success: function(model, response) {
that.model.set(model);
if (model.classificationDefs) {
that.model.set(model.classificationDefs[0], { merge: true });
}
that.renderTagDetail();
Utils.notifySuccess({
content: message
......
......@@ -60,7 +60,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'entity', 'guid', 'term', 'entityName'));
_.extend(this, _.pick(options, 'entity', 'guid', 'term', 'entityName', 'fetchCollection'));
this.collectionObject = this.entity;
this.tagTermCollection = new VTagList();
var tagorterm = _.toArray(this.collectionObject.classifications),
......@@ -204,7 +204,10 @@ define(['require',
'tagOrTerm': (that.term ? "term" : "tag"),
callback: function() {
that.$('.fontLoader').show();
that.collection.fetch({ reset: true });
if (that.fetchCollection) {
that.fetchCollection();
}
}
});
}
......
......@@ -239,19 +239,24 @@ define(['require',
attributeObj = [];
}
this.json = {
'name': this.name,
'description': this.description,
classificationDefs: [{
'name': this.name.trim(),
'description': this.description.trim(),
"typeVersion": "2",
"version": "2",
'superTypes': superTypes.length ? superTypes : [],
"attributeDefs": attributeObj
}],
entityDefs: [],
enumDefs: [],
structDefs: []
};
new this.collection.model().set(this.json).save(null, {
success: function(model, response) {
that.ui.createTag.removeAttr("disabled");
that.createTag = true;
that.fetchCollections();
that.collection.add(model)
that.collection.reset(model.get('classificationDefs'));
that.setUrl('#!/tag/tagAttribute/' + ref.ui.tagName.val(), true);
Utils.notifySuccess({
content: "Tag " + that.name + Messages.addSuccessMessage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment