X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sdnr%2Fwireless-transport%2Fcode-Carbon-SR1%2Fapps%2Fdlux%2Fdlux-web%2Fsrc%2Fapp%2FroutingConfig.js;fp=sdnr%2Fwireless-transport%2Fcode-Carbon-SR1%2Fapps%2Fdlux%2Fdlux-web%2Fsrc%2Fapp%2FroutingConfig.js;h=0000000000000000000000000000000000000000;hb=1c1e7f98416875f3ee78af9103865c32f95a82a0;hp=3e0ee90ab7dadefc676823f21937000fa4aeddc5;hpb=6a893bb0ae984d15076394d9225d4873ad953791;p=ccsdk%2Fapps.git diff --git a/sdnr/wireless-transport/code-Carbon-SR1/apps/dlux/dlux-web/src/app/routingConfig.js b/sdnr/wireless-transport/code-Carbon-SR1/apps/dlux/dlux-web/src/app/routingConfig.js deleted file mode 100644 index 3e0ee90a..00000000 --- a/sdnr/wireless-transport/code-Carbon-SR1/apps/dlux/dlux-web/src/app/routingConfig.js +++ /dev/null @@ -1,103 +0,0 @@ -(function(exports){ - - var config = { - - /* List all the roles you wish to use in the app - * You have a max of 31 before the bit shift pushes the accompanying integer out of - * the memory footprint for an integer - */ - roles :[ - 'public', - 'user', - 'admin'], - - /* - Build out all the access levels you want referencing the roles listed above - You can use the "*" symbol to represent access to all roles - */ - accessLevels : { - 'public' : "*", - 'anon': ['public'], - 'user' : ['user', 'admin'], - 'admin': ['admin'] - } - - }; - - exports.userRoles = buildRoles(config.roles); - exports.accessLevels = buildAccessLevels(config.accessLevels, exports.userRoles); - - /* - Method to build a distinct bit mask for each role - It starts off with "1" and shifts the bit to the left for each element in the - roles array parameter - */ - - function buildRoles(roles){ - - var bitMask = "01"; - var userRoles = {}; - - for(var role in roles){ - var intCode = parseInt(bitMask, 2); - userRoles[roles[role]] = { - bitMask: intCode, - title: roles[role] - }; - bitMask = (intCode << 1 ).toString(2); - } - - return userRoles; - } - - /* - This method builds access level bit masks based on the accessLevelDeclaration parameter which must - contain an array for each access level containing the allowed user roles. - */ - function buildAccessLevels(accessLevelDeclarations, userRoles){ - - var accessLevels = {}; - var resultBitMask = ''; - for(var level in accessLevelDeclarations){ - - if(typeof accessLevelDeclarations[level] == 'string'){ - if(accessLevelDeclarations[level] == '*'){ - - resultBitMask = ''; - - for( var roleTemp in userRoles){ - resultBitMask += "1"; - } - //accessLevels[level] = parseInt(resultBitMask, 2); - accessLevels[level] = { - bitMask: parseInt(resultBitMask, 2), - title: accessLevelDeclarations[level] - }; - } - else { - console.log("Access Control Error: Could not parse '" + accessLevelDeclarations[level] + "' as access definition for level '" + level + "'"); - } - - } - else { - - resultBitMask = 0; - for(var role in accessLevelDeclarations[level]){ - if(userRoles.hasOwnProperty(accessLevelDeclarations[level][role])) { - resultBitMask = resultBitMask | userRoles[accessLevelDeclarations[level][role]].bitMask; - } - else { - console.log("Access Control Error: Could not find role '" + accessLevelDeclarations[level][role] + "' in registered roles while building access for '" + level + "'"); - } - } - accessLevels[level] = { - bitMask: resultBitMask, - title: accessLevelDeclarations[level][role] - }; - } - } - - return accessLevels; - } - -})(typeof exports === 'undefined' ? this['routingConfig'] = {} : exports); \ No newline at end of file