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/07 20:32:20 UTC
[21/27] incubator-ranger git commit: Ranger-203 : Add pluggable logic
to UI code
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
new file mode 100644
index 0000000..e86d6ab
--- /dev/null
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
@@ -0,0 +1,285 @@
+/*
+ * 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/Service 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 ServiceForm = require('views/service/ServiceForm');
+ var RangerServiceDef = require('models/RangerServiceDef');
+ var ServiceCreateTmpl = require('hbs!tmpl/service/ServiceCreate_tmpl');
+
+ var ServiceCreate = Backbone.Marionette.Layout.extend(
+ /** @lends ServiceCreate */
+ {
+ _viewName : 'ServiceCreate',
+
+ template: ServiceCreateTmpl,
+
+ templateHelpers : function(){
+ return { editService : this.editService};
+ },
+
+ breadCrumbs :function(){
+ if(this.model.isNew())
+ return [XALinks.get('RepositoryManager'), XALinks.get('ServiceCreate', {model:this.model})];
+ else
+ return [XALinks.get('RepositoryManager'), XALinks.get('ServiceEdit',{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 ServiceCreate Layout
+ * @constructs
+ */
+ initialize: function(options) {
+ console.log("initialized a ServiceCreate Layout");
+ _.extend(this, _.pick(options, 'serviceTypeId'));
+ this.initializeServiceDef();
+ /*if(! this.model.isNew()){
+ this.setupModel();
+ }*/
+ if(!this.model.isNew()){
+ _.each(JSON.parse(this.model.attributes.configs),function(name, value){
+ this.model.set(value,name)
+ },this);
+ }
+ this.form = new ServiceForm({
+ model : this.model,
+ rangerServiceDefModel : this.rangerServiceDefModel,
+ template : require('hbs!tmpl/service/ServiceForm_tmpl')
+ });
+ this.editService = this.model.has('id') ? true : false;
+
+ this.bindEvents();
+ },
+ initializeServiceDef : function(){
+ this.rangerServiceDefModel = new RangerServiceDef({ id : this.serviceTypeId});
+ this.rangerServiceDefModel.fetch({
+ cache : false,
+ async : false
+ });
+
+ },
+ setupModel : function(){
+ },
+
+ /** 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.editService){
+ 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.saveService();
+
+ },
+ saveService : function(){
+ var that = this;
+ this.form.beforeSave();
+ XAUtil.blockUI();
+ this.model.save({},{
+ wait: true,
+ success: function () {
+ XAUtil.blockUI('unblock');
+ XAUtil.allowNavigation();
+ var msg = that.editService ? 'Repository updated successfully' :'Repository created successfully';
+ XAUtil.notifySuccess('Success', msg);
+
+ if(that.editService){
+ 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 Service!');
+ 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 service!');
+ }
+ });
+
+ }
+ });
+ },
+ 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 ServiceCreate;
+});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
new file mode 100644
index 0000000..de07088
--- /dev/null
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
@@ -0,0 +1,189 @@
+ /*
+ * 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 ServiceForm = Backbone.Form.extend(
+ /** @lends ServiceForm */
+ {
+ _viewName : 'ServiceForm',
+
+ /**
+ * intialize a new ServiceForm Form View
+ * @constructs
+ */
+ templateData: function(){
+ var serviceDetail="", serviceConfig="";
+ _.each(this.schema, function(obj, name){
+ if(!_.isUndefined(obj['class']) && obj['class'] == 'serviceConfig')
+ serviceConfig += name+",";
+ else
+ serviceDetail += name+",";
+ });
+ return {
+ serviceDetail : serviceDetail.slice(0,-1),
+ serviceConfig : serviceConfig.slice(0,-1)
+ };
+ },
+ initialize: function(options) {
+ console.log("initialized a ServiceForm Form View");
+ _.extend(this, _.pick(options, 'rangerServiceDefModel'));
+ Backbone.Form.prototype.initialize.call(this, options);
+
+ this.bindEvents();
+ },
+
+ /** all events binding here */
+ bindEvents : function(){
+ },
+
+ /** 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', 'isEnabled', 'type','configs', '_vPassword'],
+
+ schema : function(){
+
+ var attrs = _.pick(_.result(this.rangerServiceDefModel,'schemaBase'), 'name', 'description', 'isEnabled', 'type');
+ var that = this;
+ _.each(this.rangerServiceDefModel.get('configs'),function(v,k){
+ if (v != null) {
+
+ var formObj = {};
+ var enumObj = _.find(that.rangerServiceDefModel.get('enums'), function(e){ return e && e.name == v.type;});
+ if (enumObj !== undefined ){
+ formObj.type = 'Select';
+ formObj.options = _.pluck(_.compact(enumObj.elements),'label');
+ } else {
+ switch(v.type){
+ case 'string' : formObj.type = 'Text'; break;
+ case 'bool' : formObj.type = 'Checkbox'; formObj.options = { y: 'Yes', n: 'No' }; break;
+ case 'int' : formObj.type = 'Number'; break;
+ default : formObj.type = 'Text'; break;
+ }
+
+
+ }
+ formObj.title = v.label || v.name;
+ formObj.validators = [];
+ if (_.has(v,'mandatory') && v.mandatory){
+ formObj.validators.push('required');
+ formObj.title = formObj.title +" *"
+ }
+ formObj['class'] = 'serviceConfig';
+ var name = v.name;
+ attrs[name] = formObj;
+ }
+ });
+ 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.serviceType.editor.$el.prop('disabled',true);
+ else
+ this.fields.activeStatus.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
+ */
+ if(this.model.isNew())
+ this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
+ else{
+ //Set isEnabled Status
+ if(!_.isUndefined(this.model.get('isEnabled')))
+ if(XAEnums.ActiveStatus.STATUS_ENABLED.value == this.model.get('isEnabled'))
+ this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
+ else
+ this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_DISABLED.value);
+ }
+ },
+
+ /** all custom field rendering */
+ renderCustomFields: function(){
+ },
+
+ /** all post render plugin initialization */
+ initializePlugins: function(){
+ },
+
+ formValidation : function(){
+ //return false;
+ return true;
+ },
+
+ beforeSave : function(){
+ var that = this;
+ //Set configs for service
+ var config = {};
+ _.each(this.rangerServiceDefModel.get('configs'),function(obj){
+ if(!_.isNull(obj)){
+ config[obj.name] = that.model.get(obj.name).toString();
+ that.model.unset(obj.name);
+ }
+ });
+ this.model.set('configs',JSON.stringify(config));
+
+ //Set service type
+ _.each(XAEnums.AssetType, function(asset){
+ if(asset.label.toUpperCase() == this.rangerServiceDefModel.get('name').toUpperCase())
+ this.model.set('type',asset.label)
+ },this);
+//
+ //Set isEnabled
+ if(parseInt(this.model.get('isEnabled')) == XAEnums.ActiveStatus.STATUS_ENABLED.value)
+ this.model.set('isEnabled',true);
+ else
+ this.model.set('isEnabled',false);
+
+ //Remove unwanted attributes from model
+ if(!this.model.isNew()){
+ _.each(JSON.parse(this.model.attributes.configs),function(value, name){
+ this.model.unset(name)
+ },this);
+ }
+ },
+
+ removeElementFromArr : function(arr ,elem){
+ var index = $.inArray(elem,arr);
+ if(index >= 0) arr.splice(index,1);
+ return arr;
+ }
+ });
+
+ return ServiceForm;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/views/service/ServiceTableLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/service/ServiceTableLayout.js b/security-admin/src/main/webapp/scripts/views/service/ServiceTableLayout.js
new file mode 100644
index 0000000..284135b
--- /dev/null
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceTableLayout.js
@@ -0,0 +1,164 @@
+/*
+ * 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/9d85cb76/security-admin/src/main/webapp/styles/xa.css
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/styles/xa.css b/security-admin/src/main/webapp/styles/xa.css
index 88d2928..d339b6b 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -1678,3 +1678,18 @@ td.html-cell.renderable:last-child {
font-size: 11px;
font-family: monospace;
}
+/**************/
+.policy-form .field-name{
+ float: left;
+ margin-bottom: 0 !important;
+}
+.policy-form .field-isEnabled{
+float: left;
+margin-bottom: 0 !important;
+}
+.policy-form .field-isEnabled .controls{
+ margin-left:30px;
+}
+.policy-form .field-database,.policy-form .field-table, .policy-form .field-path, .policy-form .field-topology{
+ clear: both;
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html b/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
new file mode 100644
index 0000000..7981486
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
@@ -0,0 +1,67 @@
+{{!--
+ 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.
+--}}
+<h3 class="wrap-header bold">{{tt 'h.repositoryManager'}}</h3>
+
+<div class="wrap non-collapsible policy-manager">
+ <div class="row-fluid">
+ {{#each serviceDefs}}
+ <div class="span4">
+ <div class="position-relative">
+ <table class="table table-bordered table-striped">
+ <!-- table-policy -->
+ <thead>
+ <tr>
+ <th>
+ <span class="policy-title">
+ <img alt="HDFS" src="images/folder-grey.png">
+ {{./this.attributes.name}}
+ {{#if ../isSysAdmin}}
+ <a href="#!/service/{{./this.id}}/create"class="pull-right" title="Add"> <i class="icon-plus"></i></a>
+ {{/if}}
+ </span>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {{{getServices ../services this}}}
+
+ <!-- <tr>
+ <td>
+ <div>
+ <a data-id="{{./this.id}}" href="#!/hdfs/{{./this.id}}/policies">{{./this.attributes.name}}</a>
+ {{#if ../isSysAdmin}}
+ <div class="pull-right">
+ <a data-id="{{./this.id}}" class="btn btn-mini"
+ href="#!/asset/{{./this.id}}" title="Edit"><i
+ class="icon-edit"></i></a> <a data-id="{{./this.id}}"
+ class="deleteRep btn btn-mini btn-danger"
+ href="javascript:void(0);" title="Delete"><i
+ class="icon-trash"></i></a>
+ </div>
+ {{/if}}
+ </div>
+ </td>
+ </tr> -->
+ </tbody>
+ </table>
+ <div data-id="r_tableSpinner" class="loading">
+ </div>
+ </div>
+ </div>
+ {{/each}}
+ </div>
+ </div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/common/UserPermissionItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/common/UserPermissionItem.html b/security-admin/src/main/webapp/templates/common/UserPermissionItem.html
index 481ee61..28baacf 100644
--- a/security-admin/src/main/webapp/templates/common/UserPermissionItem.html
+++ b/security-admin/src/main/webapp/templates/common/UserPermissionItem.html
@@ -39,7 +39,7 @@
{{/if}}
{{#each permissions}}
<td style="cursor:pointer;">
- <input data-id="{{./this.value}}" type="checkbox">
+ <input data-id="{{./this.value}}" data-name="{{./this.label}}" type="checkbox">
</td>
{{/each}}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
index 572212f..d9618bb 100644
--- a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
+++ b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
@@ -481,6 +481,36 @@
}
return new Handlebars.SafeString(html);
});
+ Handlebars.registerHelper('getServices', function(services, serviceDef) {
+ var XAEnums = require('utils/XAEnums');
+ var tr = '';
+ var serviceType = serviceDef.get('name').toUpperCase();
+ _.each(XAEnums.AssetType, function(asset){
+ if(asset.label.toUpperCase() == serviceType.toUpperCase()){
+ serviceType = asset.label;
+ return;
+ }
+ });
+
+ if(!_.isUndefined(services[serviceType])){
+ _.each(services[serviceType],function(serv){
+ serviceName = serv.get('name');
+ tr += '<tr>\
+ <td>\
+ <div>\
+ <a data-id="'+serv.id+'" href="#!/service/'+serv.id+'/policies">'+serv.attributes.name+'</a>\
+ <div class="pull-right">\
+ <a data-id="'+serv.id+'" class="btn btn-mini" href="#!/service/'+serviceDef.id+'/edit/'+serv.id+'" title="Edit"><i class="icon-edit"></i></a>\
+ <a data-id="'+serv.id+'" class="deleteRep btn btn-mini btn-danger" href="javascript:void(0);" title="Delete">\
+ <i class="icon-trash"></i></a>\
+ </div>\
+ </div>\
+ </td>\
+ </tr>';
+ });
+ }
+ return tr;
+ });
return HHelpers;
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/GroupPermItem.html b/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
new file mode 100644
index 0000000..08155e1
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
@@ -0,0 +1,54 @@
+{{!--
+ 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.
+--}}
+<td>
+ <input type="text" data-js="selectGroups" />
+</td>
+
+{{#if policyKnox}}
+<td>
+ <input type="text" data-js="ipAddress" placeholder="Enter IP address"/>
+</td>
+{{/if}}
+
+{{#if policyStorm}}
+<td>
+ <span class="tags" id="tags-editable-1" data-toggle="manual" data-type="checklist"
+ data-value="{{stormPerms}}" data-original-title="Select Actions">
+ </span>
+ <a href="#" id="tags-edit-1" data-editable="tags-editable-1" class="" style="margin-left:10px;">
+ {{#if isModelNew}}
+ <i class="icon-plus" title="Add"></i>
+ {{else}}
+ <i class="icon-pencil" title="Edit"></i>
+ {{/if}}
+ </a>
+</td>
+{{/if}}
+{{#each permissions}}
+ <td style="cursor:pointer;">
+ <input data-id="{{./this.value}}" data-name="{{./this.label}}" type="checkbox">
+ </td>
+{{/each}}
+
+
+
+<td>
+ <button type="button" class="btn btn-small btn-danger " data-action="delete">
+ <i class="icon-remove"></i>
+ </button>
+</td>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/GroupPermList.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/GroupPermList.html b/security-admin/src/main/webapp/templates/policies/GroupPermList.html
new file mode 100644
index 0000000..ff40e5b
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/GroupPermList.html
@@ -0,0 +1,42 @@
+{{!--
+ 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.
+--}}
+<div class="control-group">
+ <label class="control-label">{{tt 'lbl.groupPermissions'}}</label>
+ <div class="controls">
+ <table class="table-permission table-condensed">
+ <thead>
+ <tr>
+ {{#each permHeaders}}
+ <th>{{./this}}</th>
+ {{/each}}
+
+ </tr>
+ </thead>
+ <tbody class="js-formInput">
+
+ </tbody>
+ </table>
+ </div>
+</div>
+<div class="control-group">
+ <div class="controls" style="margin-top:-14px">
+ <button type="button" class="btn btn-small" data-action="addGroup" title="Add">
+ <!-- {{tt 'btn.add'}} -->
+ <i class="icon-plus"></i>
+ </button>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
new file mode 100644
index 0000000..6f6d737
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
@@ -0,0 +1,59 @@
+{{!--
+ 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.
+--}}
+<form class="form-horizontal">
+ <fieldset>
+ <p class="formHeader">
+ Policy Details :
+ </p>
+ <!--ul id="name1"></ul-->
+ <!--div class="control-group field-name">
+ <label class="control-label" for="name2">Resource Path(new impl) *</label>
+ <div class="controls">
+ <input type="text" class="select2-input" id="name2" style="width: 250px;">
+ </div>
+ </div-->
+ <!-- <div class="" data-fields="policyName" style="float:left"></div>
+ <div class="" data-editors="resourceStatus" style="float:left"></div> -->
+ <div class="clearfix"></div>
+ <b data-fieldsets class="policy-form"></b>
+ <!-- <div class="" data-fields="name"></div>
+ -->
+ </fieldset>
+ <fieldset>
+ <p class="formHeader">
+ User and Group Permissions :
+ </p>
+ <div class="" data-customfields="groupPerms">
+ <div class="control-group">
+ <label class="control-label">{{tt 'lbl.groupPermissions'}}</label>
+ <div class="controls">
+ <img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
+ </div>
+ </div>
+ </div>
+ <div class="" data-customfields="userPerms">
+ <div class="control-group">
+ <label class="control-label">{{tt 'lbl.userPermissions'}}</label>
+ <div class="controls">
+ <img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />
+ </div>
+ </div>
+ </div>
+ <!-- <div class="" data-fields="description"></div> -->
+ </fieldset>
+</form>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/RangerPolicyTableLayout_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyTableLayout_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyTableLayout_tmpl.html
new file mode 100644
index 0000000..5a8937e
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyTableLayout_tmpl.html
@@ -0,0 +1,30 @@
+{{!--
+ 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.
+--}}
+<h3 class="wrap-header bold"> {{tt 'lbl.listOfPolicies'}} : {{rangerService.attributes.name}} </h3>
+<div class="wrap non-collapsible m-height ">
+ <div>
+ <div class="span9">
+ <div class="visual_search"></div>
+ </div>
+ <div class="clearfix">
+ <a href="#!/service/{{rangerService.id}}/policies/create" class="btn btn-primary btn-right" type="button"> {{tt 'lbl.addNewPolicy'}} </a>
+ </div>
+
+ <div data-id="r_table" class="hdfs-table clickable"></div>
+ </div>
+</div>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/UserPermItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/UserPermItem.html b/security-admin/src/main/webapp/templates/policies/UserPermItem.html
new file mode 100644
index 0000000..481ee61
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/UserPermItem.html
@@ -0,0 +1,51 @@
+{{!--
+ 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.
+--}}
+<td>
+ <input type="text" data-js="selectUsers" />
+</td>
+{{#if policyKnox}}
+<td>
+ <input type="text" data-js="ipAddress" placeholder="Enter IP address"/>
+</td>
+{{/if}}
+
+{{#if policyStorm}}
+<td>
+ <span class="tags" id="tags-editable-1" data-toggle="manual" data-type="checklist"
+ data-value="{{stormPerms}}" data-original-title="Select Actions">
+ </span>
+ <a href="#" id="tags-edit-1" data-editable="tags-editable-1" class="" style="margin-left:10px;">
+ {{#if isModelNew}}
+ <i class="icon-plus" title="Add"></i>
+ {{else}}
+ <i class="icon-pencil" title="Edit"></i>
+ {{/if}}
+ </a>
+</td>
+{{/if}}
+{{#each permissions}}
+ <td style="cursor:pointer;">
+ <input data-id="{{./this.value}}" type="checkbox">
+ </td>
+{{/each}}
+
+<td>
+ <button type="button" class="btn btn-small btn-danger " data-action="delete">
+ <i class="icon-remove"></i>
+ </button>
+</td>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/policies/UserPermList.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/UserPermList.html b/security-admin/src/main/webapp/templates/policies/UserPermList.html
new file mode 100644
index 0000000..797ae21
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/UserPermList.html
@@ -0,0 +1,42 @@
+{{!--
+ 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.
+--}}
+<div class="control-group">
+ <label class="control-label">{{tt 'lbl.userPermissions'}}</label>
+ <div class="controls">
+ <table class="table-permission table-condensed">
+ <thead>
+ <tr>
+ {{#each permHeaders}}
+ <th>{{./this}}</th>
+ {{/each}}
+
+ </tr>
+ </thead>
+ <tbody class="js-formInput">
+
+ </tbody>
+ </table>
+ </div>
+</div>
+<div class="control-group">
+ <div class="controls" style="margin-top:-14px">
+ <button type="button" class="btn btn-small" data-action="addUser" title="Add">
+ <!-- {{tt 'btn.add'}} -->
+ <i class="icon-plus"></i>
+ </button>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/service/ServiceCreate_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/service/ServiceCreate_tmpl.html b/security-admin/src/main/webapp/templates/service/ServiceCreate_tmpl.html
new file mode 100644
index 0000000..43b7f24
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/service/ServiceCreate_tmpl.html
@@ -0,0 +1,36 @@
+{{!--
+ 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.
+--}}
+{{#if editAsset}}
+ <h4 class="wrap-header bold"> Edit Repository </h4>
+{{else}}
+ <h4 class="wrap-header bold"> Create Repository </h4>
+{{/if}}
+<div class="wrap non-collapsible ">
+ <div data-id="r_form"></div>
+ <div class="form-actions form-asset" class="row-fluid">
+ <button type="submit" data-id="save" class="btn btn-primary">
+ Save
+ </button>
+ <button type="button" data-id="cancel" class="btn btn-inverse">
+ Cancel
+ </button>
+ <button type="button" data-id="delete" class="btn btn-danger" ><!-- style="margin-left: 27%;" -->
+ Delete
+ </button>
+ </div>
+</div>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html b/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
new file mode 100644
index 0000000..0a52755
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
@@ -0,0 +1,46 @@
+{{!--
+ 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.
+--}}
+<form class="form-horizontal" >
+ <fieldset class="configProp">
+ <p class="formHeader">
+ {{tt 'lbl.repositoryDetails'}} :
+ </p>
+ <div class="serviceDetail" data-fields={{serviceDetail}}></div>
+ </fieldset>
+ <fieldset class="configProp">
+ <!-- <b data-fieldsets></b> -->
+ <p class="formHeader">
+ Config Properties :
+ </p>
+ <!-- div class="" data-fields="_vPassword"></div-->
+ <!-- div class="" data-fields="pair"></div-->
+ <div class="serviceConfig" data-fields={{serviceConfig}}></div>
+ </fieldset>
+ <div>
+ <div class="control-group field-username hdfs hive knox storm" style="display: block;">
+ <label class="control-label" for="c12_username"></label>
+ <div class="controls">
+ <span data-editor="">
+ <input data-id="testConn" type="button" value="Test Connection" class="btn" />
+ </span>
+
+ </div>
+ </div>
+ </div>
+
+</form>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/templates/service/ServiceTableLayout_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/service/ServiceTableLayout_tmpl.html b/security-admin/src/main/webapp/templates/service/ServiceTableLayout_tmpl.html
new file mode 100644
index 0000000..4769039
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/service/ServiceTableLayout_tmpl.html
@@ -0,0 +1,29 @@
+{{!--
+ 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.
+--}}
+<h3 class="wrap-header bold"> {{tt 'lbl.listOfPolicies'}} : {{tt 'h.hdfs'}} </h3>
+<div class="wrap non-collapsible m-height">
+ <div class="span12">
+ <div class="clearfix">
+ <a href="#!/policy/create" class="btn btn-primary btn-right" type="button"> {{tt 'lbl.addNewAsset'}} </a>
+ <div data-id="r_filter" class="pull-left wrap-filter"></div>
+ </div>
+
+ <div data-id="r_assettable" class="hdfs-table"></div>
+ </div>
+
+</div>
+