diff options
author | 2017-02-14 19:41:00 -0500 | |
---|---|---|
committer | 2017-02-14 19:41:32 -0500 | |
commit | 91d04c64771832a0b8815ffbe1f0f9920320d94d (patch) | |
tree | fb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services | |
parent | b9d4caa40ef8e3566ac475968bce17b9b64b6939 (diff) |
Initial OpenECOMP policy/engine commit
Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services')
5 files changed, 452 insertions, 0 deletions
diff --git a/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/adminService.js b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/adminService.js new file mode 100644 index 000000000..85a4d1bdd --- /dev/null +++ b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/adminService.js @@ -0,0 +1,160 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.factory('AdminService', function ($http, $q) { + return { + getRoles: function() { + return $http.get('get_roles') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getRoleFunctionList: function() { + return $http.get('get_role_functions') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getFnMenuItems: function(){ + + return $http.get('admin_fn_menu') + .then(function(response) { + if (typeof response.data === 'object') { + + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getCacheRegions: function() { + return $http.get('get_regions') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getUsageList: function() { + return $http.get('get_usage_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getBroadcastList: function() { + return $http.get('get_broadcast_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getBroadcast: function(messageLocationId, messageLocation, messageId) { + return $http.get('get_broadcast?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : '')) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getCollaborateList: function() { + return $http.get('get_collaborate_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getRole: function(roleId) { + + return $http.get('get_role?role_id=' + roleId) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + } + }; +}); diff --git a/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/headerService.js b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/headerService.js new file mode 100644 index 000000000..4b4a2ec4e --- /dev/null +++ b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/headerService.js @@ -0,0 +1,89 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +var menuStructureConvert = function(menuItems) { + var megaMenuDataObjectTemp = [ + { + text: "ECOMP", + children:menuItems + }, + { + text: "Help", + children: [{ + text:"Contact Us", + url:"javascript:angular.element('[ng-controller=headerController]').scope().redirectLink('contact');" + }, + { + text:"Get Access", + url:"javascript:angular.element('[ng-controller=headerController]').scope().redirectLink('access');" + }] + } + ]; + return megaMenuDataObjectTemp; +}; +var unflatten = function( array, parent, tree ){ + tree = typeof tree !== 'undefined' ? tree : []; + parent = typeof parent !== 'undefined' ? parent : { menuId: null }; + var children = _.filter( array, function(child){ return child.parentMenuId == parent.menuId; }); + + if( !_.isEmpty( children ) ){ + if( parent.menuId === null ){ + tree = children; + }else{ + parent['children'] = children + } + _.each( children, function( child ){ unflatten( array, child ) } ); + } + + return tree; + } +app.service('HeaderService', function ($http,$log, $q,UserInfoService) { + return{ + + getUserNameFromSession : function(){ + UserInfoService.getFunctionalMenuStaticDetailSession() + .then(function (res) { + $scope.userName = res.userName; + $scope.redirectUrl = res.portalUrl; + }); + }, + getTopMenuStaticInfo:function() { + var promise = UserInfoService.getFunctionalMenuStaticDetailShareContext(); + promise.then( + function(res) { + if(res==null || res==''){ + $log.info('failed getting static User information'); + this.getUserNameFromSession(); + }else{ + $log.info('Received static User information'); + var resData = res; + $scope.inputUserInfo(resData); + $scope.userProfile.fullName = $scope.userProfile.firstName+ ' '+ $scope.userProfile.lastName; + return $scope.userProfile; + } + }, + function(err) { + $log.info('failed getting static User information'); + } + ); + } + } + } +); + diff --git a/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/leftMenuService.js b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/leftMenuService.js new file mode 100644 index 000000000..17e53c7d8 --- /dev/null +++ b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/leftMenuService.js @@ -0,0 +1,54 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +function isRealValue(obj){ + return obj && obj !== "null" && obj!== "undefined"; +} +app.factory('LeftMenuService', function ($http,$log, $q) { + return { + getLeftMenu: function() { + return $http.get('get_menu') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + getAppName: function() { + return $http.get('get_app_name') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + } + + }; +}); + diff --git a/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/profileService.js b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/profileService.js new file mode 100644 index 000000000..7c73bed9d --- /dev/null +++ b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/profileService.js @@ -0,0 +1,98 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ + +app.factory('ProfileService', function ($http, $q) { + return { + getProfile: function() { + return $http.get('get_user') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getProfilePagination: function(pageNum,viewPerPage) { + return $http.get('get_user_pagination?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getPostProfile: function() { + return $http.get('post_search_sample') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getProfileDetail: function(profileId) { + return $http.get('get_profile?profile_id='+profileId) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getSelfProfileDetail: function() { + return $http.get('get_self_profile') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + } + }; +}); diff --git a/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/userInfoService.js b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/userInfoService.js new file mode 100644 index 000000000..9c0d3c027 --- /dev/null +++ b/ecomp-sdk-app/src/main/webapp/app/fusion/scripts/services/userInfoService.js @@ -0,0 +1,51 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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. + * ================================================================================ + */ +app.factory('UserInfoService', function ($http, $q,$log) { + return { + getFunctionalMenuStaticDetailShareContext: function(contextId,key) { + var deferred = $q.defer(); + $http({ + method: "GET", + url: "get_userinfo", + }).success( function(res) { + if(res==null || res=='') + $log.info('Not be able to get User Info via shared context'); + deferred.resolve(res); + }).error( function(status) { + deferred.reject(status); + }); + return deferred.promise; + }, + getFunctionalMenuStaticDetailSession: function() { + var deferred = $q.defer(); + $http({ + method: "GET", + url: "get_topMenuInfo", + }).success(function(res) { + if(res==null || res=='') + $log.info('Not be able to get User Info via shared context'); + deferred.resolve(res); + }).error( function(status) { + deferred.reject(status); + }); + return deferred.promise; + } + }; +}); |