Commit f304f59f by kevalbhatt

ATLAS-3757 : Classic UI: Add import business metadata feature

parent 2b38550b
...@@ -668,7 +668,7 @@ td.searchTableName:hover { ...@@ -668,7 +668,7 @@ td.searchTableName:hover {
} }
&:hover>.dropdown-menu { &:hover>.dropdown-menu {
display: block; display: table;
} }
} }
......
...@@ -55,6 +55,7 @@ define([ ...@@ -55,6 +55,7 @@ define([
this.bindCommonEvents(); this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this); this.listenTo(this, 'route', this.postRouteExecute, this);
this.searchVent = new Backbone.Wreqr.EventAggregator(); this.searchVent = new Backbone.Wreqr.EventAggregator();
this.importVent = new Backbone.Wreqr.EventAggregator();
this.glossaryCollection = new VGlossaryList([], { this.glossaryCollection = new VGlossaryList([], {
comparator: function(item) { comparator: function(item) {
return item.get("name"); return item.get("name");
...@@ -130,14 +131,15 @@ define([ ...@@ -130,14 +131,15 @@ define([
// console.log("Post-Route Change Operations can be performed here !!"); // console.log("Post-Route Change Operations can be performed here !!");
// console.log("Route changed: ", name); // console.log("Route changed: ", name);
}, },
getHeaderOptions: function(Header) { getHeaderOptions: function(Header, options) {
var that = this;
return { return {
view: App.rNHeader, view: App.rNHeader,
manualRender: function() { manualRender: function() {
this.view.currentView.manualRender(); this.view.currentView.manualRender();
}, },
render: function() { render: function() {
return new Header(); return new Header(_.extend({ importVent: that.importVent }, that.preFetchedCollectionLists, that.sharedObj, options));
} }
} }
}, },
...@@ -238,22 +240,18 @@ define([ ...@@ -238,22 +240,18 @@ define([
], function(Header, GlossaryDetailLayoutView, SideNavLayoutView) { ], function(Header, GlossaryDetailLayoutView, SideNavLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
that.renderViewIfNotExists(that.getHeaderOptions(Header)); that.renderViewIfNotExists(that.getHeaderOptions(Header));
var options = _.extend({}, that.preFetchedCollectionLists, that.sharedObj, { 'guid': id, 'value': paramObj, importVent: that.importVent })
that.renderViewIfNotExists({ that.renderViewIfNotExists({
view: App.rSideNav, view: App.rSideNav,
manualRender: function() { manualRender: function() {
this.view.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({}, { 'guid': id, 'value': paramObj })); this.view.currentView.RGlossaryLayoutView.currentView.manualRender(options);
this.view.currentView.selectTab(); this.view.currentView.selectTab();
}, },
render: function() { render: function() {
return new SideNavLayoutView( return new SideNavLayoutView(options)
_.extend({}, that.preFetchedCollectionLists, that.sharedObj, { 'guid': id, 'value': paramObj })
)
} }
}); });
App.rNContent.show(new GlossaryDetailLayoutView(_.extend({ App.rNContent.show(new GlossaryDetailLayoutView(options));
'guid': id,
'value': paramObj
}, that.preFetchedCollectionLists, that.sharedObj)));
}); });
} }
}, },
...@@ -273,13 +271,14 @@ define([ ...@@ -273,13 +271,14 @@ define([
if (Utils.getUrlState.isTagTab()) { if (Utils.getUrlState.isTagTab()) {
this.view.currentView.RTagLayoutView.currentView.manualRender(); this.view.currentView.RTagLayoutView.currentView.manualRender();
} else if (Utils.getUrlState.isGlossaryTab()) { } else if (Utils.getUrlState.isGlossaryTab()) {
this.view.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({ "isTrigger": true }, { "value": paramObj })); this.view.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({ "isTrigger": true, "value": paramObj }));
} }
}, },
render: function() { render: function() {
return new SideNavLayoutView( return new SideNavLayoutView(
_.extend({ _.extend({
'searchVent': that.searchVent 'searchVent': that.searchVent,
'importVent': that.importVent
}, that.preFetchedCollectionLists, that.sharedObj) }, that.preFetchedCollectionLists, that.sharedObj)
) )
} }
...@@ -296,6 +295,8 @@ define([ ...@@ -296,6 +295,8 @@ define([
} else { } else {
if (App.rNContent.currentView) { if (App.rNContent.currentView) {
App.rNContent.currentView.destroy(); App.rNContent.currentView.destroy();
} else {
App.rNContent.$el.empty();
} }
} }
}); });
......
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<form action={{importUrl}} id="importGlossary" class="dropzone single-file-center"></form> <form id="importGlossary" class="dropzone single-file-center"></form>
\ No newline at end of file \ No newline at end of file
...@@ -37,12 +37,36 @@ ...@@ -37,12 +37,36 @@
<table class="header-menu"> <table class="header-menu">
<tr> <tr>
<td><a class="show-stat" href="javascript:void(0);" title="Statistics"><i class="fa fa-bar-chart"></i></a></td> <td><a class="show-stat" href="javascript:void(0);" title="Statistics"><i class="fa fa-bar-chart"></i></a></td>
<td><a target="_blank" href="http://atlas.apache.org/"><i class="fa fa-question-circle"></i></a></td>
<td> <td>
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa fa-user user-circle "></i><span class="userName"></span></a> <a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa fa-user user-circle "></i><span class="userName"></span></a>
<ul class="dropdown-menu pull-right multi-level"> <ul class="dropdown-menu pull-right multi-level">
<li><a href="javascript:void(0)" data-id='administrator'>Administration</a></li> <li><a href="javascript:void(0)" data-id='administrator'>Administration</a></li>
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li> <li class="dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)">Bulk Import</span></a>
<ul class="dropdown-menu multi-level">
<li class="dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)">Business Metadata</span></a>
<ul class="dropdown-menu">
<li><a href="{{businessMetadataImportTempUrl}}">Download Import template</a></li>
<li data-id='businessMetadataImport'><a href="javascript:void(0)">Import Business Metadata</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)">Glossary</span></a>
<ul class="dropdown-menu">
<li><a href="{{glossaryImportTempUrl}}">Download Import template</a></li>
<li data-id='glossaryImport'><a href="javascript:void(0)">Import Glossary</a></li>
</ul>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)">Help</span></a>
<ul class="dropdown-menu">
<li><a target="_blank" href="http://atlas.apache.org/">Documentation</a></li>
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
</ul>
</li>
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li><a data-id="uiSwitch" href="javascript:void(0)">Switch to New</a></li> <li><a data-id="uiSwitch" href="javascript:void(0)">Switch to New</a></li>
<li> <li>
......
...@@ -202,6 +202,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require ...@@ -202,6 +202,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
glossaryImportUrl: function() { glossaryImportUrl: function() {
return this.glossaryApiUrl() + '/import'; return this.glossaryApiUrl() + '/import';
}, },
businessMetadataImportTempUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import/template';
},
businessMetadataImportUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import';
},
categoryApiUrl: function(options) { categoryApiUrl: function(options) {
var guid = options && options.guid, var guid = options && options.guid,
list = options && options.list, list = options && options.list,
......
...@@ -97,7 +97,7 @@ define(['require', ...@@ -97,7 +97,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'associatedTerms', 'guid', 'value', 'glossaryCollection', 'glossary', 'isAssignTermView', 'isAssignCategoryView', 'isAssignEntityView', 'isAssignAttributeRelationView')); _.extend(this, _.pick(options, 'associatedTerms', 'guid', 'value', 'glossaryCollection', 'glossary', 'isAssignTermView', 'isAssignCategoryView', 'isAssignEntityView', 'isAssignAttributeRelationView', 'importVent'));
this.viewType = "term"; this.viewType = "term";
this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView || this.isAssignAttributeRelationView; this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView || this.isAssignAttributeRelationView;
this.bindEvents(); this.bindEvents();
...@@ -142,6 +142,9 @@ define(['require', ...@@ -142,6 +142,9 @@ define(['require',
that[$(this).find('a').data('fn')](e) that[$(this).find('a').data('fn')](e)
}); });
} }
this.importVent.on("Import:Glossary:Update", function(options) {
that.getGlossary();
});
}, },
onRender: function() { onRender: function() {
this.changeLoaderState(true); this.changeLoaderState(true);
...@@ -772,12 +775,13 @@ define(['require', ...@@ -772,12 +775,13 @@ define(['require',
onClickImportGlossary: function() { onClickImportGlossary: function() {
var that = this; var that = this;
require([ require([
'views/glossary/ImportGlossaryLayoutView' 'views/import/ImportLayoutView'
], function(ImportGlossaryLayoutView) { ], function(ImportLayoutView) {
var view = new ImportGlossaryLayoutView({ var view = new ImportLayoutView({
callback: function() { callback: function() {
that.getGlossary(); that.getGlossary();
} },
isGlossary: true
}); });
}); });
} }
......
...@@ -19,25 +19,19 @@ ...@@ -19,25 +19,19 @@
define([ define([
"require", "require",
"backbone", "backbone",
"hbs!tmpl/glossary/ImportGlossaryLayoutView_tmpl", "hbs!tmpl/import/ImportLayoutView_tmpl",
"modules/Modal", "modules/Modal",
'utils/CommonViewFunction', 'utils/CommonViewFunction',
"utils/Utils", "utils/Utils",
"utils/UrlLinks", "utils/UrlLinks",
"dropzone" "dropzone"
], function(require, Backbone, ImportGlossaryLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) { ], function(require, Backbone, ImportLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) {
var ImportGlossaryLayoutView = Backbone.Marionette.LayoutView.extend( var ImportLayoutView = Backbone.Marionette.LayoutView.extend(
/** @lends ImportGlossaryLayoutView */ /** @lends ImportLayoutView */
{ {
_viewName: "ImportGlossaryLayoutView", _viewName: "ImportLayoutView",
template: ImportGlossaryLayoutViewTmpl, template: ImportLayoutViewTmpl,
templateHelpers: function() {
return {
importUrl: UrlLinks.glossaryImportUrl()
};
},
/** Layout sub regions */ /** Layout sub regions */
regions: {}, regions: {},
...@@ -50,14 +44,14 @@ define([ ...@@ -50,14 +44,14 @@ define([
return events; return events;
}, },
/** /**
* intialize a new ImportGlossaryLayoutView Layout * intialize a new ImportLayoutView Layout
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, "callback")); _.extend(this, _.pick(options, "callback", "isGlossary"));
var that = this; var that = this;
this.modal = new Modal({ this.modal = new Modal({
title: "Import Glossary", title: this.isGlossary ? "Import Glossary" : "Import Business Metadata",
content: this, content: this,
cancelText: "Cancel", cancelText: "Cancel",
okText: "upload", okText: "upload",
...@@ -88,7 +82,7 @@ define([ ...@@ -88,7 +82,7 @@ define([
var headers = {}; var headers = {};
headers[CommonViewFunction.restCsrfCustomHeader] = '""'; headers[CommonViewFunction.restCsrfCustomHeader] = '""';
this.$("#importGlossary").dropzone({ this.$("#importGlossary").dropzone({
url: UrlLinks.glossaryImportUrl(), url: that.isGlossary ? UrlLinks.glossaryImportUrl() : UrlLinks.businessMetadataImportUrl(),
clickable: true, clickable: true,
acceptedFiles: ".csv,.xls,.xlsx", acceptedFiles: ".csv,.xls,.xlsx",
autoProcessQueue: false, autoProcessQueue: false,
...@@ -107,12 +101,21 @@ define([ ...@@ -107,12 +101,21 @@ define([
this.removeAllFiles(); this.removeAllFiles();
this.addFile(file); this.addFile(file);
}, },
success: function(file, response) { success: function(file, response, responseObj) {
that.modal.trigger("cancel"); var success = true;
Utils.notifySuccess({ if (response.failedImportInfoList && response.failedImportInfoList.length) {
content: "File: " + file.name + " added successfully" success = false;
}); Utils.defaultErrorHandler(null, file.xhr, { defaultErrorMessage: response.failedImportInfoList[0].remarks });
that.callback(); }
if (success) {
that.modal.trigger("cancel");
Utils.notifySuccess({
content: "File: " + file.name + " imported successfully"
});
}
if (that.callback && ((response.successImportInfoList && response.successImportInfoList.length > 0) || success)) {
that.callback();
}
}, },
error: function(file, response, responseObj) { error: function(file, response, responseObj) {
Utils.defaultErrorHandler(null, responseObj, { defaultErrorMessage: (response.errorMessage) || response }); Utils.defaultErrorHandler(null, responseObj, { defaultErrorMessage: (response.errorMessage) || response });
...@@ -124,5 +127,5 @@ define([ ...@@ -124,5 +127,5 @@ define([
} }
} }
); );
return ImportGlossaryLayoutView; return ImportLayoutView;
}); });
\ No newline at end of file
...@@ -29,6 +29,12 @@ define(['require', ...@@ -29,6 +29,12 @@ define(['require',
var Header = Marionette.LayoutView.extend({ var Header = Marionette.LayoutView.extend({
template: tmpl, template: tmpl,
regions: {}, regions: {},
templateHelpers: function() {
return {
glossaryImportTempUrl: UrlLinks.glossaryImportTempUrl(),
businessMetadataImportTempUrl: UrlLinks.businessMetadataImportTempUrl()
};
},
ui: { ui: {
backButton: "[data-id='backButton']", backButton: "[data-id='backButton']",
menuHamburger: "[data-id='menuHamburger']", menuHamburger: "[data-id='menuHamburger']",
...@@ -36,7 +42,9 @@ define(['require', ...@@ -36,7 +42,9 @@ define(['require',
clearGlobalSearch: "[data-id='clearGlobalSearch']", clearGlobalSearch: "[data-id='clearGlobalSearch']",
signOut: "[data-id='signOut']", signOut: "[data-id='signOut']",
administrator: "[data-id='administrator']", administrator: "[data-id='administrator']",
uiSwitch: "[data-id='uiSwitch']" uiSwitch: "[data-id='uiSwitch']",
glossaryImport: "[data-id='glossaryImport']",
businessMetadataImport: "[data-id='businessMetadataImport']"
}, },
events: function() { events: function() {
var events = {}; var events = {};
...@@ -76,15 +84,22 @@ define(['require', ...@@ -76,15 +84,22 @@ define(['require',
updateTabState: true updateTabState: true
}); });
}; };
events['click ' + this.ui.glossaryImport] = function() {
this.onClickImport(true);
};
events['click ' + this.ui.businessMetadataImport] = function() {
this.onClickImport()
};
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
this.bindEvent(); this.bindEvent();
this.options = options;
}, },
setSearchBoxWidth: function(options) { setSearchBoxWidth: function(options) {
var atlasHeaderWidth = this.$el.find(".atlas-header").width(), var atlasHeaderWidth = this.$el.find(".atlas-header").width(),
minusWidth = (Utils.getUrlState.isDetailPage() || Utils.getUrlState.isBSDetail()) ? 413 : 263; minusWidth = (Utils.getUrlState.isDetailPage() || Utils.getUrlState.isBSDetail()) ? 360 : 210;
if (options && options.updateWidth) { if (options && options.updateWidth) {
atlasHeaderWidth = options.updateWidth(atlasHeaderWidth); atlasHeaderWidth = options.updateWidth(atlasHeaderWidth);
} }
...@@ -276,6 +291,23 @@ define(['require', ...@@ -276,6 +291,23 @@ define(['require',
} }
} }
}; };
},
onClickImport: function(isGlossary) {
var that = this;
require([
'views/import/ImportLayoutView'
], function(ImportLayoutView) {
var view = new ImportLayoutView({
callback: function() {
if (isGlossary) {
that.options.importVent.trigger("Import:Glossary:Update");
} else {
that.options.importVent.trigger("Import:BM:Update");
}
},
isGlossary: isGlossary
});
});
} }
}); });
return Header; return Header;
......
...@@ -780,7 +780,7 @@ td.searchTableName:hover { ...@@ -780,7 +780,7 @@ td.searchTableName:hover {
} }
&:hover>.dropdown-menu { &:hover>.dropdown-menu {
display: block; display: table;
} }
} }
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<ul class="dropdown-menu pull-right multi-level" role="menu" aria-labelledby="dropdownMenu"> <ul class="dropdown-menu pull-right multi-level" role="menu" aria-labelledby="dropdownMenu">
<li><a href="javascript:void(0)" data-id='administrator'>Administration</a></li> <li><a href="javascript:void(0)" data-id='administrator'>Administration</a></li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a tabindex="-1" href="javascript:void(0)"> Help </span></a> <a tabindex="-1" href="javascript:void(0)">Help</span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a target="_blank" href="http://atlas.apache.org/">Documentation</a></li> <li><a target="_blank" href="http://atlas.apache.org/">Documentation</a></li>
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li> <li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
......
...@@ -101,18 +101,19 @@ define([ ...@@ -101,18 +101,19 @@ define([
this.removeAllFiles(); this.removeAllFiles();
this.addFile(file); this.addFile(file);
}, },
success: function(file, response) { success: function(file, response, responseObj) {
if (response.successImportInfoList.length && response.failedImportInfoList.length === 0) { var success = true;
if (response.failedImportInfoList && response.failedImportInfoList.length) {
success = false;
Utils.defaultErrorHandler(null, file.xhr, { defaultErrorMessage: response.failedImportInfoList[0].remarks });
}
if (success) {
that.modal.trigger("cancel"); that.modal.trigger("cancel");
Utils.notifySuccess({ Utils.notifySuccess({
content: "File: " + file.name + " imported successfully" content: "File: " + file.name + " imported successfully"
}); });
} else if (response.failedImportInfoList.length) {
Utils.notifyError({
content: response.failedImportInfoList[0].remarks
});
} }
if (that.callback) { if (that.callback && ((response.successImportInfoList && response.successImportInfoList.length > 0) || success)) {
that.callback(); that.callback();
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment