Repository: ranger
Updated Branches:
  refs/heads/master b087c4ccb -> f21e2b4cf


http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/scripts/Init.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/Init.js 
b/security-admin/src/main/webapp/scripts/Init.js
index 4de6b6d..4493f62 100644
--- a/security-admin/src/main/webapp/scripts/Init.js
+++ b/security-admin/src/main/webapp/scripts/Init.js
@@ -78,7 +78,10 @@
        'bootstrap-notify' :    {
           deps: ['jquery','bootstrap'],
        },
-       moment  :       { deps: ['jquery'], exports: 'moment' },
+       'moment'  :     { deps: ['jquery'], exports: 'moment' },
+
+       'momentTz'  :    { deps: ['jquery']},
+
        'localstorage' :{
             deps : ['backbone','underscore','jquery']
        },
@@ -140,7 +143,8 @@
         'tag-it'                                       : 
'../libs/bower/tag-it/js/tag-it.min',
         'select2'                                      : 
'../libs/bower/select2/select2',
         'bootbox'                                      : 
'../libs/bower/bootbox/js/bootbox',
-        'moment'                                       : 
'../libs/bower/moment/js/moment-with-langs.min',
+        'moment'                                       : 
'../libs/bower/moment/js/moment-with-locales.min',
+        'momentTz'                    : 
'../libs/bower/moment/js/moment-timezone-with-data.min',
         'visualsearch'                         : 
'../libs/other/visualsearch/js/visualsearch',
         'globalize'                    : 
