Repository: incubator-atlas Updated Branches: refs/heads/master 97209e817 -> c9a912649
ATLAS-1433 : Atlas allows creation of tag with attributes' name same as that of its parent tags. Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/c9a91264 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/c9a91264 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/c9a91264 Branch: refs/heads/master Commit: c9a9126491bef62daa91e30a8e8ff0051dc4e8ba Parents: 97209e8 Author: kalyani <[email protected]> Authored: Tue Apr 11 18:53:06 2017 +0530 Committer: kevalbhatt <[email protected]> Committed: Tue Apr 11 19:22:38 2017 +0530 ---------------------------------------------------------------------- dashboardv2/public/css/scss/graph.scss | 8 ++ dashboardv2/public/css/scss/tag.scss | 12 +++ dashboardv2/public/js/models/VTag.js | 2 +- .../tag/TagAttributeDetailLayoutView_tmpl.html | 5 ++ .../views/tag/TagAttributeDetailLayoutView.js | 85 ++++++++++++++++---- .../public/js/views/tag/TagLayoutView.js | 52 ++++++++++++ 6 files changed, 147 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/css/scss/graph.scss ---------------------------------------------------------------------- diff --git a/dashboardv2/public/css/scss/graph.scss b/dashboardv2/public/css/scss/graph.scss index feb9c10..3e55b96 100644 --- a/dashboardv2/public/css/scss/graph.scss +++ b/dashboardv2/public/css/scss/graph.scss @@ -118,3 +118,11 @@ g.type-TK > rect { top: 4px; right: 5px; } + +.legends { + > i { + > span { + font-family: 'Source Sans Pro'; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/css/scss/tag.scss ---------------------------------------------------------------------- diff --git a/dashboardv2/public/css/scss/tag.scss b/dashboardv2/public/css/scss/tag.scss index 6c2d29a..c964da3 100644 --- a/dashboardv2/public/css/scss/tag.scss +++ b/dashboardv2/public/css/scss/tag.scss @@ -64,6 +64,7 @@ text-overflow: ellipsis; max-width: 91%; overflow: hidden; + font-size: 14px; } } ul { @@ -252,6 +253,10 @@ } } +.superType { + margin-bottom: 15px; +} + form-control .tagInpput { margin-bottom: 15px; margin-top: 15px; @@ -288,6 +293,13 @@ form-control .tagInpput { margin-right: 5px; } +.superTypeLabel { + font-weight: 600; + width: 90px; + margin-right: 5px; + float: left; +} + .inputAssignTag { display: block; padding: 2px 5px; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/js/models/VTag.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/models/VTag.js b/dashboardv2/public/js/models/VTag.js index 51b53d1..046af3f 100644 --- a/dashboardv2/public/js/models/VTag.js +++ b/dashboardv2/public/js/models/VTag.js @@ -48,7 +48,7 @@ define(['require', }, options); return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options); }, - saveTagAttribute: function(guid, options) { + saveTagAttribute: function(options) { var url = UrlLinks.typesClassicationApiUrl(); options = _.extend({ contentType: 'application/json', http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/js/templates/tag/TagAttributeDetailLayoutView_tmpl.html ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/templates/tag/TagAttributeDetailLayoutView_tmpl.html b/dashboardv2/public/js/templates/tag/TagAttributeDetailLayoutView_tmpl.html index 2cb0fc9..f32ce1c 100644 --- a/dashboardv2/public/js/templates/tag/TagAttributeDetailLayoutView_tmpl.html +++ b/dashboardv2/public/js/templates/tag/TagAttributeDetailLayoutView_tmpl.html @@ -22,6 +22,11 @@ <h1><span data-id="title"></span></h1> <button type="button" data-id="editButton" class="btn btn-default pull-right editbutton" id="editText"><i class="fa fa-pencil"></i></button> <p class="sub-title" data-id="description"></p> + <div class="superType" style="display:none"> + <span class="superTypeLabel">Derived From:</span> + <div data-id="showSuperType" style="display: inline-block;"> + </div> + </div> <div class="attributes"> <span class="attrLabel">Attributes:</span> <div data-id="showAttribute"> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js b/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js index ecf32f2..dcc5c47 100644 --- a/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js +++ b/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js @@ -45,7 +45,8 @@ define(['require', addTagPlus: '[data-id="addTagPlus"]', addTagBtn: '[data-id="addTagBtn"]', description: '[data-id="description"]', - publishButton: '[data-id="publishButton"]' + publishButton: '[data-id="publishButton"]', + showSuperType: "[data-id='showSuperType']" }, /** ui events hash */ events: function() { @@ -100,8 +101,9 @@ define(['require', }, renderTagDetail: function() { var attributeData = "", - attributeDefs = this.model.get("attributeDefs"); - + supertypeData = "", + attributeDefs = this.model.get("attributeDefs"), + superTypeArr = this.model.get('superTypes'); this.ui.title.html('<span>' + (Utils.getName(this.model.toJSON())) + '</span>'); if (this.model.get("description")) { this.ui.description.text(this.model.get("description")); @@ -115,6 +117,13 @@ define(['require', }); this.ui.showAttribute.html(attributeData); } + if (superTypeArr.length > 0) { + this.$(".superType").show(); + _.each(superTypeArr, function(value, key) { + supertypeData += ' <a class="inputAttribute" href="#!/tag/tagAttribute/' + value + '">' + value + '</a>'; + }); + this.ui.showSuperType.html(supertypeData); + } Utils.hideTitleLoader(this.$('.fontLoader'), this.$('.tagDetail')); }, onSaveButton: function(saveObject, message) { @@ -138,7 +147,7 @@ define(['require', return; } Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail')); - this.model.saveTagAttribute(this.model.get('guid'), { + this.model.saveTagAttribute({ data: JSON.stringify({ classificationDefs: [saveObject], entityDefs: [], @@ -154,6 +163,9 @@ define(['require', Utils.notifySuccess({ content: message }); + }, + cust_error: function() { + Utils.hideTitleLoader(that.$('.fontLoader'), that.$('.tagDetail')); } }); that.modal.close(); @@ -182,20 +194,61 @@ define(['require', } }); that.modal.on('ok', function() { - var newAttributeList = view.collection.toJSON(); - try { - var saveJSON = JSON.parse(JSON.stringify(that.model.toJSON())); - } catch (err) { - Utils.serverErrorHandler(); - } - if (saveJSON) { - var oldAttributeList = saveJSON.attributeDefs; - } + var newAttributeList = view.collection.toJSON(), + activeTagAttribute = _.extend([], that.model.get('attributeDefs')), + superTypes = that.model.get('superTypes'); + + _.each(superTypes, function(name) { + var parentTags = that.collection.fullCollection.findWhere({ name: name }); + activeTagAttribute = activeTagAttribute.concat(parentTags.get('attributeDefs')); + }); + + var duplicateAttributeList = [], + saveObj = $.extend(true, {}, that.model.toJSON()); _.each(newAttributeList, function(obj) { - oldAttributeList.push(obj); + var duplicateCheck = _.find(activeTagAttribute, function(activeTagObj) { + return activeTagObj.name.toLowerCase() === obj.name.toLowerCase(); + }); + if (duplicateCheck) { + duplicateAttributeList.push(obj.name); + } else { + saveObj.attributeDefs.push(obj); + } }); - if (saveJSON) { - that.onSaveButton(saveJSON, Messages.addAttributeSuccessMessage); + var notifyObj = { + confirm: { + confirm: true, + buttons: [{ + text: 'Ok', + addClass: 'btn-primary', + click: function(notice) { + notice.remove(); + } + }, + null + ] + } + } + if (saveObj && !duplicateAttributeList.length) { + that.onSaveButton(saveObj, Messages.addAttributeSuccessMessage); + } else { + if (duplicateAttributeList.length < 2) { + var text = "Attribute <b>" + duplicateAttributeList.join(",") + "</b> is duplicate !" + } else { + if (newAttributeList.length > duplicateAttributeList.length) { + var text = "Attributes: <b>" + duplicateAttributeList.join(",") + "</b> are duplicate ! Do you want to continue with other attributes ?" + notifyObj = { + ok: function(argument) { + that.onSaveButton(saveObj, Messages.addAttributeSuccessMessage); + }, + cancel: function(argument) {} + } + } else { + var text = "All attributes are duplicate !" + } + } + notifyObj['text'] = text; + Utils.notifyConfirm(notifyObj); } }); that.modal.on('closeModal', function() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c9a91264/dashboardv2/public/js/views/tag/TagLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/TagLayoutView.js b/dashboardv2/public/js/views/tag/TagLayoutView.js index 8591100..d8ee351 100644 --- a/dashboardv2/public/js/views/tag/TagLayoutView.js +++ b/dashboardv2/public/js/views/tag/TagLayoutView.js @@ -228,6 +228,7 @@ define(['require', }); return; } + this.name = ref.ui.tagName.val(); this.description = ref.ui.description.val(); var superTypes = []; @@ -238,6 +239,57 @@ define(['require', if (ref.collection.length === 1 && ref.collection.first().get("name") === "") { attributeObj = []; } + + if (attributeObj.length) { + var superTypesAttributes = []; + _.each(superTypes, function(name) { + var parentTags = that.collection.fullCollection.findWhere({ name: name }); + superTypesAttributes = superTypesAttributes.concat(parentTags.get('attributeDefs')); + }); + + + var duplicateAttributeList = []; + _.each(attributeObj, function(obj) { + var duplicateCheck = _.find(superTypesAttributes, function(activeTagObj) { + return activeTagObj.name.toLowerCase() === obj.name.toLowerCase(); + }); + if (duplicateCheck) { + duplicateAttributeList.push(obj.name); + } + }); + + + var notifyObj = { + confirm: { + confirm: true, + buttons: [{ + text: 'Ok', + addClass: 'btn-primary', + click: function(notice) { + notice.remove(); + } + }, + null + ] + } + } + + if (duplicateAttributeList.length) { + if (duplicateAttributeList.length < 2) { + var text = "Attribute <b>" + duplicateAttributeList.join(",") + "</b> is duplicate !" + } else { + if (attributeObj.length > duplicateAttributeList.length) { + var text = "Attributes: <b>" + duplicateAttributeList.join(",") + "</b> are duplicate !" + } else { + var text = "All attributes are duplicate !" + } + } + notifyObj['text'] = text; + Utils.notifyConfirm(notifyObj); + return false; + } + + } this.json = { classificationDefs: [{ 'name': this.name.trim(),
