import ngModule from '../module'; var acl = window.salix ? window.salix.acl : {}; ngModule.constant('aclConstant', acl); aclService.$inject = ['aclConstant']; function aclService(aclConstant) { this.roles = aclConstant.roles || undefined; this.routeHasPermission = function(route) { let hasPermission; if (!this.roles) hasPermission = false; else if (!route.acl) hasPermission = true; else if (!this.roles || !Object.keys(this.roles).length) hasPermission = false; else hasPermission = this.aclPermission(route.acl); return hasPermission; }; this.aclPermission = function(aclCollection) { let hasPermission = false; let total = aclCollection.length; for (let i = 0; i < total; i++) { if (this.roles[aclCollection[i]]) { hasPermission = true; break; } } return hasPermission; }; } ngModule.service('aclService', aclService);