'../libs/bower/globalize/lib/globalize',
         /* handlebars from the require handlerbars plugin below */

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/scripts/utils/XATemplateHelpers.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/utils/XATemplateHelpers.js 
b/security-admin/src/main/webapp/scripts/utils/XATemplateHelpers.js
deleted file mode 100644
index b64f911..0000000
--- a/security-admin/src/main/webapp/scripts/utils/XATemplateHelpers.js
+++ /dev/null
@@ -1,171 +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.
- */
-
- 
-       /*
-        * General guidelines while writing helpers:
-        * 
-        * - If returning HTML use return new Handlebars.SafeString();
-        * - If the helper needs optional arguments use the "hash arguments"
-        *   Eg. {{{link . "See more..." story.url class="story"}}}
-        *   NOTE: the first argument after the helper name should be . which 
will be context in the helper function
-        *   Handlebars.registerHelper('link', function(context, text, url, 
options) {
-        *      var attrs = [];
-        *              
-        *      for(var prop in options.hash) {
-        *              attrs.push(prop + '="' + options.hash[prop] + '"');
-        *      }       
-        *      return new Handlebars.SafeString("<a " + attrs.join(" ") + ">" 
+ text + "</a>");
-        *   });
-        * 
-        * 
-        * NOTE: Due to some limitations in the require-handlebars-plugin, we 
cannot have helper that takes zero arguments,
-        *       for such helpers we have to pass a "." as first argument. 
[https://github.com/SlexAxton/require-handlebars-plugin/issues/72] 
-        */
-       
-
-define(function ( require ){
-
-       var Handlebars  = require('Handlebars');
-       var HHelpers = {};
-       
-       /**
-     * Convert new line (\n\r) to <br>
-     * from http://phpjs.org/functions/nl2br:480
-     */
-       Handlebars.registerHelper('nl2br', function(text) {
-        text = Handlebars.XAUtils.escapeExpression(text);
-        var nl2br = (text + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' 
+ '<br>' + '$2');
-        return new Handlebars.SafeString(nl2br);
-    });
-       
-       /*
-        * escapeHtmlChar
-        */
-       Handlebars.registerHelper("escapeHtmlChar", function(str) {
-               return Util.escapeHtmlChar(str);
-       });
-       
-       Handlebars.registerHelper("nl2brAndEscapeHtmlChar", function(str) {
-               return Util.nl2brAndEscapeHtmlChar(str);
-       });
-       
-       /*
-        * required to fetch label for enum value
-        */ 
-       Handlebars.registerHelper('convertEnumValueToLabel', function(enumName, 
enumValue) {
-               return Util.enumValueToLabel( Util.getEnum(enumName), 
enumValue);
-       });
-       
-       /*
-        * Truncate the String till n positions
-        */
-       Handlebars.registerHelper('truncStr', function(str, n, useWordBoundary) 
{
-               var len = n || 1;
-               var useWordBn = useWordBoundary || false;
-               return str.trunc(len, useWordBn);
-       });
-       
-       /*Handlebars.registerHelper('tt', function(str) {
-               return localization.tt(str);
-       });*/
-       
-       Handlebars.registerHelper('getCopyrightDate', function() {
-               return new Date().getFullYear().toString();
-       });
-       
-       Handlebars.registerHelper('if_eq', function(context, options) {
-               if (context == options.hash.compare)
-                       return options.fn(this);
-               return options.inverse(this);
-       });
-
-       Handlebars.registerHelper('if_gt', function(context, options) {
-               if (context > options.hash.compare)
-                       return options.fn(this);
-               return options.inverse(this);
-       });
-
-       Handlebars.registerHelper('ifCond', function (v1, operator, v2, 
options) {
-               switch (operator) {
-                       case '==':
-                               return (v1 == v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       case '===':
-                               return (v1 === v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       case '<':
-                               return (v1 < v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       case '<=':
-                               return (v1 <= v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       case '>':
-                               return (v1 > v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       case '>=':
-                               return (v1 >= v2) ? options.fn(this) : 
options.inverse(this);
-                       break;
-                       default:
-                               return options.inverse(this);     
-                       break;
-               }
-               //return options.inverse(this);
-       });
-
-
-    /**
-     * This helper provides a for i in range loop
-     *
-     * start and end parameters have to be integers >= 0 or their string 
representation. start should be <= end.
-     * In all other cases, the block is not rendered.
-     * Usage:
-     *        <ul>
-     *            {{#for 0 10}}
-     *                <li>{{this}}</li>
-     *            {{/for}}
-     *        </ul>
-     */
-    Handlebars.registerHelper('for', function(start, end, options) {
-        var fn = options.fn, inverse = options.inverse;
-        var isStartValid = (start != undefined && !isNaN(parseInt(start)) && 
start >= 0);
-        var isEndValid = (end != undefined && !isNaN(parseInt(end)) && end >= 
0);
-        var ret = "";
-
-        if (isStartValid && isEndValid && parseInt(start) <= parseInt(end)) {
-            for (var i = start; i <= end; i++) {
-                ret = ret + fn(i);
-            }
-        } else {
-            ret = inverse(this);
-        }
-
-        return ret;
-    });
-
-       Handlebars.registerHelper('dateFormat', function(context, block) {
-               if (window.moment) {
-                       var f = block.hash.format || "MMM Do, YYYY";
-                       return moment(Date(context)).format(f);
-               }else{
-                       return context;   //  moment plugin not available. 
return data as is.
-                }
-       });
-       return HHelpers;
-});

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/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 ed83669..7bc2914 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -1390,14 +1390,16 @@ define(function(require) {
         return (SessionMgr.isAuditor() || SessionMgr.isKMSAuditor()) ? true : 
false ;
     };
     XAUtils.isPolicyExpierd = function(model){
+        var moment = require('moment');
+        var momontTz = require('momentTz');
         return !_.some(model.get('validitySchedules') , function(m){
             if(!m.endTime){
                 return true;
             } else if(_.isEmpty(m.timeZone)){
                 return new Date().valueOf() > new Date(m.endTime).valueOf() ? 
false : true;
             }else{
-                return new Date(new Date().toLocaleString('en-US', { timeZone: 
m.timeZone }).valueOf()).valueOf() >
-                new Date(m.endTime.toLocaleString('en-US', { timeZone: 
m.timeZone }).valueOf()).valueOf() ? false : true;
+                return new Date(moment.tz(m.timeZone).format('MM/DD/YYYY 
HH:mm:ss')).valueOf() >
+                new Date(m.endTime).valueOf() ? false : true;
             }
         });
     };

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/scripts/views/DownloadServicePolicy.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/DownloadServicePolicy.js 
b/security-admin/src/main/webapp/scripts/views/DownloadServicePolicy.js
index fc8edbb..8f9dfe5 100644
--- a/security-admin/src/main/webapp/scripts/views/DownloadServicePolicy.js
+++ b/security-admin/src/main/webapp/scripts/views/DownloadServicePolicy.js
@@ -41,7 +41,6 @@ define(function(require){
                        this.bind("ok", this.okClicked);
                },
                ui:{
-                       'downloadReport'        : '[data-id="downloadReport"]',
                        'servicesName'          : '[data-id="servicesName"]',
                        'componentTypeSelected'         : 
'[data-id="componentTypeSelected"]'
                },
@@ -73,7 +72,11 @@ define(function(require){
                        success:function(data,status,response){
                                XAUtil.blockUI('unblock');
                                if(response.status == 200 || 
response.statusText == "ok"){
-                                       that.ui.downloadReport.attr("href", 
urlString + urls+ 
'?serviceName='+serviceName+'&checkPoliciesExists=false')[0].click();
+                                   var downloadUrl = urlString + 
urls+'?serviceName='+serviceName+'&checkPoliciesExists=false';
+                                   var downloadReport = $('<a href 
="'+downloadUrl+'"></a>');
+                                   downloadReport.appendTo('body');
+                                   downloadReport[0].click();
+                                   downloadReport.remove();
                                }else{
                                        
XAUtil.alertBoxWithTimeSet(localization.tt('msg.noPolicytoExport'))
                                }

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js 
b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
index 0a6b16c..7af226f 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -139,6 +139,9 @@ define(function(require) {
                                
if(!_.isUndefined(this.model.get('delegateAdmin')) && 
this.model.get('delegateAdmin')){
                                         this.ui.delegatedAdmin.prop('checked', 
true);
                                }
+                               if(this.model.has('delegateAdmin') && 
!this.model.get('delegateAdmin')){
+                                   this.model.unset('delegateAdmin');
+                               }
                                
if(!_.isUndefined(this.model.get('rowFilterInfo')) && 
!_.isUndefined(this.model.get('rowFilterInfo').filterExpr)){
                                        this.rowFilterExprVal = 
this.model.get('rowFilterInfo').filterExpr
                                }
@@ -166,8 +169,12 @@ define(function(require) {
                        var that = this;
                        $select.on('change',function(e){
                                var name = ($(e.currentTarget).attr('data-js') 
== that.ui.selectGroups.attr('data-js')) ? 'group': 'user';
+                               var otherName = (name == 'user') ? 'group': 
'user';
                                that.checkDirtyFieldForDropDown(e);
                                
+                               if(_.isNull(that.model.get(otherName+'Name'))){
+                    that.model.unset(otherName+'Name')
+                }
                                if(e.removed != undefined){
                                        var gNameArr = [];
                                        if(that.model.get(name+'Name') != 
undefined)
@@ -721,6 +728,8 @@ define(function(require) {
                                        
that.$('#policyConditions').editable('toggle');
                                });
                                
+                       }else{
+                           that.model.unset('conditions');
                        }
                },
                getSelectedValues : function($select, typeGroup){
@@ -741,7 +750,11 @@ define(function(require) {
                        var $el = $(e.currentTarget);
                        XAUtil.checkDirtyFieldForToggle($el);
                        //Set Delegated Admin value 
-                        this.model.set('delegateAdmin',$el.is(':checked'));
+                       if($el.is(':checked')){
+                           this.model.set('delegateAdmin',$el.is(':checked'));
+                       }else{
+                           this.model.unset('delegateAdmin');
+                       }
                        //select/deselect all functionality
                        
if(this.checkAll($el.find('input[type="checkbox"][value!="-1"]'))){
                                
$el.find('input[type="checkbox"][value="-1"]').prop('checked', true)

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js 
b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
index cb13908..b3da7b5 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -47,7 +47,7 @@ define(function(require) {
        var RangerPolicyRO                              = 
require('views/policies/RangerPolicyRO');
        var vPlugableServiceDiffDetail  = 
require('views/reports/PlugableServiceDiffDetail');
 
-       require('moment');
+       var moment = require('moment');
        require('bootstrap-datepicker');
        require('Backbone.BootstrapModal');
        require('visualsearch');

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/security-admin/src/main/webapp/templates/common/downloadservicepolicy_tmpl.html
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/templates/common/downloadservicepolicy_tmpl.html
 
b/security-admin/src/main/webapp/templates/common/downloadservicepolicy_tmpl.html
index e608a0f..95ea335 100644
--- 
a/security-admin/src/main/webapp/templates/common/downloadservicepolicy_tmpl.html
+++ 
b/security-admin/src/main/webapp/templates/common/downloadservicepolicy_tmpl.html
@@ -30,5 +30,4 @@
           </label>
        </div>
 
-</div>
-<a href="javascript:;" data-id="downloadReport"></a>
\ No newline at end of file
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ranger/blob/666f6f6b/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 e58bece..8ace4d7 100644
--- a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
+++ b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js
@@ -23,7 +23,7 @@
        var XAUtil                      = require('utils/XAUtils');
     var localization   = require('utils/XALangSupport');
     var SessionMgr     = require('mgrs/SessionMgr');
-       require('moment');
+    var moment = require('moment');
        /*
         * General guidelines while writing helpers:
         * 

Reply via email to