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/04/23 06:02:11 UTC

[atlas] 04/05: ATLAS-3685 :- UI Bulk import Business Metadata attribute assignment to entities

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 8baade2486b5ee5d41f8a00c19011a9484bf63be
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Sat Mar 28 16:20:27 2020 +0530

    ATLAS-3685 :- UI Bulk import Business Metadata attribute assignment to entities
---
 dashboardv3/public/css/scss/leftsidebar.scss       |  2 +-
 .../ImportLayoutView_tmpl.html}                    |  2 +-
 .../tree/BusinessMetadataTreeLayoutView_tmpl.html  |  2 -
 .../search/tree/EntityTreeLayoutView_tmpl.html     |  7 +++-
 .../search/tree/GlossaryTreeLayoutView_tmpl.html   |  2 +-
 dashboardv3/public/js/utils/UrlLinks.js            |  6 +++
 .../ImportLayoutView.js}                           | 46 +++++++++++-----------
 .../js/views/search/tree/EntityTreeLayoutView.js   | 23 +++++++++--
 .../js/views/search/tree/GlossaryTreeLayoutView.js |  9 +++--
 9 files changed, 64 insertions(+), 35 deletions(-)

diff --git a/dashboardv3/public/css/scss/leftsidebar.scss b/dashboardv3/public/css/scss/leftsidebar.scss
index 9c5475c..d547f39 100644
--- a/dashboardv3/public/css/scss/leftsidebar.scss
+++ b/dashboardv3/public/css/scss/leftsidebar.scss
@@ -427,7 +427,7 @@ span.tree-tooltip {
     }
 }
 
