You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by kb...@apache.org on 2020/02/20 14:41:39 UTC

[atlas] branch master updated (70ebb22 -> b0c85dd)

This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git.


    from 70ebb22  ATLAS-3554 : UI: changes to display/add/update/delete namespace attributes for entities in entity details page
     new 3680ab4  ATLAS-3626 : Beta UI : No option to overwrite Saved Search
     new fd1aad3  ATLAS-3627:Beta UI, Usability: Classifications default toggle set to show only classifications associated to entity
     new cd177f8  ATLAS-3623 : Beta UI: Basic search improvement to search for namespace attribute
     new b0c85dd  ATLAS-3629 : UI: skipDefaultError handler improvement

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dashboardv2/public/js/main.js                      |   5 -
 dashboardv2/public/js/utils/CommonViewFunction.js  |   9 +-
 dashboardv2/public/js/utils/Overrides.js           |   4 +-
 dashboardv2/public/js/utils/Utils.js               |  43 ++++----
 .../public/js/views/graph/LineageLayoutView.js     |   1 -
 .../js/views/profile/ProfileColumnLayoutView.js    |   1 -
 .../js/views/profile/ProfileTableLayoutView.js     |   1 -
 .../public/js/views/search/SearchLayoutView.js     |   2 -
 dashboardv2/public/js/views/site/Statistics.js     |   1 -
 dashboardv2/public/js/views/tag/AddTagModalView.js |   9 +-
 dashboardv3/public/css/scss/theme.scss             |  15 +++
 dashboardv3/public/js/main.js                      |   6 --
 .../search/save/SaveModalLayoutView_tmpl.html      |   9 +-
 .../tree/ClassificationTreeLayoutView_tmpl.html    |   2 +-
 dashboardv3/public/js/utils/CommonViewFunction.js  |   9 +-
 dashboardv3/public/js/utils/Overrides.js           |   4 +-
 dashboardv3/public/js/utils/Utils.js               |  43 ++++----
 .../administrator/PurgeAuditTableLayoutView.js     |   1 -
 .../public/js/views/graph/LineageLayoutView.js     |   1 -
 .../name_space/NameSpaceAttrTableLayoutView.js     |  75 +++++++-------
 .../name_space/NameSpaceContainerLayoutView.js     |   1 -
 .../js/views/profile/ProfileColumnLayoutView.js    |   1 -
 .../js/views/profile/ProfileTableLayoutView.js     |   1 -
 .../public/js/views/search/QueryBuilderView.js     |  25 +++++
 .../js/views/search/SearchDefaultLayoutView.js     |  21 +++-
 .../js/views/search/SearchResultLayoutView.js      |  26 ++++-
 .../js/views/search/save/SaveModalLayoutView.js    | 109 +++++++++++++++++----
 .../search/tree/ClassificationTreeLayoutView.js    |   5 +-
 .../search/tree/CustomFilterTreeLayoutView.js      |  37 ++++---
 .../js/views/search/tree/EntityTreeLayoutView.js   |   4 -
 .../views/search/tree/NameSpaceTreeLayoutView.js   |   1 -
 dashboardv3/public/js/views/site/Statistics.js     |   1 -
 dashboardv3/public/js/views/tag/AddTagModalView.js |   9 +-
 33 files changed, 283 insertions(+), 199 deletions(-)


[atlas] 02/04: ATLAS-3627:Beta UI, Usability: Classifications default toggle set to show only classifications associated to entity

Posted by kb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit fd1aad38fb762b07ee225ffae002e980658e85fd
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Thu Feb 20 15:40:43 2020 +0530

    ATLAS-3627:Beta UI, Usability: Classifications default toggle set to show only classifications associated to entity
---
 .../js/templates/search/tree/ClassificationTreeLayoutView_tmpl.html     | 2 +-
 dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dashboardv3/public/js/templates/search/tree/ClassificationTreeLayoutView_tmpl.html b/dashboardv3/public/js/templates/search/tree/ClassificationTreeLayoutView_tmpl.html
index d0d4c0b..54e3a4b 100644
--- a/dashboardv3/public/js/templates/search/tree/ClassificationTreeLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/search/tree/ClassificationTreeLayoutView_tmpl.html
@@ -22,7 +22,7 @@
             <button type="button" class="typeRefresh drop-down-menu-view" data-id="refreshTree" data-type="classification" title="Refresh">
                 <i class="fa fa-refresh"></i>
             </button>
-            <button type="button" class="typeRefresh drop-down-menu-view" data-id="showEmptyClassifications" title="Show unused classification">
+            <button type="button" class="typeRefresh drop-down-menu-view" data-id="showEmptyClassifications" title="Hide unused classification">
                 <i class="fa fa-toggle-off"></i>
             </button>
             <button type="button" class="typeRefresh dropdown">
