1angular.module('irk') 2 .factory('routePermissionFactory', function ($http, Session, $q, $controller, $rootScope) { 3 4 var routePermissionFactory = {}; 5 routePermissionFactory.routePermissionCache = {}; 6 7 routePermissionFactory.clearCache = function() { 8 routePermissionFactory.routePermissionCache = {}; 9 } 10 11 routePermissionFactory.viewPolicyChecker = function (url, params, deepCheck) { 12 return $http 13 .post('REST/policyChecker', { 14 url: url?url:'', 15 params: params ? params : {}, 16 deepCheck: deepCheck?true:false 17 }) 18 .then(function (res) { 19 return res.data; 20 }); 21 }; 22 23 routePermissionFactory.checkRoutePermission = function (nextRoute, deepCheck) { 24 //TODO obsÅuga parametrów 25 deepCheck = typeof deepCheck !== 'undefined' ? deepCheck : false; 26 var result = true; 27 28 var templateUrl = nextRoute.templateUrl; 29 30 if(!angular.isUndefined(templateUrl)) { 31 if(!deepCheck) { 32 //mozna skorzystaÄ z cache 33 if(!(templateUrl in this.routePermissionCache)) { 34 this.routePermissionCache[templateUrl] = this.viewPolicyChecker(templateUrl, {}, deepCheck); 35 } 36 result = this.routePermissionCache[templateUrl]; 37 } 38 else { 39 result = this.viewPolicyChecker(templateUrl, {}, deepCheck); 40 } 41 } 42 43 var deferred = $q.defer(); 44 deferred.resolve(result); 45 return deferred.promise; 46 }; 47 48 Session.registerObserverCallback(function() { 49 routePermissionFactory.clearCache(); 50 }); 51 52 return routePermissionFactory; 53 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.