atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kbh...@apache.org
Subject incubator-atlas git commit: ATLAS-1737: UI - Delete tag(classification) from UI.
Date Fri, 28 Apr 2017 14:36:18 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/0.8-incubating 97b71e8be -> f32436b64


ATLAS-1737: UI - Delete tag(classification) from UI.


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/f32436b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/f32436b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/f32436b6

Branch: refs/heads/0.8-incubating
Commit: f32436b64710bc6f36ee3f2a5b6cf465e2f3c4c3
Parents: 97b71e8
Author: Kalyani <kalyani.kashikar@freestoneinfotech.com>
Authored: Fri Apr 28 17:28:11 2017 +0530
Committer: kevalbhatt <kbhatt@apache.org>
Committed: Fri Apr 28 20:05:45 2017 +0530

----------------------------------------------------------------------
 dashboardv2/public/js/models/VTag.js            | 10 ++-
 .../public/js/utils/CommonViewFunction.js       |  2 +-
 dashboardv2/public/js/utils/Utils.js            | 11 ++-
 .../views/business_catalog/SideNavLayoutView.js |  3 +-
 .../public/js/views/tag/TagLayoutView.js        | 78 +++++++++++++++++---
 5 files changed, 88 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/f32436b6/dashboardv2/public/js/models/VTag.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/models/VTag.js b/dashboardv2/public/js/models/VTag.js
