summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-common/client/app/views/role
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-FE-common/client/app/views/role')
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html55
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role-controller.js219
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js160
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role-list-controller.js147
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role.html96
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role.less50
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html51
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role_function_list.html107
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html49
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/role_list.html55
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js95
-rw-r--r--ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js251
12 files changed, 1335 insertions, 0 deletions
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
new file mode 100644
index 00000000..3970960d
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html
@@ -0,0 +1,55 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+
+<div class="new-admin-modal" style="height: 350px;">
+ <form name="adminForm" novalidate>
+ <div class="title" ng-bind="label" style="color: #5a5a5a;font-size: 18px;border-bottom: #067ab4 3px solid;margin-left:0px"></div>
+
+ <div id="name-property-title" class="property required">
+ <div id="name-property-label" class="property-label" style="margin-bottom: 5px; color: #5a5a5a; font-size: 14px; font-weight: bold; padding-top: 20px;">
+ <sup><b style="color: Red;">*</b></sup>Name:</div>
+ <input id="name-property-input" type="text" class="input-field" style=" display: inline-block; width: 396px; height: 40px;"ng-model="editRoleFunction.name" maxlength="30" />
+ <div id="name-property-required" ng-show="!editRoleFunction.name||editRoleFunction.name.length==0" style="color: #cf2a2a; font-size: 10px;"><small style="position: absolute;">Name is Required</small>
+ </div>
+ </div>
+ <br />
+ <div id="code-property-title" class="property required">
+ <div id="code-property-label" class="property-label" style=" margin-bottom: 5px; color: #5a5a5a; font-size: 14px; font-weight: bold; padding-top: 20px;">
+ <sup><b style="color: Red;">*</b></sup>Code:
+ </div>
+ <input id="code-property-input" type="text" class="input-field" style=" display: inline-block; width: 396px; height: 40px;"
+ ng-model="editRoleFunction.code" ng-disabled="disableCd"
+ maxlength="30" />
+ <div id="code-property-required" ng-show="!editRoleFunction.code||editRoleFunction.code.length==0" style="color: #cf2a2a; font-size: 10px;"><small style="position: absolute;">Code is Required</small>
+ </div>
+ </div>
+
+
+
+ <div class="dialog-control">
+
+ <button id="button-app-save" class="save-button" 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="cancel-button" ng-click="closeThisDialog()" role="button" tabindex="0" herf="javascript:void(0)">Cancel</div>
+ </div>
+ </form>
+</div>
+
+
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
new file mode 100644
index 00000000..c5c7c97c
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role-controller.js
@@ -0,0 +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.");
+ });
+ }
+ });
+
+ };
+
+});
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
new file mode 100644
index 00000000..c7a1bfd8
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js
@@ -0,0 +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);
+ }
+ );
+ }
+ });
+
+ };
+
+});
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
new file mode 100644
index 00000000..5ef37165
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js
@@ -0,0 +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);
+ });
+
+ });
+
+
+ };
+
+
+});
diff --git a/ecomp-portal-FE-common/client/app/views/role/role.html b/ecomp-portal-FE-common/client/app/views/role/role.html
new file mode 100644
index 00000000..42793eee
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role.html
@@ -0,0 +1,96 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<div class="w-ecomp-admins-page-main">
+ <div class="admins-home-container" id="page-content">
+ <div id="title" class="w-ecomp-main-view-title">
+ <h3 class="heading-page" >Role</h3>
+ </div>
+ <div class="admins-table" >
+ <div>
+ <br>
+ <p class="p-info">Please edit the role details below:&nbsp;</p><br>
+
+ <div id="role-text" >
+ <label id="role-text-name-label" >*Name:</label>
+ <input id="input-name" class="input-field" maxlength="30" type="text" data-ng-model="role.name">
+ <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">
+ </div>
+ <br>
+ <div align="left" >
+ <button id="button-role-save" type="submit" ng-click="saveRole();" class="btn btn-alt btn-small">Save</button>
+ </div>
+
+ <br>
+ <div id="page-title" class="pageTitle">
+ <label>Role Functions</label>
+ <a id="add-new-role" ng-click="addNewRoleFunctionModalPopup();" ng-style="{'cursor':'pointer'}" class="icon-primary-accordion-plus" size="small"></a>
+ </div>
+
+ <div b2b-table table-data="role.roleFunctions" ng-hide="users.isLoadingTable" search-string="users.searchString" class="b2b-table-div">
+ <table>
+ <thead b2b-table-row type="header">
+ <tr >
+ <th id="table-header-name" b2b-table-header key="name" sortable="true" >Name</th>
+ <th id="table-header-remove" b2b-table-header sortable="false" >Remove</th>
+ </tr>
+ </thead>
+ <tbody b2b-table-row type="body" row-repeat="roleFunction in role.roleFunctions">
+ <tr >
+ <td id="role-function-{{roleFunction.name}}" b2b-table-body id="rowheader_t1_{{$index}}" headers="col1" ng-bind="roleFunction.name"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col4">
+ <div ng-click="removeRoleFunction(roleFunction);" ><a href="javascript:void(0)" class="icon-misc-trash"></a></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
+ <a id="manage-role" href="roleFunctions">Manage Role Functions</a><br><br>
+
+ <div id="page-title-child" class="pageTitle">
+ <label>Child Roles</label>
+ <a id="add-child-role" ng-click="addNewChildRoleModalPopup();" ng-style="{'cursor':'pointer'}" class="icon-primary-accordion-plus" size="small"></a>
+ </div>
+
+ <div b2b-table table-data="role.childRoles" ng-hide="users.isLoadingTable" search-string="users.searchString" class="b2b-table-div">
+ <table>
+ <thead b2b-table-row type="header">
+ <tr >
+ <th id="table-header-name" b2b-table-header key="firstName" sortable="true" >Name</th>
+ <th id="table-header-remove" b2b-table-header key="lastName" sortable="true" >Remove</th>
+ </tr>
+ </thead>
+ <tbody b2b-table-row type="body" row-repeat="role in role.childRoles">
+ <tr >
+ <td id="role-function-{{role.name}}" b2b-table-body id="rowheader_t1_{{$index}}" headers="col1" ng-bind="role.name"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col4">
+ <div ng-click="removeChildRole(role);" ><a href="javascript:void(0)" class="icon-misc-trash"></a></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ </div>
+ </div>
+</div>
diff --git a/ecomp-portal-FE-common/client/app/views/role/role.less b/ecomp-portal-FE-common/client/app/views/role/role.less
new file mode 100644
index 00000000..42311e64
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role.less
@@ -0,0 +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;
+} \ 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
new file mode 100644
index 00000000..278ef2cd
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html
@@ -0,0 +1,51 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<link rel="stylesheet" href="role.css">
+<div class="application-details-modal">
+ <div id="title" class="title">Select Role Functions</div>
+<div class="scrolling-table">
+
+ <div b2b-table table-data="availableRoles" class="b2b-table-div">
+ <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 availableRoles">
+ <tr>
+ <td b2b-table-body id="rowheader_t1_{{$index}}" headers="col1">
+ <label class="btn-switch-label" tabindex="0" role="option">
+ <input type="checkbox" b2b-switches ng-model="rowData.selected" ng-click="toggleChildRole(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 class="dialog-control">
+ <button id="button-app-cancel" class="btn btn-alt btn-small" ng-click="closeThisDialog()">Close</button>
+ </div>
+</div>
+
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
new file mode 100644
index 00000000..c015ee56
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role_function_list.html
@@ -0,0 +1,107 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<style>
+.c-ecomp-abs-table .tablesorter-default tbody tr td div {
+ line-height: 20px;
+}
+
+.c-ecomp-abs-table{
+ width: 100%;
+ height: 600px;
+ overflow-x: auto;
+ overflow-y: auto;
+ background-color: white;
+}
+</style>
+<div class="w-ecomp-admins-page-main">
+ <div class="admins-home-container" id="page-content">
+ <div id="title" class="w-ecomp-main-view-title">
+ <h3 class="heading-page" >Role Functions</h3>
+ </div>
+
+
+ <br>
+
+ <div class="admins-table">
+
+ <!-- <a ng-click="addNewRoleFunctionModalPopup();" class="icon-add" size="small" ></a> -->
+ <div id="create-new-admin" align="left" style="marin-bottom: 50px;">
+ <button id="button-admin-create" type="submit" ng-click="addNewRoleFunctionModalPopup();"
+ class="btn btn-alt btn-small">Create</button>
+ </div>
+
+ <div style="text-align: justify;text-align-last:auto;">
+ <!-- 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="rolesTable" class="c-ecomp-abs-table default" title="Role Functions">
+ <table b2b-table table-data="availableRoleFunctions" current-page="1">
+ <thead b2b-table-row type="header">
+ <tr>
+ <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" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
+ <tr>
+ <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);" style="font-size:20px;"><a id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-edit" href="javascript:void(0)" class="icon-edit"></a></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);" style="font-size:20px;"><a id="role-{{availableRoleFunction['name'].split(' ').join('-')}}-trash" href="javascript:void(0)" class="icon-misc-trash"></a></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
new file mode 100644
index 00000000..7d80d81e
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html
@@ -0,0 +1,49 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<link rel="stylesheet" href="role.css">
+<div class="application-details-modal">
+ <div id="title" class="title">Select Role Functions</div>
+<div class="scrolling-table">
+ <div b2b-table table-data="availableRoleFunctions" class="b2b-table-div">
+ <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 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 class="dialog-control">
+ <button id="button-app-cancel" class="btn btn-alt btn-small" ng-click="closeThisDialog()">Close</button>
+ </div>
+</div>
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
new file mode 100644
index 00000000..e8d56cab
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/role_list.html
@@ -0,0 +1,55 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<div class="w-ecomp-admins-page-main">
+ <div class="admins-home-container" id="page-content">
+ <div id="title" class="w-ecomp-main-view-title">
+ <h1 class="heading-page" >Roles</h1>
+ </div>
+ <div class="admins-table">
+ <div id="button-create-role" align="left" style="marin-bottom: 50px;" >
+ <button ng-click="goToUrl(0)" class = "btn btn-alt btn-small">Create</button>
+ </div>
+ <div b2b-table table-data="availableRoles" search-string="searchString" class="b2b-table-div">
+ <table>
+ <thead b2b-table-row type="header">
+ <tr>
+ <th b2b-table-header key="name" sortable="true" default-sort="a" id="col1">Name</th>
+ <th b2b-table-header key="priority" sortable="true" id="col2">Priority</th>
+ <th b2b-table-header id="col3" sortable="false">Active</th>
+ </tr>
+ </thead>
+ <tbody b2b-table-row type="body" row-repeat="rowData in availableRoles">
+ <tr>
+ <td b2b-table-body id="rowheader_t1_{{$index}}" headers="col1" ng-bind="rowData['name']"></td>
+ <td b2b-table-body ng-bind="rowData['priority']"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col3" >
+ <div >
+ <label class="btn-switch-label" tabindex="0" role="option">
+ <input type="checkbox" b2b-switches ng-model="rowData.active" ng-click="toggleRole(rowData.active,rowData);">
+ </label>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </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
new file mode 100644
index 00000000..6275c760
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js
@@ -0,0 +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);
+ };
+}
+);
diff --git a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js
new file mode 100644
index 00000000..7feb7f2f
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js
@@ -0,0 +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);
+ };
+
+});