From 627badaf69987c01811c477219fd943757a635f5 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (Christopher) (cl778h)" Date: Mon, 12 Jun 2017 09:49:00 -0400 Subject: [PORTAL-16 PORTAL-18] Widget ms; staging Remove staging repositories from poms. Add widget microservice code base. Add portal unit tests. Repair defects. Normalize line endings. Change-Id: Ia5e48da2a3141b352439ecd548cddf918f4df585 Signed-off-by: Christopher Lott (cl778h) --- .../app/views/role/popup_modal_rolefunction.html | 114 ++--- .../client/app/views/role/role-controller.js | 438 +++++++++--------- .../views/role/role-function-list-controller.js | 320 ++++++------- .../client/app/views/role/role-list-controller.js | 294 ++++++------ .../client/app/views/role/role.html | 192 ++++---- .../client/app/views/role/role.less | 98 ++-- .../app/views/role/role_childrole_popup.html | 106 ++--- .../client/app/views/role/role_function_list.html | 214 ++++----- .../app/views/role/role_functions_popup.html | 104 +++-- .../client/app/views/role/role_list.html | 112 ++--- .../app/views/role/rolefunctionpopupController.js | 190 ++++---- .../app/views/role/rolepopupmodelController.js | 502 ++++++++++----------- 12 files changed, 1350 insertions(+), 1334 deletions(-) (limited to 'ecomp-portal-FE-common/client/app/views/role') diff --git a/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html b/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html index 3970960d..c5673da8 100644 --- a/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html +++ b/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html @@ -1,55 +1,59 @@ - - -
-
-
- -
-
- *Name:
- -
Name is Required -
-
-
-
-
- *Code: -
- -
Code is Required -
-
- - - -
- - - -
Cancel
-
-
-
- - + + +
+
+
+ +
+
+ *Name:
+ +
Name is Required +
+
+
+
+
+ *Code: +
+ +
Code is Required +
+
+ + + +
+ + + +
Cancel
+
+
+
+ + diff --git a/ecomp-portal-FE-common/client/app/views/role/role-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-controller.js index c5c7c97c..2bd522a4 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-controller.js @@ -1,219 +1,219 @@ -/*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * 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.controller('roleController', function ($scope, $http, confirmBoxService, ngDialog, RoleService, conf, $stateParams){ - //$scope.role=${role}; - - $( "#dialogRoleFunction" ).hide(); - $( "#dialogChildRole" ).hide(); - - //$scope.ociavailableRoleFunctions=${availableRoleFunctions}; - $scope.fetchRoles = function() { - - RoleService.getRole($stateParams.roleId).then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - - $scope.role =JSON.parse($scope.data.role); - - $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - $scope.availableRoleFunctions=[]; - - if($scope.ociavailableRoleFunctions) - $.each($scope.ociavailableRoleFunctions, function(i, a){ - var availableRoleFunction = a; - availableRoleFunction.selected = false; - $.each($scope.role.roleFunctions, function(j, b){ - if(a.code === b.code) { - availableRoleFunction.selected = true; - } - }); - $scope.availableRoleFunctions.push(availableRoleFunction); - }); - - - $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); - $scope.availableRoles=[]; - - if($scope.ociavailableRoles) - $.each($scope.ociavailableRoles, function(i, a){ - var availableRole = a; - availableRole.selected = false; - if($scope.role.childRoles){ - $.each($scope.role.childRoles, function(j, b){ - if(a.id === b.id) { - availableRole.selected = true; - } - }); - }; - $scope.availableRoles.push(availableRole); - }); - - - },function(error){ - console.log("RoleService.getRole failed", error); - //reloadPageOnce(); - }); - } - - $scope.fetchRoles(); - - $scope.saveRole = function() { - var exists = false,x; - for(x in $scope.availableRoles){ - if($scope.availableRoles[x].name==$scope.role.name){ - exists = true; - //$modalInstance.close({availableRoleFunctions:message.availableRoleFunctions}); - } - } - if (exists) { - confirmBoxService.showInformation( "Role already exists."); - } - else { - var uuu = conf.api.saveRole + "?role_id="+$stateParams.roleId; - var postData = { - role: $scope.role, - childRoles: $scope.role.childRoles, - roleFunctions : $scope.role.roleFunctions - }; - $http.post(uuu, JSON.stringify(postData)).then(function(res) { - // console.log('roleController::saveRole: ' + JSON.stringify(res)); - if (res && res.data && res.data.role) - confirmBoxService.showInformation("Update Successful."); - else - confirmBoxService.showInformation('Failed to create role: ' + res.data.error) - }, - function(res){ - console.log('post failed', res.data); - confirmBoxService.showInformation("Error while saving."); - } - ); - } - }; - - $scope.addNewRoleFunctionModalPopup = function() { - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/role_functions_popup.html', - controller: 'rolepopupController', - - resolve: { - roleId: function () { - return $stateParams.roleId; - }, - role: function () { - return $scope.role; - }, - availableRoles: function () { - return $scope.ociavailableRoles; - }, - availableRoleFunctions: function () { - return $scope.ociavailableRoleFunctions; - }, - } - }); - modalInstance.closePromise.then(response => { - if($stateParams.roleId === '0'){ - return $scope.role; - }else{ - $scope.fetchRoles(); - } - // $scope.role=response.role; - }); - }; - - $scope.addNewChildRoleModalPopup = function() { - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/role_childrole_popup.html', - controller: 'rolepopupController', - - resolve: { - roleId: function () { - return $stateParams.roleId; - }, - role: function () { - return $scope.role; - }, - availableRoles: function () { - return $scope.ociavailableRoles; - }, - availableRoleFunctions: function () { - return $scope.ociavailableRoleFunctions; - }, - } - }).closePromise.then(function(response){ - if($stateParams.roleId === '0'){ - return $scope.role; - }else{ - $scope.fetchRoles(); - } - //$scope.role=response.role; - }); - }; - - $scope.removeRoleFunction = function(roleFunction) { - confirmBoxService.confirm("You are about to remove the role function "+roleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - var uuu = conf.api.toggleRoleRoleFunction + "?role_id=" + $stateParams.roleId; - var postData={roleFunction:roleFunction}; - if(confirmed) { - $http.post(uuu, postData).then( - function(response) { - $scope.role= response.data.role; - $.each($scope.availableRoleFunctions, function(k, c){ - if(c.code === roleFunction.code) { - c.selected = false; - } - }); - }, - function(response) { - confirmBoxService.showInformation("Error while saving."); - } - ); - } - - }); - - }; - - $scope.removeChildRole = function(childRole) { - confirmBoxService.confirm("You are about to remove the child role "+childRole.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - var uuu = conf.api.toggleRoleChildRole + "?role_id=" + $stateParams.roleId; - var postData={childRole:childRole}; - if(confirmed) { - $http.post(uuu,postData).then( function(response) { - $scope.role=response.data.role; - $.each($scope.availableRoles, function(k, c){ - if(c.id === childRole.id) { - c.selected = false; - } - }); - }, - - function(data) { - confirmBoxService.showInformation("Error while saving."); - }); - } - }); - - }; - -}); +/*- + * ================================================================================ + * ECOMP Portal + * ================================================================================ + * 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.controller('roleController', function ($scope, $http, confirmBoxService, ngDialog, RoleService, conf, $stateParams){ + //$scope.role=${role}; + + $( "#dialogRoleFunction" ).hide(); + $( "#dialogChildRole" ).hide(); + + //$scope.ociavailableRoleFunctions=${availableRoleFunctions}; + $scope.fetchRoles = function() { + + RoleService.getRole($stateParams.roleId).then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + + $scope.role =JSON.parse($scope.data.role); + + $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + $scope.availableRoleFunctions=[]; + + if($scope.ociavailableRoleFunctions) + $.each($scope.ociavailableRoleFunctions, function(i, a){ + var availableRoleFunction = a; + availableRoleFunction.selected = false; + $.each($scope.role.roleFunctions, function(j, b){ + if(a.code === b.code) { + availableRoleFunction.selected = true; + } + }); + $scope.availableRoleFunctions.push(availableRoleFunction); + }); + + + $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); + $scope.availableRoles=[]; + + if($scope.ociavailableRoles) + $.each($scope.ociavailableRoles, function(i, a){ + var availableRole = a; + availableRole.selected = false; + if($scope.role.childRoles){ + $.each($scope.role.childRoles, function(j, b){ + if(a.id === b.id) { + availableRole.selected = true; + } + }); + }; + $scope.availableRoles.push(availableRole); + }); + + + },function(error){ + console.log("RoleService.getRole failed", error); + //reloadPageOnce(); + }); + } + + $scope.fetchRoles(); + + $scope.saveRole = function() { + var exists = false,x; + for(x in $scope.availableRoles){ + if($scope.availableRoles[x].name==$scope.role.name){ + exists = true; + //$modalInstance.close({availableRoleFunctions:message.availableRoleFunctions}); + } + } + if (exists) { + confirmBoxService.showInformation( "Role already exists."); + } + else { + var uuu = conf.api.saveRole + "?role_id="+$stateParams.roleId; + var postData = { + role: $scope.role, + childRoles: $scope.role.childRoles, + roleFunctions : $scope.role.roleFunctions + }; + $http.post(uuu, JSON.stringify(postData)).then(function(res) { + // console.log('roleController::saveRole: ' + JSON.stringify(res)); + if (res && res.data && res.data.role) + confirmBoxService.showInformation("Update Successful."); + else + confirmBoxService.showInformation('Failed to create role: ' + res.data.error) + }, + function(res){ + console.log('post failed', res.data); + confirmBoxService.showInformation("Error while saving."); + } + ); + } + }; + + $scope.addNewRoleFunctionModalPopup = function() { + var modalInstance = ngDialog.open({ + templateUrl: 'app/views/role/role_functions_popup.html', + controller: 'rolepopupController', + + resolve: { + roleId: function () { + return $stateParams.roleId; + }, + role: function () { + return $scope.role; + }, + availableRoles: function () { + return $scope.ociavailableRoles; + }, + availableRoleFunctions: function () { + return $scope.ociavailableRoleFunctions; + }, + } + }); + modalInstance.closePromise.then(response => { + if($stateParams.roleId === '0'){ + return $scope.role; + }else{ + $scope.fetchRoles(); + } + // $scope.role=response.role; + }); + }; + + $scope.addNewChildRoleModalPopup = function() { + var modalInstance = ngDialog.open({ + templateUrl: 'app/views/role/role_childrole_popup.html', + controller: 'rolepopupController', + + resolve: { + roleId: function () { + return $stateParams.roleId; + }, + role: function () { + return $scope.role; + }, + availableRoles: function () { + return $scope.ociavailableRoles; + }, + availableRoleFunctions: function () { + return $scope.ociavailableRoleFunctions; + }, + } + }).closePromise.then(function(response){ + if($stateParams.roleId === '0'){ + return $scope.role; + }else{ + $scope.fetchRoles(); + } + //$scope.role=response.role; + }); + }; + + $scope.removeRoleFunction = function(roleFunction) { + confirmBoxService.confirm("You are about to remove the role function "+roleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + var uuu = conf.api.toggleRoleRoleFunction + "?role_id=" + $stateParams.roleId; + var postData={roleFunction:roleFunction}; + if(confirmed) { + $http.post(uuu, postData).then( + function(response) { + $scope.role= response.data.role; + $.each($scope.availableRoleFunctions, function(k, c){ + if(c.code === roleFunction.code) { + c.selected = false; + } + }); + }, + function(response) { + confirmBoxService.showInformation("Error while saving."); + } + ); + } + + }); + + }; + + $scope.removeChildRole = function(childRole) { + confirmBoxService.confirm("You are about to remove the child role "+childRole.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + var uuu = conf.api.toggleRoleChildRole + "?role_id=" + $stateParams.roleId; + var postData={childRole:childRole}; + if(confirmed) { + $http.post(uuu,postData).then( function(response) { + $scope.role=response.data.role; + $.each($scope.availableRoles, function(k, c){ + if(c.id === childRole.id) { + c.selected = false; + } + }); + }, + + function(data) { + confirmBoxService.showInformation("Error while saving."); + }); + } + }); + + }; + +}); diff --git a/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js index c7a1bfd8..e7195996 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js @@ -1,160 +1,160 @@ -/*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * 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.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog){ - $( "#dialog" ).hide(); - - RoleService.getRoleFunctionList().then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - - //$scope.resetMenu(); - - },function(error){ - console.log("failed"); - //reloadPageOnce(); - }); - - $scope.editRoleFunction = null; - var dialog = null; - $scope.editRoleFunctionPopup = function(availableRoleFunction) { - $scope.editRoleFunction = availableRoleFunction; - $( "#dialog" ).dialog({ - modal: true - }); - }; - - $scope.editRoleFunctionModalPopup = function(availableRoleFunction) { - $scope.editRoleFunction = availableRoleFunction; - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return true; - } - } - }); - modalInstance.closePromise.then(response =>{ - if(response.value!=null){ - if(response.value.result){ - $scope.availableRoleFunctions=response.value.availableRoleFunctions; - } - } - /*else - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - */ - }); - }; - - $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { - - $scope.editRoleFunction = null; - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return false; - } - } - }); - modalInstance.closePromise.then(response => { - if(response.value!=null){ - if(response.value.result){ - $scope.availableRoleFunctions=response.value.availableRoleFunctions; - } - } - /* if(response.availableRoleFunctions != undefined) - $scope.availableRoleFunctions=response.availableRoleFunctions; - else - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - */ - }); - }; - - $scope.addNewRoleFunctionPopup = function() { - $scope.editRoleFunction = null; - $( "#dialog" ).dialog({ - modal: true - }); - }; - - $scope.saveRoleFunction = function(availableRoleFunction) { - var uuu = conf.api.saveRoleFuncion; - var postData={availableRoleFunction: availableRoleFunction}; - $http.post(uuu,postData).then(function(response) { - var data = response.data; - $scope.availableRoleFunctions=data.availableRoleFunctions; - $scope.editRoleFunction = null; - }, - function() { - - confirmBoxService.showInformation("Error while saving"); - } - ); - }; - - - $scope.removeRole = function(availableRoleFunction) { - confirmBoxService.confirm("You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed){ - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - var uuu = conf.api.removeRoleFunction; - var postData={availableRoleFunction: availableRoleFunction}; - $http.post(uuu,postData).then(function(response) { - var data = response.data; - if(data.availableRoleFunctions == undefined) - confirmBoxService.showInformation("Error while deleting: "+ data); - else - $scope.availableRoleFunctions=data.availableRoleFunctions; - }, - function() { - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - } - ); - } - }); - - }; - -}); +/*- + * ================================================================================ + * ECOMP Portal + * ================================================================================ + * 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.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog){ + $( "#dialog" ).hide(); + + RoleService.getRoleFunctionList().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + //reloadPageOnce(); + }); + + $scope.editRoleFunction = null; + var dialog = null; + $scope.editRoleFunctionPopup = function(availableRoleFunction) { + $scope.editRoleFunction = availableRoleFunction; + $( "#dialog" ).dialog({ + modal: true + }); + }; + + $scope.editRoleFunctionModalPopup = function(availableRoleFunction) { + $scope.editRoleFunction = availableRoleFunction; + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + //$scope.availableRoleFunctions={}; + var modalInstance = ngDialog.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + }, + isEditing: function () { + return true; + } + } + }); + modalInstance.closePromise.then(response =>{ + if(response.value!=null){ + if(response.value.result){ + $scope.availableRoleFunctions=response.value.availableRoleFunctions; + } + } + /*else + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + */ + }); + }; + + $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { + + $scope.editRoleFunction = null; + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + //$scope.availableRoleFunctions={}; + var modalInstance = ngDialog.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + }, + isEditing: function () { + return false; + } + } + }); + modalInstance.closePromise.then(response => { + if(response.value!=null){ + if(response.value.result){ + $scope.availableRoleFunctions=response.value.availableRoleFunctions; + } + } + /* if(response.availableRoleFunctions != undefined) + $scope.availableRoleFunctions=response.availableRoleFunctions; + else + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + */ + }); + }; + + $scope.addNewRoleFunctionPopup = function() { + $scope.editRoleFunction = null; + $( "#dialog" ).dialog({ + modal: true + }); + }; + + $scope.saveRoleFunction = function(availableRoleFunction) { + var uuu = conf.api.saveRoleFuncion; + var postData={availableRoleFunction: availableRoleFunction}; + $http.post(uuu,postData).then(function(response) { + var data = response.data; + $scope.availableRoleFunctions=data.availableRoleFunctions; + $scope.editRoleFunction = null; + }, + function() { + + confirmBoxService.showInformation("Error while saving"); + } + ); + }; + + + $scope.removeRole = function(availableRoleFunction) { + confirmBoxService.confirm("You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?").then( + function(confirmed){ + if(confirmed){ + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + //$scope.availableRoleFunctions={}; + var uuu = conf.api.removeRoleFunction; + var postData={availableRoleFunction: availableRoleFunction}; + $http.post(uuu,postData).then(function(response) { + var data = response.data; + if(data.availableRoleFunctions == undefined) + confirmBoxService.showInformation("Error while deleting: "+ data); + else + $scope.availableRoleFunctions=data.availableRoleFunctions; + }, + function() { + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + confirmBoxService.showInformation("Error while deleting: "+ data.responseText); + } + ); + } + }); + + }; + +}); diff --git a/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js index 5ef37165..2e1acf37 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js @@ -1,147 +1,147 @@ -/*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * 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.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http){ - $scope.showSpinner = true; - - RoleService.getRoles().then(function(data){ - $scope.showSpinner = true; - var j = data; - $scope.data = JSON.parse(j.data); - $scope.availableRoles =JSON.parse($scope.data.availableRoles); - $scope.showSpinner = false; - //$scope.resetMenu(); - - },function(error){ - console.log("failed"); - //reloadPageOnce(); - }); - - - $scope.goToUrl = function(roleIdVal) { - $state.go("root.role", {"roleId":roleIdVal}); - } - //console.log($scope.availableRoles); - $scope.toggleRole = function(selected,availableRole) { - //alert('toggleRole: '+selected); - var toggleType = null; - if(selected) { - toggleType = "activate"; - } else { - toggleType = "inactivate"; - } - - confirmBoxService.confirm("You are about to "+toggleType+" the role "+availableRole.name+". Do you want to continue?").then( - function(confirmed){ - - if(confirmed) { - var uuu = conf.api.toggleRole; - - var postData={role:availableRole}; - $http.post(uuu, postData).then(function(response) { - var data = response.data; - if (typeof data === 'object') { - console.log(data); - $scope.availableRoles=data.availableRoles; - console.log($scope.availableRoles); - } else { - // - } - - }, function(response) { - console.log(response.data); - availableRole.active=!availableRole.active; - confirmBoxService.showInformation("Error while saving."); - }); - - /* - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - console.log(data); - $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); - console.log($scope.availableRoles); - }, - error : function(data){ - console.log(data); - availableRole.active=!availableRole.active; - confirmBoxService.showInformation("Error while saving."); - } - }); - */ - } - else { - availableRole.active=!availableRole.active; - } - - }); - //, - //function(){ - // availableRole.active=!availableRole.active; - //}) - - - }; - - $scope.removeRole = function(role) { - - confirmBoxService.confirm("You are about to delete the role "+role.name+". Do you want to continue?").then( - function(confirmed){ - var uuu = conf.api.removeRole; - var postData={role:role}; - /* $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); - }, - error : function(data){ - console.log(data); - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - } - }); */ - - - $http.post(uuu, postData).then(function(response) { - var data = response.data; - if (typeof data === 'object') { - $scope.availableRoles=data.availableRoles; - } else { - // - } - - }, function(response) { - console.log(response.data); - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - }); - - }); - - - }; - - -}); +/*- + * ================================================================================ + * ECOMP Portal + * ================================================================================ + * 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.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http){ + $scope.showSpinner = true; + + RoleService.getRoles().then(function(data){ + $scope.showSpinner = true; + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoles =JSON.parse($scope.data.availableRoles); + $scope.showSpinner = false; + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + //reloadPageOnce(); + }); + + + $scope.goToUrl = function(roleIdVal) { + $state.go("root.role", {"roleId":roleIdVal}); + } + //console.log($scope.availableRoles); + $scope.toggleRole = function(selected,availableRole) { + //alert('toggleRole: '+selected); + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + + confirmBoxService.confirm("You are about to "+toggleType+" the role "+availableRole.name+". Do you want to continue?").then( + function(confirmed){ + + if(confirmed) { + var uuu = conf.api.toggleRole; + + var postData={role:availableRole}; + $http.post(uuu, postData).then(function(response) { + var data = response.data; + if (typeof data === 'object') { + console.log(data); + $scope.availableRoles=data.availableRoles; + console.log($scope.availableRoles); + } else { + // + } + + }, function(response) { + console.log(response.data); + availableRole.active=!availableRole.active; + confirmBoxService.showInformation("Error while saving."); + }); + + /* + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + console.log(data); + $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); + console.log($scope.availableRoles); + }, + error : function(data){ + console.log(data); + availableRole.active=!availableRole.active; + confirmBoxService.showInformation("Error while saving."); + } + }); + */ + } + else { + availableRole.active=!availableRole.active; + } + + }); + //, + //function(){ + // availableRole.active=!availableRole.active; + //}) + + + }; + + $scope.removeRole = function(role) { + + confirmBoxService.confirm("You are about to delete the role "+role.name+". Do you want to continue?").then( + function(confirmed){ + var uuu = conf.api.removeRole; + var postData={role:role}; + /* $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); + }, + error : function(data){ + console.log(data); + confirmBoxService.showInformation("Error while deleting: "+ data.responseText); + } + }); */ + + + $http.post(uuu, postData).then(function(response) { + var data = response.data; + if (typeof data === 'object') { + $scope.availableRoles=data.availableRoles; + } else { + // + } + + }, function(response) { + console.log(response.data); + confirmBoxService.showInformation("Error while deleting: "+ data.responseText); + }); + + }); + + + }; + + +}); diff --git a/ecomp-portal-FE-common/client/app/views/role/role.html b/ecomp-portal-FE-common/client/app/views/role/role.html index 42793eee..2356058d 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.html +++ b/ecomp-portal-FE-common/client/app/views/role/role.html @@ -1,96 +1,96 @@ - -
-
-
-

Role

-
-
-
-
-

Please edit the role details below: 


- -
- - -
- - -
-
-
- -
- -
-
- - -
- -
- - - - - - - - - - - - - -
NameRemove
-
-
-
- - Manage Role Functions

- -
- - -
- -
- - - - - - - - - - - - - -
NameRemove
-
-
-
-
- -
-
-
+ +
+
+
+

Role

+
+
+
+
+

Please edit the role details below: 


+ +
+ + +
+ + +
+
+
+ +
+ +
+
+ + +
+ +
+ + + + + + + + + + + + + +
NameRemove
+
+
+
+ + Manage Role Functions

+ +
+ + +
+ +
+ + + + + + + + + + + + + +
NameRemove
+
+
+
+
+ +
+
+
diff --git a/ecomp-portal-FE-common/client/app/views/role/role.less b/ecomp-portal-FE-common/client/app/views/role/role.less index 42311e64..71d240dc 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.less +++ b/ecomp-portal-FE-common/client/app/views/role/role.less @@ -1,50 +1,50 @@ -.p-info { - font-size: 18px; -} - -.input-field { - width: 250px !important; -} - -.scrolling-table { - width: 548px; - margin-left: 16px; - height:575px; - overflow:auto; -} - -.scrolling-table .scroll-viewport { - height: 200px !important; - width: 99.5% !important; - background-color: white; -} - -.scrolling-table .scroll-overview { - margin-top: -14px !important; -} - -.scrolling-table .scroll-viewport:hover { - background-color: white; -} - -.scrolling-table #portal-scroll-table-content { - height: 200px; - position: absolute !important; - width: 548px; - padding-left: 0px; - padding-top: 0px; - padding-bottom: 0px; - padding-right: 5px; -} - -.vertical .scroll-thumb { - width: 13px !important; -} - -.vertical .scroll-bar { - width: 15px !important; -} - -.scroll-bar { - border-radius: 0px !important; +.p-info { + font-size: 18px; +} + +.input-field { + width: 250px !important; +} + +.scrolling-table { + width: 548px; + margin-left: 16px; + height:575px; + overflow:auto; +} + +.scrolling-table .scroll-viewport { + height: 200px !important; + width: 99.5% !important; + background-color: white; +} + +.scrolling-table .scroll-overview { + margin-top: -14px !important; +} + +.scrolling-table .scroll-viewport:hover { + background-color: white; +} + +.scrolling-table #portal-scroll-table-content { + height: 200px; + position: absolute !important; + width: 548px; + padding-left: 0px; + padding-top: 0px; + padding-bottom: 0px; + padding-right: 5px; +} + +.vertical .scroll-thumb { + width: 13px !important; +} + +.vertical .scroll-bar { + width: 15px !important; +} + +.scroll-bar { + border-radius: 0px !important; } \ No newline at end of file diff --git a/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html b/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html index 278ef2cd..e96fb062 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html @@ -1,51 +1,55 @@ - - -
-
Select Role Functions
-
- -
- - - - - - - - - - - - - - -
Name
- -
-
-
-
- -
-
- + + +
+
Select Role Functions
+
+ +
+ + + + + + + + + + + + + + +
Name
+ +
+
+
+
+ +
+
+ diff --git a/ecomp-portal-FE-common/client/app/views/role/role_function_list.html b/ecomp-portal-FE-common/client/app/views/role/role_function_list.html index c015ee56..7c50a5ac 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_function_list.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_function_list.html @@ -1,107 +1,107 @@ - - -
-
-
-

Role Functions

-
- - -
- -
- - -
- -
- -
- -
- -
- - - - - - - - - - - - - - - - - -
NameCodeEdit?Delete?
- -
-
- -
-
-
- - - -
- - -
- -
-
- -
-
-
-
- -
-
- - -
- -
-
+ + +
+
+
+

Role Functions

+
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + +
NameCodeEdit?Delete?
+ +
+
+ +
+
+
+ + + +
+ + +
+ +
+
+ +
+
+
+
+ +
+
+ + +
+ +
+
diff --git a/ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html b/ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html index 7d80d81e..52c4cb3a 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html @@ -1,49 +1,55 @@ - - -
-
Select Role Functions
-
-
- - - - - - - - - - - - - - -
Name
- -
-
-
-
- -
-
+ + +
+
Select Role Functions
+
+
+ + + + + + + + + + + + + + +
Name
+ +
+
+
+
+ +
+
+ + diff --git a/ecomp-portal-FE-common/client/app/views/role/role_list.html b/ecomp-portal-FE-common/client/app/views/role/role_list.html index e8d56cab..74de7c23 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_list.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_list.html @@ -1,55 +1,57 @@ - -
-
-
-

Roles

-
-
-
- -
-
- - - - - - - - - - - - - - - -
NamePriorityActive
-
- -
-
-
-
-
-
+ +
+
+
+

Roles

+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + +
NamePriorityActiveEdit
+
+ +
+
+
+
+
+
diff --git a/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js index 6275c760..db5bb1b6 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js @@ -1,95 +1,95 @@ -/*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * 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.controller('rolefunctionpopupController', function ($scope, confirmBoxService, message, $http,RoleService, conf, isEditing){ - if(message.availableRoleFunction==null) { - $scope.label='Add Role Function'; - var tempText = ""; - } - else{ - $scope.label='Edit Role Function' - $scope.disableCd=true; - var tempText = new String(message.availableRoleFunction.name); - $scope.editRoleFunction = angular.copy(message.availableRoleFunction); - } - - $scope.tempText = tempText; - $scope.isEditing = isEditing; - - $scope.saveRoleFunction = function(availableRoleFunction) { - var uuu = conf.api.saveRoleFunction; - var postData={availableRoleFunction: availableRoleFunction}; - - if(availableRoleFunction==null){ - confirmBoxService.showInformation("Please enter valid role function details."); - } - var exists = false,x; - for(x in message.availableRoleFunctions){ - console.log(message.availableRoleFunctions[x].name); - if(message.availableRoleFunctions[x].name==availableRoleFunction.name){ - confirmBoxService.showInformation("Role Function already exists."); - exists = true; - availableRoleFunction.name = $scope.tempText; - break; - } - if(!isEditing){ - if (message.availableRoleFunctions[x].code == availableRoleFunction.code) { - confirmBoxService.showInformation("Code already exists. Please create a role function with a different code to proceed."); - exists = true; - availableRoleFunction.name = $scope.tempText; - break; - } - } - } - - if(!exists && availableRoleFunction.name.trim() != '' && availableRoleFunction.code.trim() != ''){ - $http.post(uuu, JSON.stringify(postData)).then(function(res){ - console.log("data"); -// console.log(res.data); -// $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions; - RoleService.getRoleFunctionList().then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - - //$scope.resetMenu(); - $scope.closeThisDialog({result: true, availableRoleFunctions: $scope.availableRoleFunctions }); - },function(error){ - console.log("failed"); - //reloadPageOnce(); - $scope.closeThisDialog(true); - }); - - - }); - - - - - } - }; - - - - $scope.close = function() { - this.closeThisDialog(true); - }; -} -); +/*- + * ================================================================================ + * ECOMP Portal + * ================================================================================ + * 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.controller('rolefunctionpopupController', function ($scope, confirmBoxService, message, $http,RoleService, conf, isEditing){ + if(message.availableRoleFunction==null) { + $scope.label='Add Role Function'; + var tempText = ""; + } + else{ + $scope.label='Edit Role Function' + $scope.disableCd=true; + var tempText = new String(message.availableRoleFunction.name); + $scope.editRoleFunction = angular.copy(message.availableRoleFunction); + } + + $scope.tempText = tempText; + $scope.isEditing = isEditing; + + $scope.saveRoleFunction = function(availableRoleFunction) { + var uuu = conf.api.saveRoleFunction; + var postData={availableRoleFunction: availableRoleFunction}; + + if(availableRoleFunction==null){ + confirmBoxService.showInformation("Please enter valid role function details."); + } + var exists = false,x; + for(x in message.availableRoleFunctions){ + console.log(message.availableRoleFunctions[x].name); + if(message.availableRoleFunctions[x].name==availableRoleFunction.name){ + confirmBoxService.showInformation("Role Function already exists."); + exists = true; + availableRoleFunction.name = $scope.tempText; + break; + } + if(!isEditing){ + if (message.availableRoleFunctions[x].code == availableRoleFunction.code) { + confirmBoxService.showInformation("Code already exists. Please create a role function with a different code to proceed."); + exists = true; + availableRoleFunction.name = $scope.tempText; + break; + } + } + } + + if(!exists && availableRoleFunction.name.trim() != '' && availableRoleFunction.code.trim() != ''){ + $http.post(uuu, JSON.stringify(postData)).then(function(res){ + console.log("data"); +// console.log(res.data); +// $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions; + RoleService.getRoleFunctionList().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + + //$scope.resetMenu(); + $scope.closeThisDialog({result: true, availableRoleFunctions: $scope.availableRoleFunctions }); + },function(error){ + console.log("failed"); + //reloadPageOnce(); + $scope.closeThisDialog(true); + }); + + + }); + + + + + } + }; + + + + $scope.close = function() { + this.closeThisDialog(true); + }; +} +); diff --git a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js index 7feb7f2f..1176e50a 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js @@ -1,251 +1,251 @@ -/*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * 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.controller('rolepopupController', function ($scope, role, roleId, confirmBoxService, $http, $state, availableRoles, conf, availableRoleFunctions,ngDialog){ - - $scope.role = role; - console.log($scope.role); - if($scope.role.childRoles==null){ - $scope.role.childRoles=[]; - } - - $scope.ociavailableRoles=availableRoles; - console.log($scope.ociavailableRoles); - - $scope.availableRoles=[]; - if($scope.ociavailableRoles) - $.each($scope.ociavailableRoles, function(i, a){ - var availableRole = a; - availableRole.selected = false; - if($scope.role.childRoles){ - $.each($scope.role.childRoles, function(j, b){ - if(a.id === b.id) { - availableRole.selected = true; - } - }); - }; - $scope.availableRoles.push(availableRole); - }); - - $scope.ociavailableRoleFunctions = availableRoleFunctions; - console.log($scope.ociavailableRoleFunctions); - $scope.availableRoleFunctions = []; - if($scope.ociavailableRoleFunctions) - $.each($scope.ociavailableRoleFunctions, function(i, a){ - var availableRoleFunction = a; - availableRoleFunction.selected = false; - $.each($scope.role.roleFunctions, function(j, b){ - if(a.code === b.code) { - availableRoleFunction.selected = true; - } - }); - $scope.availableRoleFunctions.push(availableRoleFunction); - }); - //$scope.resetMenu(); - - $scope.toggleRoleFunction = function(selected,availableRoleFunction) { - //alert('toggleRole: '+selected); - - if(!selected) { - //remove role function - if(role.id==null){ - var index = $scope.role.roleFunctions.indexOf(availableRoleFunction); - if(index>=0) - $scope.role.roleFunctions.splice(index, 1); - return; - } - var uuu = conf.api.toggleRoleRoleFunction + "?role_id=" + roleId; - confirmBoxService.confirm("You are about to remove the role function "+availableRoleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed) { - var postData={roleFunction:availableRoleFunction}; - $http.post(uuu, postData).then( - function(response) { - $scope.role= response.data.role; - }, - function(response) { - confirmBoxService.showInformation("Error while saving."); - } - ); - - - - - } - else { - availableRoleFunction.selected=!availableRoleFunction.selected; - } - /* - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.role=data.role;}); - }, - error : function(data){ - modalService.showFailure("Fail","Error while saving."); - } - }); - */ - }); - - } else { - //add role function - if(role.id==null){ - $scope.role.roleFunctions.push(availableRoleFunction); - return; - } - var uuu = conf.api.addRoleRoleFunction + "?role_id=" + roleId; - - confirmBoxService.confirm("You are about to add the role function "+availableRoleFunction.name+" to the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed) { - var postData={roleFunction:availableRoleFunction}; - $http.post(uuu,postData).then( function(response) { - $scope.role=response.data.role; - }, - - function(data) { - confirmBoxService.showInformation("Error while saving."); - }); - } else { - availableRoleFunction.selected=!availableRoleFunction.selected; - } - /* - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.role=data.role;}); - }, - error : function(data){ - modalService.showFailure("Fail","Error while saving."); - } - }); - - - }, - function(){ - availableRoleFunction.selected=!availableRoleFunction.selected; - })*/ - }); - - - } - }; - - $scope.toggleChildRole = function(selected,availableRole) { - //alert('toggleRole: '+selected); - - if(!selected) { - //remove role - if(role.id==null){ - var index = $scope.role.childRoles.indexOf(availableRole); - if(index>=0) - $scope.role.childRoles.splice(index, 1); - return; - } - var uuu = conf.api.toggleRoleChildRole +"?role_id=" + roleId; - - confirmBoxService.confirm("You are about to remove the child role "+availableRole.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed) { - - var postData={childRole:availableRole}; - $http.post(uuu,postData).then(function(response) { - $scope.role=response.data.role; - }, - function(data) { - confirmBoxService.showInformation("Error while saving."); - }); - } else { - availableRole.selected=false; - } - }); - /* $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - console.log('role',data.role); - $scope.$apply(function(){$scope.role=data.role;}); - }, - error : function(data){ - modalService.showFailure("Fail","Error while saving."); - } - }); - */ - - - } else { - //add role - if(role.id==null){ - $scope.role.childRoles.push(availableRole); - return; - } - var uuu = conf.api.addRoleChildRole +"?role_id=" + roleId; - - confirmBoxService.confirm("You are about to add the child role "+availableRole.name+" to the role for "+$scope.role.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed) { - var postData={childRole:availableRole}; - $http.post(uuu,postData).then(function(response) { - $scope.role=response.data.role; - }, - function(data) { - confirmBoxService.showInformation("Error while saving."); - }); - } else { - availableRole.selected=false; - } - /* $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.role=data.role;}); - }, - error : function(data){ - modalService.showFailure("Fail","Error while saving."); - } - });*/ - - }); - - - } - }; - - $scope.close = function() { - console.log('role', $scope.role); - //$modalInstance.close({role:$scope.role}); - this.closeThisDialog(true); - }; - -}); +/*- + * ================================================================================ + * ECOMP Portal + * ================================================================================ + * 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.controller('rolepopupController', function ($scope, role, roleId, confirmBoxService, $http, $state, availableRoles, conf, availableRoleFunctions,ngDialog){ + + $scope.role = role; + console.log($scope.role); + if($scope.role.childRoles==null){ + $scope.role.childRoles=[]; + } + + $scope.ociavailableRoles=availableRoles; + console.log($scope.ociavailableRoles); + + $scope.availableRoles=[]; + if($scope.ociavailableRoles) + $.each($scope.ociavailableRoles, function(i, a){ + var availableRole = a; + availableRole.selected = false; + if($scope.role.childRoles){ + $.each($scope.role.childRoles, function(j, b){ + if(a.id === b.id) { + availableRole.selected = true; + } + }); + }; + $scope.availableRoles.push(availableRole); + }); + + $scope.ociavailableRoleFunctions = availableRoleFunctions; + console.log($scope.ociavailableRoleFunctions); + $scope.availableRoleFunctions = []; + if($scope.ociavailableRoleFunctions) + $.each($scope.ociavailableRoleFunctions, function(i, a){ + var availableRoleFunction = a; + availableRoleFunction.selected = false; + $.each($scope.role.roleFunctions, function(j, b){ + if(a.code === b.code) { + availableRoleFunction.selected = true; + } + }); + $scope.availableRoleFunctions.push(availableRoleFunction); + }); + //$scope.resetMenu(); + + $scope.toggleRoleFunction = function(selected,availableRoleFunction) { + //alert('toggleRole: '+selected); + + if(!selected) { + //remove role function + if(role.id==null){ + var index = $scope.role.roleFunctions.indexOf(availableRoleFunction); + if(index>=0) + $scope.role.roleFunctions.splice(index, 1); + return; + } + var uuu = conf.api.toggleRoleRoleFunction + "?role_id=" + roleId; + confirmBoxService.confirm("You are about to remove the role function "+availableRoleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + if(confirmed) { + var postData={roleFunction:availableRoleFunction}; + $http.post(uuu, postData).then( + function(response) { + $scope.role= response.data.role; + }, + function(response) { + confirmBoxService.showInformation("Error while saving."); + } + ); + + + + + } + else { + availableRoleFunction.selected=!availableRoleFunction.selected; + } + /* + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.role=data.role;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + */ + }); + + } else { + //add role function + if(role.id==null){ + $scope.role.roleFunctions.push(availableRoleFunction); + return; + } + var uuu = conf.api.addRoleRoleFunction + "?role_id=" + roleId; + + confirmBoxService.confirm("You are about to add the role function "+availableRoleFunction.name+" to the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + if(confirmed) { + var postData={roleFunction:availableRoleFunction}; + $http.post(uuu,postData).then( function(response) { + $scope.role=response.data.role; + }, + + function(data) { + confirmBoxService.showInformation("Error while saving."); + }); + } else { + availableRoleFunction.selected=!availableRoleFunction.selected; + } + /* + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.role=data.role;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + + + }, + function(){ + availableRoleFunction.selected=!availableRoleFunction.selected; + })*/ + }); + + + } + }; + + $scope.toggleChildRole = function(selected,availableRole) { + //alert('toggleRole: '+selected); + + if(!selected) { + //remove role + if(role.id==null){ + var index = $scope.role.childRoles.indexOf(availableRole); + if(index>=0) + $scope.role.childRoles.splice(index, 1); + return; + } + var uuu = conf.api.toggleRoleChildRole +"?role_id=" + roleId; + + confirmBoxService.confirm("You are about to remove the child role "+availableRole.name+" from the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + if(confirmed) { + + var postData={childRole:availableRole}; + $http.post(uuu,postData).then(function(response) { + $scope.role=response.data.role; + }, + function(data) { + confirmBoxService.showInformation("Error while saving."); + }); + } else { + availableRole.selected=false; + } + }); + /* $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + console.log('role',data.role); + $scope.$apply(function(){$scope.role=data.role;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + */ + + + } else { + //add role + if(role.id==null){ + $scope.role.childRoles.push(availableRole); + return; + } + var uuu = conf.api.addRoleChildRole +"?role_id=" + roleId; + + confirmBoxService.confirm("You are about to add the child role "+availableRole.name+" to the role for "+$scope.role.name+". Do you want to continue?").then( + function(confirmed){ + if(confirmed) { + var postData={childRole:availableRole}; + $http.post(uuu,postData).then(function(response) { + $scope.role=response.data.role; + }, + function(data) { + confirmBoxService.showInformation("Error while saving."); + }); + } else { + availableRole.selected=false; + } + /* $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.role=data.role;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + });*/ + + }); + + + } + }; + + $scope.close = function() { + console.log('role', $scope.role); + //$modalInstance.close({role:$scope.role}); + this.closeThisDialog(true); + }; + +}); -- cgit 1.2.3-korg