diff options
Diffstat (limited to 'ecomp-portal-FE-common/client/app/views/role')
14 files changed, 1151 insertions, 576 deletions
diff --git a/ecomp-portal-FE-common/client/app/views/role/popup_createedit_role.html b/ecomp-portal-FE-common/client/app/views/role/popup_createedit_role.html new file mode 100644 index 00000000..dc4e00da --- /dev/null +++ b/ecomp-portal-FE-common/client/app/views/role/popup_createedit_role.html @@ -0,0 +1,137 @@ +<!-- + ============LICENSE_START========================================== + ONAP Portal + =================================================================== + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + =================================================================== + + Unless otherwise specified, all software contained herein is licensed + under the Apache License, Version 2.0 (the "License"); + you may not use this software 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. + + Unless otherwise specified, all documentation contained herein is licensed + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + you may not use this documentation except in compliance with the License. + You may obtain a copy of the License at + + https://creativecommons.org/licenses/by/4.0/ + + Unless required by applicable law or agreed to in writing, documentation + 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. + + ============LICENSE_END============================================ + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + --> + <style> + .checkbox .skin { + left: 112px; + top: -8px; +} +.checkbox input { + margin: 0px; + left: 105px; + height: 20px; + top: -4px; + } +.checkbox span { + display: inline-block; + margin-left: 1px; + margin-top: 0; + position: relative; + top: -3px; +} +.property-label { + margin-right: 40px; +} +.dialog-control { + bottom: 170px; + position: fixed; + right: 588px; +} +.header-txt{ + font-size: 30px; +} + </style> + <div class="b2b-modal-header"> + <div id="title" class="w-ecomp-main-view-title"> + <h1 id="role" class="header-txt" >Role</h1> + </div> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" id="button-cancel-role" + ng-click="$dismiss('cancel')"></button> + </div> + </div> + + <div class="b2b-modal-body"> + <p class="p-info">Please <span ng-if="roleId != ''">edit</span> <span ng-if="roleId == ''">add</span> the role details below: </p><br> + + <div ng-show ="isGlobalRole" class="property-label checkbox-label"> + <label for="checkbox-app-is-restricted" class="checkbox"> + <input type="checkbox" ng-model="isGlobalRoleChecked.isChecked" id="checkbox-app-is-restricted" ng-checked="isGlobalRoleChecked.isChecked" /> + <i id="checkbox-app-is-restricted" class="skin"></i> + <span>Global Roles: </span> + </label> + </div> + + <div id="role-text" > + <label id="role-text-name-label" >*Name:</label> + <input id="input-name" class="input-field" maxlength="300" type="text" data-ng-model="role.name" ng-disabled = "isGlobalRoleChecked.isChecked && appId != 1"> + <br> + <label id="role-text-priority-label">Priority:</label> + <input id="input-priority" class="input-field" maxlength="30" type="text" data-ng-model="role.priority" ng-disabled = "isGlobalRoleChecked.isChecked && appId != 1"> + </div> + <br/> + <div class="scrolling-table"> + <div ng-if="roleFunctions.length"> + <div id="page-title" class="pageTitle"> + <label>Role Functions</label> + </div> + <div b2b-table table-data="availableRoleFunctions" class="b2b-table-div"> + <span class="ecomp-spinner" ng-show="isLoadingRoleFunctions"></span> + <table> + <thead b2b-table-row type="header"> + <tr> + <th b2b-table-header key="firstName" sortable="true" id="col1"></th> + <th b2b-table-header key="name" sortable="true" id="col2">Name</th> + </tr> + </thead> + <tbody b2b-table-row type="body" + row-repeat="rowData in availableRoleFunctions"> + <tr> + <td b2b-table-body id="rowheader_t1_{{$index}}" headers="col1"> + <label class="btn-switch-label" tabindex="0" role="option"> + <input id="row-input-{{$index}}" type="checkbox" b2b-switches + ng-model="rowData.selected" + ng-click="toggleRoleFunction(rowData.selected,rowData);"> + </label> + </td> + <td b2b-table-body headers="rowheader_t1_{{$index}} col2" + ng-bind="rowData.name"></td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + </div> + + <div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button id="button-app-save" class="btn btn-alt btn-small" size="small" ng-click="saveRole(role, editRoleFunction);" href="javascript:void(0)">Save</button> + + <button id="button-app-cancel" class="btn btn-alt btn-small" ng-click="$dismiss('cancel')" role="button" tabindex="0" href="javascript:void(0)">Cancel</button> + </div> + </div>
\ No newline at end of file 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 da8a5b31..5322dc60 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 @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at @@ -35,90 +35,135 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. --> - <style> - .dialog-control { - position: relative; - bottom: -13px; - right: 0px; -} - </style> <style> - .dialog-control { - position: relative; - bottom: -13px; - right: 0px; +.dialog-control { + position: relative; + bottom: -13px; + right: 0px; } - </style> +</style> <!-- <link rel="stylesheet" href="role.css"> - --><div class="new-admin-modal"> - <div class="b2b-modal-header"> - + --> +<div class="new-admin-modal" style="height: 600px;"> + <div class="b2b-modal-header"> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" id="button-cancel-role" - ng-click="$dismiss('cancel')"></button> - </div> + + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + id="button-cancel-role" ng-click="$dismiss('cancel')"></button> </div> + </div> - <div class="b2b-modal-body"> + <div class="b2b-modal-body"> <form id="admin-details-form" name="adminForm" novalidate> - <div class="title" ng-bind="label" class="adminForm-title"></div> -<br> - <div > - <div class="item-label"> <span ID="required" style="color: Red;" - visible="false"> *</span>Name:</div> - <input id="name-property-input" - class="adminForm-name-property-input" ng-model="editRoleFunction.name" - type="text" maxlength="30" - /> + <div class="title" ng-bind="label" class="adminForm-title"></div> + <br> + <div> + <div class="item-label"> + <span ID="required" style="color: Red;" visible="false"> *</span>Type: + <fieldset style="height: 75px;" role="radiogroup" + b2b-radio-group-accessibility aria-labelledby="radiolabel2"> + <div class="form-row" role="radio" + ng-repeat="radioObj in ngRepeatDemo"> + <label style="margin-top: 10px;" for="{{radioObj.id}}" + class="radio"> <input type="radio" + ng-model="selectedvalueradioButtonGroup.type" + id="{{radioObj.id}}" ng-disabled="disableCd" + name="nameradioButton" value="{{radioObj.value}}"> <i + style="margin-top: 10px;" class="skin"></i> <span + style="margin-top: 10px;">{{radioObj.labelvalue}}</span> + </label> + </div> + </fieldset> + <br> <input + ng-show="selectedvalueradioButtonGroup.type === 'other'" + id="type-property-input" class="adminForm-name-property-input" + ng-model="editRoleFunction.type" ng-disabled="disableCd" + type="text" maxlength="30" /> + </div> + <div class="error-container" + ng-show="selectedvalueradioButtonGroup.type === 'other'&&(!editRoleFunction.type||editRoleFunction.type.length==0)"> + <small id="microservices-details-input-url-required" + class="err-message">Type is Required</small> + </div> + </div> + <br> + <div> + <div class="item-label"> + <span ID="required" style="color: Red;" visible="false"> *</span>Instance: + </div> + <input id="code-property-input" + class="adminForm-code-property-input" + ng-model="editRoleFunction.code" ng-disabled="disableCd" + type="text" maxlength="250" /> - <div class="error-container" - ng-show="!editRoleFunction.name||editRoleFunction.name.length==0"> - <small id="microservices-details-input-url-required" - class="err-message">Name is Required</small> - </div> + <div class="error-container" + ng-show="!editRoleFunction.code||editRoleFunction.code.length==0"> + <small id="code-property-required" class="err-message">Instance + is Required</small> + </div> + </div> + <br> + <div> + <div class="item-label"> + <span ID="required" style="color: Red;" visible="false"> *</span>Action: + </div> + <input id="action-property-input" + class="adminForm-name-property-input" + ng-model="editRoleFunction.action" ng-disabled="disableCd" + type="text" maxlength="30" /> + <div class="error-container" + ng-show="!editRoleFunction.action||editRoleFunction.action.length==0"> + <small id="microservices-details-input-url-required" + class="err-message">Action is Required</small> </div> - <br> - <div > - <div class="item-label"> <span ID="required" style="color: Red;" - visible="false"> *</span>Code:</div> - <input id="code-property-input" - class="adminForm-code-property-input" ng-model="editRoleFunction.code" ng-disabled="disableCd" - type="text" maxlength="30" - /> + </div> + <br> + <div> + <div class="item-label"> + <span ID="required" style="color: Red;" visible="false"> *</span>Name: + </div> + <input id="name-property-input" + class="adminForm-name-property-input" + ng-model="editRoleFunction.name" type="text" maxlength="50" /> - <div class="error-container" - ng-show="!editRoleFunction.code||editRoleFunction.code.length==0"> - <small id="code-property-required" - class="err-message">Code is Required</small> - </div> + <div class="error-container" + ng-show="!editRoleFunction.name||editRoleFunction.name.length==0"> + <small id="microservices-details-input-url-required" + class="err-message">Name is Required</small> </div> - + </div> + <br> + <div class="item-label"> + <span style="color: #0568ae; font-size: 20px;" + class="icon-numslets-flat-info"></span> Code: <span + ng-show="selectedvalueradioButtonGroup.type !== 'other'">{{selectedvalueradioButtonGroup.type}}|{{editRoleFunction.code}}|{{editRoleFunction.action}}</span> + <span ng-show="selectedvalueradioButtonGroup.type === 'other'">{{editRoleFunction.type}}|{{editRoleFunction.code}}|{{editRoleFunction.action}}</span> + </div> </form> </div> - - <div class="b2b-modal-footer"> - <div class="dialog-control"> - -<button id="button-app-save" class="btn btn-alt btn-small" size="small" ng-disabled="(!editRoleFunction.name||editRoleFunction.name.length==0)||(!editRoleFunction.code||editRoleFunction.code.length==0 )" ng-click="!saveRoleFunction(editRoleFunction)";herf="javascript:void(0)">Save</button> - - <div id="button-app-cancel" class="btn btn-alt btn-small" ng-click="$dismiss('cancel')" role="button" tabindex="0" herf="javascript:void(0)">Cancel</div> - </div> - - <!-- <div class="dialog-control"> -<button id="button-app-save" class="btn btn-alt btn-small" size="small" ng-disabled="(!editRoleFunction.name||editRoleFunction.name.length==0)||(!editRoleFunction.code||editRoleFunction.code.length==0 )" ng-click="!saveRoleFunction(editRoleFunction)";herf="javascript:void(0)">Save</button> + <div class="b2b-modal-footer"> + <div class="dialog-control"> + + <button id="button-app-save" class="btn btn-alt btn-small" + size="small" + ng-disabled="(!editRoleFunction.name||editRoleFunction.name.length==0)||(!editRoleFunction.code||editRoleFunction.code.length==0 )||(!editRoleFunction.action||editRoleFunction.action.length==0) + ||(!selectedvalueradioButtonGroup.type||selectedvalueradioButtonGroup.type.length==0)||(selectedvalueradioButtonGroup.type ==='other'&&(!editRoleFunction.type||editRoleFunction.type.length==0))" + ng-click="!saveRoleFunction(editRoleFunction,selectedvalueradioButtonGroup.type)" + herf="javascript:void(0)">Save</button> + + <div id="button-app-cancel" class="btn btn-alt btn-small" + ng-click="$dismiss('cancel')" role="button" tabindex="0" + herf="javascript:void(0)">Cancel</div> + </div> + </div> -<div id="button-app-cancel" class="btn btn-alt btn-small" ng-click="closeThisDialog()" role="button" tabindex="0" herf="javascript:void(0)">Cancel</div> -</div> --> - </div> - </div> <script> -$(document).ready(function(){ - $(".ngdialog-close").attr('id','dialog-close'); -}); -</script> - + $(document).ready(function() { + $(".ngdialog-close").attr('id', 'dialog-close'); + }); +</script>
\ No newline at end of file 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 22b28e93..2d6f84dc 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,21 +1,39 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ @@ -43,7 +61,7 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD $scope.routeRoleId = $stateParams.roleId; $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); $scope.isGlobalRoleChecked=($scope.role.name.indexOf('global_')==-1)?false:true; - + $scope.availableRoleFunctions=[]; if($scope.ociavailableRoleFunctions) @@ -105,6 +123,11 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD }else{ $scope.role.name=$scope.role.name.replace('global_',''); } + for(let key in $scope.role.roleFunctions){ + if($scope.role.roleFunctions[key].hasOwnProperty('selected')){ + delete $scope.role.roleFunctions[key].selected; + } + } var postData = { role: $scope.role, childRoles: $scope.role.childRoles, @@ -154,11 +177,6 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD }); modalInstance.result.finally(function () { - if($stateParams.roleId === '0'){ - return $scope.role; - }else{ - $scope.fetchRoles(); - } }); }; @@ -195,22 +213,11 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD $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."); - } - ); + var index = $scope.role.roleFunctions.indexOf(roleFunction); + if(index>=0) + $scope.role.roleFunctions.splice(index, 1); + return; } }); diff --git a/ecomp-portal-FE-common/client/app/views/role/role-create-edit-popup-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-create-edit-popup-controller.js new file mode 100644 index 00000000..6475a83d --- /dev/null +++ b/ecomp-portal-FE-common/client/app/views/role/role-create-edit-popup-controller.js @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +app.controller('roleCreateEditController',function($scope, conf, $http, $modalInstance, confirmBoxService, message, RoleService) { + $scope.isGlobalRole = false; + $scope.availableRoles = message.availableRoles; + $scope.roleFunctions = message.availableRoleFunctions; + $scope.appId = message.appId; + if($scope.appId == 1){ + $scope.isGlobalRole = true; + } + $scope.role = message.role; + $scope.isGlobalRoleChecked={ + isChecked : false + } + if(message.role.name) + $scope.isGlobalRoleChecked.isChecked=(message.role.name.indexOf('global_')==-1)?false:true; + $scope.availableRoleFunctions=[]; + $scope.finalSelectedRoleFunctions=[]; + + if($scope.roleFunctions) + for(var i=0; i< $scope.roleFunctions.length; i++){ + var availableRoleFunction = $scope.roleFunctions[i]; + availableRoleFunction.selected = false; + for(var j=0; j< $scope.role.roleFunctions.length; j++){ + if($scope.roleFunctions[i].code === $scope.role.roleFunctions[j].code) { + availableRoleFunction.selected = true; + console.log(availableRoleFunction.selected); + } + }; + $scope.availableRoleFunctions.push(availableRoleFunction); + }; + + $scope.toggleRoleFunction = function(selected,selectedRoleFunction){ + if($scope.roleFunctions){ + for(var i=0; i< $scope.roleFunctions.length; i++){ + var availableRoleFunction = $scope.roleFunctions[i]; + if(availableRoleFunction.selected){ + $scope.finalSelectedRoleFunctions.push(availableRoleFunction); + } + } + } + if(!selected) { + for(var i=0; i<$scope.finalSelectedRoleFunctions.length; i++){ + var availableRoleFunction = $scope.finalSelectedRoleFunctions[i]; + if(availableRoleFunction.code == selectedRoleFunction.code){ + $scope.finalSelectedRoleFunctions.splice(i, 1); + } + } + } + } + + + $scope.saveRole = function() { + var exists = false,x; + for(x in $scope.availableRoles){ + if($scope.availableRoles[x].name==$scope.role.name){ + exists = true; + } + } + if (exists) { + confirmBoxService.showInformation( "Role already exists."); + } + else { + console.log($scope.role); + var uuu = conf.api.saveRole.replace(':appId', $scope.appId); + if($scope.isGlobalRoleChecked.isChecked ){ + $scope.role.name = ($scope.role.name.indexOf('global_')==-1)?('global_'+$scope.role.name):($scope.role.name); + saveOrUpdateRole(uuu); + }else{ + var roleName = $scope.role.name.toLowerCase(); + if(roleName.includes('global_')){ + confirmBoxService.showInformation('Global prefix:"global_" can only be used when the global flag is checked for the role name:' +$scope.role.name+ '. Please try again!' ).then(confirmed => { + }); + } else{ + saveOrUpdateRole(uuu); + } + } + } + }; + + let saveOrUpdateRole = (uuu) => { + //overriding the final list of rolefunctions to role + if($scope.finalSelectedRoleFunctions.length > 0) + $scope.role.roleFunctions = $scope.finalSelectedRoleFunctions; + var postData = { + role: $scope.role, + childRoles: $scope.role.childRoles, + roleFunctions : $scope.role.roleFunctions + }; + + $http.post(uuu, postData).then(function(res) { + if (res && res.data && res.data.role){ + confirmBoxService.showInformation("Update Successful.").then(confirmed => { + $modalInstance.close("confirmed"); + }); + } + + else{ + confirmBoxService.showInformation('Failed to create role: ' + res.data.error) + } + }, + function(res){ + console.log('post failed', res.data); + if (res.data.includes('BAD_REQUEST')){ + confirmBoxService.showInformation("Error while saving." + "BAD_REQUEST"); + } + else{ + confirmBoxService.showInformation("Error while saving." + res.data.error); + } + } + ); + } + +})
\ No newline at end of file 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 5e7c62cc..3821ed91 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,167 +1,212 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -app.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog,$modal){ - $( "#dialog" ).hide(); - $scope.isLoadingRoleFunctions = true; - 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(); - }) .finally(function(){ - $scope.isLoadingRoleFunctions = false; - }); +"use strict"; + +app.controller('roleFunctionListController', function ($scope, RoleService, applicationsService, $http, $state, conf, confirmBoxService, ngDialog, $modal) { + $("#dialog").hide(); + $scope.centralizedApps = RoleService.getManageRoleDetails().apps; + $scope.apps = { + selectedCentralizedApp: RoleService.getManageRoleDetails().id + }; + + $scope.getRoleFunctions = function (id) { + $scope.isLoadingRoleFunctions = true; + RoleService.getRoleFunctionList(id).then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoleFunctions = $scope.data.availableRoleFunctions; + }, function (error) { + confirmBoxService.showInformation("Failed to get role functions. Please try again!"); + console.log("failed"); + }).finally(function(){ + $scope.isLoadingRoleFunctions = false; + }); + }; + + function init() { + if($scope.apps.selectedCentralizedApp){ + $scope.getRoleFunctions($scope.apps.selectedCentralizedApp); + } + if($scope.apps.selectedCentralizedApp == undefined){ + $scope.getCentralizedApps(sessionStorage.userId); + } + } + + //getCentalizedApps + $scope.getCentralizedApps = function(userId) { + RoleService.getCentralizedApps(userId).then(res=> { + if (res.length>0) { + $scope.centralizedApps = res; + for(var i = 0; i<res.length; i++){ + if(res[i].appId == 1){ + $scope.apps.selectedCentralizedApp = res[i].appId; + return; + } + $scope.apps.selectedCentralizedApp = res[0].appId; + } + } + }).catch(err=> { + $log.error('RoleListCtrl::centralizedApps retrieval error: ', err); + }).finally(() => { + // this.isLoadingTable = false; + }); + + } + init(); + $scope.editRoleFunction = null; var dialog = null; - $scope.editRoleFunctionPopup = function(availableRoleFunction) { - $scope.editRoleFunction = availableRoleFunction; - $( "#dialog" ).dialog({ - modal: true - }); - }; - - $scope.editRoleFunctionModalPopup = function(availableRoleFunction) { + + $scope.editRoleFunctionModalPopup = function (availableRoleFunction) { $scope.editRoleFunction = availableRoleFunction; - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - - var modalInstance = $modal.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - sizeClass: 'modal-small', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return true; - } - } - }); - - modalInstance.result.then(function (response) { - if(response.value!=null){ - if(response.value.result){ - $scope.availableRoleFunctions=response.value.availableRoleFunctions; - } - } - else - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - - }); + $scope.availableRoleFunctionsTemp = $scope.availableRoleFunctions; + + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + sizeClass: 'modal-small', + resolve: { + message: function message() { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp, + appId: $scope.apps.selectedCentralizedApp + }; + return message; + }, + isEditing: function isEditing() { + return true; + } + } + }); + + modalInstance.result.then(function (response) { + if (response) { + $scope.getRoleFunctions($scope.apps.selectedCentralizedApp); + } + else + $scope.availableRoleFunctions = $scope.availableRoleFunctionsTemp; + }); }; - - $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { - + + $scope.addNewRoleFunctionModalPopup = function (availableRoleFunction) { + $scope.editRoleFunction = null; - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - var modalInstance = $modal.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - sizeClass: 'modal-small', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return false; - } - } - }); - - modalInstance.result.then(function (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.availableRoleFunctionsTemp = $scope.availableRoleFunctions; + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + sizeClass: 'modal-small', + resolve: { + message: function message() { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp, + appId: $scope.apps.selectedCentralizedApp + }; + return message; + }, + isEditing: function isEditing() { + return false; + } + } + }); + + modalInstance.result.then(function (response) { + if (response) { + $scope.getRoleFunctions($scope.apps.selectedCentralizedApp); + } + if (response.availableRoleFunctions != undefined) + $scope.availableRoleFunctions = response.availableRoleFunctions;else $scope.availableRoleFunctions = $scope.availableRoleFunctionsTemp; + }); }; - - $scope.addNewRoleFunctionPopup = function() { + + $scope.addNewRoleFunctionPopup = function () { $scope.editRoleFunction = null; - $( "#dialog" ).dialog({ - modal: true - }); + $("#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; - $http.post(uuu,postData).then(function(response) { + + $scope.syncRoleFunctionsFromExternalAuthSystem = function(appId){ + applicationsService.syncFunctionsFromExternalAuthSystem(appId).then(function(res){ + if(res.status == 200){ + confirmBoxService.showInformation('Sync operation completed successfully!').then(isConfirmed => { + $scope.getRoleFunctions(appId); + }); + } else{ + confirmBoxService.showInformation('Sync operation failed for '+app).then(isConfirmed => {}); + } + }); + }; + + $scope.saveRoleFunction = function (availableRoleFunction) { + var uuu = conf.api.saveRoleFuncion; + var postData = { availableRoleFunction: availableRoleFunction }; + $http.post(uuu, postData).then(function (response) { var data = response.data; - if(data == undefined) - confirmBoxService.showInformation("Error while deleting: "+ data); - else - $scope.availableRoleFunctionsTemp.splice($scope.availableRoleFunctionsTemp.indexOf(availableRoleFunction), 1); - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - }, - function() { - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - } - ); - } - }); + $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; + var uuu = conf.api.removeRoleFunction.replace(':appId', $scope.apps.selectedCentralizedApp); + var postData = availableRoleFunction; + $http.post(uuu, postData).then(function (response) { + if(response.data.status == 'OK'){ + confirmBoxService.showInformation(response.data.message); + $scope.availableRoleFunctionsTemp.splice($scope.availableRoleFunctionsTemp.indexOf(availableRoleFunction), 1); + $scope.availableRoleFunctions = $scope.availableRoleFunctionsTemp; + } else{ + confirmBoxService.showInformation("Error while deleting: " + response.data.message); + } + }, function () { + $scope.availableRoleFunctions = $scope.availableRoleFunctionsTemp; + }); + } + }); + }; }); 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 2ca149cb..4090f2fc 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,112 +1,271 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -app.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http,$log){ - $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; - - },function(error){ - $log.debug('failed'); - }); - - +app.controller('roleListController', function ($scope,RoleService, applicationsService, confirmBoxService,conf,$state,$http,$log, $modal){ + $scope.showSpinner = true; + $scope.syncRolesApplied = false; + $scope.app = { + appName: '' + } $scope.goToUrl = function(roleIdVal) { $state.go("root.role", {"roleId":roleIdVal}); } - $scope.toggleRole = function(selected,availableRole) { - var toggleType = null; - if(selected) { - toggleType = "activate"; - } else { - toggleType = "inactivate"; - } - if((availableRole.id == "1") || (availableRole.id =="999")) - { - confirmBoxService.showInformation(availableRole.name+" role cannot be disabled"); - availableRole.active=!availableRole.active - return; - } - 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') { - $log.debug('data:'+data); - $scope.availableRoles=data.availableRoles; - $log.debug('role::availableRoles:'+$scope.availableRoles); - } else { - // - } + $scope.toggleRole = function(appId, selected, availableRole) { + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + if((availableRole.id == "1") || (availableRole.id =="999")) + { + confirmBoxService.showInformation(availableRole.name+" role cannot be disabled"); + availableRole.active=!availableRole.active + return; + } + else if((appId != '1') && (availableRole.name.indexOf('global_')!=-1)) + { + confirmBoxService.showInformation("Global role cannot be disabled"); + availableRole.active=!availableRole.active + return; + } + 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 + '/' + appId + '/' + availableRole.id; + var postData={ + appId: appId, + role:availableRole + }; + $http.post(uuu, postData).then(function(response) { + var data = response.data; + if (typeof data === 'object' & data.restcallStatus=='Success') { + $scope.availableRoles = data.availableRoles; + $log.debug('role::availableRoles:'+$scope.availableRoles); + } else { + confirmBoxService.showInformation("Error while saving." + data.restCallStatus); + availableRole.active=!availableRole.active; + } - }, function(response) { - debug.log('response:'+response); - availableRole.active=!availableRole.active; - confirmBoxService.showInformation("Error while saving."); - }); - - } + }, function(response) { + debug.log('response:'+response); + availableRole.active=!availableRole.active; + confirmBoxService.showInformation("Error while saving." + data.restCallStatus); + }); + + } - }) .catch(function(err) { - $log.error('roleListController::confirmBoxService.confirm error:', err); - availableRole.active=!availableRole.active; - }); - - - }; + }) .catch(function(err) { + $log.error('roleListController::confirmBoxService.confirm error:', err); + 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( + $scope.removeRole = function(appId, availableRole) { + if ((appId != '1') && (availableRole.name.indexOf('global_')!=-1)){ + confirmBoxService.showInformation("Global role cannot be deleted"); + } + else{ + confirmBoxService.confirm("You are about to delete the role "+availableRole.name+". Do you want to continue?").then( function(confirmed){ - var uuu = conf.api.removeRole; - var postData={role:role}; - - - + var uuu = conf.api.removeRole + '/' + appId + '/' + availableRole.id; + var postData={ + appId: appId, + availableRoleId: availableRole.id + }; $http.post(uuu, postData).then(function(response) { var data = response.data; - if (typeof data === 'object') { - $scope.availableRoles=data.availableRoles; + if (typeof data === 'object' & data.restCallStatus == 'Success') { + $scope.availableRoles = data.availableRoles; } else { - // + confirmBoxService.showInformation('Failed to remove role '+ data.error ) } }, function(response) { - $log.debug('response:'+response.data); - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); + confirmBoxService.showInformation("Error while deleting: "+ data.error); }); - }); - + }); + } + }; + + //getCentalizedApps + $scope.getCentralizedApps = function(userId) { + RoleService.getCentralizedApps(userId).then(res=> { + if (res.length>0) { + $scope.centralizedApps = res; + for(var i = 0; i<res.length; i++){ + if(res[i].appId == 1){ + $scope.getRolesForSelectedCentralizedApp(res[i].appId); + $scope.apps.selectedCentralizedApp = res[i].appId; + return; + } + $scope.getRolesForSelectedCentralizedApp(res[0].appId); + $scope.apps.selectedCentralizedApp = res[0].appId; + } + } + }).catch(err=> { + $log.error('RoleListCtrl::centralizedApps retrieval error: ', err); + }).finally(() => { + // this.isLoadingTable = false; + }); + + } + + $scope.syncRolesFromExternalAuthSystem = function(appId){ + applicationsService.syncRolesEcompFromExtAuthSystem(appId).then(function(res){ + if(res.status == 200){ + confirmBoxService.showInformation('Sync operation completed successfully!').then(isConfirmed => { + $scope.getRolesForSelectedCentralizedApp(appId); + }); + } else{ + confirmBoxService.showInformation('Sync operation failed for '+app).then(isConfirmed => {}); + } + }); + }; + + + $scope.getRolesForSelectedCentralizedApp = function(val) { + $scope.showSpinner = true; + applicationsService.getSingleAppInfoById(val).then(function(res) { + if(res.centralAuth == true){ + $scope.syncRolesApplied = true; + } + }); + RoleService.getRoles(val).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoles =$scope.data.availableRoles; + $scope.showSpinner = false; + },function(error){ + $scope.showSpinner = false; + confirmBoxService.showInformation('Failed to get roles. Please try again!').then(isConfirmed => {}); + $scope.availableRoles = []; + $log.debug('failed'); + }); + } + + $scope.fnManageRoleFunctions = function(){ + RoleService.setManageRoleDetails($scope.centralizedApps, $scope.apps.selectedCentralizedApp); + }; + + function init(){ + $scope.apps = { + selectedCentralizedApp:'' + }; + $scope.getCentralizedApps(sessionStorage.userId); + } + + init(); + + //edit Role + $scope.editRoleModalPopup = function(appId, availableRole) { + $scope.editRole = availableRole; + if(appId != undefined && availableRole.id != undefined){ + RoleService.getRole(appId, availableRole.id).then(function(data){ + var response = JSON.parse(data.data); + var role = JSON.parse(response.role); + var availableRoles = JSON.parse(response.availableRoles); + var availableRoleFunctions = JSON.parse(response.availableRoleFunctions); + $scope.availableRoleFunctions = response.roleFunctions; + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_createedit_role.html', + controller: 'roleCreateEditController', + sizeClass: 'modal-large', + windowClass: "modal-docked", + resolve: { + message: function () { + var message = { + availableRoles: availableRoles, + availableRoleFunctions: availableRoleFunctions, + appId: $scope.apps.selectedCentralizedApp, + role: role + }; + return message; + } + } + }); + modalInstance.result.then(function (confirmed) { + if(confirmed == 'confirmed'){ + $scope.getRolesForSelectedCentralizedApp(appId); + } + }); + },function(error){ + $log.debug('Failed to editRole'); + }); + } + }; + //add Role + $scope.addRoleModalPopup = function(appId) { + if(appId){ + var roleId = 0; + RoleService.getRole(appId, roleId).then(function(data){ + var response = JSON.parse(data.data); + var role = JSON.parse(response.role); + var availableRoles = JSON.parse(response.availableRoles); + var availableRoleFunctions = JSON.parse(response.availableRoleFunctions); + $scope.availableRoleFunctions = response.roleFunctions; + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_createedit_role.html', + controller: 'roleCreateEditController', + sizeClass: 'modal-large', + windowClass: "modal-docked", + resolve: { + message: function () { + var message = { + role: role, + appId: $scope.apps.selectedCentralizedApp + }; + return message; + } + } + }); + modalInstance.result.then(function (confirmed) { + if(confirmed == 'confirmed'){ + $scope.getRolesForSelectedCentralizedApp(appId); + } + }); + },function(error){ + $log.debug('Failed to AddRole'); + }); + } + }; }); 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 6642b051..dfa3ce69 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.html +++ b/ecomp-portal-FE-common/client/app/views/role/role.html @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at 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 b6e92c9e..4ed5dfd8 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.less +++ b/ecomp-portal-FE-common/client/app/views/role/role.less @@ -1,3 +1,40 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ .p-info { font-size: 18px; } 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 d52ce33b..26bb2db4 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 @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at 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 51362b6c..ed4fdd7f 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 @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at @@ -53,74 +53,58 @@ <div id="title" class="w-ecomp-main-view-title"> <h3 class="heading-page" >Role Functions</h3> </div> - - - <br> <div class="admins-table"> + <!-- Centralized Apps --> + <div class="table-dropdown" ng-if="apps.selectedCentralizedApp"> + <select id="dropdown1" name="dropdown1" b2b-dropdown ng-change="getRoleFunctions(apps.selectedCentralizedApp);" + ng-model="apps.selectedCentralizedApp"> + <option b2b-dropdown-list option-repeat="item in centralizedApps" value="{{item.appId}}">{{item.appName}}</option> + </select> + </div> + <br/> - <!-- <a ng-click="addNewRoleFunctionModalPopup();" class="icon-add" size="small" ></a> --> - <div id="create-new-admin" align="left" class="admins-table-create-new-admin"> - <button id="button-admin-create" type="submit" ng-click="addNewRoleFunctionModalPopup();" - class="btn btn-alt btn-small">Create</button> - </div> - - <div class="admins-table-space"> - <!-- Click on the edit icon to update a role function, the plus icon to add additional role functions, or the delete icon to remove them. --> - </div> + <div id="create-new-admin" align="left" class="admins-table-create-new-admin"> + <button id="button-admin-create" type="submit" ng-click="addNewRoleFunctionModalPopup();" + class="btn btn-alt btn-small">Create</button> + <button ng-if="apps.selectedCentralizedApp" id="button-sync-functions" type="submit" ng-click="syncRoleFunctionsFromExternalAuthSystem(apps.selectedCentralizedApp)" + class="btn btn-alt btn-small"><i class="icon-arrows-update-refresh-syncL" aria-hidden="true"></i> Sync Functions</button> + </div> + + <div class="admins-table-space"> + </div> <div id="rolesTable" class="c-ecomp-abs-table default" title="Role Functions"> <span class="ecomp-spinner" ng-show="isLoadingRoleFunctions"></span> <table b2b-table table-data="availableRoleFunctions" current-page="1"> <thead b2b-table-row type="header"> <tr> + <th id="table-header-type" b2b-table-header width="10%" key="type" sortable="true">Type</th> + <th id="table-header-code" b2b-table-header width="10%" key="code" sortable="true">Instance</th> + <th id="table-header-action" b2b-table-header width="10%" key="action" sortable="true">Action</th> <th id="table-header-name" b2b-table-header width="70%" key="name" sortable="true">Name</th> - <th id="table-header-code" b2b-table-header width="10%" key="code" sortable="true">Code</th> <th id="table-header-edit" b2b-table-header width="10%" sortable="false">Edit?</th> <th id="table-header-delete" b2b-table-header width="10%" sortable="false">Delete?</th> </tr> </thead> <tbody b2b-table-row type="body" row-repeat="availableRoleFunction in availableRoleFunctions" class="admins-table-tbody" ><!-- background colors will alternate not properly with multiple tbody--> <tr> + <td id="table-body-role-{{availableRoleFunction['type'].split(' ').join('-')}}" b2b-table-body width="10%" ng-bind="availableRoleFunction['type']"></td> + <td id="table-body-role-{{availableRoleFunction['code'].split(' ').join('-')}}" b2b-table-body width="10%" ng-bind="availableRoleFunction['code']"></td> + <td id="table-body-role-{{availableRoleFunction['action']}}" b2b-table-body width="10%" ng-bind="availableRoleFunction['action']"></td> <td id="table-body-role-{{availableRoleFunction['name'].split(' ').join('-')}}" b2b-table-body width="70%" ng-bind="availableRoleFunction['name']"></td> - <td id="table-body-role-{{availableRoleFunction['code']}}" b2b-table-body width="10%" ng-bind="availableRoleFunction['code']"></td> <td id="table-body" b2b-table-body width="10%"> - <!-- <a ng-click="editRoleFunctionPopup(availableRoleFunction);" > - <img src="static/fusion/images/editicon.gif"> - </a> --> - <div ng-click="editRoleFunctionModalPopup(availableRoleFunction);" class="admins-table-btn-txt"><a id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-edit" href="javascript:void(0)" class="icon-edit"></a></div> + <div ng-click="editRoleFunctionModalPopup(availableRoleFunction);" class="icon-edit" id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-edit"></div> </td> <td b2b-table-body width="10%"> <!-- <a ng-click="removeRole(availableRoleFunction);" ><img src="static/fusion/images/deleteicon.gif"></a> --> - <div ng-click="removeRole(availableRoleFunction);" class="admins-table-btn-txt"><a id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-trash" href="javascript:void(0)" class="icon-misc-trash"></a></div> + <div ng-click="removeRole(availableRoleFunction);" class="icon-misc-trash" id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-trash"></div> </td> </tr> </tbody> </table> </div> - - </div> - - - <div id="dialog" title="Add Role Function"> - - <div id="fn-ebz-container-name" class="fn-ebz-container" > - <label id="fn-ebz-label-name" class="fn-ebz-text-label"><sup><b>*</b></sup>Name:</label><br> - <input id="fn-ebz-input-{{editRoleFunction.name}}" type="text" class="fn-ebz-text" ng-model="editRoleFunction.name" - maxlength="30" /> - </div> - <br/> - <div id="fn-ebz-container-code" class="fn-ebz-container" > - <label id="fn-ebz-label-code" class="fn-ebz-text-label"><sup><b>*</b></sup>Code:</label><br> - <input id="fn-ebz-input-{{editRoleFunction.code}}" type="text" class="fn-ebz-text" ng-model="editRoleFunction.code" ng-disabled="editRoleFunction.code!=null" - maxlength="30" /> - </div> - <br/> - <button id="button-admin-save" type="submit" ng-click="saveRoleFunction(editRoleFunction);" class="btn btn-alt btn-small">Save</button> - - </div> - </div> </div> 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 3f2561c1..1bccbd14 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 @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at 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 d761b726..81b0eceb 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 @@ -2,11 +2,11 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright © 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed - under the Apache License, Version 2.0 (the “License”); + under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ limitations under the License. Unless otherwise specified, all documentation contained herein is licensed - under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License. You may obtain a copy of the License at @@ -46,8 +46,20 @@ <h1 class="heading-page" >Roles</h1> </div> <div class="admins-table"> + + <!-- Centralized Apps --> + <div class="table-dropdown" ng-if="apps.selectedCentralizedApp"> + <select id="dropdown1" name="dropdown1" b2b-dropdown ng-change="getRolesForSelectedCentralizedApp(apps.selectedCentralizedApp);" + ng-model="apps.selectedCentralizedApp"> + <option b2b-dropdown-list option-repeat="item in centralizedApps" value="{{item.appId}}">{{item.appName}}</option> + </select> + </div> + + <br/> + <div id="button-create-role" align="left" class="admins-table-btn-create" > - <button id="button-create-role" ng-click="goToUrl(0)" class = "btn btn-alt btn-small">Create</button> + <button id="button-create-role" ng-click="addRoleModalPopup(apps.selectedCentralizedApp)" class = "btn btn-alt btn-small">Create</button> + <button id="button-sync-role" ng-show="syncRolesApplied" ng-click="syncRolesFromExternalAuthSystem(apps.selectedCentralizedApp)" class = "btn btn-alt btn-small"><i class="icon-arrows-update-refresh-syncL" aria-hidden="true"></i> Sync Roles</button> </div> <br> <div class="property-label"> @@ -61,6 +73,7 @@ <th b2b-table-header key="priority" sortable="true" id="col2">Priority</th> <th b2b-table-header id="col3" sortable="false">Active</th> <th b2b-table-header id="col4" sortable="false">Edit</th> + <th ng-if="apps.selectedCentralizedApp != 1" b2b-table-header id="col4" sortable="false">Delete</th> </tr> </thead> <tbody b2b-table-row type="body" row-repeat="rowData in availableRoles"> @@ -74,17 +87,19 @@ <td b2b-table-body headers="rowheader_t1_{{$index}} col3" > <div > <label class="btn-switch-label" tabindex="0" role="option"> - <input type="checkbox" id="{{$index}}-button-toggle-role" b2b-switches ng-model="rowData.active" ng-click="toggleRole(rowData.active,rowData);"> + <input type="checkbox" id="{{$index}}-button-toggle-role" b2b-switches ng-model="rowData.active" ng-click="toggleRole(apps.selectedCentralizedApp, rowData.active,rowData);"> </label> </div> </td> - <td b2b-table-body id="{{$index}}-button-edit-role" class="icon-misc-pen" ng-click="goToUrl(rowData.id)"></td> + <td b2b-table-body id="{{$index}}-button-edit-role" class="icon-misc-pen" ng-click="editRoleModalPopup(apps.selectedCentralizedApp, rowData)"></td> + <td ng-if="apps.selectedCentralizedApp != 1" b2b-table-body class="icon-trash" ng-click="removeRole(apps.selectedCentralizedApp, rowData)"></td> </tr> </tbody> </table> - - </div> + + <a id="manage-role" ng-click="fnManageRoleFunctions()" href="roleFunctions">Manage Role Functions</a><br><br> + </div> </div> </div> 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 41241500..9144bcb1 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js @@ -1,101 +1,154 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -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) { - confirmBoxService.confirm( - "You are about to Create the role function "+ availableRoleFunction.name+ ". Do you want to continue?") - .then(function(confirmed) { - if (confirmed) { - - var uuu = conf.api.saveRoleFunction; - var postData = 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) { - $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); +app.controller('rolefunctionpopupController',function($scope, confirmBoxService, message, $http, $modalInstance, RoleService, conf, isEditing) { + if (message.availableRoleFunction == null) { + $scope.label = 'Add Role Function'; + var tempText = ""; + $scope.selectedAppId = message.appId; + $scope.defaultAction = "*"; + $scope.disableTypeAction = true; + $scope.ngRepeatDemo = [ + {id: 'menuradiobutton1', value: 'menu', labelvalue: 'menu'}, + {id: 'urlradiobutton2', value: 'url', labelvalue: 'url'}, + {id: 'otherradiobutton3', value: 'other', labelvalue: 'other'} + ] + $scope.selectedvalueradioButtonGroup = { + type: 'menu' + } + $scope.editRoleFunction = { + action: '*' + } + } else { + $scope.ngRepeatDemo = [ + {id: 'menuradiobutton1', value: 'menu', labelvalue: 'menu'}, + {id: 'urlradiobutton2', value: 'url', labelvalue: 'url'}, + {id: 'otherradiobutton3', value: 'other', labelvalue: 'other'} + ] + $scope.label = 'Edit Role Function' + $scope.disableCd = true; + $scope.disableTypeAction = false; + var tempText = new String(message.availableRoleFunction.name); + $scope.editRoleFunction = angular.copy(message.availableRoleFunction); + if($scope.editRoleFunction.type.includes('menu')||$scope.editRoleFunction.type.includes('url')){ + $scope.selectedvalueradioButtonGroup = { + type: $scope.editRoleFunction.type + } + } else{ + $scope.selectedvalueradioButtonGroup = { + type: 'other' + } + } + $scope.selectedAppId = message.appId; + } + $scope.tempText = tempText; + $scope.isEditing = isEditing; - // $scope.resetMenu(); - /*$scope.closeThisDialog({ - result : true, - availableRoleFunctions : $scope.availableRoleFunctions - });*/ - $scope.$dismiss({result : true,availableRoleFunctions : $scope.availableRoleFunctions}); - }, - function(error) { - console.log("failed"); - // reloadPageOnce(); - //$scope.closeThisDialog(true); - $scope.$dismiss('cancel'); - }); + $scope.saveRoleFunction = function(availableRoleFunction, type) { + if(type !== 'other'){ + if (!availableRoleFunction.hasOwnProperty('type')) { + availableRoleFunction['type'] = type ; + } else{ + availableRoleFunction.type = type ; + } + } + if(/[^a-zA-Z0-9\-\.\_]/.test(availableRoleFunction.type)){ + confirmBoxService.showInformation('Type can only contain alphanumeric characters, dots(.) and underscores(_)').then(isConfirmed => {}); + return; + } + if(availableRoleFunction.action !== '*' && /[^a-zA-Z0-9\-\.\_]/.test(availableRoleFunction.action)){ + confirmBoxService.showInformation('Action can only contain alphanumeric characters, hyphens(-), dots(.) and underscores(_) and single asterisk character(*)').then(isConfirmed => {}); + return; + } + if(/[^a-zA-Z0-9\-\:\_\./*]/.test(availableRoleFunction.code)){ + confirmBoxService.showInformation('Instance can only contain alphanumeric characters, hyphens(-), dots(.), colons(:), forwardSlash(/) , asterisk(*) and underscores(_)').then(isConfirmed => {}); + return; + } + if(/[^a-zA-Z0-9\-\_ \.]/.test(availableRoleFunction.name)){ + confirmBoxService.showInformation('Name can only contain alphanumeric characters, spaces, hyphens(-), dots(.) and underscores(_)').then(isConfirmed => {}); + return; + } + confirmBoxService.confirm( + "You are about to Create the role function "+ availableRoleFunction.name+ ". Do you want to continue?") + .then(function(confirmed) { + if (confirmed) { + var uuu = conf.api.saveRoleFunction.replace(':appId', $scope.selectedAppId); + var postData = 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) { + if(res.data.status == 'OK'){ + confirmBoxService.showInformation(res.data.message).then(isConfirmed => {}); + } else{ + confirmBoxService.showInformation('Error:' + res.data.message).then(isConfirmed => {}); + } + $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions; + $modalInstance.close(true); + }); - } - }; + } + }; - $scope.close = function() { - this.closeThisDialog(true); - }; - } + $scope.close = function() { + this.closeThisDialog(true); + }; + } - ); - } - });
\ No newline at end of file + ); + } +});
\ No newline at end of file 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 67bf3b2e..09b2eac7 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ app.controller('rolepopupController', function ($scope, role, roleId, confirmBoxService, $http, $state, availableRoles, conf, availableRoleFunctions,ngDialog){ @@ -74,35 +92,13 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo 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."); - } - ); - - - + availableRoleFunction.id = roleId; + var index = $scope.role.roleFunctions.indexOf(availableRoleFunction); + if(index>=0) + $scope.role.roleFunctions.splice(index, 1); + return; } - /* - $.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."); - } - }); - */ }).catch(function(err) { availableRoleFunction.selected=!availableRoleFunction.selected; $log.error('roleListController::confirmBoxService.confirm error:', err); @@ -120,34 +116,10 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo 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."); - }); - } /* - $.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; - })*/ + availableRoleFunction.id = roleId; + $scope.role.roleFunctions.push(availableRoleFunction); + return; + } }).catch(function(err) { availableRoleFunction.selected=!availableRoleFunction.selected; $log.error('roleListController::confirmBoxService.confirm error:', err); @@ -186,21 +158,6 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo availableRole.selected=!availableRole.selected; $log.error('roleListController::confirmBoxService.confirm error:', err); }); - /* $.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 { @@ -222,19 +179,6 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo confirmBoxService.showInformation("Error while saving."); }); } - /* $.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."); - } - });*/ }).catch(function(err) { availableRole.selected=!availableRole.selected; |