You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/01/28 17:56:39 UTC
[4/4] incubator-ranger git commit: RANGER-203: UI - policy delete
implemented; policy permissions selection updated; landing page layout fixes
RANGER-203: UI - policy delete implemented; policy permissions selection updated; landing page layout fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/286acf6d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/286acf6d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/286acf6d
Branch: refs/heads/stack
Commit: 286acf6d27be73a2993e5f8ff0b1347b13f11840
Parents: 4130d7a
Author: Gautam Borad <gb...@gmail.com>
Authored: Wed Jan 28 08:56:24 2015 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Jan 28 08:56:24 2015 -0800
----------------------------------------------------------------------
.../webapp/scripts/controllers/Controller.js | 19 -
.../src/main/webapp/scripts/modules/XALinks.js | 5 +
.../scripts/modules/globalize/message/en.js | 1 +
.../src/main/webapp/scripts/utils/XAUtils.js | 25 +
.../webapp/scripts/views/asset/AssetCreate.js | 285 -------
.../webapp/scripts/views/asset/AssetForm.js | 369 ---------
.../scripts/views/asset/AssetTableLayout.js | 164 ----
.../scripts/views/hbase/HbasePolicyCreate.js | 300 -------
.../scripts/views/hbase/HbasePolicyForm.js | 574 --------------
.../scripts/views/hbase/HbaseTableLayout.js | 393 ----------
.../scripts/views/hdfs/HDFSTableLayout.js | 402 ----------
.../scripts/views/hive/HivePolicyCreate.js | 314 --------
.../webapp/scripts/views/hive/HivePolicyForm.js | 774 -------------------
.../scripts/views/hive/HiveTableLayout.js | 462 -----------
.../scripts/views/knox/KnoxPolicyCreate.js | 301 --------
.../webapp/scripts/views/knox/KnoxPolicyForm.js | 524 -------------
.../scripts/views/knox/KnoxTableLayout.js | 351 ---------
.../scripts/views/policies/PermissionList.js | 57 +-
.../views/policies/RangerPolicyCreate.js | 28 +-
.../views/policies/RangerPolicyTableLayout.js | 89 ++-
.../webapp/scripts/views/policy/PolicyCreate.js | 308 --------
.../webapp/scripts/views/policy/PolicyForm.js | 501 ------------
.../views/policymanager/PolicyManagerLayout.js | 123 ---
.../views/policymanager/ServiceLayout.js | 29 +-
.../scripts/views/service/ServiceCreate.js | 9 +-
.../scripts/views/storm/StormPolicyCreate.js | 301 --------
.../scripts/views/storm/StormPolicyForm.js | 510 ------------
.../scripts/views/storm/StormTableLayout.js | 351 ---------
security-admin/src/main/webapp/styles/xa.css | 20 +
.../common/ServiceManagerLayout_tmpl.html | 2 +-
.../main/webapp/templates/helpers/XAHelpers.js | 2 +-
.../templates/policies/PermissionItem.html | 10 +-
.../service/ServiceTableLayout_tmpl.html | 2 +-
33 files changed, 230 insertions(+), 7375 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/controllers/Controller.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js b/security-admin/src/main/webapp/scripts/controllers/Controller.js
index f056d15..71910a9 100644
--- a/security-admin/src/main/webapp/scripts/controllers/Controller.js
+++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js
@@ -53,25 +53,6 @@ define(function(require) {
App.rContent.show(new vDashboardLayout({}));
},
-
- //************** Policy Related *********************/
- policyManagerAction :function(){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- console.log('Policy Manager action called..');
- var view = require('views/policymanager/PolicyManagerLayout');
- var VXAssetList = require('collections/VXAssetList');
- var collection = new VXAssetList();
-
- collection.fetch({
- cache : false,
- async:false
- }).done(function(){
- if(App.rContent.currentView) App.rContent.currentView.close();
- App.rContent.show(new view({
- collection : collection
- }));
- });
- },
//************** Analytics(reports) Related *********************/
userAccessReportAction : function(){
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/modules/XALinks.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/modules/XALinks.js b/security-admin/src/main/webapp/scripts/modules/XALinks.js
index 52e6c01..00267b3 100644
--- a/security-admin/src/main/webapp/scripts/modules/XALinks.js
+++ b/security-admin/src/main/webapp/scripts/modules/XALinks.js
@@ -49,6 +49,11 @@ define(function(require) {
text : 'h.repositoryManager',
title: 'h.repositoryManager'
},
+ ServiceManager :{
+ href : '#!/policymanager',
+ text : 'h.serviceManager',
+ title: 'h.serviceManager'
+ },
Users : {
href : '#!/users/usertab',
text : 'h.usersOrGroups',
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
index fa39365..94f1444 100644
--- a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
+++ b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
@@ -235,6 +235,7 @@ define(function(require) {
analytics : 'Analytics',
audit : 'Audit',
repositoryManager : 'Manage Repository',
+ serviceManager : 'Service Manager',
hdfs : 'HDFS',
hive : 'Hive',
createPolicy : 'Create Policy',
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/utils/XAUtils.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index 4ff308f..f90a3e6 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -356,6 +356,31 @@ define(function(require) {
}else
return '--';
};
+ XAUtils.showGroupsOrUsersForPolicy = function(rawValue, model, showGroups){
+ var showMoreLess = false, groupArr = [];
+ var type = _.isUndefined(showGroups) ? 'groups' : 'users';
+ if(!_.isArray(rawValue) && !_.isUndefined(rawValue[type]))
+ return '--';
+ _.each(rawValue,function(perm){
+ groupArr = _.union(groupArr, perm[type])
+ });
+
+ var newGroupArr = _.map(groupArr, function(name, i){
+ if(i >= 4){
+ return '<span class="label label-info" policy-'+type+'-id="'+model.id+'" style="display:none;">' + name + '</span>';
+ }else if(i == 3 && groupArr.length > 4){
+ showMoreLess = true;
+ return '<span class="label label-info" policy-'+type+'-id="'+model.id+'">' + name + '</span>';
+ }else{
+ return '<span class="label label-info" policy-'+type+'-id="'+model.id+'">' + name + '</span>';
+ }
+ });
+ if(showMoreLess){
+ newGroupArr.push('<span class="pull-left"><a href="javascript:void(0);" data-id="showMore" class="" policy-'+type+'-id="'+model.id+'"><code style=""> + More..</code></a></span><span class="pull-left" ><a href="javascript:void(0);" data-id="showLess" class="" policy-'+type+'-id="'+model.id+'" style="display:none;"><code> - Less..</code></a></span>');
+ }
+ return newGroupArr.length ? newGroupArr.join(' ') : '--';
+
+ };
XAUtils.defaultErrorHandler = function(model, error) {
var App = require('App');
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/asset/AssetCreate.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/asset/AssetCreate.js b/security-admin/src/main/webapp/scripts/views/asset/AssetCreate.js
deleted file mode 100644
index 3a7e06f..0000000
--- a/security-admin/src/main/webapp/scripts/views/asset/AssetCreate.js
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-/*
- * Repository/Asset create view
- */
-
-define(function(require){
- 'use strict';
-
- var Backbone = require('backbone');
- var App = require('App');
-
- var XAUtil = require('utils/XAUtils');
- var XAEnums = require('utils/XAEnums');
- var XALinks = require('modules/XALinks');
- var localization = require('utils/XALangSupport');
-
- var AssetForm = require('views/asset/AssetForm');
- var AssetcreateTmpl = require('hbs!tmpl/asset/AssetCreate_tmpl');
-
- var AssetCreate = Backbone.Marionette.Layout.extend(
- /** @lends AssetCreate */
- {
- _viewName : 'AssetCreate',
-
- template: AssetcreateTmpl,
-
- templateHelpers : function(){
- return { editAsset : this.editAsset};
- },
-
- breadCrumbs :function(){
- if(this.model.isNew())
- return [XALinks.get('RepositoryManager'), XALinks.get('AssetCreate', {model:this.model})];
- else
- return [XALinks.get('RepositoryManager'), XALinks.get('AssetEdit',{model:this.model})];
- },
-
- /** Layout sub regions */
- regions: {
- 'rForm' :'div[data-id="r_form"]'
- },
-
- /** ui selector cache */
- ui: {
- 'btnSave' : '[data-id="save"]',
- 'btnCancel' : '[data-id="cancel"]',
- 'btnDelete' : '[data-id="delete"]',
- 'btnTestConn' : '[data-id="testConn"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.btnSave] = 'onSave';
- events['click ' + this.ui.btnCancel] = 'onCancel';
- events['click ' + this.ui.btnDelete] = 'onDelete';
- events['click ' + this.ui.btnTestConn] = 'onTestConnection';
- return events;
- },
-
- /**
- * intialize a new AssetCreate Layout
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a AssetCreate Layout");
-
- _.extend(this, _.pick(options, 'repositoryName'));
- if(! this.model.isNew()){
- this.setupModel();
- }
- this.form = new AssetForm({
- model : this.model,
- template : require('hbs!tmpl/asset/AssetForm_tmpl')
- });
- this.editAsset = this.model.has('id') ? true : false;
-
- this.bindEvents();
- },
- setupModel : function(){
- var that = this;
- //var obj = _.pick(this.model.attributes,['username','password','fsDefaultName' ,'authorization', 'authentication', 'auth_to_local', 'datanode', 'namenode', 'secNamenode']);
- if(this.model.get('config')){
- var configObj = $.parseJSON(this.model.get('config'));
- _.each(configObj,function(val,prop){
- _.each(that.model.propertiesNameMap,function(v,p){
- if(prop == v){
- that.model.set(p,val);
- }
- });
- });
- }
-
- //this.model.set('config',JSON.stringify(obj));
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
- },
-
- /** on render callback */
- onRender: function() {
- if(!this.editAsset){
- this.ui.btnDelete.hide();
- this.ui.btnSave.html('Add');
- }else{
-
- // XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavRepositoryForm'));
- }
- this.rForm.show(this.form);
- this.rForm.$el.dirtyFields();
- XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavRepositoryForm'),this.rForm.$el);
- this.initializePlugins();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- onSave: function(){
- var errors = this.form.commit({validate : false});
- if(! _.isEmpty(errors)){
- return;
- }
- this.form.formValidation();
- this.saveAsset();
-
- },
- saveAsset : function(){
- var that = this;
- this.form.beforeSave();
- XAUtil.blockUI();
- this.model.save({},{
- wait: true,
- success: function () {
- XAUtil.blockUI('unblock');
- XAUtil.allowNavigation();
- var msg = that.editAsset ? 'Repository updated successfully' :'Repository created successfully';
- XAUtil.notifySuccess('Success', msg);
-
- if(that.editAsset){
- App.appRouter.navigate("#!/policymanager",{trigger: true});
- return;
- }
-
- App.appRouter.navigate("#!/policymanager",{trigger: true});
-
- },
- error: function (model, response, options) {
- XAUtil.blockUI('unblock');
- if ( response && response.responseJSON && response.responseJSON.msgDesc){
- if(response.responseJSON.msgDesc == "serverMsg.fsDefaultNameValidationError"){
- that.form.fields.fsDefaultName.setError(localization.tt(response.responseJSON.msgDesc));
- XAUtil.scrollToField(that.form.fields.fsDefaultName.$el);
- }else if(response.responseJSON.msgDesc == "Repository Name already exists"){
- response.responseJSON.msgDesc = "serverMsg.repositoryNameAlreadyExistsError";
- that.form.fields.name.setError(localization.tt(response.responseJSON.msgDesc));
- XAUtil.scrollToField(that.form.fields.name.$el);
- }else if(response.responseJSON.msgDesc == "XUser already exists"){
- response.responseJSON.msgDesc = "serverMsg.userAlreadyExistsError";
- that.form.fields.userName.setError(localization.tt(response.responseJSON.msgDesc));
- XAUtil.scrollToField(that.form.fields.userName.$el);
- }else
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }else
- XAUtil.notifyError('Error', 'Error creating Asset!');
- console.log("error");
- }
- });
- },
- onDelete :function(){
- var that = this;
- XAUtil.confirmPopup({
- //msg :localize.tt('msg.confirmDelete'),
- msg :'Are you sure want to delete ?',
- callback : function(){
- XAUtil.blockUI();
-
- that.model.destroy({
- success: function(model, response) {
- XAUtil.blockUI('unblock');
- XAUtil.allowNavigation();
- XAUtil.notifySuccess('Success', 'Repository delete successfully');
- App.appRouter.navigate("#!/policymanager",{trigger: true});
- },
- error: function (model, response, options) {
- XAUtil.blockUI('unblock');
- if ( response && response.responseJSON && response.responseJSON.msgDesc){
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }else
- XAUtil.notifyError('Error', 'Error occured while deleting asset!');
- }
- });
-
- }
- });
- },
- onTestConnection : function(){
- var errors = this.form.commit({validate : false});
- if(! _.isEmpty(errors)){
- return;
- }
- this.form.beforeSave();
- this.model.testConfig(this.model,{
- //wait: true,
- success: function (msResponse, options) {
- if(msResponse.statusCode){
- if(!_.isUndefined(msResponse) && !_.isUndefined(msResponse.msgDesc)){
- var popupBtnOpts;
- if(!_.isEmpty(msResponse.msgDesc)){
- if(_.isArray(msResponse.messageList) && !_.isUndefined(msResponse.messageList[0].message)
- && !_.isEmpty(msResponse.messageList[0].message)){
- popupBtnOpts = [{
- label: "Show More..",
- callback:function(e){
- console.log(e)
- if($(e.currentTarget).text() == 'Show More..'){
- var div = '<div class="showMore connection-error-font"><br>'+msResponse.messageList[0].message.split('\n').join('<br>')+'</div>'
- $(e.delegateTarget).find('.modal-body').append(div)
- $(e.currentTarget).html('Show Less..')
- }else{
- $(e.delegateTarget).find('.showMore').remove();
- $(e.currentTarget).html('Show More..')
- }
- return false;
- }
- }, {
- label: "OK",
- callback:function(){}
- }];
- }else{
- popupBtnOpts = [{label: "OK",
- callback:function(){}
- }];
- }
- var msgHtml = '<b>Connection Failed.</b></br>'+msResponse.msgDesc;
- bootbox.dialog(msgHtml, popupBtnOpts);
- }else{
- bootbox.alert("Connection Failed.");
- }
- }else{
- bootbox.alert("Connection Failed.");
- }
- }
- else
- bootbox.alert("Connected Successfully.");
- },
- error: function (msResponse, options) {
- bootbox.alert("Connection Failed.");
- }
- });
- },
- onCancel : function(){
- XAUtil.allowNavigation();
- App.appRouter.navigate("#!/policymanager",{trigger: true});
- },
- /** on close */
- onClose: function(){
- XAUtil.allowNavigation();
- }
- });
-
- return AssetCreate;
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js b/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
deleted file mode 100644
index 0db1aa3..0000000
--- a/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-define(function(require){
- 'use strict';
-
- var Backbone = require('backbone');
-
- var XAEnums = require('utils/XAEnums');
- var localization = require('utils/XALangSupport');
-
- require('backbone-forms');
- require('backbone-forms.list');
- require('backbone-forms.templates');
- require('backbone-forms.XAOverrides');
-
- var AssetForm = Backbone.Form.extend(
- /** @lends AssetForm */
- {
- _viewName : 'AssetForm',
-
- /**
- * intialize a new AssetForm Form View
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a AssetForm Form View");
- Backbone.Form.prototype.initialize.call(this, options);
-
- _.extend(this, _.pick(options, ''));
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- this.on('assetType:change', function(form, fieldEditor){
- this.evFieldChange(form, fieldEditor);
- });
- },
-
- /** schema for the form
- * If you see that a field should behave similarly in all the forms, its
- * better to make the change in this.model.schema itself
- *
- * Override here ONLY if special case!!
- */
-
- fields: ['name', 'description', 'activeStatus', 'assetType','config', '_vPassword'],
-
- schema : function(){
-
- var attrs = _.pick(_.result(this.model,'schemaBase'), 'name', 'description', 'activeStatus', 'assetType', 'config');
-
- attrs._vPassword = {
- type : 'Password',
- title : localization.tt("lbl.assetConfigPass")
- };
- $.extend(attrs,{
- userName : {
- type : 'Text',
-// fieldClass : "hdfs hive knox",
- title : this.model.propertiesNameMap.userName+" *",//'xalogin.username'
- validators : ['required'],//{type:'regexp',regexp:/^[a-z][a-z0-9,._'-]+$/i,message :'Please enter valid username'}],
- editorAttrs :{'class':'stretchTextInput'}//,'maxlength': 48}
- },
- passwordKeytabfile : {
- type : 'Password',
-// fieldClass : "hdfs hive knox",
- title : this.model.propertiesNameMap.passwordKeytabfile+" *",//'xalogin.password'
- validators:['required'],
- editorAttrs :{'class':'stretchTextInput'}
- },
- fsDefaultName : {
- fieldClass : "hdfs",
- title : this.model.propertiesNameMap.fsDefaultName +" *",//'core-site.fs.default.name',
- validators:['required'],
- /*{type:'regexp',regexp:new RegExp('(hdfs://)\\s*(.*?):[0-9]{1,5}'),
- message :localization.tt('serverMsg.fsDefaultNameValidationError')}],*/
- editorAttrs :{'class':'stretchTextInput'}
-
-
- },
- authorization : {
- fieldClass : "hdfs",
- title : this.model.propertiesNameMap.authorization,//'core-site.hadoop.security.authorization',
- editorAttrs :{'class':'stretchTextInput'}
- },
- authentication : {
- fieldClass : "hdfs",
- title : this.model.propertiesNameMap.authentication,//'core-site.hadoop.security.authentication'
- editorAttrs :{'class':'stretchTextInput'}
- },
- auth_to_local : {
- fieldClass : "hdfs",
- title : this.model.propertiesNameMap.auth_to_local,//'core-site.hadoop.security.auth_to_local'
- editorAttrs :{'class':'stretchTextInput'}
- },
- datanode : {
- title : this.model.propertiesNameMap.datanode,//'hdfs-site.dfs.datanode.kerberos.principal',
- fieldClass : "hdfs",
- editorAttrs :{'class':'stretchTextInput'}
- },
- namenode : {
- title : this.model.propertiesNameMap.namenode,//'hdfs-site.dfs.namenode.kerberos.principal',
- fieldClass : "hdfs",
- editorAttrs :{'class':'stretchTextInput'}
- },
- secNamenode : {
- title : this.model.propertiesNameMap.secNamenode,//'hdfs-site.dfs.secondary.namenode.kerberos.principal',
- fieldClass : "hdfs",
- editorAttrs :{'class':'stretchTextInput'}
- },
- hadoopRpcProtection : {
- title : this.model.propertiesNameMap.hadoopRpcProtection,//'hadoop.rpc.protection',
- fieldClass : "hdfs",
- editorAttrs :{'class':'stretchTextInput'}
- },
- driverClassName : {
- fieldClass : "hive",
- title : this.model.propertiesNameMap.driverClassName,//'xalogin.jdbc.driverClassName'
- editorAttrs :{'class':'stretchTextInput'}
- },
- url : {
- fieldClass : "hive",
- title : this.model.propertiesNameMap.url,//'xalogin.jdbc.url'
- editorAttrs :{'class':'stretchTextInput'}
- },
- masterKerberos : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.masterKerberos,
- editorAttrs :{'class':'stretchTextInput'}
- },
- rpcEngine : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.rpcEngine,
- editorAttrs :{'class':'stretchTextInput'}
- },
- rpcProtection : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.rpcProtection,
- editorAttrs :{'class':'stretchTextInput'}
- },
- securityAuthentication : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.securityAuthentication+" *",
- editorAttrs :{'class':'stretchTextInput'}
- },
- zookeeperProperty : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.zookeeperProperty+" *",
- editorAttrs :{'class':'stretchTextInput'}
- },
- zookeeperQuorum : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.zookeeperQuorum+" *",
- editorAttrs :{'class':'stretchTextInput'}
- },
- zookeeperZnodeParent : {
- fieldClass : "hbase",
- title : this.model.propertiesNameMap.zookeeperZnodeParent+" *",
- editorAttrs :{'class':'stretchTextInput'}
- },
- knoxUrl : {
- fieldClass : "knox",
- title : this.model.propertiesNameMap.knoxUrl,
- editorAttrs :{'class':'stretchTextInput'}
- },
- nimbusUrl : {
- fieldClass : "storm",
- title : this.model.propertiesNameMap.nimbusUrl,
- editorAttrs :{'class':'stretchTextInput'}
- },
- commonnameforcertificate : {
- title : localization.tt('lbl.commonNameForCertificate'),
- editorAttrs :{'class':'stretchTextInput'}
- }
- });
- return attrs;
- },
-
- /** on render callback */
- render: function(options) {
- Backbone.Form.prototype.render.call(this, options);
-
- this.initializePlugins();
- this.renderCustomFields();
- if(!this.model.isNew())
- this.fields.assetType.editor.$el.prop('disabled',true);
- else
- this.fields.activeStatus.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
- },
-
- /** all custom field rendering */
- renderCustomFields: function(){
- /*this.$('[data-customfields="field1"]').append(new fieldView({
- }).render().el);*/
- //TODO FIXME
-
- if(this.model)
- this.assetTypeChanged(this.model.get('assetType'));
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- formValidation : function(){
- //return false;
- return true;
- },
-
- beforeSave : function(){
- var that = this;
- //this.model.set('assetId', XAGlobals.hardcoded.HDFSAssetId);
-// var attrs = ['userName','passwordKeytabfile','fsDefaultName' ,'authorization', 'authentication', 'auth_to_local', 'datanode', 'namenode', 'secNamenode',
-// 'driverClassName', 'url'];
- var attrs;
- switch(parseInt(this.model.get('assetType'))){
- case XAEnums.AssetType.ASSET_HDFS.value :
- attrs = ['userName','passwordKeytabfile','fsDefaultName' ,'authorization', 'authentication', 'auth_to_local', 'datanode', 'namenode', 'secNamenode',
- 'hadoopRpcProtection', 'commonnameforcertificate'];
- break;
- case XAEnums.AssetType.ASSET_HIVE.value :
- attrs = ['userName','passwordKeytabfile','driverClassName', 'url','commonnameforcertificate'];
- break;
- case XAEnums.AssetType.ASSET_HBASE.value :
-// attrs = ['userName','passwordKeytabfile','authorization', 'authentication', 'auth_to_local', 'datanode', 'namenode', 'secNamenode',
-// 'masterKerberos','rpcEngine','rpcProtection','securityAuthentication','zookeeperProperty','zookeeperQuorum','zookeeperZnodeParent','commonnameforcertificate'];
- attrs = ['userName','passwordKeytabfile', 'authentication', 'masterKerberos',
- 'securityAuthentication','zookeeperProperty','zookeeperQuorum','zookeeperZnodeParent'];
- break;
- case XAEnums.AssetType.ASSET_KNOX.value :
- attrs = ['userName','passwordKeytabfile','knoxUrl','commonnameforcertificate'];
- break;
- case XAEnums.AssetType.ASSET_STORM.value :
- attrs = ['userName','passwordKeytabfile','nimbusUrl','commonnameforcertificate'];
- }
- var obj = _.pick(this.model.attributes,attrs);
- _.each(obj,function(val,prop){
- obj[that.model.propertiesNameMap[prop]] = obj[prop];
- delete obj[prop];
- this.model.unset(prop);
- },this);
- this.model.set('config',JSON.stringify(obj));
- },
- evFieldChange : function(form, fieldEditor){
- this.assetTypeChanged(fieldEditor.getValue());
- },
- assetTypeChanged : function(val){
- this.$('.hive').parents('fieldset').show();
- this.$('.hdfs,.hive,.hbase,.knox,.storm').hide();
- switch(parseInt(val)){
- case XAEnums.AssetType.ASSET_HDFS.value :
- this.fields.fsDefaultName.$el.find('.control-label').html(this.model.propertiesNameMap.fsDefaultName+'*');
-// this.fields.fsDefaultName.editor.validators.push('required');
- this.$('.hdfs').show();
- break;
- case XAEnums.AssetType.ASSET_HIVE.value :
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- this.$('.hive').show();
- break;
- case XAEnums.AssetType.ASSET_HBASE.value :
- // this.$('.hive').parents('fieldset').hide();
-// this.fields.fsDefaultName.$el.find('.control-label').html(this.model.propertiesNameMap.fsDefaultName);
-// this.fields.fsDefaultName.$el.removeClass('error');
-// this.fields.fsDefaultName.$el.find('.help-inline').html('');
-// this.fields.fsDefaultName.editor.$el.val('');
- this.fields.authentication.editor.validators = ['required'];
-// this.fields.authentication.schema.title = this.fields.authentication.schema.title+" *"
- this.fields.authentication.$el.find('label').html(this.schema.authentication.title+" *")
-// this.schema.authentication.title = this.schema.authentication.title+" *"
-
-// this.fields.masterKerberos.editor.validators = ['required'];
- this.fields.securityAuthentication.editor.validators = ['required'];
- this.fields.zookeeperProperty.editor.validators = ['required'];
- this.fields.zookeeperQuorum.editor.validators = ['required'];
- this.fields.zookeeperZnodeParent.editor.validators = ['required'];
-
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- //Set default value to zookeeperZnodeParent
- if(this.model.isNew())
- this.fields.zookeeperZnodeParent.editor.$el.val('/hbase');
- this.$('.hdfs').show();
- this.$('.hive').show();//parents('fieldset').show();
- this.$('.hbase').show();
- this.fields.driverClassName.$el.hide();
- this.fields.url.$el.hide();
- this.fields.fsDefaultName.$el.hide();
- this.fields.authorization.$el.hide();
- this.fields.auth_to_local.$el.hide();
- this.fields.datanode.$el.hide();
- this.fields.namenode.$el.hide();
- this.fields.secNamenode.$el.hide();
- this.fields.hadoopRpcProtection.$el.hide();
- this.fields.rpcEngine.$el.hide();
- this.fields.rpcProtection.$el.hide();
- this.fields.commonnameforcertificate.$el.hide();
- break;
- case XAEnums.AssetType.ASSET_KNOX.value :
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- this.$('.knox').show();
- break;
- case XAEnums.AssetType.ASSET_STORM.value :
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- this.$('.storm').show();
- break;
-
- }
- /* if(val == XAEnums.AssetType.ASSET_HDFS.value){
- this.fields.fsDefaultName.$el.find('.control-label').html(this.model.propertiesNameMap.fsDefaultName+'*');
- this.fields.fsDefaultName.editor.validators.push('required');
- this.$('.hdfs').show();
- }else if(val == XAEnums.AssetType.ASSET_HIVE.value){
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- this.$('.hive').show();
- }else{
- // this.$('.hive').parents('fieldset').hide();
- this.fields.fsDefaultName.$el.find('.control-label').html(this.model.propertiesNameMap.fsDefaultName);
- this.fields.fsDefaultName.$el.removeClass('error');
- this.fields.fsDefaultName.$el.find('.help-inline').html('');
-// this.fields.fsDefaultName.editor.$el.val('');
- this.fields.fsDefaultName.editor.validators = this.removeElementFromArr(this.fields.fsDefaultName.editor.validators , 'required');
- //Set default value to zookeeperZnodeParent
- if(this.model.isNew())
- this.fields.zookeeperZnodeParent.editor.$el.val('/hbase');
- this.$('.hdfs').show();
- this.$('.hive').show();//parents('fieldset').show();
- this.fields.driverClassName.$el.hide();
- this.fields.url.$el.hide();
- this.$('.hbase').show();
- }*/
- this.fields.userName.setValue('');
- this.fields.passwordKeytabfile.setValue('');
- if(! this.model.isNew()){
- if(val == this.model.get('assetType') && this.model.get('config')){
- var configObj=$.parseJSON(this.model.get('config'));
- this.fields.userName.setValue(configObj[this.model.propertiesNameMap.userName]);
- this.fields.passwordKeytabfile.setValue(configObj[this.model.propertiesNameMap.passwordKeytabfile]);
- }
- }
-
- },
- removeElementFromArr : function(arr ,elem){
- var index = $.inArray(elem,arr);
- if(index >= 0) arr.splice(index,1);
- return arr;
- }
- });
-
- return AssetForm;
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/asset/AssetTableLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/asset/AssetTableLayout.js b/security-admin/src/main/webapp/scripts/views/asset/AssetTableLayout.js
deleted file mode 100644
index 284135b..0000000
--- a/security-admin/src/main/webapp/scripts/views/asset/AssetTableLayout.js
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-define(function(require){
- 'use strict';
-
- var Backbone = require('backbone');
- var Communicator = require('communicator');
- var App = require('App');
- var XALinks = require('modules/XALinks');
- var XAEnums = require('utils/XAEnums');
- var XAGlobals = require('utils/XAGlobals');
- var localization = require('utils/XALangSupport');
-
- var XABackgrid = require('views/common/XABackgrid');
- var XATableLayout = require('views/common/XATableLayout');
-
- var AssettablelayoutTmpl = require('hbs!tmpl/asset/AssetTableLayout_tmpl');
-
- require('backgrid-filter');
- require('backgrid-paginator');
- require('bootbox');
-
- var AssetTableLayout = Backbone.Marionette.Layout.extend(
- /** @lends AssetTableLayout */
- {
- _viewName : 'AssetTableLayout',
-
- template: AssettablelayoutTmpl,
-
- /*
- breadCrumbs :function(){
- if(this.model.isNew())
- return [XALinks.get(''), XALinks.get('')];
- else
- return [XALinks.get(''), XALinks.get('')];
- },
- */
-
- /** Layout sub regions */
- regions: {
- 'rTableList' : 'div[data-id="r_assettable"]'
- },
-
- /** ui selector cache */
- ui: {},
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- return events;
- },
-
- /**
- * intialize a new AssetTableLayout Layout
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a AssetTableLayout Layout");
-
- _.extend(this, _.pick(options, ''));
-
- this.collection.extraSearchParams = {
- //resourceType : XAEnums.AssetType.ASSET_HDFS.value
- };
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
- },
-
- /** on render callback */
- onRender: function() {
- this.initializePlugins();
- this.renderTable();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- renderTable : function(){
- var that = this;
- var TableRow = Backgrid.Row.extend({
- events: {
- 'click' : 'onClick'
- },
- onClick: function (e) {
- if($(e.toElement).is('.icon-edit'))
- return;
- this.$el.parent('tbody').find('tr').removeClass('tr-active');
- this.$el.toggleClass('tr-active');
- that.rFolderInfo.show(new vFolderInfo({
- model : this.model
- }));
-
- }
- });
-
- this.rTableList.show(new XATableLayout({
- columns: this.getColumns(),
- collection: this.collection,
- includeFilter : false,
- gridOpts : {
- row: TableRow,
- header : XABackgrid,
- emptyText : localization.tt('plcHldr.noAssets')
- },
- filterOpts : {
- name: ['name'],
- placeholder: localization.tt('plcHldr.searchByResourcePath'),
- wait: 150
- }
- }));
- },
-
- getColumns : function(){
- var that = this;
- var cols = {
- name : {
- label : localization.tt("lbl.resourcePath"),
- placeholder : 'Resource Path',
- editable:false
- //cell :"uri,"
- /*href: function(model){
- return '#!/policy/' + model.id;
- }*/
- }
-
- };
- return this.collection.constructor.getTableCols(cols, this.collection);
- },
-
-
- /** on close */
- onClose: function(){
- }
-
- });
-
- return AssetTableLayout;
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyCreate.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyCreate.js b/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyCreate.js
deleted file mode 100644
index 0bcb141..0000000
--- a/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyCreate.js
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-define(function(require){
- 'use strict';
-
- var App = require('App');
- var Backbone = require('backbone');
- var XALinks = require('modules/XALinks');
-
- var XAUtil = require('utils/XAUtils');
- var XAEnums = require('utils/XAEnums');
- var localization = require('utils/XALangSupport');
- var VXResourceList = require('collections/VXResourceList');
-
- var HbasePolicyForm = require('views/hbase/HbasePolicyForm');
- var HbasepolicycreateTmpl = require('hbs!tmpl/hbase/HbasePolicyCreate_tmpl');
-
- var HbasePolicyCreate = Backbone.Marionette.Layout.extend(
- /** @lends HbasePolicyCreate */
- {
- _viewName : 'HbasePolicyCreate',
-
- template: HbasepolicycreateTmpl,
- templateHelpers : function(){
- return {
- editPolicy : this.editPolicy
- };
- },
- breadCrumbs :function(){
- if(this.model.isNew())
- return [XALinks.get('RepositoryManager'),XALinks.get('ManageHbasePolicies',{model : this.assetModel}),XALinks.get('PolicyCreate')];
- else
- return [XALinks.get('RepositoryManager'),XALinks.get('ManageHbasePolicies',{model : this.assetModel}),XALinks.get('PolicyEdit')];
- } ,
- /** Layout sub regions */
- regions: {
- 'rForm' :'div[data-id="r_form"]'
- },
-
- /** ui selector cache */
- ui: {
- 'btnSave' : '[data-id="save"]',
- 'btnCancel' : '[data-id="cancel"]',
- 'btnDelete' : '[data-id="delete"]',
- 'policyDisabledAlert' : '[data-id="policyDisabledAlert"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.btnSave] = 'onSave';
- events['click ' + this.ui.btnCancel] = 'onCancel';
- events['click ' + this.ui.btnDelete] = 'onDelete';
- return events;
- },
-
- /**
- * intialize a new HbasePolicyCreate Layout
- * @constructs
- */
- initialize: function(options) {
- var that = this;
- console.log("initialized a HbasePolicyCreate Layout");
-
- _.extend(this, _.pick(options,'assetModel'));
- this.bindEvents();
-
- that.form = new HbasePolicyForm({
- template : require('hbs!tmpl/hbase/HbasePolicyForm_tmpl'),
- model : this.model,
- assetModel : this.assetModel
- });
-
- this.editPolicy = this.model.has('id') ? true : false;
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
- },
-
- /** on render callback */
- onRender: function() {
- XAUtil.showAlerForDisabledPolicy(this);
- this.rForm.show(this.form);
- this.rForm.$el.dirtyFields();
- XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavHbasePolicyForm'), this.rForm.$el);
- this.initializePlugins();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
- popupCallBack : function(msg,validateObj){
- var that = this;
- XAUtil.alertPopup({
- msg :msg,
- callback : function(){
- // if(validateObj.auditLoggin)
- // that.savePolicy();
- }
- });
- },
- onSave : function(){
- var that =this, valid = false;
- var errors = this.form.commit({validate : false});
- if(! _.isEmpty(errors)){
- return;
- }
- var validateObj = this.form.formValidation();
- valid = (validateObj.groupSet && validateObj.permSet) || (validateObj.userSet && validateObj.userPerm);
- if(!valid){
-
- if(validateObj.groupSet && (!validateObj.permSet)){
- this.popupCallBack(localization.tt('msg.addGroupPermission'),validateObj);
- }else if((!validateObj.groupSet) && (validateObj.permSet)) {
- this.popupCallBack(localization.tt('msg.addGroup'),validateObj);
-
- }else if(validateObj.userSet && (!validateObj.userPerm)){
- this.popupCallBack(localization.tt('msg.addUserPermission'),validateObj);
- }else if((!validateObj.userSet) && (validateObj.userPerm)) {
- this.popupCallBack(localization.tt('msg.addUser'),validateObj);
-
- }else if((!validateObj.auditLoggin) && (!validateObj.groupPermSet)){
- XAUtil.alertPopup({
- msg :localization.tt('msg.yourAuditLogginIsOff'),
- callback : function(){
- /*if(!that.model.isNew()){
- that.model.destroy({success: function(model, response) {
- XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
- App.appRouter.navigate("#!/hbase/"+that.assetModel.id+"/policies",{trigger: true});
- }});
- }else{
- XAUtil.notifyError('Error', localization.tt('msg.policyNotAddedMsg'));
- App.appRouter.navigate("#!/hbase/"+that.assetModel.id+"/policies",{trigger: true});
- }*/
- }
- });
- }else{
- this.savePolicy();
- }
- }else{
- if(validateObj.groupSet && (!validateObj.permSet)){
- this.popupCallBack(localization.tt('msg.addGroupPermission'),validateObj);
- }else if((!validateObj.groupSet) && (validateObj.permSet)) {
- this.popupCallBack(localization.tt('msg.addGroup'),validateObj);
-
- }else if(validateObj.userSet && (!validateObj.userPerm)){
- this.popupCallBack(localization.tt('msg.addUserPermission'),validateObj);
- }else if((!validateObj.userSet) && (validateObj.userPerm)) {
- this.popupCallBack(localization.tt('msg.addUser'),validateObj);
- }else
- this.savePolicy();
- }
-
- },
- savePolicy : function(){
- var that = this;
- this.form.afterCommit();
- this.saveMethod();
- },
- saveMethod : function(){
- var that = this;
- XAUtil.blockUI();
- this.model.save({},{
- wait: true,
- success: function () {
- XAUtil.blockUI('unblock');
- var msg = that.editPolicy ? 'Policy updated successfully' :'Policy created successfully';
- XAUtil.notifySuccess('Success', msg);
- XAUtil.allowNavigation();
- if(that.editPolicy){
- App.appRouter.navigate("#!/hbase/"+that.assetModel.id+"/policies",{trigger: true});
- return;
- }
-
- App.appRouter.navigate("#!/hbase/"+that.assetModel.id+"/policies",{trigger: false});
-
- var view = require('views/hbase/HbaseTableLayout');
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : that.assetModel.id
- }
- });
-
- resourceListForAsset.fetch({
- cache : false,
- data : {
- // 'resourceType':XAEnums.AssetType.ASSET_HIVE.value,
- 'assetId' :that.assetModel.id
- }
- }).done(function(){
- var newColl = resourceListForAsset;
- resourceListForAsset.getLastPage({
- cache : false,
- data : {
- // 'resourceType':XAEnums.AssetType.ASSET_HIVE.value,
- 'assetId' :that.assetModel.id
- }
- }).done(function(){
- var model = newColl.get(that.model.id);
- if(model){
- model.trigger("model1:highlightBackgridRow");
- }
- });
- App.rContent.show(new view({
- collection : resourceListForAsset,
- assetModel : that.assetModel
- }));
-
- });
-
- console.log("success");
- },
- error: function (model, response, options) {
- XAUtil.blockUI('unblock');
- if ( response && response.responseJSON && response.responseJSON.msgDesc){
- if( response.responseJSON.messageList && response.responseJSON.messageList.length > 0 && !_.isUndefined(response.responseJSON.messageList[0].fieldName)){
- if(response.responseJSON.messageList[0].fieldName == "parentPermission"){
- XAUtil.confirmPopup({
- msg :response.responseJSON.msgDesc,
- callback : function(){
- that.model.set('checkParentPermission',XAEnums.BooleanValue.BOOL_FALSE.value);
- that.saveMethod();
- }
- });
- }else
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }else{
- // that.form.fields.name.setError(response.responseJSON.msgDesc);
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }
- }else
- XAUtil.notifyError('Error', 'Error creating Policy!');
- console.log("error");
- }
- });
- },
-
- onDelete :function(){
- var that = this;
- XAUtil.confirmPopup({
- //msg :localize.tt('msg.confirmDelete'),
- msg :'Are you sure want to delete ?',
- callback : function(){
- XAUtil.blockUI();
- that.model.destroy({
- success: function(model, response) {
- XAUtil.blockUI('unblock');
- XAUtil.allowNavigation();
- XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
- App.appRouter.navigate("#!/hbase/"+that.assetModel.id+"/policies",{trigger: true});
- },
- error: function (model, response, options) {
- XAUtil.blockUI('unblock');
- if ( response && response.responseJSON && response.responseJSON.msgDesc){
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }else
- XAUtil.notifyError('Error', 'Error deleting Policy!');
- console.log("error");
- }
- });
-
- }
- });
- },
- onCancel : function(){
- XAUtil.allowNavigation();
- App.appRouter.navigate("#!/hbase/"+this.assetModel.id+"/policies",{trigger: true});
-
- },
-
- /** on close */
- onClose: function(){
- XAUtil.allowNavigation();
- }
-
- });
-
- return HbasePolicyCreate;
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyForm.js b/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyForm.js
deleted file mode 100644
index 4a8ecc1..0000000
--- a/security-admin/src/main/webapp/scripts/views/hbase/HbasePolicyForm.js
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-define(function(require){
- 'use strict';
-
- var Backbone = require('backbone');
-
- var XAEnums = require('utils/XAEnums');
- var localization = require('utils/XALangSupport');
- var XAUtil = require('utils/XAUtils');
-
- var VXPermMapList = require('collections/VXPermMapList');
- var VXGroupList = require('collections/VXGroupList');
- var VXAuditMapList = require('collections/VXAuditMapList');
- var VXAuditMap = require('models/VXAuditMap');
- var VXPermMap = require('models/VXPermMap');
- var VXUserList = require('collections/VXUserList');
- var FormInputItemList = require('views/common/FormInputItemList');
- var UserPermissionList = require('views/common/UserPermissionList');
-
-
-
- require('Backbone.BootstrapModal');
- require('backbone-forms.list');
- require('backbone-forms.templates');
- require('backbone-forms');
-
- var HbasePolicyForm = Backbone.Form.extend(
- /** @lends PolicyForm */
- {
- _viewName : 'PolicyForm',
-
- type : {
- //DATABASE : 1,
- TABLE : 2,
- COLUMN : 3,
- COLUMN_FAMILIES : 4
- },
-
- /**
- * intialize a new PolicyForm Form View
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a PolicyForm Form View");
- Backbone.Form.prototype.initialize.call(this, options);
-
- _.extend(this, _.pick(options, 'assetModel'));
- this.initializeCollection();
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- this.on('_vAuditListToggle:change', function(form, fieldEditor){
- this.evAuditChange(form, fieldEditor);
- });
- this.on('resourceStatus:change', function(form, fieldEditor){
- this.evResourceStatusChange(form, fieldEditor);
- });
- /*this.on('isEncrypt:change', function(form, fieldEditor){
- this.evEncryptChange(form, fieldEditor);
- });*/
- },
- initializeCollection: function(){
- this.permMapList = this.model.isNew() ? new VXPermMapList() : this.model.get('permMapList');
- this.auditList = this.model.isNew() ? new VXAuditMapList() : this.model.get('auditList');
-
- /*If the model passed to the fn is new return an empty collection
- * otherwise return a collection that has models like
- * {
- * groupId : 5,
- * permissionList : [4,3]
- * }
- * The formInputList will be passed to the forminputitemlist view.
- */
-
- this.formInputList = XAUtil.makeCollForGroupPermission(this.model);
- this.userPermInputList = XAUtil.makeCollForUserPermission(this.model);
-
- },
- /** fields for the form
- */
- // fields: ['name', 'description', '_vAuditListToggle', 'isEncrypt','isRecursive'],
- schema :function(){
- var that = this;
- //var plugginAttr = this.getPlugginAttr(true);
- return {
- policyName : {
- type : 'Text',
- title : localization.tt("lbl.policyName"),
-// validators : [{'type' :'required'}]
- editorAttrs :{ maxlength: 255}
- },
- tables : {
- type : 'Select2Remote',
- title : localization.tt("lbl.selectTableName")+' *',
- editorAttrs :{'data-placeholder': 'Select Tables'},
- validators : ['required'],//,{type:'regexp',regexp:/^[a-zA-Z*?][a-zA-Z0-9_'&-/\$]*[A-Za-z0-9]*$/i,message :localization.tt('validationMessages.enterValidName')}],
- pluginAttr : this.getPlugginAttr(true,this.type.TABLE),
- options : function(callback, editor){
- callback();
- }
- },
- columnFamilies : {
- type : 'Select2Remote',
- title : localization.tt("lbl.selectColumnFamilies"),
- editorAttrs :{'data-placeholder': 'Select Column Families'},
- // editorAttrs :{'disabled' :'disabled','data-placeholder': 'Select Column Families'},
- //validators : [{type:'regexp',regexp:/^[a-zA-Z*?][a-zA-Z0-9_'&-/\$]*[A-Za-z0-9]*$/i,message :localization.tt('validationMessages.enterValidName')}],
- pluginAttr : this.getPlugginAttr(true,this.type.COLUMN_FAMILIES),
- options : function(callback, editor){
- callback();
- }
-
-
- },
- columns : {
- type : 'Select2Remote',
-// type : 'Text',
- title : localization.tt("lbl.enterColumnName"),
- // validators : [{type:'regexp',regexp:/^[a-zA-Z*?][a-zA-Z0-9_'&-/\$]*[A-Za-z0-9]*$/i,message :localization.tt('validationMessages.enterValidName')}],
- editorAttrs :{ 'placeholder': 'Enter Column Name'},
- pluginAttr : this.getPlugginAttr(false,this.type.COLUMN),
- },
- _vAuditListToggle : {
- type : 'Switch',
- title : localization.tt("lbl.auditLogging"),
- listType : 'VNameValue',
- switchOn : true
- },
- /*isEncrypt : {
- type : 'Switch',
- title : localization.tt("lbl.encrypted"),
- switchOn : false
- // fieldAttrs : {style : 'display:none;'}
- },*/
- permMapList : {
- getValue : function(){
- console.log(this);
- }
- },
- resourceStatus : {
- type : 'Switch',
- title : localization.tt("lbl.policyStatus"),
- onText : 'enabled',
- offText : 'disabled',
- width : '85',
- switchOn : true
- },
- description : {
- type : 'TextArea',
- title : localization.tt("lbl.description"),
- // validators : [/^[A-Za-z ,.'-]+$/i],
- template :_.template('<div class="altField" data-editor></div>')
- },
- };
- },
-
- evAuditChange : function(form, fieldEditor){
- XAUtil.checkDirtyFieldForToggle(fieldEditor);
- if(fieldEditor.getValue() == 1){
- this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
- 'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
- 'resourceId' :this.model.get('id')
-
- })));
- } else {
- var validation = this.formValidation();
- if(validation.groupPermSet || validation.isUsers)
- this.model.unset('auditList');
- else{
- XAUtil.alertPopup({
- msg :localization.tt("msg.policyNotHavingPerm"),
- callback : function(){
- fieldEditor.setValue('ON');
- }
- });
- }
- }
- console.log(fieldEditor);
- },
- evResourceStatusChange : function(form, fieldEditor){
- XAUtil.checkDirtyFieldForToggle(fieldEditor);
- },
- evEncryptChange : function(form, fieldEditor){
- XAUtil.checkDirtyFieldForToggle(fieldEditor);
- },
- /** on render callback */
- render: function(options) {
- var that = this;
- Backbone.Form.prototype.render.call(this, options);
-
- this.initializePlugins();
- this.renderSelectTagsFields();
- this.renderCustomFields();
- if(!this.model.isNew()){
- this.setUpSwitches();
- if(!_.isEmpty(this.fields.tables.editor.$el.val()))
- that.fields.columnFamilies.editor.$el.prop('disabled',false);
- if(!_.isEmpty(this.fields.columnFamilies.editor.$el.val()))
- that.fields.columns.editor.$el.prop('disabled',false);
- }
- if(this.model.isNew() && this.fields._vAuditListToggle.editor.getValue() == 1){
- this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
- 'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
- 'resourceId' :this.model.get('id')
-
- })));
- }
- },
- renderSelectTagsFields :function(){
- var that = this;
-
- this.fields.tables.editor.$el.on('change',function(e){
- console.log('change on table Name');
- that.checkMultiselectDirtyField(e, that.type.TABLE);
- that.fields.tables.setValue(that.fields.tables.editor.$el.select2('data').map(function(obj){return obj.text}).toString());
-
- });
- this.fields.columnFamilies.editor.$el.on('change',function(e){
- console.log('change on column Families Name');
- that.checkMultiselectDirtyField(e, that.type.COLUMN_FAMILIES);
- that.fields.columnFamilies.setValue(that.fields.columnFamilies.editor.$el.select2('data').map(function(obj){return obj.text}).toString());
- });
-
- },
- getDataParams : function(type, term){
- var dataParams = {
- // dataSourceName : 'hadoopdev',
- dataSourceName : this.assetModel.get('name')
- // databaseName: term,
- };
- if (type == this.type.TABLE && this.fields) {
- //dataParams.databaseName = this.fields.databases.editor.$el.select2('data')[0].text;
- dataParams.tableName = term;
- }
- if (type == this.type.COLUMN_FAMILIES && !_.isEmpty(this.fields.tables.getValue())) {
- dataParams.tableName = this.fields.tables.editor.$el.select2('data')[0].text;
- dataParams.columnFamilies = _.isEmpty(term) ? "*" : term;
- }
- return dataParams;
- },
- getPlugginAttr :function(autocomplete, searchType){
- var that =this;
- var type = searchType;
- if(!autocomplete)
- return{tags : true,width :'220px',multiple: true,minimumInputLength: 1};
- else {
-
-
- return {
- closeOnSelect : true,
- //placeholder : 'Select User',
- tags:true,
- multiple: true,
- minimumInputLength: 1,
- width :'220px',
- tokenSeparators: [",", " "],
- initSelection : function (element, callback) {
- var data = [];
- $(element.val().split(",")).each(function () {
- data.push({id: this, text: this});
- });
- callback(data);
- },
- createSearchChoice: function(term, data) {
- if ($(data).filter(function() {
- return this.text.localeCompare(term) === 0;
- }).length === 0) {
- return {
- id : term,
- text: term
- };
- }
- },
- /*query: function (query) {
- var url = "service/assets/hive/resources";
- var data = _.extend(that.getDataParams(type, query.term));
- //var results = [ {id: query.term, path: query.term}];
-
- $.get(url, data, function (resp) {
- var serverRes = [];
- if(resp.resultSize){
- serverRes = resp.vXStrings.map(function(m, i){ return {id : m.value, path: m.value}; });
- }
- query.callback({results: serverRes});
- }, 'json');
-
- //query.callback({results: results});
- },*/
-
- ajax: {
- url: "service/assets/hbase/resources",
- dataType: 'json',
- params : {
- timeout: 3000
- },
- cache: false,
- data: function (term, page) {
- return _.extend(that.getDataParams(type, term));
-
- },
- results: function (data, page) {
- var results = [];
- if(!_.isUndefined(data)){
- if(data.resultSize != "0"){
- results = data.vXStrings.map(function(m, i){ return {id : m.value, text: m.value}; });
- }
- }
- return {
- results : results
- };
- },
- transport: function (options) {
- $.ajax(options).error(function() {
- console.log("ajax failed");
- this.success({
- resultSize : 0
- });
- });
- /*$.ajax.error(function(data) {
- console.log("ajax failed");
- return {
- results : []
- };
- });*/
-
- }
-
- },
- formatResult : function(result){
- return result.text;
- },
- formatSelection : function(result){
- return result.text;
- },
- formatNoMatches : function(term){
- switch (type){
- case that.type.COLUMN_FAMILIS :return localization.tt("msg.enterAlteastOneCharactere");
- case that.type.TABLE :return localization.tt("msg.enterAlteastOneCharactere");
- case that.type.COLUMN :return localization.tt("msg.enterAlteastOneCharactere");
- default : return "No Matches found";
- }
- }
- };
- }
- },
- formValidation : function(){
- var groupSet = false,permSet = false,auditStatus= false,encryptStatus= false,groupPermSet = false,
- userSet=false,userPerm = false,isUsers =false;
- console.log('validation called..');
- var breakFlag =false;
- this.formInputList.each(function(m){
- if(m.has('groupId') || m.has('_vPermList')){
- if(! breakFlag){
- groupSet = m.has('groupId') ? true : false ;
- if(!m.has('_vPermList')){
- permSet = false;
- }else
- permSet = true;
- if(groupSet && permSet)
- groupPermSet = true;
- else
- breakFlag=true;
- }
- }
- });
- breakFlag = false;
- this.userPermInputList.each(function(m){
- if(!_.isUndefined(m.attributes)){
- if(! breakFlag){
- userSet = m.has('userId') || m.has('userName') ? true : false ;//|| userSet;
- if(!m.has('_vPermList')){
- userPerm = false;
- }else
- userPerm = true;
- if(userSet && userPerm)
- isUsers = true;
- else
- breakFlag=true;
- }
- }
- });
- auditStatus = this.fields._vAuditListToggle.editor.getValue();
- //encryptStatus = this.fields.isEncrypt.editor.getValue();
- var auditLoggin = (auditStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
- //var encrypted = (encryptStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
- /*if((groupSet && permSet) || auditLoggin || encrypted )
- return true;*/
-
- return {groupPermSet: groupPermSet , groupSet : groupSet,permSet : permSet,auditLoggin :auditLoggin,/*encrypted : encrypted,*/
- userSet : userSet,userPerm:userPerm,isUsers:isUsers};
- },
- setUpSwitches :function(){
- var that = this;
- var encryptStatus = false,auditStatus = false,recursiveStatus = false;
- auditStatus = this.model.has('auditList') ? true : false;
- this.fields._vAuditListToggle.editor.setValue(auditStatus);
-
- /*_.each(_.toArray(XAEnums.BooleanValue),function(m){
- if(parseInt(that.model.get('isEncrypt')) == m.value)
- encryptStatus = (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
- });
- this.fields.isEncrypt.editor.setValue(encryptStatus); */
- if(parseInt(this.model.get('resourceStatus')) != XAEnums.BooleanValue.BOOL_TRUE.value)
- this.fields.resourceStatus.editor.setValue(false);
- },
- /** all custom field rendering */
- renderCustomFields: function(){
- var that = this;
- this.groupList = new VXGroupList();
- var params = {sortBy : 'name', cache :false};
- this.groupList.setPageSize(100,{fetch:false});
- this.groupList.fetch({
- cache :true,
- data : params
- }).done(function(){
- that.$('[data-customfields="groupPerms"]').html(new FormInputItemList({
- collection : that.formInputList,
- groupList : that.groupList,
- model : that.model,
- policyType : XAEnums.AssetType.ASSET_HBASE.value
-
- }).render().el);
- });
-
- this.userList = new VXUserList();
- var params = {sortBy : 'name', cache :false};
- this.userList.setPageSize(100,{fetch:false});
- this.userList.fetch({
- cache :true,
- data : params
- }).done(function(){
- that.$('[data-customfields="userPerms"]').html(new UserPermissionList({
- collection : that.userPermInputList,
- model : that.model,
- userList : that.userList,
- policyType : XAEnums.AssetType.ASSET_HBASE.value
- }).render().el);
- });
- },
- afterCommit : function(){
- var that = this;
- //TODO FIXME remove the hard coding
- //this.model.set('assetId', XAGlobals.hardcoded.HiveAssetId);
- this.model.set('assetId', this.assetModel.id);
- var permMapList = new VXPermMapList();
- this.formInputList.each(function(m){
- if(!_.isUndefined(m.get('groupId'))){
- var uniqueID = _.uniqueId(new Date()+':');
- _.each(m.get('groupId').split(","),function(groupId){
- _.each(m.get('_vPermList'), function(perm){
- var params = {
- //groupId: m.get('groupId'),
- groupId: groupId,
- permFor : XAEnums.XAPermForType.XA_PERM_FOR_GROUP.value,
- permType : perm.permType,
- permGroup : uniqueID
- };
- if(parseInt(groupId) == perm.groupId)
- params = $.extend(params, {id : perm.id});
- //TODO FIXME remove the hardcoding
- permMapList.add(new VXPermMap(params));
- }, this);
- });
- }
- }, this);
-
- this.userPermInputList.each(function(m){
- if(!_.isUndefined(m.get('userId'))){
- var uniqueID = _.uniqueId(new Date()+':');
- _.each(m.get('userId').split(","),function(userId){
- _.each(m.get('_vPermList'), function(perm){
- var params = {
- //groupId: m.get('groupId'),
- userId: userId,
- permFor : XAEnums.XAPermForType.XA_PERM_FOR_USER.value,
- permType : perm.permType,
- permGroup : uniqueID
- };
- if(parseInt(userId) == perm.userId)
- params = $.extend(params, {id : perm.id});
- //TODO FIXME remove the hardcoding
- permMapList.add(new VXPermMap(params));
- }, this);
- });
- }
- }, this);
-
- this.model.set('permMapList', permMapList);
- var columns = !_.isEmpty(this.model.get('columns'));
- var columnFamilies = !_.isEmpty(this.model.get('columnFamilies'));
-
- if(columns)
- this.model.set('resourceType',XAEnums.ResourceType.RESOURCE_COLUMN.value);
- else if(columnFamilies)
- this.model.set('resourceType',XAEnums.ResourceType.RESOURCE_COL_FAM.value);
- else
- this.model.set('resourceType',XAEnums.ResourceType.RESOURCE_TABLE.value);
-
- this.setResourceTypeAsPerWildCard();
- //TODO Already handled by server side so we need to remove following line
- if(_.isEmpty(this.model.get('columnFamilies'))) {
- this.model.unset('columnFamilies');
- this.model.unset('columns');
- }
-
- if(_.isEmpty(this.model.get('columns'))) this.model.unset('columns');
- if(this.model.get('resourceStatus') != XAEnums.BooleanValue.BOOL_TRUE.value){
- this.model.set('resourceStatus', XAEnums.ActiveStatus.STATUS_DISABLED.value);
- }
-
-
- },
- checkMultiselectDirtyField : function(e, type){
- var elem = $(e.currentTarget),columnName='',newNameList = [], nameList = [];
- switch(type){
- case 2 :columnName = 'tables';break;
- case 4 :columnName = 'columnFamilies';break;
- }
- if(!_.isUndefined(this.model.get(columnName)) && !_.isEqual(this.model.get(columnName),""))
- nameList = this.model.get(columnName).split(',');
- if(!_.isEqual(e.currentTarget.value, ""))
- newNameList = e.currentTarget.value.split(',');
- XAUtil.checkDirtyField(nameList, newNameList, elem);
- },
- setResourceTypeAsPerWildCard :function(){
- var type = this.model.get('resourceType');
- //Set resourceType as per WildCard operator '*'
- switch(this.model.get('resourceType')){
- case XAEnums.ResourceType.RESOURCE_COLUMN.value :
- if(_.isEqual(this.model.get('columns'),"*")){
- if(_.isEqual(this.model.get('columnFamilies'),"*"))
- type = XAEnums.ResourceType.RESOURCE_TABLE.value;
- else
- type = XAEnums.ResourceType.RESOURCE_COL_FAM.value;
-
- }
- break;
- case XAEnums.ResourceType.RESOURCE_COL_FAM.value :
- if(_.isEqual(this.model.get('columnFamilies'),"*")){
- type = XAEnums.ResourceType.RESOURCE_TABLE.value;
- }
- break;
- }
- this.model.set('resourceType',type);
- },
- /* all post render plugin initialization */
- initializePlugins: function(){
- }
-
- });
-
- return HbasePolicyForm;
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/hbase/HbaseTableLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/hbase/HbaseTableLayout.js b/security-admin/src/main/webapp/scripts/views/hbase/HbaseTableLayout.js
deleted file mode 100644
index 4db270a..0000000
--- a/security-admin/src/main/webapp/scripts/views/hbase/HbaseTableLayout.js
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-define(function(require){
- 'use strict';
-
- var Backbone = require('backbone');
-
- var XAEnums = require('utils/XAEnums');
- var XALinks = require('modules/XALinks');
- var XAGlobals = require('utils/XAGlobals');
- var SessionMgr = require('mgrs/SessionMgr');
- var XAUtil = require('utils/XAUtils');
-
- var VXResource = require('models/VXResource');
-
- var XABackgrid = require('views/common/XABackgrid');
- var XATableLayout = require('views/common/XATableLayout');
- var localization = require('utils/XALangSupport');
- var vFolderInfo = require('views/folders/FolderInfo');
-
- var HbasetablelayoutTmpl = require('hbs!tmpl/hbase/HbaseTableLayout_tmpl');
-
- var HbaseTableLayout = Backbone.Marionette.Layout.extend(
- /** @lends HbaseTableLayout */
- {
- _viewName : 'HbaseTableLayout',
-
- template: HbasetablelayoutTmpl,
- templateHelpers :function(){
- return {
- isSysAdmin :this.isSysAdmin,
- assetId : this.assetModel.id,
- assetModel : this.assetModel,
- version : XAGlobals.version
- };
- },
- breadCrumbs : function(){
- if(this.assetModel)
- return [XALinks.get('RepositoryManager'),XALinks.get('ManageHbasePolicies',{model : this.assetModel})];
- else
- return [];
- },
-
- /** Layout sub regions */
- regions: {
- 'rTableList' :'div[data-id="r_tableList"]',
- 'rPolicyDetail' : '#policyDetail'
- },
-
- /** ui selector cache */
- ui: {
- 'btnExport' : 'a[data-js="export"]',
- 'btnDeletePolicy' : '[data-name="deletePolicy"]',
- 'btnShowMore' : '[data-id="showMore"]',
- 'btnShowLess' : '[data-id="showLess"]',
- 'visualSearch' : '.visual_search'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- events['click ' + this.ui.btnExport] = 'onExport';
- events['click ' + this.ui.btnDeletePolicy] = 'onDelete';
- events['click ' + this.ui.btnShowMore] = 'onShowMore';
- events['click ' + this.ui.btnShowLess] = 'onShowLess';
- return events;
- },
-
- /**
- * intialize a new HbaseTableLayout Layout
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a HbaseTableLayout Layout");
-
- _.extend(this, _.pick(options, 'assetModel'));
- this.collection.extraSearchParams = {
- //resourceType : XAEnums.AssetType.ASSET_HBASE.value
- assetId : this.assetModel.id
- };
- this.bindEvents();
- this.isSysAdmin = SessionMgr.isSystemAdmin();
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
- },
-
- /** on render callback */
- onRender: function() {
- var that = this;
- this.initializePlugins();
- this.addVisualSearch();
- this.renderTable();
- XAUtil.highlightDisabledPolicy(this);
- },
- renderTable : function(){
- var that = this;
- /*var tableRow = Backgrid.Row.extend({
- events: {
- 'click' : 'onClick'
- },
- initialize : function(){
- var that = this;
- var args = Array.prototype.slice.apply(arguments);
- Backgrid.Row.prototype.initialize.apply(this, args);
- this.listenTo(this.model, 'model1:highlightBackgridRow', function(){
- that.$el.addClass("alert");
- $("html, body").animate({scrollTop: that.$el.position().top},"linear");
- setTimeout(function () {
- that.$el.removeClass("alert");
- }, 1500);
- }, this);
- },
- onClick: function (e) {
- if($(e.toElement).is('.icon-edit,.icon-trash,a,code'))
- return;
- this.$el.parent('tbody').find('tr').removeClass('tr-active');
- this.$el.toggleClass('tr-active');
- if(that.rPolicyDetail){
- $(that.rPolicyDetail.el).hide();
- $(that.rPolicyDetail.el).html(new vFolderInfo({
- model : this.model
- }).render().$el).slideDown();
-
- }
- }
- });*/
- this.rTableList.show(new XATableLayout({
- columns: this.getColumns(),
- collection: this.collection,
- includeFilter : false,
- gridOpts : {
-// row: tableRow,
- header : XABackgrid,
- emptyText : 'No Policies found!'
- }
- }));
- },
-
- getColumns : function(){
- var that = this;
- var cols = {
- policyName : {
- cell : "uri",
- href: function(model){
- return '#!/hbase/'+model.get('assetId')+'/policy/' + model.id;
- },
- label : localization.tt("lbl.policyName"),
- editable: false,
- sortable : false
- },
- tables : {
- label : localization.tt("lbl.tableName")+'(s)',
- cell :'html',
- editable:false,
- sortable : false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- return _.isUndefined(rawValue) ? '--': '<span title="'+rawValue+'">'+rawValue+'</span>';
- }
- })
- },
- columnFamilies : {
- label : localization.tt("lbl.columnFamilies")+'(s)',
- cell :'html',
- editable:false,
- sortable : false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- return _.isUndefined(rawValue) ? '--': '<span title="'+rawValue+'">'+rawValue+'</span>';
- }
- })
-
- },
- columns : {
- label : localization.tt("lbl.columnName")+'(s)',
- cell :'html',
- editable:false,
- sortable : false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- return _.isUndefined(rawValue) ? '--': '<span title="'+rawValue+'">'+rawValue+'</span>';
- }
- })
-
- },
- permMapList : {
- reName : 'groupName',
- cell : Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
- label : localization.tt("lbl.group"),
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- if(!_.isUndefined(rawValue))
- return XAUtil.showGroups(rawValue);
- return '--';
-
- }
- }),
- editable : false,
- sortable : false
- },
- auditList : {
- label : localization.tt("lbl.auditLogging"),
- cell: "html",
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue, model) {
- return model.has('auditList') ? '<label class="label label-success">ON</label>' : '<label class="label label">OFF</label>';
- }
- }),
- click : false,
- drag : false,
- sortable : false,
- editable : false
- },
- /*isEncrypt:{
- label:localization.tt("lbl.encrypted"),
- cell :"html",
- editable:false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue ,model) {
- return model.get('isEncrypt') == XAEnums.BooleanValue.BOOL_TRUE.value ? '<label class="label label-success">ON</label>' : '<label class="label label">OFF</label>';
- //You can use rawValue to custom your html, you can change this value using the name parameter.
- }
- }),
- click : false,
- drag : false,
- onText : 'ON',
- offText : 'OFF',
- sortable : false
- },*/
- resourceStatus:{
- label:localization.tt('lbl.status'),
- cell :"html",
- editable:false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- var status;
- _.each(_.toArray(XAEnums.BooleanValue),function(m){
- if(parseInt(rawValue) == m.value){
- status = (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
- }
- });
- return status ? '<label class="label label-success">Enabled</label>' : '<label class="label label-important">Disabled</label>';
- }
- }),
- click : false,
- drag : false,
- sortable : false
- },
-
- permissions : {
- cell : "html",
- label : localization.tt("lbl.action"),
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue,model) {
- return '<a href="#!/hbase/'+model.get('assetId')+'/policy/'+model.id+'" class="btn btn-mini" title="Edit"><i class="icon-edit icon-large" /></a>\
- <a href="javascript:void(0);" data-name ="deletePolicy" data-id="'+model.id+'" class="btn btn-mini btn-danger" title="Delete"><i class="icon-trash icon-large" /></a>';
- //You can use rawValue to custom your html, you can change this value using the name parameter.
- }
- }),
- editable:false,
- sortable : false
- }
-
-
- };
- return this.collection.constructor.getTableCols(cols, this.collection);
- },
-
- onExport : function(e){
- $(e.currentTarget).attr('href', 'service/assets/policyList/'+this.assetModel.get('name')+'?epoch=0');
- //$(e.currentTarget).attr('href', 'service/assets/hive?epoch=0');
- },
- onDelete :function(e){
- var that = this;
- var obj = this.collection.get($(e.currentTarget).data('id'));
- var model = new VXResource(obj.attributes);
- model.collection = this.collection;
- XAUtil.confirmPopup({
- msg :localization.tt('msg.areYouSureWantToDelete'),
- //msg :'Are you sure want to delete ?',
- callback : function(){
- XAUtil.blockUI();
- model.destroy({
- success: function(model, response) {
- XAUtil.blockUI('unblock');
- that.collection.remove(model.get('id'));
- /*if(that.rPolicyDetail.currentView)
- that.rPolicyDetail.currentView.close();*/
- $(that.rPolicyDetail.el).hide();
- XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
- if(that.collection.length == 0){
- that.renderTable();
- that.collection.fetch();
- }
- },
- error: function (model, response, options) {
- XAUtil.blockUI('unblock');
- if ( response && response.responseJSON && response.responseJSON.msgDesc){
- XAUtil.notifyError('Error', response.responseJSON.msgDesc);
- }else
- XAUtil.notifyError('Error', 'Error deleting Policy!');
- console.log("error");
- }
- });
- }
- });
- },
- onShowMore : function(e){
- var id = $(e.currentTarget).attr('policy-group-id');
- this.rTableList.$el.find('[policy-group-id="'+id+'"]').show();
- $('[data-id="showLess"][policy-group-id="'+id+'"]').show();
- $('[data-id="showMore"][policy-group-id="'+id+'"]').hide();
- },
- onShowLess : function(e){
- var id = $(e.currentTarget).attr('policy-group-id');
- this.rTableList.$el.find('[policy-group-id="'+id+'"]').slice(4).hide();
- $('[data-id="showLess"][policy-group-id="'+id+'"]').hide();
- $('[data-id="showMore"][policy-group-id="'+id+'"]').show();
- },
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
- addVisualSearch : function(){
- var that = this;
- var searchOpt = ['Table Name(s)','Column Families(s)','Column Name(s)','Group','Policy Name'];//,'Start Date','End Date','Today'];
- var serverAttrName = [{text : "Table Name(s)", label :"tables"},{text : "Column Families(s)", label :"columnFamilies"},
- {text : "Column Name(s)", label :"columns"},{text : "Group", label :"groupName"},
- {text : "Policy Name", label :"policyName"}];
- // {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'},
- // {text : 'Today',label :'today'}];
-
- var pluginAttr = {
- placeholder :localization.tt('h.searchForPolicy'),
- container : this.ui.visualSearch,
- query : '',
- callbacks : {
- valueMatches :function(facet, searchTerm, callback) {
- switch (facet) {
- case 'Result':
- callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthStatus));
- break;
- case 'Login Type':
- callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthType));
- break;
- /* case 'Start Date' :
- setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0);
- break;
- case 'End Date' :
- setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0);
- break;
- case 'Today' :
- var today = Globalize.format(new Date(),"yyyy/mm/dd");
- callback([today]);
- break;*/
- }
-
- }
- }
- };
- XAUtil.addVisualSearch(searchOpt,serverAttrName, this.collection,pluginAttr);
- },
-
- /** on close */
- onClose: function(){
- }
-
- });
-
- return HbaseTableLayout;
-});