index 046af3f..c875d5a 100644
--- a/dashboardv2/public/js/models/VTag.js
+++ b/dashboardv2/public/js/models/VTag.js
@@ -40,7 +40,7 @@ define(['require',
         /*************************
          * Non - CRUD operations
          *************************/
-        deleteTag: function(guid, name, options) {
+        deleteAssociation: function(guid, name, options) {
             var url = UrlLinks.entitiesApiUrl(guid, name);
             options = _.extend({
                 contentType: 'application/json',
@@ -48,6 +48,14 @@ define(['require',
             }, options);
             return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
         },
+        deleteTag: function(options) {
+            var url = UrlLinks.typesClassicationApiUrl();
+            options = _.extend({
+                contentType: 'application/json',
+                dataType: 'json'
+            }, options);
+            return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
+        },
         saveTagAttribute: function(options) {
             var url = UrlLinks.typesClassicationApiUrl();
             options = _.extend({

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/f32436b6/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index 1890ce3..ce12466 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -39,7 +39,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
                 if (options.showLoader) {
                     options.showLoader();
                 }
-                tagModel.deleteTag(options.guid, options.tagName, {
+                tagModel.deleteAssociation(options.guid, options.tagName, {
                     skipDefaultError: true,
                     success: function(data) {
                         var msg = "Tag " + name.name + Messages.removeSuccessMessage;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/f32436b6/dashboardv2/public/js/utils/Utils.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/Utils.js b/dashboardv2/public/js/utils/Utils.js
index d62a726..0d43814 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -94,10 +94,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
                 history: false
             }
         }, options)).get().on('pnotify.confirm', function() {
+            $('.ui-pnotify-modal-overlay').remove().fadeOut();
             if (options.ok) {
                 options.ok();
             }
         }).on('pnotify.cancel', function() {
+            $('.ui-pnotify-modal-overlay').remove().fadeOut();
             if (options.cancel) {
                 options.cancel();
             }
@@ -229,8 +231,11 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
     };
 
     Utils.getUrlState = {
-        getQueryUrl: function() {
+        getQueryUrl: function(url) {
             var hashValue = window.location.hash;
+            if (url) {
+                hashValue = url;
+            }
             return {
                 firstValue: hashValue.split('/')[1],
                 hash: hashValue,
@@ -259,8 +264,8 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
         getFirstValue: function() {
             return this.getQueryUrl().firstValue;
         },
-        getQueryParams: function() {
-            var qs = this.getQueryUrl().queyParams[1];
+        getQueryParams: function(url) {
+            var qs = this.getQueryUrl(url).queyParams[1];
             if (typeof qs == "string") {
                 qs = qs.split('+').join(' ');
                 var params = {},

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/f32436b6/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
index 9bd1bbf..8c67d11 100644
--- a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
@@ -97,7 +97,8 @@ define(['require',
             require(['views/tag/TagLayoutView'], function(TagLayoutView) {
                 that.RTagLayoutView.show(new TagLayoutView({
                     collection: that.collection,
-                    tag: that.tag
+                    tag: that.tag,
+                    typeHeaders: that.typeHeaders
                 }));
             });
         },

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/f32436b6/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 d8ee351..0174fa5 100644
--- a/dashboardv2/public/js/views/tag/TagLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagLayoutView.js
@@ -22,8 +22,9 @@ define(['require',
     'utils/Utils',
     'utils/Messages',
     'utils/Globals',
-    'utils/UrlLinks'
-], function(require, Backbone, TagLayoutViewTmpl, Utils, Messages, Globals, UrlLinks) {
+    'utils/UrlLinks',
+    'models/VTag'
+], function(require, Backbone, TagLayoutViewTmpl, Utils, Messages, Globals, UrlLinks, VTag)
{
     'use strict';
 
     var TagLayoutView = Backbone.Marionette.LayoutView.extend(
@@ -58,11 +59,11 @@ define(['require',
              * @constructs
              */
             initialize: function(options) {
-                _.extend(this, _.pick(options, 'tag', 'collection'));
+                _.extend(this, _.pick(options, 'tag', 'collection', 'typeHeaders'));
             },
             bindEvents: function() {
                 var that = this;
-                this.listenTo(this.collection, "reset add", function() {
+                this.listenTo(this.collection, "reset add remove", function() {
                     this.tagsAndTypeGenerator('collection');
                 }, this);
                 this.ui.tagsParent.on('click', 'li.parent-node a', function() {
@@ -163,7 +164,6 @@ define(['require',
                 if (this.createTag) {
                     this.createTag = false;
                 }
-
             },
             onClickCreateTag: function(e) {
                 var that = this;
@@ -257,8 +257,6 @@ define(['require',
                             duplicateAttributeList.push(obj.name);
                         }
                     });
-
-
                     var notifyObj = {
                         confirm: {
                             confirm: true,
@@ -288,7 +286,6 @@ define(['require',
                         Utils.notifyConfirm(notifyObj);
                         return false;
                     }
-
                 }
                 this.json = {
                     classificationDefs: [{
@@ -312,6 +309,7 @@ define(['require',
                             content: "Tag " + that.name + Messages.addSuccessMessage
                         });
                         modal.trigger('cancel');
+                        that.typeHeaders.fetch({ reset: true });
                     }
                 });
             },
@@ -342,7 +340,8 @@ define(['require',
                     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>"
+
+                            "<li class='listTerm' ><i class='fa fa-search'></i>
<a href='javascript:void(0)' data-fn='onSearchTag'>Search Tag</a></li>"
+
+                            "<li class='listTerm' ><i class='fa fa-trash-o'></i>
<a href='javascript:void(0)' data-fn='onDeleteTag'>Delete Tag</a></li>"
+
                             "</ul>";
                     }
                 });
@@ -353,7 +352,7 @@ define(['require',
                     $(this).popover('toggle');
                 });
             },
-            onSearchTerm: function() {
+            onSearchTag: function() {
                 Utils.setUrl({
                     url: '#!/search/searchResult',
                     urlParams: {
@@ -367,6 +366,65 @@ define(['require',
                     mergeBrowserUrl: false,
                     trigger: true
                 });
+            },
+            onDeleteTag: function() {
+                var that = this;
+                this.tagName = this.ui.tagsParent.find('li.active').find("a").data('name');
+                this.tagDeleteData = this.ui.tagsParent.find('li.active');
+                var notifyObj = {
+                    ok: function(argument) {
+                        that.onNotifyOk();
+                    },
+                    cancel: function(argument) {}
+                }
+                var text = "Are you sure you want to delete the tag"
+                notifyObj['text'] = text;
+                notifyObj['stack'] = {
+                    'dir1': 'down',
+                    'dir2': 'right',
+                    'modal': true
+                };
+                Utils.notifyConfirm(notifyObj);
+            },
+            onNotifyOk: function(data) {
+                var that = this,
+                    deleteTagData = this.collection.fullCollection.findWhere({ name: this.tagName
}),
+                    classificationData = deleteTagData.toJSON(),
+                    deleteJson = {
+                        classificationDefs: [classificationData],
+                        entityDefs: [],
+                        enumDefs: [],
+                        structDefs: []
+                    };
+                deleteTagData.deleteTag({
+                    data: JSON.stringify(deleteJson),
+                    success: function() {
+                        Utils.notifySuccess({
+                            content: "Tag " + that.tagName + Messages.deleteSuccessMessage
+                        });
+                        var searchUrl = Globals.saveApplicationState.tabState.searchUrl;
+                        var urlObj = Utils.getUrlState.getQueryParams(searchUrl);
+                        if (urlObj && urlObj.tag && urlObj.tag === that.tagName)
{
+                            Globals.saveApplicationState.tabState.searchUrl = "#!/search";
+                        }
+                        that.ui.tagsParent.find('li.active').removeClass('active');
+                        if (that.tagDeleteData.prev().length === 0) {
+                            that.tagDeleteData.next().addClass('active');
+                        } else {
+                            that.tagDeleteData.prev().addClass('active');
+                        }
+                        Utils.setUrl({
+                            url: that.ui.tagsParent.find('li.active').find("a").attr("href"),
+                            mergeBrowserUrl: false,
+                            trigger: true,
+                            updateTabState: function() {
+                                return { tagUrl: that.url, stateChanged: true };
+                            }
+                        });
+                        that.collection.remove(deleteTagData);
+                        that.typeHeaders.fetch({ reset: true });
+                    }
+                });
             }
         });
     return TagLayoutView;


Mime
View raw message