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