[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-FE-common / client / app / views / role / role-function-list-controller.js
index c7a1bfd..e719599 100644 (file)
-/*-\r
- * ================================================================================\r
- * ECOMP Portal\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ================================================================================\r
- */\r
-app.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog){\r
-       $( "#dialog" ).hide();\r
-       \r
-       RoleService.getRoleFunctionList().then(function(data){\r
-               \r
-               var j = data;\r
-               $scope.data = JSON.parse(j.data);\r
-               $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions);\r
-               \r
-               //$scope.resetMenu();\r
-       \r
-       },function(error){\r
-               console.log("failed");\r
-               //reloadPageOnce();\r
-       });\r
-       \r
-       $scope.editRoleFunction = null;\r
-       var dialog = null;\r
-       $scope.editRoleFunctionPopup = function(availableRoleFunction) {\r
-               $scope.editRoleFunction = availableRoleFunction;\r
-               $( "#dialog" ).dialog({\r
-                     modal: true\r
-           });\r
-       };\r
-       \r
-       $scope.editRoleFunctionModalPopup = function(availableRoleFunction) {\r
-               $scope.editRoleFunction = availableRoleFunction;\r
-               $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions;\r
-               //$scope.availableRoleFunctions={};\r
-               var modalInstance = ngDialog.open({\r
-                   templateUrl: 'app/views/role/popup_modal_rolefunction.html',\r
-                   controller: 'rolefunctionpopupController',\r
-                   resolve: {\r
-                       message: function () {\r
-                               var message = {\r
-                                               availableRoleFunction:  $scope.editRoleFunction,\r
-                                               availableRoleFunctions: $scope.availableRoleFunctionsTemp\r
-                               };\r
-                         return message;\r
-                       },\r
-                       isEditing: function () {\r
-                               return true;\r
-                       }\r
-                     }\r
-                 }); \r
-               modalInstance.closePromise.then(response =>{\r
-                       if(response.value!=null){\r
-               if(response.value.result){\r
-                       $scope.availableRoleFunctions=response.value.availableRoleFunctions;    \r
-               }\r
-            }                  \r
-            /*else\r
-               $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp;\r
-            */\r
-        });\r
-       };\r
-       \r
-       $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) {\r
-               \r
-               $scope.editRoleFunction = null;\r
-               $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions;\r
-               //$scope.availableRoleFunctions={};\r
-               var modalInstance = ngDialog.open({\r
-                   templateUrl: 'app/views/role/popup_modal_rolefunction.html',\r
-                   controller: 'rolefunctionpopupController',\r
-                   resolve: {\r
-                       message: function () {\r
-                               var message = {\r
-                                               availableRoleFunction: $scope.editRoleFunction,\r
-                                               availableRoleFunctions: $scope.availableRoleFunctionsTemp\r
-                               };\r
-                         return message;\r
-                       },\r
-                       isEditing: function () {\r
-                               return false;\r
-                       }\r
-                     }\r
-                 });\r
-               modalInstance.closePromise.then(response => {\r
-            if(response.value!=null){\r
-               if(response.value.result){\r
-                       $scope.availableRoleFunctions=response.value.availableRoleFunctions;    \r
-               }\r
-            }\r
-           /* if(response.availableRoleFunctions != undefined)\r
-               $scope.availableRoleFunctions=response.availableRoleFunctions;\r
-            else\r
-               $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp;\r
-               */\r
-        });\r
-       };\r
-       \r
-       $scope.addNewRoleFunctionPopup = function() {\r
-               $scope.editRoleFunction = null;\r
-               $( "#dialog" ).dialog({\r
-                     modal: true\r
-           });\r
-       };\r
-       \r
-       $scope.saveRoleFunction = function(availableRoleFunction) {\r
-                 var uuu = conf.api.saveRoleFuncion;\r
-                 var postData={availableRoleFunction: availableRoleFunction};\r
-                 $http.post(uuu,postData).then(function(response) {\r
-                         var data = response.data;\r
-                       $scope.availableRoleFunctions=data.availableRoleFunctions; \r
-                       $scope.editRoleFunction = null;\r
-                 },              \r
-               function() {\r
-                       \r
-                       confirmBoxService.showInformation("Error while saving");\r
-                 }\r
-                 );\r
-               };\r
-       \r
-               \r
-               $scope.removeRole = function(availableRoleFunction) {\r
-                       confirmBoxService.confirm("You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?").then(\r
-                               function(confirmed){\r
-                                       if(confirmed){\r
-                                                       $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions;\r
-                                                       //$scope.availableRoleFunctions={};\r
-                                                 var uuu = conf.api.removeRoleFunction;\r
-                                                 var postData={availableRoleFunction: availableRoleFunction};\r
-                                                 $http.post(uuu,postData).then(function(response) {\r
-                                                         var data = response.data;\r
-                                                         if(data.availableRoleFunctions == undefined)\r
-                                                               confirmBoxService.showInformation("Error while deleting: "+ data);\r
-                                                         else \r
-                                                                 $scope.availableRoleFunctions=data.availableRoleFunctions; \r
-                                                 },\r
-                                               function() {\r
-                                                       $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp;\r
-                                                       confirmBoxService.showInformation("Error while deleting: "+ data.responseText);\r
-                                                 }\r
-                                                 );\r
-                                       }                       \r
-                               });\r
-                       \r
-               };\r
-\r
-});\r
+/*-
+ * ================================================================================
+ * 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);
+                                                 }
+                                                 );
+                                       }                       
+                               });
+                       
+               };
+
+});