Repository: incubator-atlas Updated Branches: refs/heads/master a05107a07 -> 440bd2ae4
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/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 4a40f4a..a89c692 100644 --- a/dashboardv2/public/js/views/tag/TagLayoutView.js +++ b/dashboardv2/public/js/views/tag/TagLayoutView.js @@ -20,8 +20,9 @@ define(['require', 'backbone', 'hbs!tmpl/tag/TagLayoutView_tmpl', 'collection/VTagList', + 'collection/VEntityList', 'utils/Utils', -], function(require, Backbone, TagLayoutViewTmpl, VTagList, Utils) { +], function(require, Backbone, TagLayoutViewTmpl, VTagList, VEntityList, Utils) { 'use strict'; var TagLayoutView = Backbone.Marionette.LayoutView.extend( @@ -36,18 +37,24 @@ define(['require', /** ui selector cache */ ui: { - listTag: "[data-id='listTag']", - listType: "[data-id='listType']", - tagElement: "[data-id='tags']", - referesh: "[data-id='referesh']", - searchTag: "[data-id='searchTag']" + tagsParent: "[data-id='tagsParent']", + createTag: "[data-id='createTag']", + tags: "[data-id='tags']", + offLineSearchTag: "[data-id='offlineSearchTag']", + deleteTerm: "[data-id='deleteTerm']", + }, /** ui events hash */ events: function() { var events = {}; - events["click " + this.ui.tagElement] = 'onTagClick'; - events["click " + this.ui.referesh] = 'refereshClick'; - events["keyup " + this.ui.searchTag] = 'offlineSearchTag'; + events["click " + this.ui.createTag] = 'onClickCreateTag'; + /* events["dblclick " + this.ui.tags] = function(e) { + this.onTagList(e, true); + }*/ + events["click " + this.ui.tags] = 'onTagList'; + // events["click " + this.ui.referesh] = 'refereshClick'; + events["keyup " + this.ui.offLineSearchTag] = 'offlineSearchTag'; + events["click " + this.ui.deleteTerm] = 'onDeleteTerm'; return events; }, /** @@ -55,72 +62,218 @@ define(['require', * @constructs */ initialize: function(options) { - _.extend(this, _.pick(options, 'globalVent', 'vent')); + _.extend(this, _.pick(options, 'globalVent', 'tag')); this.tagCollection = new VTagList(); - $.extend(this.tagCollection.queryParams, { type: 'TRAIT' }); - this.typeCollection = new VTagList(); - $.extend(this.typeCollection.queryParams, { type: 'CLASS' }); - this.bindEvents(); + this.collection = new Backbone.Collection(); + this.json = { + "enumTypes": [], + "traitTypes": [], + "structTypes": [], + "classTypes": [] + }; }, bindEvents: function() { - this.listenTo(this.tagCollection, 'reset', function() { - this.tagsAndTypeGenerator('tagCollection', 'listTag'); - }, this); - this.listenTo(this.typeCollection, 'reset', function() { - this.tagsAndTypeGenerator('typeCollection', 'listType'); + var that = this; + this.listenTo(this.tagCollection, "reset", function() { + this.tagsAndTypeGenerator('tagCollection'); + this.createTagAction(); }, this); + this.ui.tagsParent.on('click', 'li.parent-node a', function() { + that.setUrl(this.getAttribute("href")); + }); }, onRender: function() { + var that = this; + this.bindEvents(); this.fetchCollections(); + $('body').on("click", '.tagPopoverList li', function(e) { + that[$(this).find("a").data('fn')](e); + }); + $('body').click(function(e) { + if ($('.tagPopoverList').length) { + if ($(e.target).hasClass('tagPopover')) { + return; + } + that.$('.tagPopover').popover('hide'); + } + }); }, fetchCollections: function() { + $.extend(this.tagCollection.queryParams, { type: 'TRAIT', }); this.tagCollection.fetch({ reset: true }); - this.typeCollection.fetch({ reset: true }); }, - tagsAndTypeGenerator: function(collection, element, searchString) { - if (element == "listType") { - var searchType = "dsl"; - var icon = "fa fa-cogs"; - } else { - var searchType = "fulltext"; - var icon = "fa fa-tags"; + manualRender: function(tagName) { + this.setValues(tagName); + }, + setValues: function(tagName) { + if (Utils.getUrlState.isTagTab() || Utils.getUrlState.isInitial()) { + if (!this.tag && !tagName) { + this.selectFirst = false; + this.ui.tagsParent.find('li').first().addClass('active'); + Utils.setUrl({ + url: this.ui.tagsParent.find('li a').first().attr("href"), + mergeBrowserUrl: false, + trigger: true + }); + } else { + var tag = Utils.getUrlState.getLastValue(); + if (tagName) { + tag = tagName; + } else if (this.tag) { + tag = this.tag; + } + this.ui.tagsParent.find('li').removeClass('active'); + this.ui.tagsParent.find('li').filter(function() { + return $(this).text() === tag; + }).addClass('active'); + } } - var str = ''; + }, + tagsAndTypeGenerator: function(collection, searchString) { + var that = this, + str = ''; _.each(this[collection].fullCollection.models, function(model) { var tagName = model.get("tags"); if (searchString) { if (tagName.search(new RegExp(searchString, "i")) != -1) { - str += '<a href="javascript:void(0)" data-id="tags" data-type="' + searchType + '" class="list-group-item"><i class="' + icon + '"></i>' + tagName + '</a>'; + str = '<li class="parent-node" data-id="tags"><div class="tools"><i class="fa fa-trash-o" data-id="deleteTerm"></i></div><a href="#!/tag/tagAttribute/' + tagName + '">' + tagName + '</a></li>' + str; } else { return; } } else { - str += '<a href="javascript:void(0)" data-id="tags" data-type="' + searchType + '" class="list-group-item"><i class="' + icon + '"></i>' + tagName + '</a>'; + //str = '<li class="parent-node" data-id="tags"><div class="tools"><i class="fa fa-trash-o" data-id="deleteTerm"></i></div><a href="#!/tag/tagAttribute/' + tagName + '">' + tagName + '</a></li>' + str; + str = '<li class="parent-node" data-id="tags"><div class="tools"><i class="fa fa-ellipsis-h tagPopover"></i></div><a href="#!/tag/tagAttribute/' + tagName + '">' + tagName + '</a></li>' + str; } }); - this.ui[element].empty().append(str); + this.ui.tagsParent.empty().html(str); + this.setValues(); + }, - onTagClick: function(e) { - var data = $(e.currentTarget).data(); - this.vent.trigger("tag:click", { 'query': e.currentTarget.text, 'searchType': data.type }); - Utils.setUrl({ - url: '#!/dashboard/assetPage', - urlParams: { - query: e.currentTarget.text, - searchType: data.type + + onClickCreateTag: function(e) { + var that = this; + $(e.currentTarget).blur(); + require([ + 'views/tag/CreateTagLayoutView', + 'modules/Modal' + ], function(CreateTagLayoutView, Modal) { + var view = new CreateTagLayoutView({ 'tagCollection': that.tagCollection }); + var modal = new Modal({ + title: 'Create a new tag', + content: view, + cancelText: "Cancel", + okText: 'Create', + allowCancel: true, + }).open(); + modal.$el.find('button.ok').attr("disabled", "true"); + view.ui.tagName.on('keyup', function(e) { + modal.$el.find('button.ok').removeAttr("disabled"); + }); + view.ui.tagName.on('keyup', function(e) { + if (e.keyCode == 8 && e.currentTarget.value == "") { + modal.$el.find('button.ok').attr("disabled", "true"); + } + }); + modal.on('ok', function() { + that.onCreateButton(view); + }); + modal.on('closeModal', function() { + modal.trigger('cancel'); + }); + }); + }, + onCreateButton: function(ref) { + var that = this; + this.name = ref.ui.tagName.val(); + + if (ref.ui.parentTag.val().length <= 1 && ref.ui.parentTag.val()[0] == "") { + var superTypes = []; + } else { + var superTypes = ref.ui.parentTag.val(); + } + this.json.traitTypes[0] = { + attributeDefinitions: this.collection.toJSON(), + typeName: this.name, + typeDescription: null, + superTypes: superTypes, + hierarchicalMetaTypeName: "org.apache.atlas.typesystem.types.TraitType" + }; + new this.tagCollection.model().set(this.json).save(null, { + success: function(model, response) { + that.fetchCollections(); + that.setUrl('#!/tag/tagAttribute/' + ref.ui.tagName.val()); + Utils.notifySuccess({ + content: that.name + " has been created" + }); + that.collection.reset([]); }, - mergeBrowserUrl: true, - trigger: false + error: function(model, response) { + if (response.responseJSON && response.responseJSON.error) { + Utils.notifyError({ + content: response.responseJSON.error + }); + } + } }); }, - refereshClick: function() { - this.fetchCollections(); + + setUrl: function(url) { + Utils.setUrl({ + url: url, + mergeBrowserUrl: false, + trigger: true, + updateTabState: function() { + return { tagUrl: this.url, stateChanged: true }; + } + }); + }, + onTagList: function(e, toggle) { + /*if (toggle) { + var assetUl = $(e.currentTarget).siblings('.tagAsset') + assetUl.slideToggle("slow"); + }*/ + this.ui.tagsParent.find('li').removeClass("active"); + $(e.currentTarget).addClass("active"); }, offlineSearchTag: function(e) { var type = $(e.currentTarget).data('type'); - var collectionType = type == "listTag" ? "tagCollection" : "typeCollection"; - this.tagsAndTypeGenerator(collectionType, type, $(e.currentTarget).val()); + this.tagsAndTypeGenerator('tagCollection', $(e.currentTarget).val()); + }, + createTagAction: function() { + var that = this; + this.$('.tagPopover').popover({ + placement: 'bottom', + html: true, + trigger: 'manual', + container: 'body', + content: function() { + return "<ul class='tagPopoverList'>" + + "<li class='listTerm' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearchTerm'>Search Tag</a></li>" + + "</ul>"; + } + }); + this.$('.tagPopover').off('click').on('click', function(e) { + // if any other popovers are visible, hide them + e.preventDefault(); + that.$('.tagPopover').not(this).popover('hide'); + $(this).popover('toggle'); + }); + }, + onSearchTerm: function() { + Utils.setUrl({ + url: '#!/search/searchResult', + urlParams: { + query: this.ui.tagsParent.find('li.active').find("a").text(), + searchType: "fulltext", + dslChecked: false + }, + updateTabState: function() { + return { searchUrl: this.url, stateChanged: true }; + }, + mergeBrowserUrl: false, + trigger: true + }); } }); return TagLayoutView; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/dashboardv2/public/js/views/tag/addTagAttributeItemView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/addTagAttributeItemView.js b/dashboardv2/public/js/views/tag/addTagAttributeItemView.js deleted file mode 100644 index c588ba8..0000000 --- a/dashboardv2/public/js/views/tag/addTagAttributeItemView.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -define(['require', - 'backbone', - 'hbs!tmpl/tag/addTagAttributeItemView_tmpl', - -], function(require, Backbone, addTagAttributeItemViewTmpl) { - 'use strict'; - - return Backbone.Marionette.ItemView.extend( - /** @lends GlobalExclusionListView */ - { - - template: addTagAttributeItemViewTmpl, - - /** Layout sub regions */ - regions: {}, - - /** ui selector cache */ - ui: {}, - /** ui events hash */ - events: { - 'click #close': 'onCloseButton', - 'change input': function(e) { - this.saveBtn.removeAttr("disabled"); - this.model.set({ name: e.currentTarget.value }); - }, - 'keypress #attributeId': function(e) { - if (this.$(e.currentTarget).val() == "") { - this.saveBtn.removeAttr("disabled"); - } - }, - 'keyup #attributeId': function(e) { - if (e.keyCode == 8 && this.$(e.currentTarget).val() == "") { - this.saveBtn.attr("disabled", "true"); - } - }, - }, - /** - * intialize a new GlobalExclusionComponentView Layout - * @constructs - */ - initialize: function(options) { - this.saveBtn = options.saveBtn; - }, - onRender: function() {}, - bindEvents: function() {}, - onCloseButton: function() { - this.model.destroy(); - this.saveBtn.removeAttr("disabled"); - } - }); -}); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/dashboardv2/public/js/views/tag/addTagModalView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/addTagModalView.js b/dashboardv2/public/js/views/tag/addTagModalView.js index 546df22..2591a3f 100644 --- a/dashboardv2/public/js/views/tag/addTagModalView.js +++ b/dashboardv2/public/js/views/tag/addTagModalView.js @@ -23,11 +23,11 @@ define(['require', 'modules/Modal', 'models/VEntity', 'utils/Utils' -], function(require, addTagModalViewTmpl, VTagList, VCommonList, Modal, VEntity, Utils) { +], function(require, AddTagModalViewTmpl, VTagList, VCommonList, Modal, VEntity, Utils) { 'use strict'; var AddTagModel = Marionette.LayoutView.extend({ - template: addTagModalViewTmpl, + template: AddTagModalViewTmpl, regions: {}, ui: { @@ -55,8 +55,8 @@ define(['require', cancelText: "Cancel", allowCancel: true, }).open(); - var saveBtn = this.modal.$el.find('.btn-success'); - saveBtn[0].setAttribute('disabled', true); + // var saveBtn = this.modal.$el.find('.btn-atlas'); + // saveBtn[0].setAttribute('disabled', true); this.on('ok', function() { that.saveTagData(); }); @@ -107,11 +107,11 @@ define(['require', '<div class="col-sm-8 input-spacing">' + '<input type="text" class="form-control attributeInputVal attrName" data-key="' + attribute[i].name + '" ></input></div>'; this.ui.tagAttribute.append(this.strAttribute); - if (this.commonCollection.models[0].attributes.traitTypes[0].superTypes.length > 0) { - for (var j = 0; j < this.commonCollection.models[0].attributes.traitTypes[0].superTypes.length; j++) { - var superTypeAttr = this.commonCollection.models[0].attributes.traitTypes[0].superTypes[j]; - this.fetchTagSubData(superTypeAttr); - } + } + if (this.commonCollection.models[0].attributes.traitTypes[0].superTypes.length > 0) { + for (var j = 0; j < this.commonCollection.models[0].attributes.traitTypes[0].superTypes.length; j++) { + var superTypeAttr = this.commonCollection.models[0].attributes.traitTypes[0].superTypes[j]; + this.fetchTagSubData(superTypeAttr); } } } @@ -137,18 +137,16 @@ define(['require', success: function(data) { that.modalCollection.fetch({ reset: true }); Utils.notifySuccess({ - content: "Tag " + tagName + " has been added successfully" + content: "Tag " + tagName + " has been added to entity" }); }, error: function(error, data, status) { - var message = "Tag " + tagName + " could not be added"; if (error && error.responseText) { var data = JSON.parse(error.responseText); - message = data.error; + Utils.notifyError({ + content: data.error + }); } - Utils.notifyError({ - content: message - }); }, complete: function() {} }); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/dashboardv2/public/js/views/tag/createTagsLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/createTagsLayoutView.js b/dashboardv2/public/js/views/tag/createTagsLayoutView.js deleted file mode 100644 index 95ac2b1..0000000 --- a/dashboardv2/public/js/views/tag/createTagsLayoutView.js +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -define(['require', - 'backbone', - 'hbs!tmpl/tag/createTagLayoutView_tmpl', - 'views/tag/addTagAttributeItemView', - 'utils/Utils' -], function(require, Backbone, createTagLayoutViewTmpl, addTagAttributeItemView, Utils) { - 'use strict'; - - var CreateTagView = Marionette.CompositeView.extend({ - template: createTagLayoutViewTmpl, - regions: {}, - - childView: addTagAttributeItemView, - - childViewContainer: "div[data-id='addAttributeDiv']", - - childViewOptions: function() { - return { - saveBtn: this.ui.saveButton - }; - }, - /** ui selector cache */ - ui: { - parentTag: "[data-id='parentTag']", - addAttrBtn: "[data-id='addAttrBtn']", - refreshBtn: "[data-id='refreshBtn']", - typeName: "[data-id='typeName']", - saveButton: "[data-id='saveButton']" - }, - events: function() { - var events = {}, - that = this; - events["click " + this.ui.refreshBtn] = 'onRefreshClick'; - events["click " + this.ui.addAttrBtn] = 'onAddAttribute'; - events["keypress " + this.ui.typeName] = 'onTypeName'; - events["keyup " + this.ui.typeName] = 'onBackSpceName'; - events["click " + this.ui.saveButton] = 'onSaveButton'; - return events; - }, - /** - * intialize a new createTagLayoutView_tmpl Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options, 'globalVent', 'tagsCollection')); - this.collection = new Backbone.Collection(); - this.bindEvents(); - this.json = { - "enumTypes": [], - "traitTypes": [], - "structTypes": [], - "classTypes": [] - }; - }, - bindEvents: function() { - this.listenTo(this.tagsCollection, 'reset', function() { - this.tagsCollectionList(); - }, this); - }, - onRender: function() { - this.fetchCollection(); - }, - tagsCollectionList: function() { - this.ui.parentTag.empty(); - for (var i = 0; i < this.tagsCollection.fullCollection.models.length; i++) { - var tags = this.tagsCollection.fullCollection.models[i].get("tags"); - var str = '<option>' + tags + '</option>'; - this.ui.parentTag.append(str); - } - }, - fetchCollection: function() { - $.extend(this.tagsCollection.queryParams, { type: 'TRAIT' }); - this.tagsCollection.fetch({ reset: true }); - }, - onRefreshClick: function() { - this.fetchCollection(); - }, - onAddAttribute: function(e) { - e.preventDefault(); - this.collection.add(new Backbone.Model({ - "dataTypeName": "string", - "multiplicity": "optional", - "isComposite": false, - "isUnique": false, - "isIndexable": true, - "reverseAttributeName": null - })); - if (this.ui.addAttrBtn.val() == "") { - this.ui.saveButton.attr("disabled", "true"); - } - }, - onTypeName: function() { - if (this.ui.typeName.val() == "") { - this.ui.saveButton.removeAttr("disabled"); - this.ui.addAttrBtn.removeAttr("disabled"); - } - }, - onBackSpceName: function(e) { - if (e.keyCode == 8 && this.ui.typeName.val() == "") { - this.ui.saveButton.attr("disabled", "true"); - this.ui.addAttrBtn.attr("disabled", "true"); - } - }, - onSaveButton: function() { - var that = this; - this.name = this.ui.typeName.val(); - this.json.traitTypes[0] = { - attributeDefinitions: this.collection.toJSON(), - typeName: this.name, - typeDescription: null, - superTypes: this.ui.parentTag.val(), - hierarchicalMetaTypeName: "org.apache.atlas.typesystem.types.TraitType" - }; - new this.tagsCollection.model().set(this.json).save(null, { - success: function(model, response) { - that.fetchCollection(); - that.ui.typeName.val(""); - that.ui.saveButton.attr("disabled", "true"); - Utils.notifySuccess({ - content: that.name + " has been created" - }); - that.collection.reset(); - }, - error: function(model, response) { - if (response.responseJSON && response.responseJSON.error) { - Utils.notifyError({ - content: response.responseJSON.error - }); - } - } - }); - } - }); - return CreateTagView; -}); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 30fb95a..685eb7d 100755 --- a/pom.xml +++ b/pom.xml @@ -1670,6 +1670,7 @@ <exclude>**/public/css/font-awesome.min.css</exclude> <exclude>**/public/js/require-handlebars-plugin/**</exclude> <exclude>**/node_modules/**</exclude> + <exclude>**/public/css/scss/**</exclude> <!-- All the npm plugins are copied here, so exclude it --> <exclude>**/public/js/libs/**</exclude> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/440bd2ae/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 6e73a39..c44ad0b 100644 --- a/release-log.txt +++ b/release-log.txt @@ -21,6 +21,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags) ALL CHANGES: +ATLAS-802 New look UI to show Business Catalog functionalities (kevalbhatt18 via yhemanth) ATLAS-658 Improve Lineage with Backbone porting (kevalbhatt18 via yhemanth) ATLAS-491 Business Catalog / Taxonomy (jspeidel via yhemanth) ATLAS-713 Entity lineage based on entity id (shwethags)