diff --git a/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
index 5c2026b..78a8b24 100644
--- a/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
@@ -142,7 +142,7 @@ define([
             );
             this.bindEvents();
             this.entityCountObj = _.first(this.metricCollection.toJSON());
-            this.isEmptyClassification = true;
+            this.isEmptyClassification = false;
             this.entityTreeData = {};
             this.tagId = null;
             this.isGroupView = true;


[atlas] 04/04: ATLAS-3629 : UI: skipDefaultError handler improvement

Posted by kb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit b0c85dd99aaabe296875847fdab0e0d5fe6cd846
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Thu Feb 20 16:25:04 2020 +0530

    ATLAS-3629 : UI: skipDefaultError handler improvement
---
 dashboardv2/public/js/main.js                      |  5 --
 dashboardv2/public/js/utils/CommonViewFunction.js  |  9 +--
 dashboardv2/public/js/utils/Overrides.js           |  4 +-
 dashboardv2/public/js/utils/Utils.js               | 43 ++++++-------
 .../public/js/views/graph/LineageLayoutView.js     |  1 -
 .../js/views/profile/ProfileColumnLayoutView.js    |  1 -
 .../js/views/profile/ProfileTableLayoutView.js     |  1 -
 .../public/js/views/search/SearchLayoutView.js     |  2 -
 dashboardv2/public/js/views/site/Statistics.js     |  1 -
 dashboardv2/public/js/views/tag/AddTagModalView.js |  9 +--
 dashboardv3/public/js/main.js                      |  6 --
 dashboardv3/public/js/utils/CommonViewFunction.js  |  9 +--
 dashboardv3/public/js/utils/Overrides.js           |  4 +-
 dashboardv3/public/js/utils/Utils.js               | 43 ++++++-------
 .../administrator/PurgeAuditTableLayoutView.js     |  1 -
 .../public/js/views/graph/LineageLayoutView.js     |  1 -
 .../name_space/NameSpaceAttrTableLayoutView.js     | 75 +++++++++++-----------
 .../name_space/NameSpaceContainerLayoutView.js     |  1 -
 .../js/views/profile/ProfileColumnLayoutView.js    |  1 -
 .../js/views/profile/ProfileTableLayoutView.js     |  1 -
 .../search/tree/ClassificationTreeLayoutView.js    |  3 -
 .../js/views/search/tree/EntityTreeLayoutView.js   |  4 --
 .../views/search/tree/NameSpaceTreeLayoutView.js   |  1 -
 dashboardv3/public/js/views/site/Statistics.js     |  1 -
 dashboardv3/public/js/views/tag/AddTagModalView.js |  9 +--
 25 files changed, 85 insertions(+), 151 deletions(-)

diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js
index 01dd0ae..75e16c3 100644
--- a/dashboardv2/public/js/main.js
+++ b/dashboardv2/public/js/main.js
@@ -258,7 +258,6 @@ require(['App',
         }
     });
     this.entityDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.entityDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -269,7 +268,6 @@ require(['App',
         }
     });
     this.typeHeaders.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.typeHeaders.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -280,7 +278,6 @@ require(['App',
         }
     });
     this.enumDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.enumDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -291,7 +288,6 @@ require(['App',
         }
     });
     this.classificationDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.classificationDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -303,7 +299,6 @@ require(['App',
     });
 
     this.metricCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             --that.asyncFetchCounter;
             startApp();
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index b9896a9..1d03732 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -34,7 +34,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
                                 options.showLoader();
                             }
                             tagModel.deleteAssociation(options.guid, options.tagName, options.associatedGuid, {
-                                skipDefaultError: true,
+                                defaultErrorMessage: options.tagName + Messages.deleteErrorMessage,
                                 success: function(data) {
                                     Utils.notifySuccess({
                                         content: "Classification " + options.tagName + Messages.getAbbreviationMsg(false, 'removeSuccessMessage')
@@ -48,16 +48,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
 
                                 },
                                 cust_error: function(model, response) {
-                                    var message = options.tagName + Messages.deleteErrorMessage;
-                                    if (response && response.responseJSON) {
-                                        message = response.responseJSON.errorMessage;
-                                    }
                                     if (options.hideLoader) {
                                         options.hideLoader();
                                     }
-                                    Utils.notifyError({
-                                        content: message
-                                    });
                                 }
                             });
                         },
diff --git a/dashboardv2/public/js/utils/Overrides.js b/dashboardv2/public/js/utils/Overrides.js
index 7e493d6..1b0947b 100644
--- a/dashboardv2/public/js/utils/Overrides.js
+++ b/dashboardv2/public/js/utils/Overrides.js
@@ -37,9 +37,7 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
         return oldBackboneSync.apply(this, [method, model,
             _.extend(options, {
                 error: function(response) {
-                    if (!options.skipDefaultError) {
-                        Utils.defaultErrorHandler(that, response);
-                    }
+                    Utils.defaultErrorHandler(that, response, options);
                     that.trigger("error", that, response);
                     if (options.cust_error) {
                         options.cust_error(that, response);
diff --git a/dashboardv2/public/js/utils/Utils.js b/dashboardv2/public/js/utils/Utils.js
index 5274ef3..53b8714 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -218,22 +218,20 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
             }
         });
     }
-    Utils.defaultErrorHandler = function(model, error) {
+    Utils.defaultErrorHandler = function(model, error, options) {
+        var skipDefaultError = null,
+            defaultErrorMessage = null;
+        if (options) {
+            skipDefaultError = options.skipDefaultError;
+            defaultErrorMessage = options.defaultErrorMessage;
+        }
         if (error && error.status) {
             if (error.status == 401) {
                 window.location = 'login.jsp'
             } else if (error.status == 419) {
                 window.location = 'login.jsp'
             } else if (error.status == 403) {
-                var message = "You are not authorized";
-                if (error.statusText) {
-                    try {
-                        message = JSON.parse(error.statusText).AuthorizationError;
-                    } catch (err) {}
-                    Utils.notifyError({
-                        content: message
-                    });
-                }
+                Utils.serverErrorHandler(error, "You are not authorized");
             } else if (error.status == "0" && error.statusText != "abort") {
                 var diffTime = (new Date().getTime() - prevNetworkErrorTime);
                 if (diffTime > 3000) {
@@ -243,22 +241,23 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
                             "It seems you are not connected to the internet. Please check your internet connection and try again"
                     });
                 }
-            } else {
-                Utils.serverErrorHandler(model, error)
+            } else if (skipDefaultError !== true) {
+                Utils.serverErrorHandler(error, defaultErrorMessage);
             }
-        } else {
-            Utils.serverErrorHandler(model, error)
+        } else if (skipDefaultError !== true) {
+            Utils.serverErrorHandler(error, defaultErrorMessage);
         }
     };
-    Utils.serverErrorHandler = function(model, response) {
-        var responseJSON = response ? response.responseJSON : response;
-        if (response && responseJSON && (responseJSON.errorMessage || responseJSON.message || responseJSON.error)) {
-            Utils.notifyError({
-                content: responseJSON.errorMessage || responseJSON.message || responseJSON.error
-            });
-        } else {
+    Utils.serverErrorHandler = function(response, defaultErrorMessage) {
+        var responseJSON = response ? response.responseJSON : response,
+            message = defaultErrorMessage ? defaultErrorMessage : Messages.defaultErrorMessage
+        if (response && responseJSON) {
+            message = responseJSON.errorMessage || responseJSON.message || responseJSON.error || message
+        }
+        var existingError = $(".ui-pnotify-container.alert-danger .ui-pnotify-text").text();
+        if (existingError !== message) {
             Utils.notifyError({
-                content: Messages.defaultErrorMessage
+                content: message
             });
         }
     };
diff --git a/dashboardv2/public/js/views/graph/LineageLayoutView.js b/dashboardv2/public/js/views/graph/LineageLayoutView.js
index af406b9..0f99ca5 100644
--- a/dashboardv2/public/js/views/graph/LineageLayoutView.js
+++ b/dashboardv2/public/js/views/graph/LineageLayoutView.js
@@ -225,7 +225,6 @@ define(['require',
                     "el": that.$(".graph-button-group button,select[data-id='selectDepth']")
                 });
                 this.collection.getLineage(this.guid, {
-                    skipDefaultError: true,
                     queryParam: queryParam,
                     success: function(data) {
                         if (that.isDestroyed) {
diff --git a/dashboardv2/public/js/views/profile/ProfileColumnLayoutView.js b/dashboardv2/public/js/views/profile/ProfileColumnLayoutView.js
index 874474f..74e19c0 100644
--- a/dashboardv2/public/js/views/profile/ProfileColumnLayoutView.js
+++ b/dashboardv2/public/js/views/profile/ProfileColumnLayoutView.js
@@ -69,7 +69,6 @@ define(['require',
             fetchEntity: function(argument) {
                 var that = this;
                 this.entityModel.getEntity(this.entityDetail.table.guid, {
-                    skipDefaultError: true,
                     success: function(data) {
                         var entity = data.entity,
                             profileData = entity && entity.attributes && entity.attributes.profileData ? entity.attributes.profileData.attributes : null;
diff --git a/dashboardv2/public/js/views/profile/ProfileTableLayoutView.js b/dashboardv2/public/js/views/profile/ProfileTableLayoutView.js
index 2414210..ada7e62 100644
--- a/dashboardv2/public/js/views/profile/ProfileTableLayoutView.js
+++ b/dashboardv2/public/js/views/profile/ProfileTableLayoutView.js
@@ -110,7 +110,6 @@ define(['require',
             fetchEntity: function(argument) {
                 var that = this;
                 this.entityModel.getEntity(this.entityDetail.db.guid, {
-                    skipDefaultError: true,
                     success: function(data) {
                         var entity = data.entity;
                         if (entity.attributes) {
diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js b/dashboardv2/public/js/views/search/SearchLayoutView.js
index 06455a9..3cd0ab4 100644
--- a/dashboardv2/public/js/views/search/SearchLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchLayoutView.js
@@ -381,7 +381,6 @@ define(['require',
                         }
                     };
                 this.metricCollection.fetch({
-                    skipDefaultError: true,
                     complete: function() {
                         --apiCount;
                         that.entityCountObj = _.first(that.metricCollection.toJSON());
@@ -390,7 +389,6 @@ define(['require',
                 });
 
                 this.typeHeaders.fetch({
-                    skipDefaultError: true,
                     silent: true,
                     complete: function() {
                         --apiCount;
diff --git a/dashboardv2/public/js/views/site/Statistics.js b/dashboardv2/public/js/views/site/Statistics.js
index 93cc87e..4bef471 100644
--- a/dashboardv2/public/js/views/site/Statistics.js
+++ b/dashboardv2/public/js/views/site/Statistics.js
@@ -104,7 +104,6 @@ define(['require',
             fetchMetricData: function(options) {
                 var that = this;
                 this.metricCollection.fetch({
-                    skipDefaultError: true,
                     success: function(data) {
                         var data = _.first(data.toJSON());
                         that.renderStats({ valueObject: data.general.stats, dataObject: data.general });
diff --git a/dashboardv2/public/js/views/tag/AddTagModalView.js b/dashboardv2/public/js/views/tag/AddTagModalView.js
index f5a5eb8..214de07 100644
--- a/dashboardv2/public/js/views/tag/AddTagModalView.js
+++ b/dashboardv2/public/js/views/tag/AddTagModalView.js
@@ -439,9 +439,9 @@ define(['require',
                 this.showLoader();
             }
             this.entityModel.saveTraitsEntity(this.tagModel ? options.guid : null, {
-                skipDefaultError: true,
                 data: JSON.stringify(json),
                 type: this.tagModel ? 'PUT' : 'POST',
+                defaultErrorMessage: "Tag " + tagName + " could not be added",
                 success: function(data) {
                     var addupdatetext = that.tagModel ? 'updated successfully to ' : 'added to ';
                     Utils.notifySuccess({
@@ -455,13 +455,6 @@ define(['require',
                     }
                 },
                 cust_error: function(model, response) {
-                    var message = "Tag " + tagName + " could not be added";
-                    if (response && response.responseJSON) {
-                        message = response.responseJSON.errorMessage;
-                    }
-                    Utils.notifyError({
-                        content: message
-                    });
                     if (that.hideLoader) {
                         that.hideLoader();
                     }
diff --git a/dashboardv3/public/js/main.js b/dashboardv3/public/js/main.js
index 9bf190f..26fd709 100644
--- a/dashboardv3/public/js/main.js
+++ b/dashboardv3/public/js/main.js
@@ -268,7 +268,6 @@ require(['App',
         }
     });
     this.entityDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.entityDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -279,7 +278,6 @@ require(['App',
         }
     });
     this.typeHeaders.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.typeHeaders.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -290,7 +288,6 @@ require(['App',
         }
     });
     this.enumDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.enumDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -301,7 +298,6 @@ require(['App',
         }
     });
     this.classificationDefCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.classificationDefCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
@@ -313,7 +309,6 @@ require(['App',
     });
 
     this.metricCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             --that.asyncFetchCounter;
             startApp();
@@ -321,7 +316,6 @@ require(['App',
     });
 
     this.nameSpaceCollection.fetch({
-        skipDefaultError: true,
         complete: function() {
             that.nameSpaceCollection.fullCollection.comparator = function(model) {
                 return model.get('name').toLowerCase();
diff --git a/dashboardv3/public/js/utils/CommonViewFunction.js b/dashboardv3/public/js/utils/CommonViewFunction.js
index f83aa0a..e429321 100644
--- a/dashboardv3/public/js/utils/CommonViewFunction.js
+++ b/dashboardv3/public/js/utils/CommonViewFunction.js
@@ -34,7 +34,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
                                 options.showLoader();
                             }
                             tagModel.deleteAssociation(options.guid, options.tagName, options.associatedGuid, {
-                                skipDefaultError: true,
+                                defaultErrorMessage: options.tagName + Messages.deleteErrorMessage,
                                 success: function(data) {
                                     Utils.notifySuccess({
                                         content: "Classification " + options.tagName + Messages.getAbbreviationMsg(false, 'removeSuccessMessage')
@@ -48,16 +48,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
 
                                 },
                                 cust_error: function(model, response) {
-                                    var message = options.tagName + Messages.deleteErrorMessage;
-                                    if (response && response.responseJSON) {
-                                        message = response.responseJSON.errorMessage;
-                                    }
                                     if (options.hideLoader) {
                                         options.hideLoader();
                                     }
-                                    Utils.notifyError({
-                                        content: message
-                                    });
                                 }
                             });
                         },
diff --git a/dashboardv3/public/js/utils/Overrides.js b/dashboardv3/public/js/utils/Overrides.js
index 42d047e..26808e4 100644
--- a/dashboardv3/public/js/utils/Overrides.js
+++ b/dashboardv3/public/js/utils/Overrides.js
@@ -37,9 +37,7 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
         return oldBackboneSync.apply(this, [method, model,
             _.extend(options, {
                 error: function(response) {
-                    if (!options.skipDefaultError) {
-                        Utils.defaultErrorHandler(that, response);
-                    }
+                    Utils.defaultErrorHandler(that, response, options);
                     that.trigger("error", that, response);
                     if (options.cust_error) {
                         options.cust_error(that, response);
diff --git a/dashboardv3/public/js/utils/Utils.js b/dashboardv3/public/js/utils/Utils.js
index 7aab725..1a5b3bc 100644
--- a/dashboardv3/public/js/utils/Utils.js
+++ b/dashboardv3/public/js/utils/Utils.js
@@ -224,22 +224,20 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
             }
         });
     }
-    Utils.defaultErrorHandler = function(model, error) {
+    Utils.defaultErrorHandler = function(model, error, options) {
+        var skipDefaultError = null,
+            defaultErrorMessage = null;
+        if (options) {
+            skipDefaultError = options.skipDefaultError;
+            defaultErrorMessage = options.defaultErrorMessage;
+        }
         if (error && error.status) {
             if (error.status == 401) {
                 window.location = 'login.jsp'
             } else if (error.status == 419) {
                 window.location = 'login.jsp'
             } else if (error.status == 403) {
-                var message = "You are not authorized";
-                if (error.statusText) {
-                    try {
-                        message = JSON.parse(error.statusText).AuthorizationError;
-                    } catch (err) {}
-                    Utils.notifyError({
-                        content: message
-                    });
-                }
+                Utils.serverErrorHandler(error, "You are not authorized");
             } else if (error.status == "0" && error.statusText != "abort") {
                 var diffTime = (new Date().getTime() - prevNetworkErrorTime);
                 if (diffTime > 3000) {
@@ -249,22 +247,23 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
                             "It seems you are not connected to the internet. Please check your internet connection and try again"
                     });
                 }
-            } else {
-                Utils.serverErrorHandler(model, error)
+            } else if (skipDefaultError !== true) {
+                Utils.serverErrorHandler(error, defaultErrorMessage);
             }
-        } else {
-            Utils.serverErrorHandler(model, error)
+        } else if (skipDefaultError !== true) {
+            Utils.serverErrorHandler(error, defaultErrorMessage);
         }
     };
-    Utils.serverErrorHandler = function(model, response) {
-        var responseJSON = response ? response.responseJSON : response;
-        if (response && responseJSON && (responseJSON.errorMessage || responseJSON.message || responseJSON.error)) {
-            Utils.notifyError({
-                content: responseJSON.errorMessage || responseJSON.message || responseJSON.error
-            });
-        } else {
+    Utils.serverErrorHandler = function(response, defaultErrorMessage) {
+        var responseJSON = response ? response.responseJSON : response,
+            message = defaultErrorMessage ? defaultErrorMessage : Messages.defaultErrorMessage
+        if (response && responseJSON) {
+            message = responseJSON.errorMessage || responseJSON.message || responseJSON.error || message
+        }
+        var existingError = $(".ui-pnotify-container.alert-danger .ui-pnotify-text").text();
+        if (existingError !== message) {
             Utils.notifyError({
-                content: Messages.defaultErrorMessage
+                content: message
             });
         }
     };
diff --git a/dashboardv3/public/js/views/administrator/PurgeAuditTableLayoutView.js b/dashboardv3/public/js/views/administrator/PurgeAuditTableLayoutView.js
index 6b5b4d3..ada59d2 100644
--- a/dashboardv3/public/js/views/administrator/PurgeAuditTableLayoutView.js
+++ b/dashboardv3/public/js/views/administrator/PurgeAuditTableLayoutView.js
@@ -310,7 +310,6 @@ define(['require',
                     }
                 }
                 var apiObj = {
-                    skipDefaultError: true,
                     sort: false,
                     success: function(dataOrCollection, response) {
                         if (!(that.ui.pageRecordText instanceof jQuery)) {
diff --git a/dashboardv3/public/js/views/graph/LineageLayoutView.js b/dashboardv3/public/js/views/graph/LineageLayoutView.js
index 4fc3fce..4e7a45b 100644
--- a/dashboardv3/public/js/views/graph/LineageLayoutView.js
+++ b/dashboardv3/public/js/views/graph/LineageLayoutView.js
@@ -240,7 +240,6 @@ define(['require',
                     "el": that.$(".graph-button-group button,select[data-id='selectDepth']")
                 });
                 this.collection.getLineage(this.guid, {
-                    skipDefaultError: true,
                     queryParam: queryParam,
                     success: function(data) {
                         if (that.isDestroyed) {
diff --git a/dashboardv3/public/js/views/name_space/NameSpaceAttrTableLayoutView.js b/dashboardv3/public/js/views/name_space/NameSpaceAttrTableLayoutView.js
index 218f9c5..b5bdeb2 100644
--- a/dashboardv3/public/js/views/name_space/NameSpaceAttrTableLayoutView.js
+++ b/dashboardv3/public/js/views/name_space/NameSpaceAttrTableLayoutView.js
@@ -132,7 +132,6 @@ define(['require',
                                 enumDefCollection.fetch({ reset: true });
                                 that.nameSpaceAttr.fullCollection.reset();
                                 that.options.selectedNameSpace.fetch({
-                                    skipDefaultError: true,
                                     complete: function(model, status) {
                                         that.nameSpaceAttr.fullCollection.add(model.responseJSON.attributeDefs);
                                     }
@@ -179,40 +178,40 @@ define(['require',
             getNamespaceTableColumns: function() {
                 var that = this;
                 return this.nameSpaceAttr.constructor.getTableCols({
-                        name: {
-                            label: "Attribute Name",
-                            cell: "html",
-                            editable: false,
-                            formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-                                fromRaw: function(rawValue, model) {
-                                    return model.get('name');
-                                }
-                            })
-                        },
-                        typeName: {
-                            label: "typeName",
-                            cell: "html",
-                            editable: false,
-                            formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-                                fromRaw: function(rawValue, model) {
-                                    return model.get('typeName');
-                                }
-                            })
-                        },
-                        options: {
-                            label: "Entity Type(s)",
-                            cell: "html",
-                            editable: false,
-                            formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-                                    fromRaw: function(rawValue, model) {
-                                        var applicableEntityTypes = '',
-                                            attrEntityTypes = JSON.parse(model.get('options').applicableEntityTypes);
-                                        _.each(attrEntityTypes, function(values) {
-                                            applicableEntityTypes += '<label class="btn btn-action btn-xs btn-blue no-pointer">' + values + '</label>';
-                                        });
-                                    return applicableEntityTypes;
-                                }
-                            })
+                    name: {
+                        label: "Attribute Name",
+                        cell: "html",
+                        editable: false,
+                        formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                            fromRaw: function(rawValue, model) {
+                                return model.get('name');
+                            }
+                        })
+                    },
+                    typeName: {
+                        label: "typeName",
+                        cell: "html",
+                        editable: false,
+                        formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                            fromRaw: function(rawValue, model) {
+                                return _.escape(model.get('typeName'));
+                            }
+                        })
+                    },
+                    options: {
+                        label: "Entity Type(s)",
+                        cell: "html",
+                        editable: false,
+                        formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                            fromRaw: function(rawValue, model) {
+                                var applicableEntityTypes = '',
+                                    attrEntityTypes = JSON.parse(model.get('options').applicableEntityTypes);
+                                _.each(attrEntityTypes, function(values) {
+                                    applicableEntityTypes += '<label class="btn btn-action btn-xs btn-blue no-pointer">' + values + '</label>';
+                                });
+                                return applicableEntityTypes;
+                            }
+                        })
                     },
                     tool: {
                         label: "Action",
@@ -226,7 +225,7 @@ define(['require',
                         })
                     }
                 }, this.nameSpaceAttr);
-        }
-    });
-return NameSpaceAttrTableLayoutView;
+            }
+        });
+    return NameSpaceAttrTableLayoutView;
 });
\ No newline at end of file
diff --git a/dashboardv3/public/js/views/name_space/NameSpaceContainerLayoutView.js b/dashboardv3/public/js/views/name_space/NameSpaceContainerLayoutView.js
index 3874a8d..481125d 100644
--- a/dashboardv3/public/js/views/name_space/NameSpaceContainerLayoutView.js
+++ b/dashboardv3/public/js/views/name_space/NameSpaceContainerLayoutView.js
@@ -69,7 +69,6 @@ define([
             fetchNameSpaceGuid: function() {
                 var that = this;
                 this.selectedNameSpace.fetch({
-                    skipDefaultError: true,
                     complete: function(model, status) {
                         that.nameSpaceAttr.fullCollection.add(model.responseJSON.attributeDefs);
                     }
diff --git a/dashboardv3/public/js/views/profile/ProfileColumnLayoutView.js b/dashboardv3/public/js/views/profile/ProfileColumnLayoutView.js
index 874474f..74e19c0 100644
--- a/dashboardv3/public/js/views/profile/ProfileColumnLayoutView.js
+++ b/dashboardv3/public/js/views/profile/ProfileColumnLayoutView.js
@@ -69,7 +69,6 @@ define(['require',
             fetchEntity: function(argument) {
                 var that = this;
                 this.entityModel.getEntity(this.entityDetail.table.guid, {
-                    skipDefaultError: true,
                     success: function(data) {
                         var entity = data.entity,
                             profileData = entity && entity.attributes && entity.attributes.profileData ? entity.attributes.profileData.attributes : null;
diff --git a/dashboardv3/public/js/views/profile/ProfileTableLayoutView.js b/dashboardv3/public/js/views/profile/ProfileTableLayoutView.js
index 2414210..ada7e62 100644
--- a/dashboardv3/public/js/views/profile/ProfileTableLayoutView.js
+++ b/dashboardv3/public/js/views/profile/ProfileTableLayoutView.js
@@ -110,7 +110,6 @@ define(['require',
             fetchEntity: function(argument) {
                 var that = this;
                 this.entityModel.getEntity(this.entityDetail.db.guid, {
-                    skipDefaultError: true,
                     success: function(data) {
                         var entity = data.entity;
                         if (entity.attributes) {
diff --git a/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
index 78a8b24..d0c41c6 100644
--- a/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/ClassificationTreeLayoutView.js
@@ -174,7 +174,6 @@ define([
                 var opt = options || {};
                 if (opt && !opt.metricData) {
                     that.metricCollection.fetch({
-                        skipDefaultError: true,
                         complete: function() {
                             that.entityCountObj = _.first(that.metricCollection.toJSON());
                             that.classificationTreeUpdate = true;
@@ -351,7 +350,6 @@ define([
                     }
                 };
             this.classificationDefCollection.fetch({
-                skipDefaultError: true,
                 silent: true,
                 complete: function() {
                     --apiCount;
@@ -359,7 +357,6 @@ define([
                 }
             });
             this.metricCollection.fetch({
-                skipDefaultError: true,
                 complete: function() {
                     --apiCount;
                     that.entityCountObj = _.first(that.metricCollection.toJSON());
diff --git a/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
index 421fb2d..6df64ad 100644
--- a/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
@@ -91,7 +91,6 @@ define([
                 var opt = options || {};
                 if (opt && !opt.metricData) {
                     that.metricCollection.fetch({
-                        skipDefaultError: true,
                         complete: function() {
                             that.entityCountObj = _.first(that.metricCollection.toJSON());
                             that.ui.entitySearchTree.jstree(true).refresh();
@@ -510,7 +509,6 @@ define([
                     }
                 };
             this.entityDefCollection.fetch({
-                skipDefaultError: true,
                 complete: function() {
                     that.entityDefCollection.fullCollection.comparator = function(model) {
                         return model.get('name').toLowerCase();
@@ -522,7 +520,6 @@ define([
             });
 
             this.metricCollection.fetch({
-                skipDefaultError: true,
                 complete: function() {
                     --apiCount;
                     that.entityCountObj = _.first(that.metricCollection.toJSON());
@@ -531,7 +528,6 @@ define([
             });
 
             this.typeHeaders.fetch({
-                skipDefaultError: true,
                 complete: function() {
                     that.typeHeaders.fullCollection.comparator = function(model) {
                         return model.get('name').toLowerCase();
diff --git a/dashboardv3/public/js/views/search/tree/NameSpaceTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/NameSpaceTreeLayoutView.js
index 2ece151..f6477cf 100644
--- a/dashboardv3/public/js/views/search/tree/NameSpaceTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/NameSpaceTreeLayoutView.js
@@ -215,7 +215,6 @@ define([
         refresh: function(options) {
             var that = this;
             this.nameSpaceCollection.fetch({
-                skipDefaultError: true,
                 silent: true,
                 complete: function() {
                     that.nameSpaceCollection.fullCollection.comparator = function(model) {
diff --git a/dashboardv3/public/js/views/site/Statistics.js b/dashboardv3/public/js/views/site/Statistics.js
index 0329e04..9673bb0 100644
--- a/dashboardv3/public/js/views/site/Statistics.js
+++ b/dashboardv3/public/js/views/site/Statistics.js
@@ -99,7 +99,6 @@ define(['require',
             fetchMetricData: function(options) {
                 var that = this;
                 this.metricCollection.fetch({
-                    skipDefaultError: true,
                     success: function(data) {
                         var data = _.first(data.toJSON());
                         that.renderStats({ valueObject: data.general.stats, dataObject: data.general });
diff --git a/dashboardv3/public/js/views/tag/AddTagModalView.js b/dashboardv3/public/js/views/tag/AddTagModalView.js
index f5a5eb8..214de07 100644
--- a/dashboardv3/public/js/views/tag/AddTagModalView.js
+++ b/dashboardv3/public/js/views/tag/AddTagModalView.js
@@ -439,9 +439,9 @@ define(['require',
                 this.showLoader();
             }
             this.entityModel.saveTraitsEntity(this.tagModel ? options.guid : null, {
-                skipDefaultError: true,
                 data: JSON.stringify(json),
                 type: this.tagModel ? 'PUT' : 'POST',
+                defaultErrorMessage: "Tag " + tagName + " could not be added",
                 success: function(data) {
                     var addupdatetext = that.tagModel ? 'updated successfully to ' : 'added to ';
                     Utils.notifySuccess({
@@ -455,13 +455,6 @@ define(['require',
                     }
                 },
                 cust_error: function(model, response) {
-                    var message = "Tag " + tagName + " could not be added";
-                    if (response && response.responseJSON) {
-                        message = response.responseJSON.errorMessage;
-                    }
-                    Utils.notifyError({
-                        content: message
-                    });
                     if (that.hideLoader) {
                         that.hideLoader();
                     }


[atlas] 01/04: ATLAS-3626 : Beta UI : No option to overwrite Saved Search

Posted by kb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 3680ab428969bcc23606537d1dab49171bcc37ab
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Thu Feb 20 15:33:51 2020 +0530

    ATLAS-3626 : Beta UI : No option to overwrite Saved Search
---
 dashboardv3/public/css/scss/theme.scss             |  15 +++
 .../search/save/SaveModalLayoutView_tmpl.html      |   9 +-
 .../js/views/search/save/SaveModalLayoutView.js    | 109 +++++++++++++++++----
 .../search/tree/CustomFilterTreeLayoutView.js      |  37 ++++---
 4 files changed, 129 insertions(+), 41 deletions(-)

diff --git a/dashboardv3/public/css/scss/theme.scss b/dashboardv3/public/css/scss/theme.scss
index 56e998c..2b0c45d 100644
--- a/dashboardv3/public/css/scss/theme.scss
+++ b/dashboardv3/public/css/scss/theme.scss
@@ -829,4 +829,19 @@ td.searchTableName:hover {
         }
 
     }
+}
+
+.select2-results__option {
+    &.select2-results__option--highlighted {
+        .option-title-light {
+            color: #eaeaea;
+        }
+    }
+
+    .option-title-light {
+        font-size: 12px;
+        color: #a4a4a4;
+    }
+
+
 }
\ No newline at end of file
diff --git a/dashboardv3/public/js/templates/search/save/SaveModalLayoutView_tmpl.html b/dashboardv3/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
index 7b199bd..23f4beb 100644
--- a/dashboardv3/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/search/save/SaveModalLayoutView_tmpl.html
@@ -14,11 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<form name="saveAsform" class="form-horizontal" data-id="">
+<div class='fontLoader show'><i class='fa fa-refresh fa-spin-custom'></i></div>
+<form name="saveAsform" class="form-horizontal hide" data-id="">
     <div class="form-group">
         <label class="control-label col-sm-2 required" for="name">Name</label>
-        <div class="col-sm-10">
+        <div class="col-sm-9">
+            {{#if rename}}
             <input class="form-control" data-id="saveAsName" placeholder="Name(required)" value="{{selectedModel.name}}" autofocus />
+            {{else}}
+            <select data-id="saveAsName"></select>
+            {{/if}}
         </div>
     </div>
 </form>
\ No newline at end of file
diff --git a/dashboardv3/public/js/views/search/save/SaveModalLayoutView.js b/dashboardv3/public/js/views/search/save/SaveModalLayoutView.js
index bfc1d9f..9d8c8c1 100644
--- a/dashboardv3/public/js/views/search/save/SaveModalLayoutView.js
+++ b/dashboardv3/public/js/views/search/save/SaveModalLayoutView.js
@@ -24,9 +24,10 @@ define(['require',
     'utils/UrlLinks',
     'platform',
     'models/VSearch',
+    "collection/VSearchList",
     'utils/CommonViewFunction',
     'utils/Messages'
-], function(require, Backbone, SaveModalLayoutViewTmpl, Utils, Modal, UrlLinks, platform, VSearch, CommonViewFunction, Messages) {
+], function(require, Backbone, SaveModalLayoutViewTmpl, Utils, Modal, UrlLinks, platform, VSearch, VSearchList, CommonViewFunction, Messages) {
 
 
     var SaveModalLayoutView = Backbone.Marionette.LayoutView.extend({
@@ -38,7 +39,8 @@ define(['require',
         },
         templateHelpers: function() {
             return {
-                selectedModel: this.selectedModel ? this.selectedModel.toJSON() : null
+                selectedModel: this.selectedModel ? this.selectedModel.toJSON() : null,
+                rename: this.rename
             };
         },
         events: function() {
@@ -47,20 +49,32 @@ define(['require',
         },
         initialize: function(options) {
             var that = this;
-            _.extend(this, _.pick(options, 'selectedModel', 'collection', 'getValue', 'isBasic', 'saveObj'));
+            _.extend(this, _.pick(options, 'rename', 'selectedModel', 'collection', 'getValue', 'isBasic', 'saveObj'));
             this.model = new VSearch();
+            this.saveSearchCollection = new VSearchList();
+            this.saveSearchCollection.url = UrlLinks.saveSearchApiUrl();
+            this.saveSearchCollection.fullCollection.comparator = function(model) {
+                return getModelName(model);
+            }
+
+            function getModelName(model) {
+                if (model.get('name')) {
+                    return model.get('name').toLowerCase();
+                }
+            };
             if (this.saveObj) {
                 this.onCreateButton();
             } else {
-                var modal = new Modal({
+                this.modal = modal = new Modal({
                     titleHtml: true,
-                    title: '<span>' + (this.selectedModel ? 'Rename' : 'Save') + (this.isBasic ? " Basic" : " Advanced") + ' Custom Filter</span>',
+                    title: '<span>' + (this.selectedModel && this.rename ? 'Rename' : 'Save/Save As..') + (this.isBasic ? " Basic" : " Advanced") + ' Custom Filter</span>',
                     content: this,
                     cancelText: "Cancel",
                     okCloses: false,
                     okText: this.selectedModel ? 'Update' : 'Save',
                     allowCancel: true
-                }).open();
+                });
+                this.modal.open();
                 modal.$el.find('button.ok').attr("disabled", "true");
                 this.ui.saveAsName.on('keyup', function(e) {
                     modal.$el.find('button.ok').removeAttr("disabled");
@@ -72,27 +86,84 @@ define(['require',
                 });
                 modal.on('ok', function() {
                     modal.$el.find('button.ok').attr("disabled", "true");
-                    that.onCreateButton(modal);
+                    that.onCreateButton();
                 });
                 modal.on('closeModal', function() {
                     modal.trigger('cancel');
                 });
             }
         },
-        onCreateButton: function(modal) {
+        hideLoader: function() {
+            this.$el.find("form").removeClass("hide");
+            this.$el.find(".fontLoader").removeClass("show");
+        },
+        onRender: function() {
+            if (this.rename == true) {
+                this.hideLoader();
+            } else {
+                var that = this;
+                this.saveSearchCollection.fetch({
+                    success: function(collection, data) {
+                        that.saveSearchCollection.fullCollection.reset(_.where(data, { searchType: that.isBasic ? "BASIC" : "ADVANCED" }));
+                        var options = "";
+                        that.saveSearchCollection.fullCollection.each(function(model) {
+                            options += '<option value="' + model.get("name") + '">' + model.get("name") + '</option>';
+                        })
+                        that.ui.saveAsName.append(options);
+                        that.ui.saveAsName.val("");
+                        that.ui.saveAsName.select2({
+                            placeholder: "Save/Save As.. filter",
+                            allowClear: false,
+                            tags: true,
+                            multiple: false,
+                            templateResult: function(state) {
+                                if (!state.id) {
+                                    return state.text;
+                                }
+                                if (!state.element) {
+                                    return $("<span><span class='option-title-light'>Save:</span> <strong> " + _.escape(state.text) + "</strong></span>");
+                                } else {
+                                    return $("<span><span class='option-title-light'>Save As:</span> <strong>" + _.escape(state.text) + "</strong></span>");
+                                }
+                            }
+                        }).on("change", function() {
+                            var val = that.ui.saveAsName.val();
+                            if (val.length) {
+                                that.selectedModel = that.saveSearchCollection.fullCollection.find({ name: val });
+                                if (that.selectedModel) {
+                                    that.modal.$el.find('button.ok').text("Save As");
+                                } else {
+                                    that.modal.$el.find('button.ok').text("Save");
+                                }
+                                that.modal.$el.find('button.ok').removeAttr("disabled");
+                            } else {
+                                that.modal.$el.find('button.ok').attr("disabled", "true");
+                                that.selectedModel = null;
+                            }
+                        });
+                    },
+                    silent: true
+                });
+                this.hideLoader();
+            }
+        },
+        onCreateButton: function() {
             var that = this,
-                obj = { name: this.ui.saveAsName.val ? this.ui.saveAsName.val() : null };
+                obj = { name: this.ui.saveAsName.val() || null, value: this.getValue() };
+            if (this.saveObj) {
+                // Save search Filter
+                _.extend(obj, this.saveObj);
+            }
+            var saveObj = CommonViewFunction.generateObjectForSaveSearchApi(obj);
             if (this.selectedModel) {
                 // Update Name only.
-                var saveObj = this.selectedModel.toJSON();
-                saveObj.name = obj.name;
-            } else {
-                obj.value = this.getValue();
-                if (this.saveObj) {
-                    // Save search Filter
-                    _.extend(obj, this.saveObj);
+                var selectedModel = this.selectedModel.toJSON();
+                if (this.rename !== true) {
+                    _.extend(selectedModel.searchParameters, saveObj.searchParameters);
                 }
-                var saveObj = CommonViewFunction.generateObjectForSaveSearchApi(obj);
+                selectedModel.name = obj.name;
+                saveObj = selectedModel;
+            } else {
                 if (this.isBasic) {
                     saveObj['searchType'] = "BASIC";
                 } else {
@@ -125,8 +196,8 @@ define(['require',
 
                 }
             });
-            if (modal) {
-                modal.trigger('cancel');
+            if (this.modal) {
+                this.modal.trigger('cancel');
             }
         }
     });
diff --git a/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js
index 9766b32..3031ced 100644
--- a/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js
@@ -74,7 +74,7 @@ define([
                 this.ui.groupOrFlatTree.find("i").toggleClass("group-tree-deactivate");
                 this.ui.groupOrFlatTree.find("span").html(this.isGroupView ? "Show flat tree" : "Show group tree");
                 that.ui[type + "SearchTree"].jstree(true).destroy();
-                that.renderCustomFilter();
+                that.fetchCustomFilter();
             };
 
             return events;
@@ -133,6 +133,18 @@ define([
             this.saveSearchCollection = new VSearchList();
             this.saveSearchAdvanceCollection = new VSearchList();
             this.saveSearchCollection.url = UrlLinks.saveSearchApiUrl();
+            this.saveSearchBaiscCollection.fullCollection.comparator = function(model) {
+                return getModelName(model);
+            }
+            this.saveSearchAdvanceCollection.fullCollection.comparator = function(model) {
+                return getModelName(model);
+            }
+
+            function getModelName(model) {
+                if (model.get('name')) {
+                    return model.get('name').toLowerCase();
+                }
+            };
             this.bindEvents();
             this.customFilterData = null;
             this.isBasic = true;
@@ -140,7 +152,7 @@ define([
             this.isGroupView = true;
         },
         onRender: function() {
-            this.renderCustomFilter();
+            this.fetchCustomFilter();
         },
         manualRender: function(options) {
             _.extend(this.options, options);
@@ -160,21 +172,8 @@ define([
             });
             this.createCustomFilterAction();
         },
-        renderCustomFilter: function() {
+        fetchCustomFilter: function() {
             var that = this;
-            this.saveSearchBaiscCollection.fullCollection.comparator = function(model) {
-                return getModelName(model);
-            }
-            this.saveSearchAdvanceCollection.fullCollection.comparator = function(model) {
-                return getModelName(model);
-            }
-
-            function getModelName(model) {
-                if (model.get('name')) {
-                    return model.get('name').toLowerCase();
-                }
-            };
-
             this.saveSearchCollection.fetch({
                 success: function(collection, data) {
                     that.saveSearchBaiscCollection.fullCollection.reset(_.where(data, { searchType: "BASIC" }));
@@ -403,9 +402,7 @@ define([
                 require([
                     'views/search/save/SaveModalLayoutView'
                 ], function(SaveModalLayoutView) {
-
-                    new SaveModalLayoutView({ 'selectedModel': options.model.clone(), 'collection': that.isBasic ? that.saveSearchBaiscCollection.fullCollection : that.saveSearchAdvanceCollection.fullCollection, 'getValue': that.getValue, 'isBasic': that.isBasic });
-
+                    new SaveModalLayoutView({ 'rename': true, 'selectedModel': options.model.clone(), 'collection': that.isBasic ? that.saveSearchBaiscCollection.fullCollection : that.saveSearchAdvanceCollection.fullCollection, 'getValue': that.getValue, 'isBasic': that.isBasic });
                 });
             }
         },
@@ -474,7 +471,7 @@ define([
             }
         },
         refreshCustomFilterTree: function() {
-            this.ui.customFilterSearchTree.jstree(true).refresh();
+            this.fetchCustomFilter();
         }
 
     });


[atlas] 03/04: ATLAS-3623 : Beta UI: Basic search improvement to search for namespace attribute

Posted by kb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit cd177f83d24dbce0a992e3c2cf7c2f3001f0f806
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Thu Feb 20 15:59:32 2020 +0530

    ATLAS-3623 : Beta UI: Basic search improvement to search for namespace attribute
---
 .../public/js/views/search/QueryBuilderView.js     | 25 +++++++++++++++++++++
 .../js/views/search/SearchDefaultLayoutView.js     | 21 ++++++++++++++---
 .../js/views/search/SearchResultLayoutView.js      | 26 ++++++++++++++++++++--
 3 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/dashboardv3/public/js/views/search/QueryBuilderView.js b/dashboardv3/public/js/views/search/QueryBuilderView.js
index cca7992..20179bf 100644
--- a/dashboardv3/public/js/views/search/QueryBuilderView.js
+++ b/dashboardv3/public/js/views/search/QueryBuilderView.js
@@ -61,6 +61,7 @@ define(['require',
                     'entityDefCollection',
                     'enumDefCollection',
                     'classificationDefCollection',
+                    'nameSpaceCollection',
                     'tag',
                     'searchTableFilters',
                     'systemAttrArr'));
@@ -364,6 +365,30 @@ define(['require',
                         filters.push(returnObj);
                     }
                 });
+                if (this.attrObj.length > 0) {
+
+                    var sortedNamespaceData = _.sortBy(this.nameSpaceCollection.models, function(obj) {
+                        return obj.get('name')
+                    });
+                    _.each(sortedNamespaceData, function(obj) {
+                        var namespaceName = obj.get('name');
+
+                        var sortedNamespaceAttr = _.sortBy(obj.attributes.attributeDefs, function(obj) {
+                            return obj.name;
+                        });
+                        _.each(sortedNamespaceAttr, function(attrDetails) {
+                            if (attrDetails.options && attrDetails.options.applicableEntityTypes && that.options.applicableType && (JSON.parse(attrDetails.options.applicableEntityTypes).indexOf(that.options.applicableType) != -1)) {
+                                var returnObj = that.getObjDef(attrDetails, rules_widgets, isGroupView, 'Select Namespace Attribute', true);
+                                if (returnObj) {
+                                    returnObj.id = namespaceName + "." + returnObj.id;
+                                    returnObj.label = namespaceName + ": " + returnObj.label;
+                                    returnObj.data = { 'entityType': "namespace" };
+                                    filters.push(returnObj);
+                                }
+                            }
+                        })
+                    });
+                }
                 filters = _.uniq(filters, 'id');
                 if (filters && !_.isEmpty(filters)) {
                     this.ui.builder.queryBuilder({
diff --git a/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js b/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js
index 707ff14..4f5c434 100644
--- a/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js
+++ b/dashboardv3/public/js/views/search/SearchDefaultLayoutView.js
@@ -57,9 +57,11 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
                 events["click " + this.ui.attrFilter] = function(e) {
                     if (this.$('.attribute-filter-container').hasClass("hide")) {
                         this.onClickAttrFilter();
+                        this.$('.attributeResultContainer').addClass("overlay");
+                    } else {
+                        this.$('.attributeResultContainer').removeClass("overlay");
                     }
                     this.$('.fa-angle-right').toggleClass('fa-angle-down');
-                    this.$('.attributeResultContainer').addClass("overlay");
                     this.$('.attribute-filter-container, .attr-filter-overlay').toggleClass('hide');
                 };
 
@@ -236,6 +238,7 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
                         enumDefCollection: that.options.enumDefCollection,
                         typeHeaders: that.options.typeHeaders,
                         classificationDefCollection: that.options.classificationDefCollection,
+                        nameSpaceCollection: that.options.nameSpaceCollection,
                         searchTableFilters: that.checkEntityFilter(that.options)
                     };
                 if (that.options.value) {
@@ -295,7 +298,8 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
                         this.renderQueryBuilder(_.extend({}, obj, {
                             tag: false,
                             type: true,
-                            attrObj: attrTypeObj
+                            attrObj: attrTypeObj,
+                            applicableType: that.options.value ? that.options.value.type : null
                         }), this.RQueryBuilderEntity);
 
                         this.ui.entityName.html(that.options.value.type);
@@ -362,13 +366,24 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
                 return col;
             },
             updateFilterOptions: function(rule, filtertype, isTag) {
-                var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true });
+                var that = this,
+                    ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true });
                 this.options.searchTableFilters[filtertype][isTag ? this.options.value.tag : this.options.value.type] = ruleUrl;
                 if (!isTag && this.options.value && this.options.value.type && this.options.searchTableColumns) {
                     if (!this.options.searchTableColumns[this.options.value.type]) {
                         this.options.searchTableColumns[this.options.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"];
                     }
                     this.options.searchTableColumns[this.options.value.type] = _.sortBy(_.union(this.options.searchTableColumns[this.options.value.type], this.getIdFromRuleObj(rule)));
+                    if (rule.rules) {
+                        _.find(rule.rules, function(checkNamespace) {
+                            if (checkNamespace.data && checkNamespace.data.entityType && checkNamespace.data.entityType == 'namespace') {
+                                if (that.options.searchTableColumns[that.options.value.type].indexOf('namespace') == -1) {
+                                    that.options.searchTableColumns[that.options.value.type].push(checkNamespace.data.entityType);
+                                }
+                                return true;
+                            }
+                        });
+                    }
                 }
             },
             renderQueryBuilder: function(obj, rQueryBuilder) {
diff --git a/dashboardv3/public/js/views/search/SearchResultLayoutView.js b/dashboardv3/public/js/views/search/SearchResultLayoutView.js
index 01083ff..6d67bb6 100644
--- a/dashboardv3/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv3/public/js/views/search/SearchResultLayoutView.js
@@ -641,12 +641,12 @@ define(['require',
                 var that = this,
                     nameCheck = 0,
                     columnToShow = null,
-                    col = {};
+                    col = {},
+                    namespaceRenderable = false;
                 this.value = Utils.getUrlState.getQueryParams() || this.value;
                 if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) {
                     columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type];
                 }
-
                 col['Check'] = {
                     name: "selected",
                     label: "Select",
@@ -787,6 +787,28 @@ define(['require',
                             }
                         })
                     };
+                    col['Namespaces'] = {
+                        label: "Namespaces",
+                        cell: "Html",
+                        editable: false,
+                        resizeable: true,
+                        orderable: true,
+                        renderable: _.contains(columnToShow, 'namespace'),
+                        formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                            fromRaw: function(rawValue, model) {
+                                var obj = model.toJSON(),
+                                    namespaceStr = '';
+                                if (obj && obj.attributes) {
+                                    _.each(obj.attributes, function(namespaceValue, attributeName) {
+                                        if (attributeName.indexOf('.') != -1) {
+                                            namespaceStr += '<label class="btn btn-action btn-xs btn-blue no-pointer">' + attributeName + ': ' + namespaceValue + '</label>';
+                                        }
+                                    })
+                                    return namespaceStr;
+                                }
+                            }
+                        })
+                    };
                     this.getTagCol({ 'col': col, 'columnToShow': columnToShow });
                     if ((!_.contains(["glossary"], this.fromView))) {
                         this.getTermCol({ 'col': col, 'columnToShow': columnToShow });