-.glossary-dropdown {
+.tree-droupdown {
     left: -190px !important;
 
     span a {
diff --git a/dashboardv3/public/js/templates/glossary/ImportGlossaryLayoutView_tmpl.html b/dashboardv3/public/js/templates/import/ImportLayoutView_tmpl.html
similarity index 89%
rename from dashboardv3/public/js/templates/glossary/ImportGlossaryLayoutView_tmpl.html
rename to dashboardv3/public/js/templates/import/ImportLayoutView_tmpl.html
index abf11b7..5bb9ab5 100644
--- a/dashboardv3/public/js/templates/glossary/ImportGlossaryLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/import/ImportLayoutView_tmpl.html
@@ -14,4 +14,4 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<form action={{importUrl}} id="importGlossary" class="dropzone single-file-center"></form>
\ No newline at end of file
+<form id="importGlossary" class="dropzone single-file-center"></form>
\ No newline at end of file
diff --git a/dashboardv3/public/js/templates/search/tree/BusinessMetadataTreeLayoutView_tmpl.html b/dashboardv3/public/js/templates/search/tree/BusinessMetadataTreeLayoutView_tmpl.html
index 757a1ed..d7d2679 100644
--- a/dashboardv3/public/js/templates/search/tree/BusinessMetadataTreeLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/search/tree/BusinessMetadataTreeLayoutView_tmpl.html
@@ -25,8 +25,6 @@
             <button type="button" class="typeRefresh drop-down-menu-view" data-id="createBusinessMetadata" title="Open Business Metadata">
                 <i class="fa fa-external-link"></i>
             </button>
-            </ul>
-            </button>
         </div>
     </div>
     <div id="businessMetadataTree" class="panel-collapse collapse jstree-with-action in">
diff --git a/dashboardv3/public/js/templates/search/tree/EntityTreeLayoutView_tmpl.html b/dashboardv3/public/js/templates/search/tree/EntityTreeLayoutView_tmpl.html
index 4966a8c..2f286dc 100644
--- a/dashboardv3/public/js/templates/search/tree/EntityTreeLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/search/tree/EntityTreeLayoutView_tmpl.html
@@ -29,11 +29,16 @@
                 <div class=" btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                     <i class="fa fa-ellipsis-v"></i>
                 </div>
-                <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+                <ul class="dropdown-menu tree-droupdown" aria-labelledby="dropdownMenuButton">
                     <li data-id="groupOrFlatTreeView" data-type="entity"> <i class="fa fa-list-ul"></i><span>Show flat tree</span>
                     </li>
+                    <li data-id="downloadBusinessMetadata"><i class="fa fa-download"></i> <span><a href="{{importTmplUrl}}"><span>Download Import template</span></a></span>
+                    </li>
+                    <li data-id="importBusinessMetadata"> <i class="fa fa-upload"></i><a href="javascript:void(0)"><span>Import Business Metadata</span></a>
+                    </li>
                 </ul>
             </button>
+            </button>
         </div>
     </div>
     <div id="c_entity" class="panel-collapse collapse jstree-with-action in">
diff --git a/dashboardv3/public/js/templates/search/tree/GlossaryTreeLayoutView_tmpl.html b/dashboardv3/public/js/templates/search/tree/GlossaryTreeLayoutView_tmpl.html
index ffafa60..0d9994e 100644
--- a/dashboardv3/public/js/templates/search/tree/GlossaryTreeLayoutView_tmpl.html
+++ b/dashboardv3/public/js/templates/search/tree/GlossaryTreeLayoutView_tmpl.html
@@ -27,7 +27,7 @@
                 <div class=" btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                     <i class="fa fa-ellipsis-v"></i>
                 </div>
-                <ul class="dropdown-menu glossary-dropdown" aria-labelledby="dropdownMenuButton">
+                <ul class="dropdown-menu tree-droupdown" aria-labelledby="dropdownMenuButton">
                     <li data-id="createGlossary" data-type="term"> <i class="fa fa-plus"></i><span>Create Glossary</span>
                     </li>
                     <li data-id="downloadTemplate" data-type="term"><i class="fa fa-download"></i> <span><a href="{{importTmplUrl}}"><span>Download Import template</span></a></span>
diff --git a/dashboardv3/public/js/utils/UrlLinks.js b/dashboardv3/public/js/utils/UrlLinks.js
index 7793aaa..69e5274 100644
--- a/dashboardv3/public/js/utils/UrlLinks.js
+++ b/dashboardv3/public/js/utils/UrlLinks.js
@@ -191,6 +191,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
         glossaryImportUrl: function() {
             return this.glossaryApiUrl() + '/import';
         },
+        businessMetadataImportTempUrl: function() {
+            return this.entitiesApiUrl() + '/businessmetadata/import/template';
+        },
+        businessMetadataImportUrl: function() {
+            return this.entitiesApiUrl() + '/businessmetadata/import';
+        },
         categoryApiUrl: function(options) {
             var guid = options && options.guid,
                 list = options && options.list,
diff --git a/dashboardv3/public/js/views/glossary/ImportGlossaryLayoutView.js b/dashboardv3/public/js/views/import/ImportLayoutView.js
similarity index 73%
rename from dashboardv3/public/js/views/glossary/ImportGlossaryLayoutView.js
rename to dashboardv3/public/js/views/import/ImportLayoutView.js
index 23b0ef7..d04847e 100644
--- a/dashboardv3/public/js/views/glossary/ImportGlossaryLayoutView.js
+++ b/dashboardv3/public/js/views/import/ImportLayoutView.js
@@ -19,25 +19,19 @@
 define([
     "require",
     "backbone",
-    "hbs!tmpl/glossary/ImportGlossaryLayoutView_tmpl",
+    "hbs!tmpl/import/ImportLayoutView_tmpl",
     "modules/Modal",
     'utils/CommonViewFunction',
     "utils/Utils",
     "utils/UrlLinks",
     "dropzone"
-], function(require, Backbone, ImportGlossaryLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) {
-    var ImportGlossaryLayoutView = Backbone.Marionette.LayoutView.extend(
-        /** @lends ImportGlossaryLayoutView */
+], function(require, Backbone, ImportLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) {
+    var ImportLayoutView = Backbone.Marionette.LayoutView.extend(
+        /** @lends ImportLayoutView */
         {
-            _viewName: "ImportGlossaryLayoutView",
+            _viewName: "ImportLayoutView",
 
-            template: ImportGlossaryLayoutViewTmpl,
-
-            templateHelpers: function() {
-                return {
-                    importUrl: UrlLinks.glossaryImportUrl()
-                };
-            },
+            template: ImportLayoutViewTmpl,
 
             /** Layout sub regions */
             regions: {},
@@ -50,14 +44,14 @@ define([
                 return events;
             },
             /**
-             * intialize a new ImportGlossaryLayoutView Layout
+             * intialize a new ImportLayoutView Layout
              * @constructs
              */
             initialize: function(options) {
-                _.extend(this, _.pick(options, "callback"));
+                _.extend(this, _.pick(options, "callback", "isGlossary"));
                 var that = this;
                 this.modal = new Modal({
-                    title: "Import Glossary",
+                    title: this.isGlossary ? "Import Glossary" : "Import Business Metadata",
                     content: this,
                     cancelText: "Cancel",
                     okText: "upload",
@@ -88,7 +82,7 @@ define([
                 var headers = {};
                 headers[CommonViewFunction.restCsrfCustomHeader] = '""';
                 this.$("#importGlossary").dropzone({
-                    url: UrlLinks.glossaryImportUrl(),
+                    url: that.isGlossary ? UrlLinks.glossaryImportUrl() : UrlLinks.businessMetadataImportUrl(),
                     clickable: true,
                     acceptedFiles: ".csv,.xls,.xlsx",
                     autoProcessQueue: false,
@@ -108,11 +102,19 @@ define([
                         this.addFile(file);
                     },
                     success: function(file, response) {
-                        that.modal.trigger("cancel");
-                        Utils.notifySuccess({
-                            content: "File: " + file.name + " added successfully"
-                        });
-                        that.callback();
+                        if (response.successImportInfoList.length && response.failedImportInfoList.length === 0) {
+                            that.modal.trigger("cancel");
+                            Utils.notifySuccess({
+                                content: "File: " + file.name + " imported successfully"
+                            });
+                        } else if (response.failedImportInfoList.length) {
+                            Utils.notifyError({
+                                content: response.failedImportInfoList[0].remarks
+                            });
+                        }
+                        if (that.callback) {
+                            that.callback();
+                        }
                     },
                     error: function(file, response, responseObj) {
                         Utils.defaultErrorHandler(null, responseObj, { defaultErrorMessage: (response.errorMessage) || response });
@@ -124,5 +126,5 @@ define([
             }
         }
     );
-    return ImportGlossaryLayoutView;
+    return ImportLayoutView;
 });
\ No newline at end of file
diff --git a/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
index e136d36..a42ecfd 100644
--- a/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/EntityTreeLayoutView.js
@@ -43,11 +43,14 @@ define([
 
             // Show/hide empty values in tree
             showEmptyServiceType: '[data-id="showEmptyServiceType"]',
-            entityTreeLoader: '[data-id="entityTreeLoader"]'
+            entityTreeLoader: '[data-id="entityTreeLoader"]',
+            importBusinessMetadata: "[data-id='importBusinessMetadata']",
+            downloadBusinessMetadata: "[data-id='downloadBusinessMetadata']"
         },
         templateHelpers: function() {
             return {
-                apiBaseUrl: UrlLinks.apiBaseUrl
+                apiBaseUrl: UrlLinks.apiBaseUrl,
+                importTmplUrl: UrlLinks.businessMetadataImportTempUrl()
             };
         },
         events: function() {
@@ -79,6 +82,13 @@ define([
                 that.ui[type + "SearchTree"].jstree(true).destroy();
                 that.renderEntityTree();
             };
+            events["click " + this.ui.importBusinessMetadata] = function(e) {
+                e.stopPropagation();
+                that.onClickImportBusinessMetadata();
+            };
+            events["click " + this.ui.downloadBusinessMetadata] = function(e) {
+                e.stopPropagation();
+            };
 
             return events;
         },
@@ -558,7 +568,14 @@ define([
                     renderTree();
                 }
             });
-
+        },
+        onClickImportBusinessMetadata: function() {
+            var that = this;
+            require([
+                'views/import/ImportLayoutView'
+            ], function(ImportLayoutView) {
+                var view = new ImportLayoutView({});
+            });
         }
     });
     return EntityTreeLayoutview;
diff --git a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js
index d068b8c..0f10607 100644
--- a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js
+++ b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js
@@ -711,12 +711,13 @@ define([
         onClickImportGlossary: function() {
             var that = this;
             require([
-                'views/glossary/ImportGlossaryLayoutView'
-            ], function(ImportGlossaryLayoutView) {
-                var view = new ImportGlossaryLayoutView({
+                'views/import/ImportLayoutView'
+            ], function(ImportLayoutView) {
+                var view = new ImportLayoutView({
                     callback: function() {
                         that.refresh();
-                    }
+                    },
+                    isGlossary: true
                 });
             });
         }