Commit a7870cde by kalyanikk Committed by Madhan Neethiraj

ATLAS-1502: added configuration to restrict entity-types editable via UI

parent c8f9f363
......@@ -407,3 +407,7 @@ legend.scheduler-border {
.topMargin {
margin-top: 13px;
}
.entityLink {
font-size: 16px;
}
......@@ -182,6 +182,16 @@ require(['App',
if (response && response['atlas.entity.update.allowed'] !== undefined) {
Globals.entityUpdate = response['atlas.entity.update.allowed'];
}
if (response && response['atlas.ui.editable.entity.types'] !== undefined) {
var entityTypeList = response['atlas.ui.editable.entity.types'].trim().split(",");
if (entityTypeList.length) {
if (entityTypeList[0] === "*") {
Globals.entityTypeConfList = [];
} else if (entityTypeList.length > 0) {
Globals.entityTypeConfList = entityTypeList;
}
}
}
App.start();
}
});
......
......@@ -171,7 +171,6 @@ define([
'collection': that.tagCollection
}));
} else {
App.rSideNav.currentView.RTagLayoutView.currentView.manualRender(tagName);
App.rSideNav.currentView.selectTab();
}
......@@ -191,7 +190,9 @@ define([
'views/site/Header',
'views/business_catalog/BusinessCatalogLayoutView',
'views/business_catalog/SideNavLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView) {
'views/search/SearchDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header({ 'globalVent': that.globalVent }));
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({
......@@ -206,8 +207,16 @@ define([
App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender(undefined, true);
}
}
App.rNContent.$el.html('');
App.rNContent.destroy();
if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) {
App.rNContent.show(new SearchDetailLayoutView({
'globalVent': that.globalVent,
'value': paramObj,
'initialView': true
}))
} else {
App.rNContent.$el.html("");
App.rNContent.destroy();
}
});
},
searchResult: function() {
......@@ -232,7 +241,8 @@ define([
App.rSideNav.currentView.selectTab();
App.rNContent.show(new SearchDetailLayoutView({
'globalVent': that.globalVent,
'value': paramObj
'value': paramObj,
'initialView': paramObj.query.trim().length === 0
}));
});
},
......
......@@ -23,7 +23,7 @@
<a href="javascript:void(0);" class="backButton" data-id="backButton"><i class="fa fa-chevron-left"></i> Back To Results</a>
</div>
<h1><span data-id="title"></span></h1> {{#if entityUpdate}}
<button data-id="editButton" class="btn btn-default pull-right editbutton" id="editText"><i class="fa fa-pencil"></i></button>
<button data-id="editButton" style="display:none" class="btn btn-default pull-right editbutton" id="editText"><i class="fa fa-pencil"></i></button>
{{/if}}
<div class="tagTerm">
<span class="tagSpan">Tags:</span>
......
......@@ -15,11 +15,6 @@
* limitations under the License.
-->
<div class="row row-margin-bottom">
{{#if entityCreate}}
<div class="col-sm-12">
<button class="btn btn-atlasAction btn-atlas pull-left" data-id="createEntity"><i class="fa fa-plus"></i> Create Entity</button>
</div>
{{/if}}
<div class="col-sm-12" style="margin:15px 0px;">
<div class="row">
<div class="col-md-6">
......
......@@ -32,6 +32,14 @@
</ul>
</div>
<div id="r_searchResultTableLayoutView">
{{#if entityCreate}}
<div class="entityLink" style="display:none">
<h1><b>Atlas Search</b></h1>
<p class="entityLink">Search Atlas for existing entities or
<a href="javascript:void(0)" data-id='createEntity'> create new entity </a><i class="fa fa-question-circle" aria-hidden="true"></i>
</p>
</div>
{{/if}}
</div>
</div>
</div>
......@@ -40,6 +40,15 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
})
]);
}
_.mixin({
isEmptyArray: function(val) {
if (val && _.isArray(val)) {
return _.isEmpty(val);
} else {
return false;
}
}
});
// For placeholder support
if (!('placeholder' in HTMLInputElement.prototype)) {
......
......@@ -147,7 +147,7 @@ define(['require',
that.$('.fontLoader').hide();
that.$('.auditTable').show();
that.renderOffset(options);
if ((that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
options.next.attr('disabled', true);
options.previous.removeAttr("disabled");
} else {
......
......@@ -20,8 +20,9 @@ define(['require',
'backbone',
'hbs!tmpl/audit/CreateAuditTableLayoutView_tmpl',
'utils/Enums',
'utils/CommonViewFunction'
], function(require, Backbone, CreateAuditTableLayoutViewTmpl, Enums, CommonViewFunction) {
'utils/CommonViewFunction',
'utils/Utils'
], function(require, Backbone, CreateAuditTableLayoutViewTmpl, Enums, CommonViewFunction, Utils) {
'use strict';
var CreateAuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -65,11 +66,17 @@ define(['require',
if (this.entityModel.get('details').search('{') >= 0) {
var appendedString = "{" + this.entityModel.get('details') + "}";
var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1];
var detailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
try {
var detailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
} catch (err) {
Utils.serverErrorHandler();
}
//Append string for JSON parse
var valueObject = detailsObject.values;
if (this.action == Enums.auditAction.TAG_ADD) {
this.ui.auditHeaderValue.html('<th>' + Enums.auditAction.TAG_ADD + '</th>');
if (detailsObject) {
var valueObject = detailsObject.values;
}
if ((this.action == Enums.auditAction.TAG_ADD || Enums.auditAction.ENTITY_CREATE) && detailsObject) {
this.ui.auditHeaderValue.html('<th>' + (this.action === Enums.auditAction.ENTITY_CREATE ? Enums.auditAction.ENTITY_CREATE : Enums.auditAction.TAG_ADD) + '</th>');
this.ui.auditValue.html("<tr><td>" + _.escape(detailsObject.typeName) + "</td></tr>");
} else {
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>');
......@@ -84,9 +91,8 @@ define(['require',
}
}
} else if (this.action == Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE) {
//var appendedString = this.entityModel.get('details').split(':');
this.ui.auditHeaderValue.html('<th>' + this.action + '</th>');
this.ui.auditValue.html("<tr><td>" + this.entityObject.name + "</td></tr>");
this.ui.auditHeaderValue.html('<th>' + Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE + '</th>');
this.ui.auditValue.html("<tr><td>" + (this.entityObject.name || this.entityObject.qualifiedName) + "</td></tr>");
}
},
......
......@@ -164,13 +164,21 @@ define(['require',
} else {
this.addTagToTerms([]);
}
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
this.ui.editButton.show();
} else {
if (_.contains(Globals.entityTypeConfList, collectionJSON.typeName)) {
this.ui.editButton.show();
}
}
}
this.hideLoader();
this.auditVent.trigger("reset:collection");
this.renderEntityDetailTableLayoutView();
this.renderAuditTableLayoutView(this.id, collectionJSON.attributes);
this.renderTagTableLayoutView(tagGuid);
this.renderTermTableLayoutView(tagGuid);
this.renderAuditTableLayoutView(this.id, collectionJSON.attributes);
this.renderLineageLayoutView(this.id);
this.renderSchemaLayoutView(this.id);
}, this);
this.listenTo(this.collection, 'error', function(model, response) {
this.$('.fontLoader').hide();
......@@ -185,9 +193,6 @@ define(['require',
var that = this;
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.entityDetail'));
this.$('.fontLoader').show(); // to show tab loader
this.renderLineageLayoutView(this.id);
this.renderSchemaLayoutView(this.id);
},
fetchCollection: function() {
this.collection.fetch({ reset: true });
......
......@@ -43,7 +43,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'value'));
_.extend(this, _.pick(options, 'globalVent', 'value', 'initialView'));
},
bindEvents: function() {},
onRender: function() {
......@@ -63,7 +63,8 @@ define(['require',
if (that.RSearchResultLayoutView) {
that.RSearchResultLayoutView.show(new SearchResultLayoutView({
value: value,
tag: that.tag
tag: that.tag,
initialView: that.initialView
}));
}
});
......
......@@ -43,14 +43,7 @@ define(['require',
searchBtn: '[data-id="searchBtn"]',
clearSearch: '[data-id="clearSearch"]',
typeLov: '[data-id="typeLOV"]',
refreshBtn: '[data-id="refreshBtn"]',
createEntity: "[data-id='createEntity']",
},
templateHelpers: function() {
return {
entityCreate: Globals.entityCreate
};
refreshBtn: '[data-id="refreshBtn"]'
},
/** ui events hash */
......@@ -72,7 +65,6 @@ define(['require',
events["click " + this.ui.clearSearch] = 'clearSearchData';
events["change " + this.ui.typeLov] = 'onChangeTypeList';
events["click " + this.ui.refreshBtn] = 'onRefreshButton';
events["click " + this.ui.createEntity] = 'onClickCreateEntity';
return events;
},
/**
......@@ -132,7 +124,9 @@ define(['require',
return model.get('name').toLowerCase();
}
this.typecollection.fullCollection.sort().each(function(model) {
str += '<option>' + _.escape(model.get("name")) + '</option>';
if (model.get('category') == 'ENTITY') {
str += '<option>' + _.escape(model.get("name")) + '</option>';
}
});
that.ui.typeLov.html(str);
},
......@@ -257,20 +251,7 @@ define(['require',
mergeBrowserUrl: false,
trigger: true
});
},
onClickCreateEntity: function(e) {
var that = this;
$(e.currentTarget).blur();
require([
'views/entity/CreateEntityLayoutView'
], function(CreateEntityLayoutView) {
var view = new CreateEntityLayoutView({
callback: function() {
that.fetchCollection();
}
});
});
},
}
});
return SearchLayoutView;
});
......@@ -58,9 +58,14 @@ define(['require',
nextData: "[data-id='nextData']",
pageRecordText: "[data-id='pageRecordText']",
addAssignTag: "[data-id='addAssignTag']",
editEntityButton: "[data-id='editEntityButton']"
editEntityButton: "[data-id='editEntityButton']",
createEntity: "[data-id='createEntity']",
},
templateHelpers: function() {
return {
entityCreate: Globals.entityCreate
};
},
/** ui events hash */
events: function() {
var events = {};
......@@ -109,6 +114,7 @@ define(['require',
events["click " + this.ui.nextData] = "onClicknextData";
events["click " + this.ui.previousData] = "onClickpreviousData";
events["click " + this.ui.editEntityButton] = "onClickEditEntity";
events["click " + this.ui.createEntity] = 'onClickCreateEntity';
return events;
},
/**
......@@ -116,7 +122,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'vent', 'value'));
_.extend(this, _.pick(options, 'globalVent', 'vent', 'value', 'initialView'));
var pagination = "";
this.entityModel = new VEntity();
this.searchCollection = new VSearchList();
......@@ -178,26 +184,32 @@ define(['require',
}, this);
},
onRender: function() {
var value = {},
that = this;
if (this.value) {
value = this.value;
} else {
value = {
'query': '',
'searchType': 'fulltext'
};
}
this.fetchCollection(value);
$('body').click(function(e) {
var iconEvnt = e.target.nodeName;
if (that.$('.popoverContainer').length) {
if ($(e.target).hasClass('tagDetailPopover') || iconEvnt == "I") {
return;
if (!this.initialView) {
var value = {},
that = this;
if (this.value) {
value = this.value;
} else {
value = {
'query': '',
'searchType': 'fulltext'
};
}
this.fetchCollection(value);
$('body').click(function(e) {
var iconEvnt = e.target.nodeName;
if (that.$('.popoverContainer').length) {
if ($(e.target).hasClass('tagDetailPopover') || iconEvnt == "I") {
return;
}
that.$('.popover.popoverTag').hide();
}
that.$('.popover.popoverTag').hide();
});
} else {
if (Globals.entityTypeConfList) {
this.$(".entityLink").show();
}
});
}
},
fetchCollection: function(value) {
var that = this;
......@@ -264,13 +276,16 @@ define(['require',
}
var resultData = 'Results for <b>' + _.escape(that.searchCollection.queryParams.query) + '</b>';
var multiAssignDataTag = '<a href="javascript:void(0)" class="inputAssignTag multiSelectTag assignTag" style="display:none" data-id="addAssignTag"><i class="fa fa-plus"></i>' + " " + 'Assign Tag</a>';
var resultText = that.searchCollection.queryParams.query;
var multiAssignDataTerm = "",
createEntityTag = "";
if (Globals.taxonomy) {
var multiAssignDataTerm = '<a href="javascript:void(0)" class="inputAssignTag multiSelect" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i>' + " " + 'Assign Term</a>';
that.$('.searchResult').html(resultData + multiAssignDataTerm + multiAssignDataTag);
} else {
that.$('.searchResult').html(resultData + multiAssignDataTag);
multiAssignDataTerm = '<a href="javascript:void(0)" class="inputAssignTag multiSelect" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i>' + " " + 'Assign Term</a>';
}
if (Globals.entityCreate && (resultText.indexOf("\`") != 0) && Globals.entityTypeConfList) {
createEntityTag = "<p>If you do not find the entity in search result below then you can" + '<a href="javascript:void(0)" data-id="createEntity"> create new entity</a></p>';
}
that.$('.searchResult').html(resultData + multiAssignDataTag + multiAssignDataTerm + createEntityTag);
},
silent: true,
reset: true
......@@ -341,7 +356,13 @@ define(['require',
return '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
} else {
if (Globals.entityUpdate) {
nameHtml += '<button title="Edit" data-id="editEntityButton" data-giud= "' + obj.guid + '" class="btn btn-atlasAction btn-atlas editBtn"><i class="fa fa-pencil"></i></button>'
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
nameHtml += '<button title="Edit" data-id="editEntityButton" data-giud= "' + obj.guid + '" class="btn btn-atlasAction btn-atlas editBtn"><i class="fa fa-pencil"></i></button>'
} else {
if (_.contains(Globals.entityTypeConfList, obj.typeName)) {
nameHtml += '<button title="Edit" data-id="editEntityButton" data-giud= "' + obj.guid + '" class="btn btn-atlasAction btn-atlas editBtn"><i class="fa fa-pencil"></i></button>'
}
}
}
return nameHtml;
}
......@@ -606,6 +627,19 @@ define(['require',
}
});
});
},
onClickCreateEntity: function(e) {
var that = this;
$(e.currentTarget).blur();
require([
'views/entity/CreateEntityLayoutView'
], function(CreateEntityLayoutView) {
var view = new CreateEntityLayoutView({
callback: function() {
that.fetchCollection();
}
});
});
}
});
return SearchResultLayoutView;
......
......@@ -98,8 +98,8 @@ define(['require',
});
}
if (obj.skipEntity.length) {
var text = "<b>" + obj.skipEntity.join(', ') +
"</b> <br/> entities selected have already been associated with <b>" + tagName +
var text = "<b>" + obj.skipEntity.length + " of " + that.multiple.length +
"</b> entities selected have already been associated with <b>" + tagName +
"</b> tag, Do you want to associate the tag with other entities ?",
removeCancelButton = false;
if ((obj.skipEntity.length + obj.deletedEntity.length) === that.multiple.length) {
......
......@@ -48,6 +48,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
......@@ -65,6 +66,8 @@ public class AdminResource {
private static final String isTaxonomyEnabled = "atlas.feature.taxonomy.enable";
private static final String isEntityUpdateAllowed = "atlas.entity.update.allowed";
private static final String isEntityCreateAllowed = "atlas.entity.create.allowed";
private static final String editableEntityTypes = "atlas.ui.editable.entity.types";
private static final String DEFAULT_EDITABLE_ENTITY_TYPES = "hdfs_path,hdfs_path,hbase_table,hbase_column,hbase_column_family,kafka_topic";
private Response version;
private ServiceState serviceState;
private MetricsService metricsService;
......@@ -213,6 +216,7 @@ public class AdminResource {
responseData.put(isTaxonomyEnabled, enableTaxonomy);
responseData.put(isEntityUpdateAllowed, isEntityUpdateAccessAllowed);
responseData.put(isEntityCreateAllowed, isEntityCreateAccessAllowed);
responseData.put(editableEntityTypes, getEditableEntityTypes(configProperties));
responseData.put("userName", userName);
responseData.put("groups", groups);
......@@ -244,4 +248,30 @@ public class AdminResource {
return metrics;
}
private String getEditableEntityTypes(PropertiesConfiguration config) {
String ret = DEFAULT_EDITABLE_ENTITY_TYPES;
if (config.containsKey(editableEntityTypes)) {
Object value = config.getProperty(editableEntityTypes);
if (value instanceof String) {
ret = (String)value;
} else if (value instanceof Collection) {
StringBuilder sb = new StringBuilder();
for (Object elem : ((Collection)value)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(elem.toString());
}
ret = sb.toString();
}
}
return ret;
}
}
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