diff options
Diffstat (limited to 'vid/src/main/webapp/app/fusion/scripts/controllers')
24 files changed, 3247 insertions, 0 deletions
diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/adminController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/adminController.js new file mode 100644 index 00000000..a99be9fe --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/adminController.js @@ -0,0 +1,65 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.config(function($routeProvider) { + $routeProvider + + + .when('/role_function_list', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/role_function_list.html', + controller: 'roleFunctionListController' + }) + + .when('/admin_menu_edit', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/admin_menu_edit.html', + controller: 'AdminMenuEditController' + }) + .when('/role/:roleId', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/role.html', + controller: 'roleController' + }) + .when('/jcs_admin', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/jcs_admin.html', + controller: 'cacheAdminController' + }) + .when('/broadcast_list', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/broadcast_list.html', + controller: 'broadcastListController' + }) + .when('/broadcast/:messageLocationId/:messageLocation/:messageId', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/broadcast.html', + controller: 'broadcastController' + }) + .when('/broadcast/:messageLocationId/:messageLocation', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/broadcast.html', + controller: 'broadcastController' + }) + .when('/collaborate_list', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/collaborate_list.html', + controller: 'collaborateListController' + }) + .when('/usage_list', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/usage_list.html', + controller: 'usageListController' + }) + .otherwise({ + templateUrl: 'app/fusion/scripts/view-models/profile-page/role_list.html', + controller : "roleListController" + }); +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/admin_menu_edit.js b/vid/src/main/webapp/app/fusion/scripts/controllers/admin_menu_edit.js new file mode 100644 index 00000000..54d58a45 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/admin_menu_edit.js @@ -0,0 +1,230 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('AdminMenuEditController', function ($scope, AdminService, modalService, $modal, $route){ + $( "#dialog" ).hide(); + +/* AdminService.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.init = function () { + $scope.numberOfRecordstoShow=20; + AdminService.getFnMenuItems().then(function(data){ + var j = data; + $scope.data =JSON.parse(j.data); + $scope.fnMenuItems =($scope.data.fnMenuItems); + + },function(error){ + console.log("failed"); + //reloadPageOnce(); + }); + } + $scope.init(); + $scope.mapActiveStatus = function(status){ + if(status) + status = "Y"; + else + status = "N"; + return status; + + }; + + + $scope.addNewFnMenuItemModalPopup = function(availableFnMenuItem) { + $scope.editFnMenuItem = null; + var modalInstance = $modal.open({ + templateUrl: 'fn_menu_add_popup.html', + controller: 'fn_menu_popupController', + resolve: { + message: function () { + var message = { + availableFnMenuItem: $scope.editFnMenuItem + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.availableFnMenuItems=response.availableFnMenuItems; + $route.reload(); + }); + }; + + $scope.removeMenuItem = function(fnMenuItem) { + modalService.popupConfirmWin("Confirm","You are about to delete the menu item "+fnMenuItem.label+". Do you want to continue?", + function(){ + var uuu = "admin_fn_menu/removeMenuItem.htm"; + var postData={fnMenuItem: fnMenuItem}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.fnMenuItem=data.fnMenuItem;}); + $route.reload(); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + }) + + }; + + $scope.editRoleFunction = null; + var dialog = null; + $scope.editRoleFunctionPopup = function(availableRoleFunction) { + $scope.editRoleFunction = availableRoleFunction; + $( "#dialog" ).dialog({ + modal: true + }); + }; + + $scope.editMenuItemModalPopup = function(availableFnMenuItem) { + $scope.editFnMenuItem = availableFnMenuItem; + var modalInstance = $modal.open({ + templateUrl: 'fn_menu_add_popup.html', + controller: 'fn_menu_popupController', + resolve: { + message: function () { + var message = { + availableFnMenuItem: $scope.editFnMenuItem + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + $scope.availableFnMenuItems=response.availableFnMenuItems; + $route.reload(); + }); + }; + + $scope.editRoleFunctionModalPopup = function(availableRoleFunction) { + $scope.editRoleFunction = availableRoleFunction; + var modalInstance = $modal.open({ + templateUrl: 'edit_role_function_popup.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.availableRoleFunctions=response.availableRoleFunctions; + }); + }; + + $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { + $scope.editRoleFunction = null; + var modalInstance = $modal.open({ + templateUrl: 'edit_role_function_popup.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.availableRoleFunctions=response.availableRoleFunctions; + }); + }; + + $scope.addNewRoleFunctionPopup = function() { + $scope.editRoleFunction = null; + $( "#dialog" ).dialog({ + modal: true + }); + }; + + $scope.saveRoleFunction = function(availableRoleFunction) { + var uuu = "role_function_list/saveRoleFunction.htm"; + var postData={availableRoleFunction: availableRoleFunction}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.availableRoleFunctions=[];$scope.$apply(); + $scope.availableRoleFunctions=data.availableRoleFunctions;}); + //alert("Update Successful.") ; + console.log($scope.availableRoleFunctions); + + $scope.editRoleFunction = null; + $( "#dialog" ).dialog("close"); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }; + + + $scope.removeRole = function(availableRoleFunction) { + modalService.popupConfirmWin("Confirm","You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?", + function(){ + var uuu = "role_function_list/removeRoleFunction.htm"; + var postData={availableRoleFunction: availableRoleFunction}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.availableRoleFunctions=data.availableRoleFunctions;}); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + }) + + }; + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/ase-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/ase-controller.js new file mode 100644 index 00000000..45fc31ac --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/ase-controller.js @@ -0,0 +1,22 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('aseCtrl', function ($scope){ +/* do nothing yet*/ +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-controller.js new file mode 100644 index 00000000..77ee22f5 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-controller.js @@ -0,0 +1,79 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('broadcastController', function ($scope, modalService, $modal,AdminService,$routeParams){ + //$scope.broadcastMessage=${broadcastMessage}; + //$scope.broadcastSites=${broadcastSites}; + //console.log($scope.broadcastMessage); + $scope.broadcastMessage=[]; + $scope.broadcastSites=[]; + AdminService.getBroadcast($routeParams.messageLocationId, $routeParams.messageLocation, $routeParams.messageId).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.broadcastMessage=JSON.parse($scope.data.broadcastMessage); + $scope.broadcastSites=JSON.parse($scope.data.broadcastSites); + console.log($scope.broadcastMessage); + console.log($scope.broadcastMessage.id); + console.log($scope.broadcastSites); + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + $scope.save = function() { + var uuu = "broadcast/save"; + var postData={broadcastMessage: $scope.broadcastMessage}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + window.location.href = "admin#/broadcast_list"; + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }; + + $scope.close = function() { + window.location.href = "admin#/broadcast_list"; +}; + +}); + +$(function() { + $( "#startDatepicker" ).datepicker(); + $( "#endDatepicker" ).datepicker(); + + $( "#startDatepicker" ).change(function() { + var tempStartDate = moment($( "#startDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S'); + $( "#startDateHidden" ).val(tempStartDate.toString()); + //alert( $( "#startDateHidden" ).val() ); + }); + $( "#endDatepicker" ).change(function() { + var tempEndDate = moment($( "#endDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S'); + $( "#endDateHidden" ).val(tempEndDate.toString()); + //alert( $( "#endDateHidden" ).val() ); + }); +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-list-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-list-controller.js new file mode 100644 index 00000000..cb10a29b --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/broadcast-list-controller.js @@ -0,0 +1,120 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('broadcastListController', function ($scope, modalService, $modal,AdminService){ + //$scope.broadcastMessage=${broadcastMessage}; + //$scope.broadcastSites=${broadcastSites}; + //console.log($scope.broadcastMessage); + var messagesMap = {}; + AdminService.getBroadcastList().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.messagesList=(($scope.data.messagesList===null) ? [""]:$scope.data.messagesList); + $scope.messageLocations=(($scope.data.messageLocations===null) ? [""]:$scope.data.messageLocations); + console.log("messages: "+$scope.messagesList); + console.log("location: "+$scope.messageLocations); + $.each($scope.messageLocations, function(i, a){ + //var result = []; + angular.forEach($scope.messagesList, function(value, key) { + if (key+'' === a.value+'') { + //var objsJSON = JSON.parse(value); + + $.each(value, function(i, a){ + var startDateLong = a.startDate; + var tempStartDate = new Date(startDateLong); + tempStartDate = moment(tempStartDate).format('DD MMM YYYY hh:mmA zz');//03 Jun 2013 04:15PM EDT + a.displayStartDate=tempStartDate.toString(); + + var endDateLong = a.endDate; + var tempEndDate = new Date(endDateLong); + tempEndDate = moment(tempEndDate).format('DD MMM YYYY hh:mmA zz');//03 Jun 2013 04:15PM EDT + a.displayEndDate=tempEndDate.toString(); + }); + a.messages = value; + } + }); + console.log(a.messages); + }); + + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + + $scope.editMessage = function(location) { + + editMessage(location.value, location.label); + }; + + $scope.toggleActive = function(broadcastMessage) { + + //alert('deleted'+role.name); + var uuu = "broadcast_list/toggleActive"; + var postData={broadcastMessage:broadcastMessage}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + //window.location.reload(); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while toggling: "+ data.responseText); + + } + }); + + + }; + + $scope.remove = function(broadcastMessage) { + + //alert('deleted'+role.name); + var uuu = "broadcast_list/remove"; + var postData={broadcastMessage:broadcastMessage}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + window.location.reload(); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + + }; + +}); + +function editMessage(messageLocationId, messageLocation, messageId) { + window.location='admin#/broadcast/'+messageLocationId + '/' + messageLocation + ((messageId != null) ? '/' + messageId : ''); +} diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/collaborate-list-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/collaborate-list-controller.js new file mode 100644 index 00000000..5b0b9342 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/collaborate-list-controller.js @@ -0,0 +1,63 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller("collaborateListController", function ($scope,$http,modalService, $modal,AdminService) { + // Table Data + AdminService.getCollaborateList().then(function(data){ + + var j = data; + $scope.tableData = JSON.parse(j.data); + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + $scope.viewPerPage = 20; + $scope.scrollViewsPerPage = 2; + $scope.currentPage = 1; + $scope.totalPage; + $scope.searchCategory = ""; + $scope.searchString = ""; + /* modalService.showSuccess('','Modal Sample') ; */ + for(x in $scope.tableData){ + if($scope.tableData[x].active_yn=='Y') + $scope.tableData[x].active_yn=true; + else + $scope.tableData[x].active_yn=false; + } + $scope.openCollaboration = function(chatId){ + openInNewTab('collaboration?chat_id=' + chatId); + } + + $scope.toggleProfileActive = function(profileId) { + modalService.popupConfirmWin("Confirm","You are about to change user's active status. Do you want to continue?", + function(){ + $http.get("profile/toggleProfileActive?profile_id="+profileId).success(function(){}); + + }) + }; + +}); + +function openInNewTab(url) { + var win = window.open(url, '_blank'); + win.focus(); +}; diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/dummy.txt b/vid/src/main/webapp/app/fusion/scripts/controllers/dummy.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/dummy.txt diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/fn_menu_add_popup_controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/fn_menu_add_popup_controller.js new file mode 100644 index 00000000..e0179946 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/fn_menu_add_popup_controller.js @@ -0,0 +1,281 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +var fn_menu_popupController = function ($scope, $modalInstance, message, $http){ /// examine the LeftMenuService + if(message.availableFnMenuItem==null) + $scope.label='Add New Menu Item' + + else{ + $scope.label='Edit Menu Item' + //$scope.disableParentId=true; + } + + $scope.getParentData = function(){ + var uuu = "admin_fn_menu/get_parent_list" + $.ajax({ + type : 'GET', + url : uuu, + dataType: 'json', // data type expected from server + contentType: 'application/json', + //data: JSON.stringify(postData), // data type sent to server + success : function(data){ + $scope.$apply(function(){ + //$scope.availableRoleFunctions=[];$scope.$apply(); + $scope.parentListSelectData=data; // data from server + menuItems = $scope.parentListSelectData; + var heirarchicalMenuItems = []; + var children = []; + for ( var i=0; i<menuItems.length; i++){ + for(var j=0; j<menuItems.length; j++){ + if(menuItems[j][2]==menuItems[i][0]) + children.push( + { + menuId: menuItems[j][0], + label: menuItems[j][1] + } + ); + } + if(children.length!=0){ + heirarchicalMenuItems.push( + { + + menuId: menuItems[i][0], + label: menuItems[i][1], + children: children.sort($scope.sortItems("label")) + } + + ); + } + children = []; + + } + heirarchicalMenuItems.sort($scope.sortItems("label")); + $scope.childListSelectData = heirarchicalMenuItems; + //console.log(data); + }); + //$scope.editRoleFunction = null; + ///$modalInstance.close({functionCDselectData:$scope.functionCDselectData}); + }, + error : function(data){ + alert("Parent Data not available !"); + } + }); + + }; + + $scope.sortItems = function(prop){ + return function(a, b) { + if (a[prop] > b[prop]) { + return 1; + } else if (a[prop] < b[prop]) { + return -1; + } + return 0; + } + + }; + + $scope.getParentLabel = function(parentId, parentListSelectData){ + var element; + element = parentListSelectData[0]; + for (var i=0; i<parentListSelectData.length; i++){ + + element = parentListSelectData[i]; + if (element[0] == parentId) + return element[1]; + else "---"; + } + }; + + + $scope.getFunctionCDselectData = function(){ + var uuu = "admin_fn_menu/get_function_cd_list" + $.ajax({ + type : 'GET', + url : uuu, + dataType: 'json', // data type expected from server + contentType: 'application/json', + //data: JSON.stringify(postData), // data type sent to server + success : function(data){ + $scope.$apply(function(){ + //$scope.availableRoleFunctions=[];$scope.$apply(); + $scope.functionCDselectData=data; + }); + //alert("Update Successful.") ; + //$scope.editRoleFunction = null; + ///$modalInstance.close({functionCDselectData:$scope.functionCDselectData}); + }, + error : function(data){ + alert("Function Code Data not available !"); + } + }); + + }; + + if(message.availableFnMenuItem){ + $scope.addFnMenuItem = message.availableFnMenuItem; + } else { + $scope.addFnMenuItem = {}; + } + $scope.addFnMenuItem.menuSetCode = "APP"; + + $scope.statusOptions = [ + {index: 0, value: 'true', title: 'Y'}, + {index: 1, value: 'false', title: 'N'} + ]; + $scope.selectedValue = $scope.statusOptions[0]; + + $scope.separator = { + availableOptions:[ + {value: 'true', name: 'Y'}, + {value: 'false', name: 'N'} + ], + + selectedOption: {value: 'true', name: 'Y'} + + }; + + + $scope.activeStatusOptions = [ + {index: 0, value: 'true', title: 'Y'}, + {index: 1, value: 'false', title: 'N'} + ]; + $scope.activeSelectedValue = $scope.activeStatusOptions[0]; + + $scope.separatorStatusOptions = [ + {index: 0, value: 'true', title: 'Y'}, + {index: 1, value: 'false', title: 'N'} + ]; + $scope.separatorSelectedValue = $scope.separatorStatusOptions[1]; + + $scope.active = { + availableOptions:[ + {value: 'true', name: 'Y'}, + {value: 'false', name: 'N'} + ], + + selectedOption: {value: 'true', name: 'Y'} + + }; + + + $scope.updateFnMenu = function(availableFnMenuItem) { + // form validation + if( document.getElementById("popupAddMenuItemImageSrc").value == "" ) availableFnMenuItem.imageSrc = "N/A"; + if( document.getElementById("popupAddMenuItemTarget").value == "" ) availableFnMenuItem.target = "N/A"; + if( document.getElementById("popupAddMenuItemExternalUrl").value == "" ) availableFnMenuItem.externalUrl = "N/A"; + if( document.getElementById("popupAddMenuItemQueryString").value == "" ) availableFnMenuItem.queryString = "N/A"; + if( document.getElementById("popupAddMenuItemServlet").value == "" ) availableFnMenuItem.servlet = "N/A"; + + validationRule = /^\S{3,}$/; + var selectedFunction = document.getElementById("repeatSelect"); + var selectedFunctionText = selectedFunction.options[selectedFunction.selectedIndex].text; + if( + (document.getElementById("popupAddMenuItemLabel").value == "" || document.getElementById("popupAddMenuItemLabel").value.replace(" ", "").length == 0 ) ||//!validationRule.test(document.getElementById("popupAddMenuItemLabel").value)) || + document.getElementById("popupAddMenuItemParentId").value == "" || + document.getElementById("popupAddMenuItemAction").value == "" || + selectedFunctionText == "" || + document.getElementById("popupAddMenuItemSortOrder").value == "" || + document.getElementById("popupAddMenuItemMenuSetCode").value == "" + ) + { + alert("please provide valid entries !"); + } + + else{ + var uuu = "admin_fn_menu/updateFnMenu.htm"; + var postData={availableFnMenuItem: availableFnMenuItem}; + + $.ajax({ + type : 'POST', + url : uuu, + //dataType: 'json', // data type expected from server + contentType: 'application/json', + data: JSON.stringify(postData), // data type sent to server + success : function(data){ + $scope.$apply(function(){ + $scope.availableFnMenuItems=data.availableFnMenuItems; + }); + + $modalInstance.close({availableFnMenuItems:$scope.availableRoleFunctions}); + }, + error : function(data){ + alert("Error while saving."); + } + }); + + } + $scope.getLeftMenuItems(); // get left menu items again from database + + }; + + $scope.getLeftMenuItems = function() { + return $http.get('get_menu') + .then(function(response) { + if (typeof response.data === 'object') { + var leftChildData=[]; + var leftParentData=[]; + var leftMenuItems = []; + var j = response; + try{ + if(j && j !== "null" && j!== "undefined"){ + leftParentData = JSON.parse(j.data); + leftChildData = JSON.parse(j.data2); + }else{ + throw "Get Left Menu respsone is not an object/is empty"; + } + try{ + var leftChildItemList = leftChildData; + var pageUrl = window.location.href.split('/')[window.location.href.split('/').length-1]; + var leftParentList = leftParentData; + for (var i = 0; i < leftParentList.length; i++) { + $scope.item = { + parentLabel : leftParentList[i].label, + parentAction : leftParentList[i].action, + parentImageSrc : leftParentList[i].imageSrc, + open:pageUrl==leftParentList[i].action?true:false, + childItemList : leftChildItemList[i]==null?'x':leftChildItemList[i] + } + leftMenuItems.push($scope.item); + }; + + $scope.leftMenuItems = leftMenuItems; + + }catch(err){ + console.log("error happened while trying to set left menu structure: "+err); + } + }catch (e) { + console.log("error happened while trying to get left menu items: "+e); + reloadPageOnce(); + return; + } + return response.data; + } else { + return $q.reject(response.data); + } + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }; + + $scope.close = function() { + $modalInstance.close(); + }; +} diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/jcs-admin-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/jcs-admin-controller.js new file mode 100644 index 00000000..3891c5eb --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/jcs-admin-controller.js @@ -0,0 +1,83 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('cacheAdminController', function ($scope,$interval,$http,$modal,modalService,AdminService){ + + AdminService.getCacheRegions().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.regions =$scope.data; + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + $scope.clearAll = function() { + modalService.popupConfirmWin("Confirm",'You are about to clear all of the items for all cache regions. Do you want to continue?', + function(){ + $http.get("jcs_admin/clearAll").success(function(response){$scope.regions=response;}); + + }) + }; + + $scope.clearRegion = function(cacheName) { + modalService.popupConfirmWin("Confirm",'You are about to clear all of the items in the cache region "' + cacheName + '". Do you want to continue?', + function(){ + $http.get("jcs_admin/clearRegion?cacheName="+cacheName).success(function(response){$scope.regions=response;}); + + }) + }; + + $scope.clearItem = function(cacheName,key) { + modalService.popupConfirmWin("Confirm",'You are about to clear this item from the cache region "' + cacheName + '". Do you want to continue?', + function(){ + $http.get("jcs_admin/clearItem?keyName="+key+"&cacheName="+cacheName).success(function(response){$scope.regions=response;}); + + }) + }; + + $scope.showRegionDetails = function(cacheName) { + $http.get("jcs_admin/showRegionDetails?cacheName="+cacheName).success(function(response){modalService.showSuccess('',response);}); + }; + + $scope.showItemDetails = function(cacheName,key) { + $http.get("jcs_admin/showItemDetails?keyName="+key+"&cacheName="+cacheName).success(function(response){ + var message = "CacheName: "+ response.cacheName + +"\nkey: "+response.key + +"\nIS_SPOOL: "+response.attr.IS_SPOOL + +"\nIS_LATERAL: "+response.attr.IS_LATERAL + +"\nIS_REMOTE: "+response.attr.IS_REMOTE + +"\nIS_ETERNAL: "+response.attr.IS_ETERNAL + +"\nversion: "+response.attr.version + +"\nmaxLifeSeconds: "+response.attr.maxLifeSeconds + +"\nmaxIdleTimeSeconds: "+response.attr.maxIdleTimeSeconds + +"\nsize: "+response.attr.size + +"\ncreateTime: "+response.attr.createTime + +"\nlastAccessTime: "+response.attr.lastAccessTime + +"\nidleTime: "+response.attr.idleTime + +"\ntimeToLiveSeconds: "+response.attr.timeToLiveSeconds + +"\nisSpool: "+response.attr.isSpool + +"\nisLateral: "+response.attr.isLateral + +"\nisRemote: "+response.attr.isRemote + +"\nisEternal: "+response.attr.isEternal; + modalService.showSuccess('',message);}); + }; +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/modelpopupController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/modelpopupController.js new file mode 100644 index 00000000..8d66d728 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/modelpopupController.js @@ -0,0 +1,40 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +var modalpopupController = function ($scope, $modalInstance, message){ + + $scope.message = message; + + + $scope.hello = function () { + $modalInstance.close($scope.digitPattern); + }; + $modalInstance.ok = function() { + //add the ok functionality + alert("Logout"); + }; + $modalInstance.cancel = function() { + //add the cancel functionality + alert("Keep Log in"); + }; + $modalInstance.cancelbutton = function() { + //add the cancel functionality + alert("Modal Waring popup close event"); + }; +} diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/post-search-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/post-search-controller.js new file mode 100644 index 00000000..edb2cc53 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/post-search-controller.js @@ -0,0 +1,202 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('postSearchCtrl', function ($scope,$http,ProfileService,modalService){ + + $scope.viewPerPage = 200; + $scope.currentPage = 1; + $scope.totalPage; + $scope.searchCategory = ""; + $scope.searchString = ""; + + $scope.noResultsString = ""; + + ProfileService.getPostProfile().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + + $scope.postSearchBean =JSON.parse($scope.data.postSearchBean); + $scope.profileList =JSON.parse($scope.data.profileList); + $scope.ngexistingUsers=JSON.parse($scope.data.existingUsers); + $scope.ocisortByList=JSON.parse($scope.data.sortByList); + + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + $scope.sortByList = []; + if($scope.ocisortByList) + $.each($scope.ocisortByList, function(i, a){ + var sortBy = {"index":i, "value":a.value, "title":a.label}; + $scope.sortByList.push(sortBy); + }); + ; + + $scope.search = function(postSearchBean) { + console.log(postSearchBean); + var uuu = "post_search/search"; + var postData={postSearchBean:postSearchBean}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.profileList=data.users; + //$scope.postSearchBean={}; + console.log($scope.profileList); + if($scope.profileList.length == 0) + $scope.noResultsString = "There is currently no one in WEBPHONE matching your search criteria."; + else + $scope.noResultsString = ""; + }); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while searching: "+ data.responseText); + } + }); + + }; + + $scope.reset = function() { + $scope.postSearchBean={}; + $scope.profileList=[]; + $scope.noResultsString = ""; + //console.log($scope.postSearchBean); + }; + + $scope.process = function() { + $scope.prepareProfileSelection(); + var uuu = "post_search/process"; + var postData={postSearchBean:$scope.postSearchBean}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.profileList=data.users; + //$scope.postSearchBean={}; + $scope.ngexistingUsers=data.existingUsers; + $scope.postSearchBean.selected=null; + }); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while searching: "+ data.responseText); + } + }); + + }; + $scope.importProfileList=[]; + $scope.toggleSelection = function(profile) { + if(profile.selected) + $scope.importProfileList.push(profile); + else{ + var index = $scope.importProfileList.indexOf(profile); + if(index>=0) + $scope.importProfileList.splice(index, 1); + } + }; + + $scope.prepareProfileSelection = function() { + if($scope.importProfileList) + $.each($scope.importProfileList, function(i, profile){ + $scope.preparePostSearchBean(profile); + }); + ; + } + + $scope.preparePostSearchBean = function(profile) { + //console.log('Importing: '+profile.orgUserId); + //console.log('ngexistinguser:'+$scope.ngexistingUsers[profile.orgUserId]) + if($scope.postSearchBean.selected==null){ + $scope.postSearchBean.selected=[]; + $scope.postSearchBean.postOrgUserId=[]; + $scope.postSearchBean.postHrid=[]; + $scope.postSearchBean.postFirstName=[]; + $scope.postSearchBean.postLastName=[]; + $scope.postSearchBean.postOrgCode=[]; + $scope.postSearchBean.postPhone=[]; + $scope.postSearchBean.postEmail=[]; + $scope.postSearchBean.postAddress1=[]; + $scope.postSearchBean.postAddress2=[]; + $scope.postSearchBean.postCity=[]; + $scope.postSearchBean.postState=[]; + $scope.postSearchBean.postZipCode=[]; + $scope.postSearchBean.postLocationClli=[]; + $scope.postSearchBean.postBusinessCountryCode=[]; + $scope.postSearchBean.postBusinessCountryName=[]; + $scope.postSearchBean.postDepartment=[]; + $scope.postSearchBean.postDepartmentName=[]; + $scope.postSearchBean.postBusinessUnit=[]; + $scope.postSearchBean.postBusinessUnitName=[]; + $scope.postSearchBean.postJobTitle=[]; + $scope.postSearchBean.postOrgManagerUserId=[]; + $scope.postSearchBean.postCommandChain=[]; + $scope.postSearchBean.postCompanyCode=[]; + $scope.postSearchBean.postCompany=[]; + $scope.postSearchBean.postCostCenter=[]; + $scope.postSearchBean.postSiloStatus=[]; + $scope.postSearchBean.postFinancialLocCode=[]; + } + + $scope.postSearchBean.selected.push(profile.orgUserId); + $scope.postSearchBean.postOrgUserId.push(profile.orgUserId); + $scope.postSearchBean.postHrid.push(profile.hrid); + $scope.postSearchBean.postFirstName.push(profile.firstName); + $scope.postSearchBean.postLastName.push(profile.lastName); + $scope.postSearchBean.postOrgCode.push(profile.orgCode); + $scope.postSearchBean.postPhone.push(profile.phone); + $scope.postSearchBean.postEmail.push(profile.email); + $scope.postSearchBean.postAddress1.push(profile.address1); + $scope.postSearchBean.postAddress2.push(profile.address2); + $scope.postSearchBean.postCity.push(profile.city); + $scope.postSearchBean.postState.push(profile.state); + if(profile.zipCodeSuffix==null) + $scope.postSearchBean.postZipCode.push(profile.zipCode); + else + $scope.postSearchBean.postZipCode.push(profile.zipCode+'-'+profile.zipCodeSuffix); + $scope.postSearchBean.postLocationClli.push(profile.locationClli); + $scope.postSearchBean.postBusinessCountryCode.push(profile.businessCountryCode); + $scope.postSearchBean.postBusinessCountryName.push(profile.businessCountryName); + $scope.postSearchBean.postDepartment.push(profile.department); + $scope.postSearchBean.postDepartmentName.push(profile.departmentName); + $scope.postSearchBean.postBusinessUnit.push(profile.businessUnit); + $scope.postSearchBean.postBusinessUnitName.push(profile.businessUnitName); + $scope.postSearchBean.postJobTitle.push(profile.jobTitle); + $scope.postSearchBean.postOrgManagerUserId.push(profile.orgManagerUserId); + $scope.postSearchBean.postCommandChain.push(profile.commandChain); + $scope.postSearchBean.postCompanyCode.push(profile.companyCode); + $scope.postSearchBean.postCompany.push(profile.company); + $scope.postSearchBean.postCostCenter.push(profile.costCenter); + $scope.postSearchBean.postSiloStatus.push(profile.siloStatus); + $scope.postSearchBean.postFinancialLocCode.push(profile.financialLocCode); + }; + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/profile-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/profile-controller.js new file mode 100644 index 00000000..aa0066b0 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/profile-controller.js @@ -0,0 +1,286 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('profileController', function ($scope,$http,ProfileService,$routeParams,modalService){ + $scope.tableData=[]; + $scope.profile=[]; + $scope.ociavailableRoles=[]; + $scope.ociTimeZones; + $scope.ociCountries; + var stateList=[]; + $scope.availableRoles = []; + $scope.timeZones = []; + $scope.selectedTimeZone = null; + $scope.countries = []; + $scope.selectedCountry = null; + + ProfileService.getProfileDetail($routeParams.profileId).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profile =JSON.parse($scope.data.profile); + $scope.ociavailableRoles =JSON.parse($scope.data.availableRoles); + $scope.ociTimeZones=JSON.parse($scope.data.timeZones); + $scope.ociCountries=JSON.parse($scope.data.countries); + stateList=JSON.parse($scope.data.stateList); + $scope.orgUserId=$scope.profile.orgUserId; + $scope.orgManagerUserId=$scope.profile.orgManagerUserId; + + + if($scope.ociavailableRoles) + $.each($scope.ociavailableRoles, function(i, a){ + var availableRole = a; + availableRole.selected = false; + $.each($scope.profile.roles, function(j, b){ + if(a.id === b.id) { + availableRole.selected = true; + } + }); + $scope.availableRoles.push(availableRole); + }); + ; + + /*$scope.ociTimeZones = ${model.timeZones};*/ + + if($scope.ociTimeZones){ + $.each($scope.ociTimeZones, function(i, a){ + var timeZone = {"index":i, "value":a.value, "title":a.label}; + $scope.timeZones.push(timeZone); + if($scope.profile.timeZoneId !== null && a.value === $scope.profile.timeZoneId.toString()){ + $scope.selectedTimeZone = timeZone; + } + }); + }; + + /*$scope.ociCountries = ${model.countries};*/ + + //alert($scope.ociCountries[0].label); + if($scope.ociCountries) + $.each($scope.ociCountries, function(i, a){ + var country = {"index":i, "value":a.value, "title":a.label}; + $scope.countries.push(country); + if(a.value === $scope.profile.country){ + $scope.selectedCountry = country; + } + }); + ; + + /*var stateList=${model.stateList};*/ + //alert(stateList[0].label); + stateList = stateList== null? []: stateList; + var selectedState= $scope.profile.state ? $scope.profile.state:""; + $scope.stateList = initDropdownWithLookUp(stateList,selectedState ); + + //$scope.resetMenu(); + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + /*$scope.profile=${model.profile};*/ + $scope.orgUserId=$scope.profile.orgUserId; + $scope.orgManagerUserId=$scope.profile.orgManagerUserId; + + $scope.viewPerPage = 2; + $scope.currentPage = 1; + $scope.totalPage; + $scope.searchCategory = ""; + $scope.searchString = ""; + + $( "#dialog" ).hide(); + + /*$scope.ociavailableRoles=${model.availableRoles};*/ + //modalService.showFailure('Error','') ; + + + $scope.saveProfile = function() { + var uuu = "profile/saveProfile?profile_id=" + $routeParams.profileId; + var postData={profile: $scope.profile, + selectedCountry:$scope.selectedCountry!=null?$scope.selectedCountry.value:"", + selectedState:$scope.stateList.selected!=null?$scope.stateList.selected.value:"", + selectedTimeZone:$scope.selectedTimeZone!=null?$scope.selectedTimeZone.value:"" + }; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + modalService.showSuccess("Success","Update Successful."); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }; + + $scope.addNewRolePopup = function(role) { + $( "#dialog" ).dialog({ + modal: true, + width: 500, + height:600 + }); + $(".ui-dialog").css("z-index",2001); + $(".ui-dialog-titlebar").hide(); + }; + + $scope.toggleRole = function(selected,availableRole) { + $scope.profileTemp=$scope.profile; + $scope.profile={}; + //alert('toggleRole: '+selected); + if(!selected) { + //remove role + var uuu = "profile/removeRole?profile_id=" + $routeParams.profileId; + modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the role "+availableRole.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + var postData={role:availableRole}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.profile=data;}); + }, + error : function(data){ + $scope.$apply(function(){$scope.profile=$scope.profileTemp;}); + modalService.showFailure("Fail","Error while saving."); + } + }); + }, + function(){ + availableRole.selected=!availableRole.selected; + }); + + + } else { + //add role + var uuu = "profile/addNewRole?profile_id=" + $routeParams.profileId; + modalService.popupConfirmWinWithCancel("Confirm","You are about to add the role "+availableRole.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + var postData={role:availableRole}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.profile=data;}); + }, + error : function(data){ + $scope.$apply(function(){$scope.profile=$scope.profileTemp;}); + modalService.showFailure("Fail","Error while saving."); + } + }); + + },function(){ + availableRole.selected=!availableRole.selected; + }) + + } + + + }; + + $scope.removeRole = function(role) { + + + modalService.popupConfirmWin("Confirm","You are about to remove the role "+role.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + $scope.profileTemp=$scope.profile; + $scope.profile={}; + var uuu = "profile/removeRole?profile_id=" + $routeParams.profileId; + 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.profile=data; + $.each($scope.availableRoles, function(k, c){ + if(c.id === role.id) { + c.selected = false; + } + }); + }); + + }, + error : function(data){ + $scope.$apply(function(){$scope.profile=$scope.profileTemp;}); + modalService.showFailure("Fail","Error while saving."); + } + }); + + }) + + + }; + + function initDropdownWithLookUp(arr,selectedValue){ + var dropdownArray=[]; + var selected = null; + if(arr){ + for(var i = 0,l = arr.length; i < l; i++) { + var option = { + "index" : i , + "value" : arr[i].value, + "title" : arr[i].label + }; + dropdownArray.push(option); + if(arr[i].value === selectedValue){ + selected = option; + } + } + } + var dropDown={}; + dropDown.options = dropdownArray; + dropDown.selected = selected; + return dropDown; + }; + + $scope.doRolePopup = function() { + var modalInstance = $modal.open({ + templateUrl: 'roles_popup.html', + controller: 'rolepopupController', + resolve: { + message: function () { + var message ={ + availableRoles: $scope.availableRoles + }; + return message; + } + } + }); + modalInstance.result.then(function (opts) { + if(opts!=null){ + $scope.profile=opts.profile; + } + }); + } + + $scope.close = function(){ + $('#dialog').dialog('close'); + } + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/profile-search-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/profile-search-controller.js new file mode 100644 index 00000000..6da82dcc --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/profile-search-controller.js @@ -0,0 +1,80 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('profileSearchCtrl', function($scope, $http,ProfileService,modalService){ + + $scope.showInput = true; + $scope.totalPages1 = 5; + $scope.viewPerPage1 = 8; + $scope.currentPage1 = 1; + + $scope.$watch('viewPerPage1', function(val) { + ProfileService.getProfilePagination($scope.currentPage1, val).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.tableData =JSON.parse($scope.data.profileList); + $scope.totalPages1 =JSON.parse($scope.data.totalPage); + for(x in $scope.tableData){ + if($scope.tableData[x].active_yn=='Y') + $scope.tableData[x].active_yn=true; + else + $scope.tableData[x].active_yn=false; + } + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + }); + + $scope.customHandler = function(num) { + $scope.currentPage1 = num; + ProfileService.getProfilePagination($scope.currentPage1,$scope.viewPerPage1).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.tableData =JSON.parse($scope.data.profileList); + $scope.totalPages1 =JSON.parse($scope.data.totalPage); + for(x in $scope.tableData){ + if($scope.tableData[x].active_yn=='Y') + $scope.tableData[x].active_yn=true; + else + $scope.tableData[x].active_yn=false; + } + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + }; + + $scope.editRow = function(profileId){ + window.location = 'userProfile#/profile/' + profileId; + }; + + $scope.toggleProfileActive = function(rowData) { + modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?", + function(){ + $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){}); + }, + function(){ + rowData.active=!rowData.active; + }) + }; + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/profileController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/profileController.js new file mode 100644 index 00000000..4b30e40e --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/profileController.js @@ -0,0 +1,38 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.config(function($routeProvider) { + $routeProvider + .when('/profile/:profileId', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/profile_detail.html', + controller: 'profileController' + }) + .when('/post_search', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/post_search.html', + controller: 'postSearchCtrl' + }) + .when('/self_profile', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/self_profile.html', + controller: 'selfProfileController' + }) + .otherwise({ + templateUrl: 'app/fusion/scripts/view-models/profile-page/profile_search.html', + controller : "profileSearchCtrl" + }); +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/role-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/role-controller.js new file mode 100644 index 00000000..50913af8 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/role-controller.js @@ -0,0 +1,226 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('roleController', function ($scope, modalService, $modal, AdminService,$routeParams){ + //$scope.role=${role}; + //console.log($scope.role.roleFunctions); + + $( "#dialogRoleFunction" ).hide(); + $( "#dialogChildRole" ).hide(); + + //$scope.ociavailableRoleFunctions=${availableRoleFunctions}; + + AdminService.getRole($routeParams.roleId).then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + + $scope.role =JSON.parse($scope.data.role); + console.log($scope.role); + + $scope.ociavailableRoleFunctions =JSON.parse($scope.data.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.ociavailableRoles=JSON.parse($scope.data.availableRoles); + console.log($scope.ociavailableRoles); + console.log("testing roles if exist"); + $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("failed"); + reloadPageOnce(); + }); + + $scope.saveRole = function() { + var exists = false; + for(x in $scope.availableRoles){ + console.log($scope.availableRoles[x].name); + if($scope.availableRoles[x].name==$scope.role.name){ + modalService.showFailure("Warning", "Role already exists."); + exists = true; + //$modalInstance.close({availableRoleFunctions:message.availableRoleFunctions}); + } + } + if(!exists){ + var uuu = "role/saveRole.htm?role_id="+$routeParams.roleId; + var postData={role: $scope.role, childRoles: $scope.role.childRoles, roleFunctions : $scope.role.roleFunctions}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + modalService.showSuccess("Success","Update Successful."); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while saving."); + } + }); + } + + }; + + $scope.addNewRoleFunctionModalPopup = function() { + var modalInstance = $modal.open({ + templateUrl: 'role_functions_popup.html', + controller: 'rolepopupController', + backdrop: 'static', + resolve: { + roleId: function () { + return $routeParams.roleId; + }, + role: function () { + return $scope.role; + }, + availableRoles: function () { + return $scope.ociavailableRoles; + }, + availableRoleFunctions: function () { + return $scope.ociavailableRoleFunctions; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.role=response.role; + }); + }; + + $scope.addNewChildRoleModalPopup = function() { + var modalInstance = $modal.open({ + templateUrl: 'child_roles_popup.html', + controller: 'rolepopupController', + backdrop: 'static', + resolve: { + roleId: function () { + return $routeParams.roleId; + }, + role: function () { + return $scope.role; + }, + availableRoles: function () { + return $scope.ociavailableRoles; + }, + availableRoleFunctions: function () { + return $scope.ociavailableRoleFunctions; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.role=response.role; + }); + }; + + + + $scope.removeRoleFunction = function(roleFunction) { + modalService.popupConfirmWin("Confirm","You are about to remove the role function "+roleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var uuu = "role/removeRoleFunction.htm?role_id=" + $routeParams.roleId; + var postData={roleFunction:roleFunction}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.role=data.role; + $.each($scope.availableRoleFunctions, function(k, c){ + if(c.code === roleFunction.code) { + c.selected = false; + } + }); + }); + + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + + }) + + }; + + $scope.removeChildRole = function(childRole) { + modalService.popupConfirmWin("Confirm","You are about to remove the child role "+childRole.name+" from the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var uuu = "role/removeChildRole.htm?role_id=" + $routeParams.roleId; + var postData={childRole:childRole}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.role=data.role; + $.each($scope.availableRoles, function(k, c){ + if(c.id === childRole.id) { + c.selected = false; + } + }); + }); + + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + + }) + + }; + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/role-function-list-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/role-function-list-controller.js new file mode 100644 index 00000000..eedac3e0 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/role-function-list-controller.js @@ -0,0 +1,157 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('roleFunctionListController', function ($scope, AdminService, modalService, $modal){ + $( "#dialog" ).hide(); + + AdminService.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 = $modal.open({ + templateUrl: 'edit_role_function_popup.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + if(response!=null) + $scope.availableRoleFunctions=response.availableRoleFunctions; + else + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + }); + }; + + $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { + $scope.editRoleFunction = null; + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + $scope.availableRoleFunctions={}; + var modalInstance = $modal.open({ + templateUrl: 'edit_role_function_popup.html', + controller: 'rolefunctionpopupController', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + if(response!=null) + $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 = "role_function_list/saveRoleFunction.htm"; + var postData={availableRoleFunction: availableRoleFunction}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.availableRoleFunctions=[];$scope.$apply(); + $scope.availableRoleFunctions=data.availableRoleFunctions;}); + //alert("Update Successful.") ; + console.log($scope.availableRoleFunctions); + + $scope.editRoleFunction = null; + $( "#dialog" ).dialog("close"); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }; + + + $scope.removeRole = function(availableRoleFunction) { + modalService.popupConfirmWin("Confirm","You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?", + function(){ + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + $scope.availableRoleFunctions={}; + var uuu = "role_function_list/removeRoleFunction.htm"; + var postData={availableRoleFunction: availableRoleFunction}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.availableRoleFunctions=data.availableRoleFunctions;}); + }, + error : function(data){ + console.log(data); + $scope.$apply(function(){$scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp;}); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + }) + + }; + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/role-list-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/role-list-controller.js new file mode 100644 index 00000000..a16d61ef --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/role-list-controller.js @@ -0,0 +1,102 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('roleListController', function ($scope,AdminService,modalService){ + + AdminService.getRoles().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoles =JSON.parse($scope.data.availableRoles); + + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + //console.log($scope.availableRoles); + $scope.toggleRole = function(selected,availableRole) { + //alert('toggleRole: '+selected); + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + + modalService.popupConfirmWinWithCancel("Confirm","You are about to "+toggleType+" the test role "+availableRole.name+". Do you want to continue?", + function(){ + var uuu = "role_list/toggleRole"; + + var postData={role:availableRole}; + $.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); + modalService.showFailure("Fail","Error while saving."); + } + }); + + }, + function(){ + availableRole.active=!availableRole.active; + }) + + + }; + + $scope.removeRole = function(role) { + + modalService.popupConfirmWin("Confirm","You are about to delete the role "+role.name+". Do you want to continue?", + function(){ + var uuu = "role_list/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); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + }) + + + }; + + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/rolefunctionpopupController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/rolefunctionpopupController.js new file mode 100644 index 00000000..14aea22c --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/rolefunctionpopupController.js @@ -0,0 +1,84 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +var rolefunctionpopupController = function ($scope, modalService, $modalInstance, message, $http,AdminService){ + 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 = message.availableRoleFunction; + } + + $scope.tempText = tempText; + + $scope.saveRoleFunction = function(availableRoleFunction) { + var uuu = "role_function_list/saveRoleFunction.htm"; + var postData={availableRoleFunction: availableRoleFunction}; + + if(availableRoleFunction==null){ + modalService.showFailure("Warning", "Please enter valid role function details."); + } + var exists = false; + for(x in message.availableRoleFunctions){ + console.log(message.availableRoleFunctions[x].name); + if(message.availableRoleFunctions[x].name==availableRoleFunction.name){ + modalService.showFailure("Warning", "Role Function already exists."); + exists = true; + availableRoleFunction.name = $scope.tempText; + } + } + + 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; + AdminService.getRoleFunctionList().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + + //$scope.resetMenu(); + $modalInstance.close(); + },function(error){ + console.log("failed"); + reloadPageOnce(); + $modalInstance.close(); + }); + + + }); + + + + + } + }; + + + + $scope.close = function() { + $modalInstance.close(); + }; +} diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/rolepopupmodelController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/rolepopupmodelController.js new file mode 100644 index 00000000..f8ecfadd --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/rolepopupmodelController.js @@ -0,0 +1,205 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +var rolepopupController = function ($scope, $modalInstance, role, roleId, availableRoles, availableRoleFunctions,AdminService,modalService){ + + $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 = "role/removeRoleFunction.htm?role_id=" + roleId; + modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the role function "+availableRoleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var postData={roleFunction:availableRoleFunction}; + $.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; + }) + + } else { + //add role function + if(role.id==null){ + $scope.role.roleFunctions.push(availableRoleFunction); + return; + } + var uuu = "role/addRoleFunction.htm?role_id=" + roleId; + + modalService.popupConfirmWinWithCancel("Confirm","You are about to add the role function "+availableRoleFunction.name+" to the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var postData={roleFunction:availableRoleFunction}; + $.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 = "role/removeChildRole.htm?role_id=" + roleId; + + modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the child role "+availableRole.name+" from the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var postData={childRole:availableRole}; + $.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."); + } + }); + + }, + function(){ + availableRole.selected=true; + }) + + } else { + //add role + if(role.id==null){ + $scope.role.childRoles.push(availableRole); + return; + } + var uuu = "role/addChildRole.htm?role_id=" + roleId; + + modalService.popupConfirmWinWithCancel("Confirm","You are about to add the child role "+availableRole.name+" to the role for "+$scope.role.name+". Do you want to continue?", + function(){ + var postData={childRole:availableRole}; + $.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(){ + availableRole.selected=false; + }) + } + + + }; + + $scope.close = function() { + console.log('role', $scope.role); + $modalInstance.close({role:$scope.role}); + }; + +} diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/self-profile-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/self-profile-controller.js new file mode 100644 index 00000000..b82dae30 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/self-profile-controller.js @@ -0,0 +1,284 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('selfProfileController', function ($scope,$http,ProfileService,$routeParams,modalService){ + $scope.tableData=[]; + $scope.profile=[]; + $scope.ociavailableRoles=[]; + $scope.ociTimeZones; + $scope.ociCountries; + var stateList=[]; + $scope.availableRoles = []; + $scope.timeZones = []; + $scope.selectedTimeZone = null; + $scope.countries = []; + $scope.selectedCountry = null; + $scope.isUserSystemAdmin = false; + + ProfileService.getSelfProfileDetail().then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profile =JSON.parse($scope.data.profile); + $scope.profileId = $scope.profile.id; + $scope.ociavailableRoles =JSON.parse($scope.data.availableRoles); + $scope.ociTimeZones=JSON.parse($scope.data.timeZones); + $scope.ociCountries=JSON.parse($scope.data.countries); + stateList=JSON.parse($scope.data.stateList); + $scope.orgUserId=$scope.profile.orgUserId; + $scope.orgManagerUserId=$scope.profile.orgManagerUserId; + + if($scope.ociavailableRoles) + $.each($scope.ociavailableRoles, function(i, a){ + var availableRole = a; + availableRole.selected = false; + $.each($scope.profile.roles, function(j, b){ + if(a.id === b.id) { + availableRole.selected = true; + if(a.id === 1){ + $scope.isUserSystemAdmin = true; + } + } + }); + $scope.availableRoles.push(availableRole); + }); + ; + + /*$scope.ociTimeZones = ${model.timeZones};*/ + + if($scope.ociTimeZones){ + $.each($scope.ociTimeZones, function(i, a){ + var timeZone = {"index":i, "value":a.value, "title":a.label}; + $scope.timeZones.push(timeZone); + if($scope.profile.timeZoneId !== null && a.value === $scope.profile.timeZoneId.toString()){ + $scope.selectedTimeZone = timeZone; + } + }); + }; + + /*$scope.ociCountries = ${model.countries};*/ + + //alert($scope.ociCountries[0].label); + if($scope.ociCountries) + $.each($scope.ociCountries, function(i, a){ + var country = {"index":i, "value":a.value, "title":a.label}; + $scope.countries.push(country); + if(a.value === $scope.profile.country){ + $scope.selectedCountry = country; + } + }); + ; + + /*var stateList=${model.stateList};*/ + //alert(stateList[0].label); + stateList = stateList== null? []: stateList; + var selectedState= $scope.profile.state ? $scope.profile.state:""; + $scope.stateList = initDropdownWithLookUp(stateList,selectedState ); + + //$scope.resetMenu(); + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + /*$scope.profile=${model.profile};*/ + $scope.orgUserId=$scope.profile.orgUserId; + $scope.orgManagerUserId=$scope.profile.orgManagerUserId; + + $scope.viewPerPage = 2; + $scope.currentPage = 1; + $scope.totalPage; + $scope.searchCategory = ""; + $scope.searchString = ""; + + $( "#dialog" ).hide(); + + /*$scope.ociavailableRoles=${model.availableRoles};*/ + //modalService.showFailure('Error','') ; + + + $scope.saveProfile = function() { + var uuu = "profile/saveProfile?profile_id=" + $scope.profileId;; + var postData={profile: $scope.profile, + selectedCountry:$scope.selectedCountry!=null?$scope.selectedCountry.value:"", + selectedState:$scope.stateList.selected!=null?$scope.stateList.selected.value:"", + selectedTimeZone:$scope.selectedTimeZone!=null?$scope.selectedTimeZone.value:"" + }; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + modalService.showSuccess("Success","Update Successful."); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }; + + $scope.addNewRolePopup = function(role) { + $( "#dialog" ).dialog({ + modal: true, + width: 500, + height:600 + }); + + $(".ui-dialog").css("z-index",10002); + $(".ui-dialog-titlebar").hide(); + }; + + $scope.toggleRole = function(selected,availableRole) { + //alert('toggleRole: '+selected); + if(!selected) { + //remove role + var uuu = "profile/removeRole?profile_id=" + $scope.profileId;; + modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the role "+availableRole.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + var postData={role:availableRole}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.profile=data;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + }, + function(){ + availableRole.selected=!availableRole.selected; + }); + + + } else { + //add role + var uuu = "profile/addNewRole?profile_id=" + $scope.profileId;; + modalService.popupConfirmWinWithCancel("Confirm","You are about to add the role "+availableRole.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + var postData={role:availableRole}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.profile=data;}); + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + + },function(){ + availableRole.selected=!availableRole.selected; + }) + + } + + + }; + + $scope.removeRole = function(role) { + + + modalService.popupConfirmWin("Confirm","You are about to remove the role "+role.name+" from the profile for "+$scope.profile.firstName+" "+$scope.profile.lastName+". Do you want to continue?", + function(){ + var uuu = "profile/removeRole?profile_id=" + $scope.profileId;; + 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.profile=data; + $.each($scope.availableRoles, function(k, c){ + if(c.id === role.id) { + c.selected = false; + } + }); + }); + + }, + error : function(data){ + modalService.showFailure("Fail","Error while saving."); + } + }); + + }) + + + }; + + function initDropdownWithLookUp(arr,selectedValue){ + var dropdownArray=[]; + var selected = null; + if(arr){ + for(var i = 0,l = arr.length; i < l; i++) { + var option = { + "index" : i , + "value" : arr[i].value, + "title" : arr[i].label + }; + dropdownArray.push(option); + if(arr[i].value === selectedValue){ + selected = option; + } + } + } + var dropDown={}; + dropDown.options = dropdownArray; + dropDown.selected = selected; + return dropDown; + }; + + $scope.doRolePopup = function() { + var modalInstance = $modal.open({ + templateUrl: 'roles_popup.html', + controller: 'rolepopupController', + resolve: { + message: function () { + var message ={ + availableRoles: $scope.availableRoles + }; + return message; + } + } + }); + modalInstance.result.then(function (opts) { + if(opts!=null){ + $scope.profile=opts.profile; + } + }); + } + + $scope.close = function(){ + $('#dialog').dialog('close'); + } + +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/usage-list-controller.js b/vid/src/main/webapp/app/fusion/scripts/controllers/usage-list-controller.js new file mode 100644 index 00000000..b495b934 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/usage-list-controller.js @@ -0,0 +1,41 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('usageListController', function ($scope,$interval,$http,$modal,modalService,AdminService){ + + AdminService.getUsageList().then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.users =$scope.data; + //$scope.resetMenu(); + + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + + $scope.removeSession = function(sessionId) { + modalService.popupConfirmWin("Confirm","You are about to expel this user from the application. All of their unsaved data will be lost. Do you want to continue?", + function(){ + $http.get("usage_list/removeSession?deleteSessionId="+sessionId).success(function(response){$scope.users=response;}); + }) + + } +}); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowApp.js b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowApp.js new file mode 100644 index 00000000..0a5c8019 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowApp.js @@ -0,0 +1,24 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +angular.module('att.abs.helper', []); +angular.module('quantum', []); + +var app=angular.module("workflowApp", ["att.abs", "att.abs.helper","modalServices", + "att.gridster","checklist-model","ngRoute", "ui.bootstrap"]); diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowController.js b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowController.js new file mode 100644 index 00000000..169a8868 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowController.js @@ -0,0 +1,509 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.controller('workflowsController', function($scope, $http, $uibModal, $log, modalService, $modal) { + + $scope.viewPerPage = 5; + $scope.scrollViewsPerPage = 20; + $scope.currentPage = 2; + $scope.totalPage; + $scope.searchCategory = ""; + $scope.searchString = ""; + $scope.radio = { + value: "" + }; + + + $scope.showModal = false; + $scope.toggleModal = function(){ + $scope.showModal = !$scope.showModal; + }; + + $scope.workflow = {}; + $scope.workflow.active = "true"; + + $scope.updateAllWorkflowStatus = function() { + angular.forEach($scope.workflows,function(value){ + $scope.checkWorkflowStatus(value); + }) + } + + $scope.fetchWorkflowsList = function() { + $http.get('workflows/list').then(function(workflowList){ + console.log('Got new list from server = ' + workflowList.data); + $scope.workflows = workflowList.data; + $scope.updateAllWorkflowStatus(); + }); + }; + + $scope.addNewWorkflow = function(newWorkflow) { + $http.post('workflows/addWorkflow/', JSON.stringify(newWorkflow)).success(function() { + $scope.fetchWorkflowsList(); + }); + + $scope.workflow.name = ''; + + }; + + $scope.updateWorkflow = function (workflowToEdit) { + //workflowToEdit.active='true'; + var modalInstance = $uibModal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-new.html', + //size : modalSize, + controller: ['$scope', '$uibModalInstance', '$http', function ($scope, $uibModalInstance, $http) { + $scope.workflow = workflowToEdit; + $scope.ok = function() { + console.log('Updating existing workflow ... ' + JSON.stringify($scope.workflow)); + $http.post('workflows/editWorkflow/', JSON.stringify($scope.workflow)).then(function(returnedWorkflow){ + console.log('Returned Workflow = ' + JSON.stringify(returnedWorkflow)); + $uibModalInstance.close($scope.workflow); + }); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss(); + }; + }], + //End of inner controller + resolve: { + workflow: function() { + console.log('Passing ' + JSON.stringify($scope.workflow)); + return $scope.workflow; + } + } + }); + + modalInstance.result.then(function (editedWorkFlow) { + //Need to convert to proper date - later + delete editedWorkFlow.created; + delete editedWorkFlow.updated; + + delete editedWorkFlow.createdBy; + delete editedWorkFlow.modifiedBy; + + console.log('selected Item ' + JSON.stringify(editedWorkFlow)); + $scope.$emit('workflowAdded', editedWorkFlow); + + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + }; + + $scope.reset = function(){ + console.log("Resetting ...."); + }; + + $scope.update = function(){ + console.log("updating ...."); + }; + + $scope.createWorkflow = function (modalSize) { + + var modalInstance = $uibModal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-new.html', + size : modalSize, + controller: ['$scope', '$uibModalInstance', '$http', function ($scope, $uibModalInstance, $http) { + $scope.workflow = {}; + $scope.workflow.active = 'true'; + $scope.ok = function() { + console.log('Saving new workflow ... ' + JSON.stringify($scope.workflow)); + $http.post('workflows/addWorkflow/', JSON.stringify($scope.workflow)).then(function(returnedWorkflow){ + console.log('Returned Workflow = ' + JSON.stringify(returnedWorkflow)); + $uibModalInstance.close($scope.workflow); + }); + }; +/* console.log(size);*/ + $scope.cancel = function() { + $uibModalInstance.dismiss(); + }; + }], + //End of inner controller + resolve: { + workflow: function() { + console.log('Passing ' + JSON.stringify($scope.workflow)); + return $scope.workflow; + } + } + }); + + modalInstance.result.then(function (newWorkflow) { + console.log('selected Item ' + JSON.stringify(newWorkflow)); + $scope.$emit('workflowAdded', newWorkflow); + + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + };//End of createWorkflow function + + + $scope.removeWorkflow = function(workflowToRemove){ + var modalInstance = $uibModal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-remove.html', + controller: ['$scope', '$uibModalInstance', '$http', function ($scope, $uibModalInstance, $http) { + $scope.workflowToRemove = workflowToRemove; + $scope.ok = function() { + console.log('Removing workflow ... ' + JSON.stringify($scope.workflowToRemove) + ' on client request.'); + $http.post('workflows/removeWorkflow/', JSON.stringify($scope.workflowToRemove.id)).then(function(){ + console.log('Workflow successfully removed !!!'); + $uibModalInstance.close(); + }); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('workflowRemoved'); + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + + }; + + + + $scope.scheduleWorkflow = function(workflowToSchedule){ + var modalInstance = $uibModal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-schedule.html', + size:'lg', + + controller: ['$scope', '$uibModalInstance', '$http','dateFilter', function ($scope, $uibModalInstance, $http,dateFilter) { + + $scope.workflowToSchedule = workflowToSchedule; + $scope.dt = new Date(); + $scope.dt2 = new Date(); + $scope.dateformat = 'MM/dd/yyyy', + $scope.datetimeformat = "hh:mm a"; + + $scope.recurrenceOptions =[{ + index:0, value:'One-Time', title:'One-Time' + },{ + index:1, value: 'Hourly',title:'Hourly' + },{ + index:2, value: 'Daily',title:'Daily' + },{ + index:3, value: 'Weekly',title:'Weekly' + }] + $scope.selectRecurrenceOpt = $scope.recurrenceOptions[0]; + + $scope.hours = []; + for (var i=0; i<24; i++){ + var newObj={} + newObj.index = i; + newObj.value = ""+i; + newObj.title = ""+i; + $scope.hours.push(newObj); + } + + $scope.minutes = []; + for (var i=0; i<60; i++){ + var newObj={} + newObj.index = i; + newObj.value = ""+i; + newObj.title = ""+i; + $scope.minutes.push(newObj); + } + + $scope.AMPMOptions =[ + { + index:0, value:'AM', title:'AM' + },{ + index:1, value: 'PM',title:'PM' + }] + + $scope.selectFirstHour =$scope.hours[0]; + $scope.selectFirstMinute =$scope.minutes[0]; + + $scope.selectLastHour =$scope.hours[0]; + $scope.selectLastMinute =$scope.minutes[0]; + + $scope.selectStartAMPMOption=$scope.AMPMOptions[0]; + $scope.selectLastAMPMOption=$scope.AMPMOptions[0]; + + var GenerateCronExpression = function(trigger_dt, RecurrenceOpt) { + var CRON_sec = trigger_dt.getSeconds(); + var CRON_min = trigger_dt.getMinutes(); + var CRON_hr = trigger_dt.getHours(); + var CRON_date= trigger_dt.getDate(); + var CRON_month = trigger_dt.toLocaleString('en-US', {month: 'short'}).toUpperCase(); + var CRON_day = trigger_dt.toLocaleString('en-US', {weekday: 'short'}).toUpperCase(); + var CRON_year = trigger_dt.getFullYear(); + if (RecurrenceOpt ==="One-Time") { + CRON_day = '?' + } else { + if (RecurrenceOpt ==="Hourly") { + CRON_hr = '*'; + CRON_date = '*' + CRON_month = '*' + CRON_day = '?' + CRON_year = '*' + } else if (RecurrenceOpt ==="Daily") { + CRON_date = '*' + CRON_month = '*' + CRON_day = '?' + CRON_year = '*' + } else if (RecurrenceOpt ==="Weekly") { + CRON_date = '*' + CRON_month = '*' + CRON_year = '*' + } + } + + var CRON_Expression = [CRON_sec, CRON_min, CRON_hr, CRON_date, CRON_month, CRON_day, CRON_year]; + return CRON_Expression.join(" "); + } + + $scope.ok = function() { + + // DateTime for the start time: it should be noted that the start time + // for a CRON job should be prior to the trigger time. + $scope.trigger_dt = new Date( $scope.dt.getFullYear() + + "-" + ("0"+($scope.dt.getMonth()+1)).slice(-2) + + "-" +("0"+ $scope.dt.getDate()).slice(-2) + + " " + ("0" + $scope.selectFirstHour.value).slice(-2) + + ":" +("0" + $scope.selectFirstMinute.value).slice(-2) + + ":00.0"); + + $scope.startDateTime_CRON = GenerateCronExpression($scope.trigger_dt, $scope.selectRecurrenceOpt.value) + + //roll back the the start date time by 30 seconds (start time should be 30 seconds prior to trigger time) + dt_st = new Date($scope.trigger_dt - 30*1000) + + startDateTime = dt_st.getFullYear() + + "-" + ("0"+(dt_st.getMonth()+1)).slice(-2) + + "-" +("0"+ dt_st.getDate()).slice(-2) + + " " + ("0" + dt_st.getHours()).slice(-2) + + ":" +("0" + dt_st.getMinutes()).slice(-2) + + ":" + ("0" + dt_st.getSeconds()).slice(-2) +".0"; + $scope.startDateTime = startDateTime; + + $scope.endDateTime = $scope.dt2.getFullYear() + + "-" + ("0"+($scope.dt2.getMonth()+1)).slice(-2) + + "-" +("0"+ $scope.dt2.getDate()).slice(-2) + + " " + ("0"+ $scope.selectLastHour.value).slice(-2) + + ":" +("0" + $scope.selectLastMinute.value).slice(-2) + + ":00.0" + + $scope.WorkflowScheduleObject = {}; + $scope.WorkflowScheduleObject['startDateTime_CRON'] = $scope.startDateTime_CRON; + $scope.WorkflowScheduleObject['startDateTime'] = $scope.startDateTime; + $scope.WorkflowScheduleObject['endDateTime'] = $scope.endDateTime; + $scope.WorkflowScheduleObject['workflowKey'] = $scope.workflowToSchedule.workflowKey; + $scope.WorkflowScheduleObject['recurrence'] = $scope.selectRecurrenceOpt.value; + $scope.WorkflowScheduleObject['workflow_arguments'] = "test"; + $scope.WorkflowScheduleObject['workflow_server_url'] = $scope.workflowToSchedule.runLink; + + + TimeFromNowToStart = new Date($scope.startDateTime)-new Date() + TimeStartToEnd = new Date($scope.endDateTime)-new Date($scope.startDateTime) + + if (TimeFromNowToStart<=0) { + console.log("invalid start time input") + alert("Please ensure the scheduled start date time is later than current time.") + return; + } + if (TimeStartToEnd<=0) { + console.log("invalid end time input") + alert("Please ensure the schduled end date time is later than the start time.") + return; + } + // if successful then save and close + $scope.saveCronJob($scope.WorkflowScheduleObject); + $uibModalInstance.close(); + + }; + + $scope.saveCronJob = function(cronJobData){ + + console.log('saving cron job data: ' + cronJobData); + var uuu = "workflows/saveCronJob.htm"; + var postData={cronJobDataObj: cronJobData}; + $.ajax({ + type : 'POST', + url : uuu, + //dataType: 'json', // data type expected from server + contentType: 'application/json', + data: JSON.stringify(postData), // data type sent to server + success : function(data){ + $scope.$apply(function(){ + //$scope.availableRoleFunctions=[];$scope.$apply(); + // new // $scope.availableFnMenuItems=data.availableFnMenuItems; + } + ); + //alert("Update Successful.") ; + //$scope.editRoleFunction = null; + // new /// $modalInstance.close({availableFnMenuItems:$scope.availableRoleFunctions}); + }, + error : function(data){ + alert("Error while saving."); + } + }); + + }; + + $scope.cancel = function() { + console.log("cancel triggered") + $uibModalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('workflowRemoved'); + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + + }; + + + + + + + + + $scope.previewWorkflow = function(workflowToPreview,modalSize){ + var modalInstance = $uibModal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-preview.html', + size:modalSize, + controller: ['$scope', '$uibModalInstance', '$http', function ($scope, $uibModalInstance, $http) { + $scope.workflowToPreview = workflowToPreview; + console.log('previewWorkFlow invoked'); + console.log($scope.workflowToPreview); + + $scope.cancel = function() { + $uibModalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('workflowRemoved'); + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + + }; + + + /* change work flow status based on the boolean variable "suspendBool" which corresponds whether + * we would like to suspend or activate a workflow specified by key. */ + $scope.changeWorkflowStatus = function(workflowToChangeStatus,suspendBool){ + if (workflowToChangeStatus!==null) { + var statusUrl= workflowToChangeStatus.runLink+"/engine-rest/process-definition/key/"+workflowToChangeStatus.workflowKey + var suspendedUrl= statusUrl+"/suspended" + var xmlHttp = new XMLHttpRequest(); + xmlHttp.open('PUT', suspendedUrl, false); + xmlHttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); + xmlHttp.onload = function() { + if (suspendBool) { + console.log("process definition is now suspended"); + workflowToChangeStatus.active="false" + } else { + console.log("process definition is now activated"); + workflowToChangeStatus.active="true" + } + }; + xmlHttp.send(JSON.stringify({ + "suspended" : suspendBool, + "includeProcessInstances" : true, + "executionDate" : "2013-11-21T10:49:45" + })); + } + + }; + + $scope.activateWorkflow = function(workflowToActivate){ + $scope.changeWorkflowStatus(workflowToActivate,false) + + }; + + $scope.suspendWorkflow = function(workflowToActivate){ + $scope.changeWorkflowStatus(workflowToActivate,true) + }; + + $scope.checkWorkflowStatus = function(workflow) { + if (workflow!==null) { + var statusUrl= workflow.runLink+"/engine-rest/process-definition/key/"+workflow.workflowKey + var xmlHttp3 = new XMLHttpRequest(); + xmlHttp3.open('GET', statusUrl, true); + xmlHttp3.withCredentials = true; + xmlHttp3.send(); + xmlHttp3.onreadystatechange = function() { + if (xmlHttp3.readyState == 4 && xmlHttp3.status == 200) { + // do something with the response in the variable data + var temp = JSON.parse(xmlHttp3.responseText) + if (temp.suspended == false){ + console.log("Activated") + workflow.active="true" + } else { + console.log("Suspended") + workflow.active="false" + } + } + } + } + }; + + $scope.StartWorkflowInstance = function(workflowToStart){ + if (workflowToStart!==null) { + var statusUrl= workflowToStart.runLink+"/engine-rest/process-definition/key/"+workflowToStart.workflowKey + var suspendedUrl= statusUrl+"/submit-form" + var xmlHttp = new XMLHttpRequest(); + xmlHttp.open('POST', suspendedUrl, false); + xmlHttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); + xmlHttp.onload = function() { + }; + xmlHttp.send(JSON.stringify({ + "variables": { + "customerId": {"value":"asdasda","type":"String"}, + "amount":{"value":"100","type":"String"} + } + })); + } + + }; + + + $scope.$on('workflowAdded', function(event, newWorkflow) { + console.log("New Workflow to be added in list scope " + JSON.stringify(newWorkflow)); + //$scope.workflows.push(newWorkflow); + $scope.fetchWorkflowsList(); + console.log('newly added workflow = ' + JSON.stringify(newWorkflow)); + }); + + $scope.$on('workflowRemoved', function(event) { + $scope.fetchWorkflowsList(); + }); + + $scope.fetchWorkflowsList(); + + + +}); + diff --git a/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowRouting.js b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowRouting.js new file mode 100644 index 00000000..81fe4e28 --- /dev/null +++ b/vid/src/main/webapp/app/fusion/scripts/controllers/workflows/workflowRouting.js @@ -0,0 +1,26 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +app.config(function($routeProvider) { + $routeProvider + .when('/all', { + templateUrl: 'app/fusion/scripts/view-models/workflows/workflow-listing.html', + controller: 'workflowsController' + }) +}); |