atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suma...@apache.org
Subject incubator-atlas git commit: ATLAS-793 Business Catalog Delete / ATLAS-845 : Atlas UI to delete terms using API
Date Fri, 03 Jun 2016 19:56:34 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 86494ffd7 -> db0d3f9b7


ATLAS-793 Business Catalog Delete / ATLAS-845 : Atlas UI to delete terms using API


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

Branch: refs/heads/master
Commit: db0d3f9b7b935ce6b36c14c8dbc11c1bc270e608
Parents: 86494ff
Author: Kalyani Kashikar <kalyani.kashikar@freestoneinfotech.com>
Authored: Fri Jun 3 13:40:55 2016 +0530
Committer: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Committed: Fri Jun 3 12:56:27 2016 -0700

----------------------------------------------------------------------
 dashboardv2/public/js/models/VCatalog.js        |   8 ++
 .../business_catalog/AddTermView_tmpl.html      |   2 +-
 .../templates/tag/AddTagAttributeView_tmpl.html |   2 +-
 .../templates/tag/createTagLayoutView_tmpl.html |   2 +-
 .../BusinessCatalogLayoutView.js                | 101 +++++++++++++------
 5 files changed, 80 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/db0d3f9b/dashboardv2/public/js/models/VCatalog.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/models/VCatalog.js b/dashboardv2/public/js/models/VCatalog.js
index 7cb7359..346de51 100644
--- a/dashboardv2/public/js/models/VCatalog.js
+++ b/dashboardv2/public/js/models/VCatalog.js
@@ -37,6 +37,14 @@ define(['require',
         toString: function() {
             return this.get('name');
         },
+        deleteTerm: function(termURL, options) {
+            var url = Globals.baseURL + termURL;
+            options = _.extend({
+                contentType: 'application/json',
+                dataType: 'json'
+            }, options);
+            return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
+        }
     }, {});
     return VCatalog;
 });

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/db0d3f9b/dashboardv2/public/js/templates/business_catalog/AddTermView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/business_catalog/AddTermView_tmpl.html b/dashboardv2/public/js/templates/business_catalog/AddTermView_tmpl.html
index d893527..c63826b 100644
--- a/dashboardv2/public/js/templates/business_catalog/AddTermView_tmpl.html
+++ b/dashboardv2/public/js/templates/business_catalog/AddTermView_tmpl.html
@@ -17,7 +17,7 @@
 <form name="tagDefinitionform" class="css-form" onsubmit="return false;">
     <!-- <h4 style="margin-bottom:30px">Add Term</h4> -->
     <div class="form-group">
-        <input class="form-control" data-id="termName" placeholder="Add subterm">
+        <input class="form-control" data-id="termName" placeholder="Add subterm" autofocus>
     </div>
     <div class="form-group">
         <textarea class="form-control" data-id="termDetail" placeholder="Description"></textarea>

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/db0d3f9b/dashboardv2/public/js/templates/tag/AddTagAttributeView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/tag/AddTagAttributeView_tmpl.html b/dashboardv2/public/js/templates/tag/AddTagAttributeView_tmpl.html
index c13344c..a62b079 100644
--- a/dashboardv2/public/js/templates/tag/AddTagAttributeView_tmpl.html
+++ b/dashboardv2/public/js/templates/tag/AddTagAttributeView_tmpl.html
@@ -17,7 +17,7 @@
 <div class="row row-margin-bottom">
     <div class="col-sm-12">
         <div class="form-group">
-            <input type="text" class="form-control row-margin-top" name="name" data-id="attributeId"
placeholder="Attribute name" required="" value={{name}}>
+            <input type="text" class="form-control row-margin-top" name="name" data-id="attributeId"
autofocus placeholder="Attribute name" required="" value={{name}}>
         </div>
     </div>
 </div>

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/db0d3f9b/dashboardv2/public/js/templates/tag/createTagLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/tag/createTagLayoutView_tmpl.html b/dashboardv2/public/js/templates/tag/createTagLayoutView_tmpl.html
index 3e0bd32..574ab7f 100644
--- a/dashboardv2/public/js/templates/tag/createTagLayoutView_tmpl.html
+++ b/dashboardv2/public/js/templates/tag/createTagLayoutView_tmpl.html
@@ -17,7 +17,7 @@
 <form name="tagDefinitionform" class="css-form">
     <!-- <h4 style="margin-bottom:30px"></h4> -->
     <div class="form-group">
-        <input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)">
+        <input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)"
autofocus>
         </input>
         <input class="form-control row-margin-bottom" data-id="description" placeholder="Description">
         </input>

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/db0d3f9b/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js b/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
index 3112963..53511e6 100644
--- a/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
@@ -101,8 +101,7 @@ define(['require',
                             content: response.responseJSON.message
                         });
                     }
-                    this.$('.taxanomyloader').hide();
-                    this.$('.contentLoading').hide();
+                    this.hideLoader();
                 }, this);
                 this.listenTo(this.parentCollection, 'error', function(model, response) {
                     if (response && response.responseJSON && response.responseJSON.message)
{
@@ -110,8 +109,7 @@ define(['require',
                             content: response.responseJSON.message
                         });
                     }
-                    this.$('.taxanomyloader').hide();
-                    this.$('.contentLoading').hide();
+                    this.hideLoader();
                 }, this);
             },
             onRender: function() {
@@ -153,7 +151,6 @@ define(['require',
                 }
             },
             changeArrowState: function(e) {
-
                 var scope = this.$('[data-id="expandArrow"]');
                 if (e) {
                     scope = $(e.currentTarget);
@@ -174,8 +171,6 @@ define(['require',
                         this.ui.childList.show();
                     }
                 }
-
-
             },
             fetchCollection: function(url, isParent) {
                 if (url) {
@@ -189,8 +184,7 @@ define(['require',
                     }
 
                 }
-                this.$('.taxanomyloader').show();
-                this.$('.contentLoading').show();
+                this.showLoader();
                 if (isParent) {
                     this.parentCollection.url = this.url;
                     this.parentCollection.fullCollection.reset(undefined, { silent: true
});
@@ -201,6 +195,14 @@ define(['require',
                     this.childCollection.fetch({ reset: true });
                 }
             },
+            showLoader() {
+                this.$('.taxonomyTree').find('li.active .tools .taxanomyloader').show();
+                this.$('.contentLoading').show();
+            },
+            hideLoader() {
+                this.$('.taxanomyloader').hide();
+                this.$('.contentLoading').hide();
+            },
             forwardClick: function(e, forward, url) {
                 var hrefUrl = "";
                 if (e) {
@@ -296,21 +298,22 @@ define(['require',
                     this.$('.taxonomyTree').find('a[data-href="' + this.refresh + '"]').parent().addClass('active');
                     this.refresh = undefined;
                 }
-                this.$('.taxanomyloader').hide();
-                this.$('.contentLoading').hide();
+                this.hideLoader();
                 this.$('.termPopover').popover({
                     placement: 'bottom',
                     html: true,
                     trigger: 'manual',
                     container: 'body',
                     content: function() {
-                        return "<ul class='termPopoverList'>" +
-                            "<li class='listTerm' ><i class='fa fa-search'></i>
<a href='javascript:void(0)' data-fn='onSearchTerm'>Search Assets</a></li>"
+
-                            "<li class='listTerm'><i class='fa fa-plus'></i>
<a href='javascript:void(0)' data-fn='onAddTerm'>Add Subterm</a></li>" +
-                            /* "<li class='listTerm' ><i class='fa fa-arrow-right'></i>
<a href='javascript:void(0)' data-fn='moveTerm'>Move Term</a></li>" +
-                             "<li class='listTerm' ><i class='fa fa-edit'></i>
<a href='javascript:void(0)' data-fn='onEditTerm'>Edit Term</a></li>" +
-                             "<li class='listTerm'><i class='fa fa-trash'></i>
<a href='javascript:void(0)' data-fn='deleteTerm'>Delete Term</a></li>"
+*/
-                            "</ul>";
+                        var li = "<li class='listTerm' ><i class='fa fa-search'></i>
<a href='javascript:void(0)' data-fn='onSearchTerm'>Search Assets</a></li>"
+
+                            "<li class='listTerm'><i class='fa fa-plus'></i>
<a href='javascript:void(0)' data-fn='onAddTerm'>Add Subterm</a></li>";
+                        /* "<li class='listTerm' ><i class='fa fa-arrow-right'></i>
<a href='javascript:void(0)' data-fn='moveTerm'>Move Term</a></li>" +
+                         "<li class='listTerm' ><i class='fa fa-edit'></i>
<a href='javascript:void(0)' data-fn='onEditTerm'>Edit Term</a></li>" +*/
+                        var termDataURL = Utils.getUrlState.getQueryUrl().hash.split("terms");
+                        if (termDataURL.length > 1) {
+                            li += "<li class='listTerm'><i class='fa fa-trash'></i>
<a href='javascript:void(0)' data-fn='deleteTerm'>Delete Term</a></li>"
+                        }
+                        return "<ul class='termPopoverList'>" + li + "</ul>";
                     }
                 });
                 this.$('.termPopover').off('click').on('click', function(e) {
@@ -338,9 +341,18 @@ define(['require',
                         allowCancel: true,
                         okText: 'Create',
                     }).open();
+                    modal.$el.find('button.ok').attr('disabled', true);
                     modal.on('ok', function() {
                         that.saveAddTerm(view);
                     });
+                    view.ui.termName.on('keyup', function() {
+                        if (this.value.indexOf(' ') >= 0) {
+                            modal.$el.find('button.ok').prop('disabled', true);
+                        } else {
+                            modal.$el.find('button.ok').prop('disabled', false);
+                        }
+
+                    });
                     view.on('closeModal', function() {
                         modal.trigger('cancel');
                     });
@@ -351,6 +363,7 @@ define(['require',
                 var that = this;
                 var url = view.url;
                 view.model.url = url + "/terms/" + view.ui.termName.val();
+                this.showLoader();
                 view.model.set({ description: view.ui.termDetail.val() }).save(null, {
                     success: function(model, response) {
                         that.create = true;
@@ -363,30 +376,54 @@ define(['require',
                     },
                     error: function(model, response) {
                         Utils.notifyError({
-                            content: response.responseJSON.message
+                            content: "Term " + view.ui.termName.val() + " could not be Created"
                         });
+                    },
+                    complete: function() {
+                        that.hideLoader();
                     }
                 });
             },
             deleteTerm: function(e) {
-                var tagName = this.$('.taxonomyTree').find('li.active').find("a").text(),
+                var termName = this.$('.taxonomyTree').find('li.active a').data("name"),
                     that = this,
-                    modal = CommonViewFunction.deleteTagModel(tagName);
+                    modal = CommonViewFunction.deleteTagModel(termName);
                 modal.on('ok', function() {
-                    that.deleteTagData(e);
+                    that.deleteTermData(e);
                 });
                 modal.on('closeModal', function() {
                     modal.trigger('cancel');
                 });
             },
-            deleteTagData: function(e) {
-                var that = this,
-                    tagName = this.$('.taxonomyTree').find('li.active').find("a").text(),
-                    guid = $(e.target).data("guid");
-                CommonViewFunction.deleteTag({
-                    'tagName': tagName,
-                    'guid': guid,
-                    'collection': that.parentCollection
+            deleteTermData: function(e) {
+                var that = this;
+                this.showLoader();
+                require(['models/VCatalog'], function(VCatalog) {
+                    var termModel = new VCatalog(),
+                        url = that.$('.taxonomyTree').find('li.active a').data('href');
+                    var termName = that.$('.taxonomyTree').find('li.active a').text();
+                    termModel.deleteTerm(url, {
+                        beforeSend: function() {},
+                        success: function(data) {
+                            Utils.notifySuccess({
+                                content: "Term " + termName + " has been deleted successfully"
+                            });
+                            var termURL = url.split("/").slice(0, -2).join("/");
+                            that.forwardClick(undefined, true, termURL);
+                        },
+                        error: function(error, data, status) {
+                            var message = "Term " + termName + " could not be deleted";
+                            if (data.error) {
+                                message = data.error;
+                            }
+                            Utils.notifyError({
+                                content: message
+                            });
+                        },
+                        complete: function() {
+                            that.hideLoader();
+                        }
+                    });
                 });
             },
             moveTerm: function() {
@@ -415,6 +452,7 @@ define(['require',
                 });
             },
             onSearchTerm: function() {
+                this.showLoader();
                 Utils.setUrl({
                     url: '#!/search/searchResult',
                     urlParams: {
@@ -452,7 +490,6 @@ define(['require',
                 this.taxanomy.fetch({ reset: true });
             },
             searchResult: function() {
-
                 var that = this;
                 _.each(this.taxanomy.models, function(model, key) {
                     var name = model.get('name');
@@ -479,7 +516,7 @@ define(['require',
                 this.refresh = this.$('.taxonomyTree').find('.active a').data('href');
                 this.fetchCollection(this.url);
                 this.changeArrowState();
-            },
+            }
         });
     return BusinessCatalogLayoutView;
 });


Mime
View raw message