diff options
Diffstat (limited to 'usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers')
33 files changed, 6240 insertions, 0 deletions
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-closed-cloop.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-closed-cloop.js new file mode 100644 index 00000000..94169ff4 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-closed-cloop.js @@ -0,0 +1,28 @@ +appDS2.controller('adminClosedLoopController', ['$scope','$http','$q','$log',function ($scope, $http,$q, $log){ + $scope.camunda_cockpit_url = ''; + var deferred = $q.defer(); + $http({ + method: "GET", + url: "get_camunda_cockpit_link", + }).success( function(res) { + // if the returned response is error HTML page in string format + if(res.link_defined=='false'){ + $log.error('Retrieval of camunda cockpit link failed. Please make sure the variable "camunda_cockpit_url" is defined in the system.properties file.'); + deferred.reject(status); + } + // valid cockpit url + else if(res.camunda_cockpit_link!=null & res.camunda_cockpit_link!= '') { + $scope.camunda_cockpit_url = res.camunda_cockpit_link; + deferred.resolve(res); + // if the defined url is empty; + } else { + $log.error('Please ensure the variable "camunda_cockpit_url" is properly defined in system.properties file (i.e., neither null nor empty).'); + deferred.reject(status); + } + // API call fails + }).error( function(status) { + $log.error('get_camunda_cockpit_link RestAPI call failed.'); + deferred.reject(status); + }); + return deferred.promise; +}]);
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js new file mode 100644 index 00000000..dc59b6c7 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js @@ -0,0 +1,877 @@ +appDS2.controller('adminController', function($scope, $http,AdminService, $modal, $routeParams, $rootScope){ + + $scope.totalPages = 5; + $scope.viewPerPage = 8; + $scope.searchString = ""; + $scope.currentPage = 1; + $scope.nextSort=""; + $scope.showLoader = false; + $scope.tableData=[]; + $scope.showLoader=false; + $scope.routeRoleId = $routeParams.roleId; + $scope.regions = []; + /*function*/ + $scope.getFunctionList = function(){ + $scope.tableData.length=0; + $scope.showLoader=true; + AdminService.getRoleFunctionList().then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.tableData =JSON.parse($scope.data.availableRoleFunctions); + },function(error){ + console.log("failed"); + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success + }); + } + + $scope.getCacheRegionsList = function(){ + AdminService.getCacheRegions().then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.regions =$scope.data; + },function(error){ + console.log("failed"); + }); + } + + + $scope.delRoleFunc = function(roleData){ + AdminService.delRoleFunctionList(roleData).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successPopUp(); + $scope.getFunctionList(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + $scope.saveRoleFunction = function(roleData){ + AdminService.saveRoleFunctionList(roleData).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successPopUp(); + $scope.getFunctionList(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + $scope.addRoleFunction = function(roleData){ + AdminService.addRoleFunctionList(roleData).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successPopUp(); + $scope.getFunctionList(); + }else if(status=='"code exists"'){ + $scope.errorPopUp('Code already exists'); + $scope.getFunctionList(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + /*init*/ + $scope.getFunctionList(); + $scope.getCacheRegionsList(); + /*popup*/ + var ModalInstanceCtrl = function ($scope, $modalInstance, items, AdminService,$rootScope) { + $scope.roleFun=items; + $scope.msg=items; + + // remove role function associated to a role on Role Edit page + $scope.roleFunRemoveRole = function (roleFunction) { + AdminService.removeRoleFunction(roleFunction, $routeParams.roleId).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.role){ + $rootScope.$broadcast('updateRoleFunctions',{data:message.role}); + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + //role activation for selected child role + $scope.activateRoleChildConfirmPopUp = function (selected, availableRole) { + $scope.msg.roleFun = availableRole.name; + $scope.msg.selected = selected; + $scope.msg.availableRole = availableRole; + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-child-add-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return $scope.msg; + } + } + }); + } + + // confirm Child Role Add + $scope.confirmRoleChildAdd = function(selected,availableRole,id){ + AdminService.confirmRoleChildAdd(selected,availableRole,id).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.role){ + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + // confirm Child Role Remove + $scope.confirmRoleChildRemove = function(selected,availableRole,id){ + AdminService.confirmRoleChildRemove(selected,availableRole,id).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.role){ + //$rootScope.$broadcast('updateAvailbleRoles',{data:message.availableRoles}); + /*$modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + sizeClass: 'modal-small', + })*/ + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + //role activation for role function + $scope.activateRoleConfirmPopUp = function (selected, availableRole) { + $scope.msg.roleFun = availableRole.name; + $scope.msg.selected = selected; + $scope.msg.availableRole = availableRole; + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-add-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return $scope.msg; + } + } + }); + } + + // confirm Role Function Add + $scope.confirmRoleFunAdd = function(selected,availableRole,id){ + AdminService.confirmRoleFunAdd(selected,availableRole,id).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.role){ + $rootScope.$broadcast('updateRoleFunctions',{data:message.role}); + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + // confirm Role Function Remove + $scope.confirmRoleFunRemove = function(selected,availableRole,id){ + AdminService.confirmRoleFunRemove(selected,availableRole,id).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.role){ + $rootScope.$broadcast('updateRoleFunctions',{data:message.role}); + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + //role activation + $scope.roleActivate = function(selected,availableRole){ + AdminService.activateRole(selected,availableRole).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.availableRoles){ + $rootScope.$broadcast('updateAvailbleRoles',{data:message.availableRoles}); + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + console.log("error"); + }); + } + + //role deletion + $scope.delRole = function(roleData){ + AdminService.delRoleList(roleData).then(function(msg){ + var message = msg; + $scope.cancel(); + if(message.availableRoles){ + $rootScope.$broadcast('updateAvailbleRoles',{data:message.availableRoles}); + }else{ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }) + } + + },function(error){ + + }); + } + + $scope.save = function (data) { + $modalInstance.close(data); + }; + + // Cancel for toggle switch on Role Fn + $scope.cancelRoleFunSwitch = function (msg) { + $scope.msg.availableRole.selected = !$scope.msg.availableRole.selected; + $modalInstance.dismiss('cancel'); + }; + + // Cancel for toggle switch on Role List + $scope.cancelRoleSwitch = function (msg) { + $scope.msg.availableRole.active = !$scope.msg.availableRole.active; + $modalInstance.dismiss('cancel'); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.deleteFun = function(data){ + $modalInstance.close(data); + } + }; + + $scope.successPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + + $scope.successTestModelPopUp = function (response) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modalpopup.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-large', + resolve: { + items: function () { + var message = { + title: '', + text: response + }; + return message; + } + } + }); + }; + $scope.errorPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }); + }; + $scope.saveRoleFuncPopUp = function (availableRoleFunction) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-function-edit.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return availableRoleFunction; + } + } + }); + + modalInstance.result.then(function (data) { + $scope.saveRoleFunction(data); + }); + } + + $scope.addRoleFuncPopUp = function (availableRoleFunction) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-function-add.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return availableRoleFunction; + } + } + }); + + modalInstance.result.then(function (data) { + $scope.addRoleFunction(data); + }); + } + + $scope.delRoleFuncConfirmPopUp = function (availableRoleFunction) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-function-del-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + title: '', + text: availableRoleFunction.name, + content: availableRoleFunction + }; + return message; + } + } + }); + + modalInstance.result.then(function (data) { + $scope.delRoleFunc(data.content); + }); + } + $scope.clearAllFuncPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/cache-menu-clear-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + } + } + }); + + modalInstance.result.then(function () { + $scope.clearAll(); + }); + } + + $scope.clearAll = function(){ + AdminService.clearAdminRegions().then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successTestModelPopUp(''); + $scope.getCacheRegionsList(); + }else{ + $scope.errorPopUp(); + } + } + + },function(error){ + + }); + } + $scope.showRegionDetailsFuncPopUp = function (response) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/success_modalpopup.html', + controller: ModalInstanceCtrl, + resolve: { + items: function () { + var message = { + title: '', + text: response, + }; + return message; + } + } + }); + + modalInstance.result.then(function (response) { + $scope.showRegionDetails(response); + }); + } + + $scope.showRegionDetails = function(cacheName) { + AdminService.showRegionDetails(cacheName).then(function(res){ + + var message = res.data; + var msgParsed = JSON.stringify(message); + + var messaged = message.data; + var msgParsedd = JSON.stringify(messaged); + + if(message.data!=null && message.data!=''){ + var status = res.status; + + + if(status==200){ + + + + var htmlstring = message.data.toString(); + var htmlStrReplace = htmlstring.replace(/['"]+/g, ''); + var htmlStrReplaceSplit = htmlStrReplace.split('\n'); + var dataStr = htmlStrReplace.replace(/\\n/g, "\n"); + $scope.successTestModelPopUp(dataStr); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + $scope.clearRegionFuncPopUp = function (cacheName) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/cache-menu-clear-region-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + title: '', + text: cacheName + }; + return message; + } + } + }); + + modalInstance.result.then(function (cacheName) { + $scope.clearRegionFunction(cacheName); + }); + } + + $scope.clearRegionFunction = function(cacheName){ + AdminService.clearRegionFunction(cacheName).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successPopUp(); + $scope.getCacheRegionsList()(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + $scope.clearItemFuncPopUp = function (cacheName, key) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/clearItem-region-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + title: '', + text: cacheName + }; + return message; + } + } + }); + + modalInstance.result.then(function (cacheName, key) { + $scope.clearItemFunction(cacheName, key); + }); + } + + $scope.clearItemFunction = function(cacheName, key){ + AdminService.clearItemnFunction(cacheName, key).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + $scope.successPopUp(); + $scope.getCacheRegionsList()(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + + + $scope.showItemDetails = function(cacheName, key){ + AdminService.showItemDetails(cacheName, key).then(function(msg){ + var message = msg; + if(message.data!=null && message.data!=''){ + var status = message.data; + if(status=='"success"'){ + + $scope.successPopUp(); + $scope.getCacheRegionsList()(); + }else{ + $scope.errorPopUp(''); + } + } + + },function(error){ + + }); + } + + + //role deletion pop up + $scope.delRoleConfirmPopUp = function (availableRole) { + + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-delete-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + availableRole:availableRole, + roleName: availableRole.name + }; + return message; + } + } + }); + } + + // role activation + $scope.activateRoleConfirmPopUp = function (selected, availableRole) { + var toggleType = null; + if(selected) { + toggleType = "activate"; + } else { + toggleType = "inactivate"; + } + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-confirm-activation.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + text: toggleType, + selected:selected, + availableRole:availableRole, + roleName:availableRole.name + }; + return message; + } + } + }); + } + + $scope.roleFnInit = function(){ + $scope.showLoader=true; + AdminService.getRole($routeParams.roleId).then(function(data){ + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.role =JSON.parse($scope.data.role); + + $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + $scope.availableRoleFunctions=[]; + + if($scope.ociavailableRoleFunctions) + angular.forEach($scope.ociavailableRoleFunctions, function(a,i){ + var availableRoleFunction = a; + availableRoleFunction.selected = false; + angular.forEach($scope.role.roleFunctions, function(b,j){ + if(a.code === b.code) { + availableRoleFunction.selected = true; + } + }); + $scope.availableRoleFunctions.push(availableRoleFunction); + }); + + + $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); + $scope.availableRoles=[]; + + },function(error){ + console.log("roleControllerDS2 failed: " + error); + reloadPageOnce(); + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success + }); + } + + // updating roles on role list page after deletion of a role + $rootScope.$on('updateAvailbleRoles', function(e,d){ + $scope.ociavailableRoles = d.data; + }) + + // updating role functions on roles page after deletion of a role function + $rootScope.$on('updateRoleFunctions',function(e,d){ + $scope.role = d.data; + }) + + $scope.roleFnInit(); + + $scope.saveRole = function() { + var errorMsg; + $scope.showLoader=true; + if($scope.role.id == null || $scope.role.id == undefined ){ + $scope.role = { + 'id':null, + 'created':null, + 'modified':null, + 'createdId':null, + 'modifiedId':null, + 'rowNum':null, + 'auditUserId':null, + 'auditTrail':null, + 'name':$scope.role.name, + 'active':false, + 'priority':$scope.role.priority, + 'roleFunctions':null, + 'childRoles':null, + 'toggleActiveAltText':"Click to Activate Role ", + 'toggleActiveImage':" / static fusion images inactive.png ", + 'editUrl':" role.htm ? role_id = null", + }; + } + // Validate non-empty priority as integer + if ($scope.role.priority && $scope.role.priority != '' && isNaN(parseInt($scope.role.priority))) { + errorMsg = 'Priority must be an integer.'; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return errorMsg; + } + } + }); + return; + } + for (x in $scope.availableRoles){ + if ($scope.availableRoles[x].name==$scope.role.name){ + errorMsg = 'Role already exists.'; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return errorMsg; + } + } + }); + return; + } + } + if(!errorMsg){ + var postData={ + role: $scope.role, + childRoles: $scope.role.childRoles, + roleFunctions : $scope.role.roleFunctions + }; + AdminService.saveRole(postData, $routeParams.roleId).then(function(msg){ + if(msg.role){ + sessionStorage.setItem('addCall', true); + location.href='admin#/role/'+msg.role.id; + $scope.availableRoles.push(msg); + $scope.routeRoleId = msg.role.id; + $rootScope.$broadcast('updateAvailbleRoles',{data:$scope.availableRoles}); + //saving the addCall variable in sessionStorage to change the url from AddRole to Edit Role on success of Save and displaying the success pop up + if(sessionStorage.addCall){ + $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + sizeClass: 'modal-small' + }); + sessionStorage.removeItem('addCall'); + } + } else{ + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + msg = 'Error saving Role. Please retry'; + return msg; + } + } + }); + } + },function(error){ + console.log("error msg"); + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success + }); + + } + } + + $scope.addNewRoleFunctionModalPopup = function(data, role,info) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-functions-modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-large', + windowClass:"modal-docked", + resolve: { + items: function () { + var message = { + role:role, + roleId:info.id, + availableRoleFunctions:$scope.ociavailableRoleFunctions + }; + return message; + } + } + }); + } + + $scope.addNewChildRoleFunctionModalPopup = function(data, role,info) { + data = $scope.role; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-functions-child-roles-modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-large', + resolve: { + items: function () { + var message = { + roleChildFunctions:$scope.ociavailableRoles, + role:role, + roleId:info.id + }; + return message; + } + } + }); + } + + // remove role function associated to a role on Role Edit page + $scope.removeRoleFunction= function(roleFunction){ + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-role-del-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + roleFunction:roleFunction + }; + return message; + } + } + }); + } + +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-menu-edit.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-menu-edit.js new file mode 100644 index 00000000..00cd92d7 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-menu-edit.js @@ -0,0 +1,184 @@ +appDS2.controller('AdminMenuEditController', function ($scope, AdminMenuService, $modal, $route,AdminService){ + + $scope.showInput = true; + $scope.totalPages1 = 5; + $scope.viewPerPage1 = 8; + $scope.currentPage1 = 1; + $scope.showLoader = false; + $scope.firstPlay = true; + $scope.tableFnMenuItems = []; + $scope.$watch('viewPerPage1', function(val) { + $scope.showLoader = true; + AdminMenuService.getFnMenuItems($scope.currentPage1, val).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.fnMenuItems = $scope.data.fnMenuItems; + var totalItems = $scope.fnMenuItems.length; + $scope.totalPages1 = Math.ceil(totalItems / $scope.viewPerPage1); + for (x in $scope.fnMenuItems) { + if ($scope.fnMenuItems[x].active_yn=='Y') + $scope.fnMenuItems[x].active_yn=true; + else + $scope.fnMenuItems[x].active_yn=false; + } + $scope.showLoader = false; + $scope.currentPage1=1; + var endIndex = 1 * $scope.viewPerPage1; + var startIndex = endIndex - $scope.viewPerPage1; + $scope.tableFnMenuItems = $scope.fnMenuItems.slice(startIndex, endIndex); + },function(error){ + console.log('AdminMenuEditControler::$watch viewPerPage1 failed', error); + reloadPageOnce(); + }); + + }); + + $scope.customHandler1 = function(num) { + $scope.currentPage1=num; + var endIndex = num * $scope.viewPerPage1; + var startIndex = endIndex - $scope.viewPerPage1; + $scope.tableFnMenuItems = $scope.fnMenuItems.slice(startIndex, endIndex); + }; + + $scope.init = function () { + $scope.numberOfRecordstoShow=20; + AdminMenuService.getFnMenuItems().then(function(data){ + var j = data; + $scope.data =JSON.parse(j.data); + $scope.fnMenuItems =($scope.data.fnMenuItems); + },function(error){ + console.log('AdminMenuEditControler::init failed'); + }); + } + + $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: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/popup-modal-fnmenu-add.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) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/admin-menu-del-confirm.html', + controller: deletefn_menu_popupController, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + title: '', + text: fnMenuItem.label + }; + return fnMenuItem; + } + } + }); + }; + + + $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: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/popup-modal-fnmenu-add.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){ + $scope.availableRoleFunctions=response.availableRoleFunctions; + }); + }; + + $scope.addNewRoleFunctionPopup = function() { + $scope.editRoleFunction = null; + $( "#dialog" ).dialog({ + modal: true + }); + }; + + + +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-route.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-route.js new file mode 100644 index 00000000..c7c06a7e --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-route.js @@ -0,0 +1,43 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .when('/net_map', { + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-sample-page/net_map.html', + controller: "netMapController" + }) + .when('/jcs_admin', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/jcs_admin.html', + controller: 'adminController' + }) + .when('/admin_menu_edit', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/admin-menu-edit.html', + controller: 'AdminMenuEditController' + }) + .when('/usage_list', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/usage.html', + controller: 'usageListControllerDS2' + }) + .when('/role_function_list', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/role-function.html', + controller : "adminController" + }) + .when('/role/:roleId', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/role.html', + controller: 'adminController' + }) + .when('/collaborate_list', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/collaborate-list.html', + controller: 'collaborateListControllerDS2' + }) + .when('/adminClosedLoop', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/admin_closed_loop.html', + controller: 'adminClosedLoopController' + }) + .when('/all', { + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-listing.html', + controller: 'workflowsController' + }) + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/role_list.html', + controller : 'adminController' + }); +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-whitelist.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-whitelist.js new file mode 100644 index 00000000..3e82df8e --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-whitelist.js @@ -0,0 +1,3 @@ +appDS2.config(function ($sceDelegateProvider) { + $sceDelegateProvider.resourceUrlWhitelist(['self','**']); +});
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-controller.js new file mode 100644 index 00000000..74a7423e --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-controller.js @@ -0,0 +1,5 @@ +appDS2.controller( + 'bootstrapSampleController', + function($scope, $interval, $http, $modal, $log, ManifestService) { + + }); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-route.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-route.js new file mode 100644 index 00000000..ac1ba168 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/bootstrap-sample-route.js @@ -0,0 +1,7 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/bootstrap-sample-content.html', + controller : "bootstrapSampleController" + }); +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate-list-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate-list-controller.js new file mode 100644 index 00000000..670e8fc1 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate-list-controller.js @@ -0,0 +1,71 @@ +appDS2.controller("collaborateListControllerDS2", function ($scope,$http, $modal,AdminService) { + + $scope.showInput = true; + $scope.totalPages1 = 5; + $scope.viewPerPage1 = 8; + $scope.currentPage1 = 1; + $scope.showLoader = false; + $scope.firstPlay = true; + // Start with empty list to silence error in console + $scope.tableData = []; + $scope.tableCollbItems = []; + // $scope.totalPages1 = 20; + $scope.$watch('viewPerPage1', function(val) { + $scope.showLoader = true; + AdminService.getCollaborateList($scope.currentPage1, val).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.tableData = $scope.data; + var totalItems = $scope.tableData.length; + //console.log(totalItems); + $scope.totalPages1 = Math.ceil(totalItems / $scope.viewPerPage1); + $scope.showLoader = false; + $scope.currentPage1=1; + var endIndex = 1 * $scope.viewPerPage1; + var startIndex = endIndex - $scope.viewPerPage1; + $scope.tableCollbItems = $scope.tableData.slice(startIndex, endIndex); + },function(error){ + console.log("failed"); + reloadPageOnce(); + }); + }); + + $scope.customHandler1 = function(num) { + $scope.currentPage1=num; + var endIndex = num * $scope.viewPerPage1; + var startIndex = endIndex - $scope.viewPerPage1; + $scope.tableCollbItems = $scope.tableData.slice(startIndex, endIndex); + }; + + $scope.openCollaboration = function(chatId){ + openInNewTab('openCollaboration?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(); +}; + +function downloadScreenCaptureExtenstion() { + + var chromeURL = 'https://chrome.google.com/webstore/detail/icgmlogfeajbfdffajhoebcfbibfhaen'; + var firefoxURL = 'https://addons.mozilla.org/en-US/firefox/addon/screen-capturing-capability'; + var url; + + if(isChrome) + url = chromeURL; + else if(isFirefox) + url = firefoxURL; + + var win = window.open(url); + win.focus(); +}; diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/collaborate.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/collaborate.js new file mode 100644 index 00000000..fa9af088 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/collaborate.js @@ -0,0 +1,7 @@ +app.config(function($routeProvider) { + $routeProvider + .when('/collaborate_list', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/collaborate-list.html', + controller: 'collaborateListControllerDS2' + }) +});
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/workflowController.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/workflowController.js new file mode 100644 index 00000000..c43ad8b7 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborate/workflowController.js @@ -0,0 +1,490 @@ +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/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborateList-route.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborateList-route.js new file mode 100644 index 00000000..d402fd7b --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaborateList-route.js @@ -0,0 +1,19 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .when('/collaborate_list', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/collaborate-list.html', + controller: 'collaborateListControllerDS2' + }) + .when('/notebook', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-samplePages/notebook-page.html', + controller: 'nbookController' + }) + .when('/leafletMap', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-samplePages/leafletMap.html', + controller: 'leafletController' + }) + .when('/notebook', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-samplePages/notebook-page.html', + controller: 'nbookController' + }) +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaboration-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaboration-controller.js new file mode 100644 index 00000000..a800c009 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/collaboration-controller.js @@ -0,0 +1,266 @@ + + +appDS2.controller('collaborationControllerDS2', function ($scope,$http, $modal) { + console.log("modal", $modal); + var popupModalService; + + }); + + + $(document).ready(function () { + + // OUTER-LAYOUT + panelLayout = $('body').layout({ + center__paneSelector: ".outer-center" + , west__paneSelector: ".outer-west" + , east__paneSelector: ".outer-east" + //, west__size: 800 + //, east__size: 125 + , spacing_open: 8 // ALL panes + , spacing_closed: 12 // ALL panes + + , center__childOptions: { + center__paneSelector: ".inner-center" + , west__paneSelector: ".inner-west" + , east__paneSelector: ".inner-east" + , west__size: 75 + , east__size: 75 + , spacing_open: 8 // ALL panes + , spacing_closed: 8 // ALL panes + , west__spacing_closed: 12 + , east__spacing_closed: 12 + } + + + + + }); + + + function initializeConnections() { + + var channelId = null; + channelId = location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''); + var videoChannelId = channelId.concat("video"); + var screenChannelId = channelId.concat("screen"); + + videoConnection = new RTCMultiConnection(videoChannelId); + screenConnection = new RTCMultiConnection(screenChannelId); + + configConnection(videoConnection,true,true,false,true,false); + configConnection(screenConnection,false,false,true,false,true); + + }; + + function configConnection(_connection, _audio, _video, _screen, _data, _oneway) { + _connection.session = { + audio: _audio, // by default, it is true + video: _video, // by default, it is true + screen: _screen, + data: _data, + oneway: _oneway, + broadcast: false + }; + + _connection.direction = "one-to-one"; + + if( _data == true ) { + _connection.onmessage = function(e) { + appendDIV(e.data); + + console.debug(e.userid, 'posted', e.data); + console.log('latency:', e.latency, 'ms'); + }; + } + + + }; + + function assignStreamToDom() { + + + screenConnection.screenbody = document.querySelector('.screenContainer1'); + screenConnection.videobody = document.querySelector('.videoContainer2'); + + videoConnection.screenbody = document.querySelector('.screenContainer2'); + videoConnection.videobody = document.querySelector('.videoContainer1'); + }; + + function maximizeLayout() { + + // open the panes and maximize the window. + top.window.resizeTo(screen.availWidth,screen.availHeight); + panelLayout.open('west'); + // panelLayout.open('south'); is not working due to state initialization problem; debug to find out. so replacing the call with work around below - hack. + $(".ui-layout-toggler-south-closed").first().click(); + + }; + + function minimizeLayout() { + + // close the panes and minimize the window. + top.window.resizeTo(screen.availWidth - 2*screen.availWidth/3, screen.availHeight - screen.availHeight/2); + panelLayout.close('west'); + // panelLayout.close('south'); is not working due to state initialization problem; debug to find out. so replacing the call with work around below - hack. + $(".ui-layout-toggler-south-opened").first().click(); + }; + + function emptyContainers() { + $('.screenContainer1').empty(); + $('.videoContainer2').empty(); + + $('.screenContainer2').empty(); + $('.videoContainer1').empty(); + }; + + function appendDIV(div, parent) { + if (typeof div === 'string') { + var content = div; + div = document.createElement('div'); + div.innerHTML = content; + }; + + var chatOutput = document.getElementById('chat-output'), + fileProgress = document.getElementById('file-progress'); + + if (!parent) chatOutput.insertBefore(div, chatOutput.firstChild); + else fileProgress.insertBefore(div, fileProgress.firstChild); + + div.tabIndex = 0; + $('#chat-input').focus(); + }; + + function confirmClose() { + var message = "Are you sure you want to close the session?"; + + /* if(popupModalService != undefined) { + popupModalService.popupConfirmWin("Confirm", message, function(){ location.reload();}); + } + + else */ + if (confirm(message) == true) { + location.reload(); + //window.opener.location.reload(); // go to the parent window + //close(); + } else { + // do nothing + } + + }; + + function notifyOthers() { + + // var websocket = localStorage.getItem('notifySocket'); + //if( websocket != null) { + // handling websocket peer broadcast session + var currentUser = "${sessionScope.user.sbcid}"; + var initialPageVisit = "${sessionScope.initialPageVisit}"; + var remoteUser = ''; + + var userList = location.search.split('chat_id=')[1].split('-'); + for(var i=0;i<userList.length;i++) { + if(userList[i] !== currentUser) { + remoteUser = userList[i]; + break; + } + } + + socketSetup(initialPageVisit, currentUser, remoteUser,"socketSend"); + + + + + + + }; + + function makeChatVisible() { + + $('#chat-input').css("visibility", 'visible'); + }; + + + + /* on click button enabled*/ + window.onload = function () { + document.getElementById('share-screen').onclick = function() { + + emptyContainers(); + videoConnection.close(); + screenConnection.close(); + + maximizeLayout(); + emptyContainers(); + makeChatVisible(); + + videoConnection.open(); + screenConnection.open(); + + + notifyOthers(); + + + + }; + }; + + document.getElementById('stop-share-screen').onclick = function() { + + emptyContainers(); + + videoConnection.close(); + screenConnection.close(); + + confirmClose(); + + }; + + document.getElementById('view-screen').onclick = function() { + + maximizeLayout(); + emptyContainers(); + makeChatVisible(); + + // timeout is required for the sharing to properly work + setTimeout(function() { + screenConnection.connect(); + },2000); + setTimeout(function() { + videoConnection.connect(); + },1000); + + + }; + + document.getElementById('chat-input').onkeypress = function(e) { + if (e.keyCode !== 13 || !this.value) return; + var message = "<b>${model.name}</b>: " + this.value; + appendDIV(message); + + // sending text message + videoConnection.send(message); + + this.value = ''; + }; + + /* + document.getElementById('file').onchange = function() { + videoConnection.send(this.files[0]); + }; + */ + + + //document.querySelector('.screenContainerPane').appenChild(document.querySelector('.screenContainer')); + //document.querySelector('.videoContainerPane').appendChild(document.querySelector('.videoContainer')); + + //panelLayout.bindButton($('#share-screen'), 'open', 'outer-west'); + //panelLayout.bindButton($('#stop-share-screen'), 'close', 'outer-west'); + var videoConnection = null, screenConnection = null; + initializeConnections(); + assignStreamToDom(); + + // start the share + //document.getElementById('share-screen').click(); + // + }); + diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-profile/self-profile-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-profile/self-profile-controller.js new file mode 100644 index 00000000..efe2b749 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-profile/self-profile-controller.js @@ -0,0 +1,358 @@ +appDS2.controller('selfProfileController', function($scope, $http, $modal, $routeParams, $rootScope,SelfProfileService){ + + /************init values***********************/ + $scope.tableData=[]; + $scope.profile=[]; + $scope.oriProfile=[]; + $scope.ociavailableRoles=[]; + $scope.ociTimeZones; + $scope.ociCountries; + var stateList=[]; + $scope.availableRoles = []; + $scope.timeZones = []; + $scope.selectedTimeZone = {"index":'',"value":"","title":""}; + $scope.countries = []; + $scope.selectedCountry = {"index":'',"value":"","title":""}; + + $scope.isUserSystemAdmin = false; + $scope.profileId=''; + $scope.showLoader=false; + $scope.pageType=1 /*1 for slef page 2 for general profile page*/ + $scope.pageTitle='Self Profile Detail'; + $scope.profileIdParam = $routeParams.profileId; + if (typeof($scope.profileIdParam) != "undefined" && $scope.profileIdParam!=''){ + $scope.pageTitle='Profile Detail'; + $scope.pageType=2; + } + + $scope.sbcid=$scope.profile.sbcid; + $scope.managerAttuid=$scope.profile.managerAttuid; + + /***********************************************************functions***********************************************/ + $scope.getProfileDetail = function(profileIdParam){ + $scope.showLoader=true; + SelfProfileService.getProfileDetail(profileIdParam).then(function(data){ + $scope.showLoader=false; + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profile =JSON.parse($scope.data.profile); + $scope.oriProfile=JSON.parse($scope.data.profile); /*original value*/ + $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.sbcid=$scope.profile.sbcid; + $scope.managerAttuid=$scope.profile.managerAttuid; + + 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); + }); + ; + 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; + } + }); + }; + 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; + } + }); + ; + stateList = stateList== null? []: stateList; + var selectedState= $scope.profile.state ? $scope.profile.state:""; + $scope.stateList = initDropdownWithLookUp(stateList,selectedState ); + },function(error){ + $scope.errorPopUp(error); + $scope.showLoader=false; + }); + } + + $scope.getSelfProfileDetail = function(){ + $scope.showLoader=true; + SelfProfileService.getSelfProfileDetail().then(function(data){ + $scope.showLoader=false; + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profile =JSON.parse($scope.data.profile); + $scope.oriProfile=JSON.parse($scope.data.profile); /*original value*/ + $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.sbcid=$scope.profile.sbcid; + $scope.managerAttuid=$scope.profile.managerAttuid; + + 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); + }); + ; + 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; + } + }); + }; + 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; + } + }); + ; + stateList = stateList== null? []: stateList; + var selectedState= $scope.profile.state ? $scope.profile.state:""; + $scope.stateList = initDropdownWithLookUp(stateList,selectedState ); + },function(error){ + $scope.errorPopUp(error); + $scope.showLoader=false; + }); + } + + + $scope.removeRole = function(data) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/role-del-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + role:data, + roleId:$scope.profileId, + }; + return message; + } + } + }); + }; + $scope.addNewRoleFunctionModalPopup = function(data) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/role-add.html', + controller: ModalInstanceCtrl, + windowClass:'modal-docked', + sizeClass: 'modal-medium', + resolve: { + items: function () { + var message = { + roleFunctions:data, + roleId:$scope.profileId, + availableRoleFunctions:$scope.ociavailableRoles + }; + return message; + } + } + }); + } + + + $scope.successPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + + $scope.errorPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return msg; + } + } + }); + }; + $scope.saveProfile = function() { + $scope.errorMsg = ''; + if($scope.oriProfile.orgUserId != $scope.profile.orgUserId){ + $scope.errorPopUp('Organization User ID cannot be changed'); + return; + } + if($scope.oriProfile.orgManagerUserId != $scope.profile.orgManagerUserId){ + $scope.errorPopUp('Organization Manager ID cannot be changed'); + return; + } + if($scope.oriProfile.loginId != $scope.profile.loginId){ + $scope.errorPopUp('Login ID cannot be changed'); + return; + } + if($scope.oriProfile.loginPwd != $scope.profile.loginPwd){ + $scope.errorPopUp('Login Password cannot be changed'); + return; + } + + 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:"" + }; + SelfProfileService.saveProfile(postData, $scope.profileId).then(function(msg){ + $scope.successPopUp(); + },function(error){ + $scope.errorPopUp(error); + }); + } + /* updating role tables after adding or deleting*/ + $rootScope.$on('updateRoles',function(e,d){ + $scope.profile.roles = d.data; + }) + /*****init call*****/ + + if ($scope.pageType==2){ + $scope.getProfileDetail($scope.profileIdParam); + }else{ + $scope.getSelfProfileDetail(); + } + + + /****************************************************************popup modal*************************************************************/ + var ModalInstanceCtrl = function ($scope, $modalInstance, items,$rootScope) { + $scope.roleFun=items; + $scope.msg=items; + $scope.activateRoleConfirmPopUp = function (selected, availableRole) { + $scope.msg.roleFun = availableRole.name; + $scope.msg.selected = selected; + $scope.msg.availableRole = availableRole; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/role-add-confirm.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return $scope.msg; + } + } + }); + } + $scope.confirmRoleDel = function(role,profileId){ + var postData={role:role}; + SelfProfileService.removeRole(postData,profileId).then(function(msg){ + $scope.cancel(); + $scope.roleTableRefresh(profileId); + },function(error){ + $scope.errorPopUp(error); + }); + } + $scope.confirmRoleFunAdd = function(availableRole,profileId){ + var postData={role:availableRole}; + SelfProfileService.addRole(postData,profileId).then(function(msg){ + $scope.cancel(); + $scope.roleTableRefresh(profileId); + },function(error){ + $scope.errorPopUp(error); + }); + } + + // confirm Role Function Remove + $scope.confirmRoleFunRemove = function(availableRole,profileId){ + var postData={role:availableRole}; + SelfProfileService.deRole(postData,profileId).then(function(msg){ + $scope.cancel(); + $scope.roleTableRefresh(profileId); + },function(error){ + $scope.errorPopUp(error); + }); + } + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.cancelRoleFunSwitch = function (msg) { + $scope.msg.availableRole.selected = !$scope.msg.availableRole.selected; + $modalInstance.dismiss('cancel'); + }; + + $scope.selfProfileRoleRefresh = function(){ + SelfProfileService.getSelfProfileDetail().then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profileTemp =JSON.parse($scope.data.profile); + $rootScope.$broadcast('updateRoles',{data:$scope.profileTemp.roles}); + }); + } + $scope.profileRoleRefresh = function(profileId){ + SelfProfileService.getProfileDetail(profileId).then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.profileTemp =JSON.parse($scope.data.profile); + $rootScope.$broadcast('updateRoles',{data:$scope.profileTemp.roles}); + }); + } + $scope.roleTableRefresh = function (profileId) { + if($scope.pageType==1) + $scope.selfProfileRoleRefresh(); + else + $scope.profileRoleRefresh(profileId); + }; + + }; + +}); +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!=null?selected:{"index":'',"value":"","title":""}; + return dropDown; +}; diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js new file mode 100644 index 00000000..8fa14643 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js @@ -0,0 +1,459 @@ +appDS2.controller('reportChartController', function ($scope, $rootScope, $timeout, $window, $http, $routeParams,modalService) { + $scope.showLoader = true; + $scope.commonOptionOpen = false; + $scope.additionalOptionOpen = false; + $scope.barChartOptionOpen = false; + $scope.timeSeriesChartOptionOpen = false; + $scope.selectedChartType = {value:""}; + $scope.chartTypeOptions = [ + {value: 'BarChart3D', text: 'Bar Chart'}, + {value: 'TimeSeriesChart', text: 'Time Series/Area Chart'}, + {value: 'PieChart', text: 'Pie Chart'}, + {value: 'AnnotationChart', text: 'Annotation Chart'}, + {value: 'FlexTimeChart', text: 'Flexible Time Chart'} + ]; + + $scope.populateChrtWzdFields = function() { + $scope.reportRunJson = {}; + $http.get("raptor.htm?action=chart.json&c_master="+$routeParams.reportId).then(function (response) { + $scope.reportRunJson = response.data; + //Set chart type + $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+""; + $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + ""; + $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + ""; + + // if barChartOptions is not null + if ($scope.reportRunJson.barChartOptions) { + $scope.reportRunJson.barChartOptions.displayBarControls = $scope.reportRunJson.barChartOptions.displayBarControls+""; + $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = $scope.reportRunJson.barChartOptions.minimizeXAxisTickers+""; + $scope.reportRunJson.barChartOptions.stackedChart = $scope.reportRunJson.barChartOptions.stackedChart+""; + $scope.reportRunJson.barChartOptions.timeAxis =$scope.reportRunJson.barChartOptions.timeAxis+""; + $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +""; + $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +""; + } + + if ($scope.reportRunJson.chartTypeJSON) { + var chrtTypeValue = $scope.reportRunJson.chartType; + for(var i = 0; i < $scope.chartTypes.length; i++) { + if ($scope.chartTypes[i].value==chrtTypeValue) { + $scope.reportRunJson.chartTypeJSON.index=$scope.chartTypes[i].index; + $scope.reportRunJson.chartTypeJSON.value=$scope.chartTypes[i].value; + $scope.reportRunJson.chartTypeJSON.title=$scope.chartTypes[i].title; + } + + } + } + + //Set Domain Axis + if ($scope.reportRunJson.domainAxisJSON) { + var domaninAxisValue = $scope.reportRunJson.domainAxisJSON.value; + for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) { + if ($scope.reportRunJson.chartColumnJSONList[i].value==domaninAxisValue) { + $scope.reportRunJson.domainAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index; + $scope.reportRunJson.domainAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title; + } + + } + } + + //Set Category + if ($scope.reportRunJson.categoryAxisJSON) { + var categoryAxisValue = $scope.reportRunJson.categoryAxisJSON.value; + for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) { + if ($scope.reportRunJson.chartColumnJSONList[i].value==categoryAxisValue) { + $scope.reportRunJson.categoryAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index; + $scope.reportRunJson.categoryAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title; + } + } + } + + //Set range axis label + if ($scope.reportRunJson.rangeAxisList) { + for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { + + if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON) { + var rangeAxisLabelValue = $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value; + for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) { + if ($scope.reportRunJson.chartColumnJSONList[i].value==rangeAxisLabelValue) { + $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index; + $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title; + } + } + } + } + } + + + //set range linetype + if ($scope.reportRunJson.rangeAxisList) { + for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { + if ($scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != "" + && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != null) { + var lineTypeValue = $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value; + for(var i = 0; i < $scope.lineTypes.length; i++) { + if ($scope.lineTypes[i].value==lineTypeValue) { + $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.index=$scope.lineTypes[i].index; + $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.title=$scope.lineTypes[i].title; + } + } + } else { + $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON = null; + } + } + } + //set range color + if ($scope.reportRunJson.rangeAxisList) { + for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) { + if ($scope.reportRunJson.rangeAxisList[j].rangeColorJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != "" + && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != null) { + var colorValue = $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value; + for(var i = 0; i < $scope.rangeColors.length; i++) { + if ($scope.rangeColors[i].value==colorValue) { + $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.index=$scope.rangeColors[i].index; + $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.title=$scope.rangeColors[i].title; + } + } + }else { + $scope.reportRunJson.rangeAxisList[j].rangeColorJSON = null; + } + } + } + $scope.showLoader = false; + }); + + $scope.legend = "true"; + } + + $scope.saveChartData = function() { + $scope.showLoader = true; + + $scope.reportRunJson.commonChartOptions.animateAnimatedChart = ($scope.reportRunJson.commonChartOptions.animateAnimatedChart=="true") + $scope.reportRunJson.commonChartOptions.hideLegend = ($scope.reportRunJson.commonChartOptions.hideLegend=="true"); + $scope.reportRunJson.showTitle = ($scope.reportRunJson.showTitle=="true"); + + $scope.reportRunJson.chartTypeJSON = { + 'index':0,'title':'','value':''}; + + + if (($scope.reportRunJson.chartType == "BarChart3D")&&($scope.reportRunJson.barChartOptions)) { + $scope.reportRunJson.barChartOptions.displayBarControls = ($scope.reportRunJson.barChartOptions.displayBarControls=="true") ; + $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = ($scope.reportRunJson.barChartOptions.minimizeXAxisTickers=="true") ; + $scope.reportRunJson.barChartOptions.stackedChart = ($scope.reportRunJson.barChartOptions.stackedChart=="true") ; + $scope.reportRunJson.barChartOptions.timeAxis= ($scope.reportRunJson.barChartOptions.timeAxi=="true") ; + $scope.reportRunJson.barChartOptions.verticalOrientation = ($scope.reportRunJson.barChartOptions.verticalOrientation=="true") ; + $scope.reportRunJson.barChartOptions.xAxisDateType = ($scope.reportRunJson.barChartOptions.xAxisDateType=="true") ; + } + + for (var i=0;i<$scope.chartTypes.length;i++) { + if ($scope.reportRunJson.chartType==$scope.chartTypes[i].value) { + $scope.reportRunJson.chartTypeJSON = { + 'index':$scope.chartTypes[i].index, + 'title':$scope.chartTypes[i].title, + 'value':$scope.chartTypes[i].value + } + } + } + + $scope.reportRunJson.domainAxisJSON = { + "index":0,"value":$scope.reportRunJson.domainAxis,"title": $scope.reportRunJson.domainAxis + }; + $scope.reportRunJson.categoryAxisJSON = { + "index":0,"value":$scope.reportRunJson.categoryAxis,"title": $scope.reportRunJson.categoryAxis + }; + + // Specifically for DS2 for color + for (var i=0; i<$scope.reportRunJson.rangeAxisList.length; i ++) { + $scope.reportRunJson.rangeAxisList[i].rangeColorJSON = + {"index":0, "value": $scope.reportRunJson.rangeAxisList[i].rangeColor, "title": ""}; + + $scope.reportRunJson.rangeAxisList[i].rangeLineTypeJSON = + {"index":0, "value": "", "title": ""}; + for (var j=0;j<$scope.lineTypes.length;j++) { + if ($scope.reportRunJson.rangeAxisList[i].rangeLineType ==$scope.lineTypes[j].value) { + $scope.reportRunJson.rangeAxisList[i].rangeLineTypeJSON = + {"index":$scope.lineTypes[j].index, "value": $scope.lineTypes[j].value, "title": $scope.lineTypes[j].title}; + } + } + + } + + //Converting string variables to numbers + $scope.reportRunJson.commonChartOptions.rightMargin = Number($scope.reportRunJson.commonChartOptions.rightMargin); + $scope.reportRunJson.commonChartOptions.topMargin = Number($scope.reportRunJson.commonChartOptions.topMargin); + $scope.reportRunJson.commonChartOptions.bottomMargin = Number($scope.reportRunJson.commonChartOptions.bottomMargin); + $scope.reportRunJson.commonChartOptions.leftMargin = Number($scope.reportRunJson.commonChartOptions.leftMargin); + + if ($scope.reportRunJson.categoryAxisJSON == "") { + $scope.reportRunJson.categoryAxisJSON = {}; + $scope.reportRunJson.categoryAxisJSON.value = -1; + } + //add the remove list to the json + $scope.reportRunJson.rangeAxisRemoveList= $scope.rangeAxisRemoveList; + $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) { + $scope.successSubmit=true; + $scope.showLoader = false; + $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+""; + $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + ""; + $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + ""; + if ($scope.reportRunJson.chartType == "BarChart3D") { + $scope.reportRunJson.barChartOptions.displayBarControls = $scope.reportRunJson.barChartOptions.displayBarControls+""; + $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = $scope.reportRunJson.barChartOptions.minimizeXAxisTickers+""; + $scope.reportRunJson.barChartOptions.stackedChart = $scope.reportRunJson.barChartOptions.stackedChart+""; + $scope.reportRunJson.barChartOptions.timeAxis =$scope.reportRunJson.barChartOptions.timeAxis+""; + $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +""; + $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +""; + } + $scope.populateChrtWzdFields(); + }) + } + + + $scope.addRangeAxisRow = function (rangeaxisitem) { + $scope.reportRunJson.rangeAxisList.push({ + }); + }; + + $scope.rangeAxisRemoveList= []; + $scope.removeRangeAxisRow = function (index) { + $scope.rangeAxisRemoveList.push($scope.reportRunJson.rangeAxisList[index]); + $scope.reportRunJson.rangeAxisList[index].removed="true"; + }; + + + $scope.init = function () { + if ($scope) { + $scope.populateChrtWzdFields(); + $scope.reportRunJson.rangeAxisRemoveList= []; + } + }; + + + + $scope.domainItems = [{title:"Domain Axis1", content:"Test1", open: false},{title:"Domain Axis2", content:"Test2", open: false}]; + + $scope.chartTypes = [ + {index: 0, value: 'BarChart3D', title: 'Bar Chart'}, + {index: 1, value: 'TimeSeriesChart', title: 'Time Series/Area Chart'}, + {index: 2, value: 'PieChart', title: 'Pie Chart'}, + {index: 3, value: 'AnnotationChart', title: 'Annotation Chart'}, + {index: 4, value: 'FlexTimeChart', title: 'Flexible Time Chart'} + ]; + + $scope.categories = [ + {index: 0, value: 'scenario_name', title: 'scenario_name'}, + {index: 1, value: 'total_traffic_in_PB', title: 'Total Traffic in PB'}, + {index: 2, value: 'Avg Utilization Day', title: 'Avg Utilization Day'} + ]; + + $scope.rangeColors = [ + {index: 0, value: "#1f77b4",title: "Dodger Blue"}, + {index: 1, value: "#ff7f0e",title: "Vivid orange"}, + {index: 2, value: "#2ca02c",title: "Forest Green"}, + {index: 3, value: "#8c864b",title: "Greenish Red"}, + {index: 4, value: "#9467bd",title: "Desaturated violet"}, + {index: 5, value: "#8c564b",title: "Dark moderate red"}, + {index: 6, value: "#e377c2",title: "Soft pink"}, + {index: 7, value: "#7f7f7f",title: "Dark gray"}, + {index: 8, value: "#bcbd22",title: "Strong yellow"}, + {index: 9, value: "#17becf",title: "Strong cyan"}, + {index: 10, value: "#dc143c",title: "Vivid red"}, + {index: 11, value: "#800080",title: "Dark magenta"}, + {index: 12, value: "#0000FF",title: "Blue"}, + {index: 13, value: "#008000",title: "Dark lime green"}, + {index: 14, value: "#D2691E",title: "Reddish Orange"}, + {index: 15, value: "#FF0000",title: "Red"}, + {index: 16, value: "#000000",title: "Black"}, + {index: 17, value: "#DB7093",title: "Pink"}, + {index: 18, value: "#FF00FF",title: "Pure Magenta"}, + {index: 19, value: "#7B68EE",title: "Soft blue"}, + {index: 20, value: "#1f77b6",title: "Strong blue"}, + {index: 21, value: "#9edae5",title: "Very soft cyan"}, + {index: 22, value: "#393b79",title: "Dark Blue"}, + {index: 23, value: "#5254a3",title: "Dark moderate Blue"}, + {index: 24, value: "#6b6ecf",title: "Slightly desaturated blue"}, + {index: 25, value: "#9c9ede",title: "Very soft blue"}, + {index: 26, value: "#637939",title: "Dark Green"}, + {index: 27, value: "#8ca252",title: "Dark moderate green"}, + {index: 28, value: "#b5cf6b",title: "Slightly desaturated green"}, + {index: 29, value: "#cedb9c",title: "Desaturated Green"}, + + /* Old Colors */ + {index: 30, value: "#00FFFF",title: "Aqua"}, + {index: 31, value: "#000000",title: "Black"}, + {index: 32, value: "#0000FF",title: "Blue"}, + {index: 33, value: "#FF00FF",title: "Fuchsia"}, + {index: 34, value: "#808080",title: "Gray"}, + {index: 35, value: "#008000",title: "Green"}, + {index: 36, value: "#00FF00",title: "Lime"}, + {index: 37, value: "#800000",title: "Maroon"}, + {index: 38, value: "#000080",title: "Navy"}, + {index: 39, value: "#808000",title: "Olive"}, + {index: 40, value: "#FF9900",title: "Orange"}, + {index: 41, value: "#800080",title: "Purple"}, + {index: 42, value: "#FF0000",title: "Red"}, + {index: 43, value: "#C0C0C0",title: "Silver"}, + {index: 44, value: "#008080",title: "Teal"}, + {index: 45, value: "#FFFFFF",title: "White"}, + {index: 46, value: "#FFFF00",title: "Yellow"} + ]; + + + $scope.lineTypes = [ + {index: 0, value: 'default', title: 'Default'}, + {index: 1, value: 'dotted_lines', title: 'Dotted Lines'}, + {index: 2, value: 'dashed_lines', title: 'Dashed Lines'} + ]; + + $scope.hardCodeReport= { + "reportID":"3356", + "reportName":"Test: Line Chart", + "reportDescr":"", + "reportTitle":"", + "reportSubTitle":"", + "formFieldList":[ + ], + "chartColumnJSONList":[ + { + "index":0, + "value":"tr0", + "title":"traffic_date", + "$$hashKey":"056" + }, + { + "index":1, + "value":"ut1", + "title":"util_perc", + "$$hashKey":"057" + } + ], + "formfield_comments":null, + "totalRows":0, + "chartSqlWhole":"SELECT traffic_date tr0, traffic_date tr0_1,util_perc ut1, 1 FROM portal.demo_util_chart ORDER BY 1", + "chartAvailable":true, + "chartType":{"index": "", "value": "Bar Chart", "title": ""}, + "width":"700", + "height":"420", + "animation":false, + "rotateLabels":"90", + "staggerLabels":false, + "showTitle":"false", + "domainAxis":{ + "index":0, + "value":"tr0", + "title":"traffic_date", + "$$hashKey":"11H" + }, + + "categoryAxis":{ + "index":1, + "value":"ut1", + "title":"util_perc", + "$$hashKey":"11I" + }, + + "hasCategoryAxis":false, + "rangeAxisList":[ + { + + "rangeColor":{ + "index":"", + "value":"#bcbd22", + "title":"" + }, + + "rangeLineType":{ + "index":"", + "value":"dotted_lines", + "title":"" + }, + "rangeAxisLabel":{ + "index":0, + "value":"tr0", + "title":"traffic_date", + "$$hashKey":"056" + }, + "YAxis":"10", + "chartTitle":"test" + }, + { + "rangeColor":{ + "index":"", + "value":"#2ca02c", + "title":"" + }, + + "rangeLineType":{ + "index":"", + "value":"dashed_lines", + "title":"" + + + }, + + "rangeAxisLabel":{ + "index":0, + "value":"tr0", + "title":"traffic_date", + "$$hashKey":"056" + }, + "YAxis":"10", + "chartTitle":"test" + } + + + ], + + "primaryAxisLabel":"testlabel", + "secondaryAxisLabel":"testseclabel", + "minRange":"10", + "maxRange":"20", + "topMargin":"6", + "bottomMargin":"5", + "leftMargin":"4", + "rightMargin":"3" + }; + + var colorValue = $scope.hardCodeReport.rangeAxisList[0].rangeColor.value; + + $timeout(function() { + $rootScope.isViewRendering = false; + }); + + +}); + +appDS2.directive('onlyDigits', function () { + + return { + restrict: 'A', + require: '?ngModel', + link: function (scope, element, attrs, ngModel) { + if (!ngModel) return; + ngModel.$parsers.unshift(function (inputValue) { + var digits = inputValue.split('').filter(function (s) { return (!isNaN(s) && s != ' '); }).join(''); + ngModel.$viewValue = digits; + ngModel.$render(); + return digits; + }); + } + }; +}); + +appDS2.directive('onlyCharacters', function () { + return { + restrict: 'A', + require: '?ngModel', + link: function (scope, element, attrs, ngModel) { + if (!ngModel) return; + ngModel.$parsers.unshift(function (inputValue) { + var digits = inputValue.split('').filter(function (s) { return (isNaN(s) && s != ' '); }).join(''); + ngModel.$viewValue = digits; + ngModel.$render(); + return digits; + }); + } + }; +}); + + + diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js new file mode 100644 index 00000000..a8f853fd --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js @@ -0,0 +1,20 @@ +appDS2.controller('reportImportController', function($scope,$http,$location, $routeParams, $q, $modal,$log,$window, raptorReportFactory, stepFormFactory, DOMHelper) { + $scope.importXML = function(){ + + var importXMLJSON = { + "tabId":"Import", + "tabName":"Import", + "reportXML":$scope.xmlContent + } + $scope.errorMessage = "" + raptorReportFactory.postImportXml(importXMLJSON).then(function(data){ + if (data.errormessage) { + $scope.errorMessage = data.errormessage; + } else { + $window.location.href = 'report#/report_wizard/-1'; + }; + },function(error){ + $log.error("raptorReportFactory: postImportXml failed."); + }); + } +});
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js new file mode 100644 index 00000000..1e22cca3 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js @@ -0,0 +1,41 @@ +appDS2.config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', + controller: 'reportSearchController' + }). + when('/report_search', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', + controller: 'reportSearchController' + }). + when('/report_run/:reportUrlParams*', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html', + controller: 'reportRunController' + }). + when('/report_chart_wizard/:reportId', { + templateUrl: 'static/fusion/raptor/ebz/report_chart_wizard.html', + controller: 'ChartController' + }). + when('/report_chart/:reportId', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html', + controller: 'reportChartController' + }). + when("/report_wizard", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", + controller: "reportStepController" + }). + when("/report_wizard/:reportId", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", + controller: "reportStepController" + }). + when("/report_wizard/:reportMode/:reportId", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", + controller: "reportStepController" + }). + when("/report_import", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-import.html", + controller: "reportImportController" + }) + ; + }]);
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js new file mode 100644 index 00000000..6eb0afe6 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js @@ -0,0 +1,331 @@ +appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams','$http','dateFilter', '$window', '$timeout', 'rowSorter', + function ($scope,$rootScope,$routeParams,$http,dateFilter,$window,$timeout,rowSorter) { + $scope.dateformat = "MM/dd/yyyy"; + $scope.datetimeformat = "MM/dd/yyyy hh:mm a"; + $scope.showFormFields = false; + $scope.showGrid = false; + $scope.showChart = false; + $scope.showBackButton = false; + $scope.reportData = {}; + $scope.reportData.allowEdit = false; + $scope.formFieldSelectedValues = {}; + $scope.showFormFieldIds = false; + $scope.showFormFieldId = { + value: false + }; + $scope.isInProgress = true; + + if($routeParams.reportUrlParams.indexOf("parent___params===")>-1) { + $scope.showBackButton = true; + $scope.parentReportUrlParams = $routeParams.reportUrlParams.substring($routeParams.reportUrlParams.indexOf("parent___params===")+18); + $scope.currentReportUrlParams = $routeParams.reportUrlParams.substring(0,$routeParams.reportUrlParams.indexOf("parent___params===")); + } else { + $scope.currentReportUrlParams = $routeParams.reportUrlParams; + } + // console.log($routeParams.reportUrlParams); + var parseQueryString = function( queryString ) { + var params = {}, queries, temp, i, l; + // Split into key/value pairs + queries = queryString.split("&"); + // Convert the array of strings into an object + for ( i = 0, l = queries.length; i < l; i++ ) { + temp = queries[i].split('='); + //console.log(temp[0]); + //console.log(temp[0] != "refresh"); + if(temp[0] && temp[0] != "refresh") + params[temp[0]] = temp[1]; + } + return params; + }; + + var convertQueryString = function(queryString) { + var keys = ""; var str = ""; + keys = Object.keys(queryString); + //console.log(keys); + for ( i = 0, l = keys.length; i < l; i++ ) { + str += keys[i]+"="+queryString[keys[i]] + "&"; + + } + return str; + //queryString = + } + + + + $scope.backToParentReport = function (){ + $window.location.href = "report#/report_run/"+$scope.parentReportUrlParams + } + + $scope.urlParams = parseQueryString($scope.currentReportUrlParams); + + $scope.reportChartURL = 'report#/report_chart/'+$scope.urlParams.c_master; + + $scope.reportEditURL = 'report#/report_wizard/'+$scope.urlParams.c_master; + + + $http.get('raptor.htm?action=report.run.container&'+$scope.currentReportUrlParams).then( + function(response){ + // console.log(response); + $scope.isInProgress = false; + $scope.reportData = response.data; + // console.log('reportData report run container response',$scope.reportData); + if ($scope.reportData.reportTitle) { + $scope.reportData.reportHeading = $scope.reportData.reportTitle; + if ($scope.reportData.reportSubTitle) { + $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle; + } + } + else + $scope.reportData.reportHeading = $scope.reportData.reportName; + if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){ + // console.log('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)); + $http.get('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)).then( + function(response){ + $scope.showChart = true; + document.getElementById('chartiframe').contentWindow.document.write(response.data); + document.getElementById('chartiframe').contentWindow.document.close(); + }); + } + + if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields){ + $scope.showFormFields = true; + } + }); + $scope.getFormFieldSelectedValuesAsURL = function(){ + var formFieldsUrl = ''; + $scope.reportData.formFieldList.forEach(function(formField) { + if(formField.fieldType==='LIST_BOX') { + if($scope.formFieldSelectedValues && $scope.formFieldSelectedValues[formField.fieldId] && $scope.formFieldSelectedValues[formField.fieldId].value != '') { + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId].value+'&'; + } + } else if(formField.fieldType==='LIST_MULTI_SELECT') { + if($scope.formFieldSelectedValues[formField.fieldId].length >0) { + for (var i = 0; i < $scope.formFieldSelectedValues[formField.fieldId].length; i++) { + if($scope.formFieldSelectedValues[formField.fieldId][i].defaultValue){ + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId][i].value+'&'; + } + } + } + } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && formField.validationType === 'DATE'){ + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+dateFilter($scope.formFieldSelectedValues[formField.fieldId],$scope.dateformat)+'&'; + } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && formField.validationType === 'TIMESTAMP_MIN'){ + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+dateFilter($scope.formFieldSelectedValues[formField.fieldId],$scope.datetimeformat)+'&'; + } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && $scope.formFieldSelectedValues[formField.fieldId] && $scope.formFieldSelectedValues[formField.fieldId] != ''){ + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId]+'&'; + } + }); + return formFieldsUrl; + + } + + $scope.runReport = function(pagination){ + var formFieldsUrl = $scope.getFormFieldSelectedValuesAsURL(); + /*if ($scope.reportData.reportTitle) + $scope.reportData.reportHeading = $scope.reportData.reportTitle; + else + $scope.reportData.reportHeading = $scope.reportData.reportName;*/ + + // console.log("pagination"); + if(!pagination) { + //console.log("refreshed ..."); + $scope.gridOptions.pageNumber = 1; + paginationOptions.pageNumber = 1; + paginationOptions.pageSize = $scope.reportData.pageSize; + //console.log($scope.gridOptions); + $scope.gridOptions.paginationCurrentPage = 1; + $scope.gridOptions.paginationPageSizes= [$scope.reportData.pageSize]; + $scope.gridOptions.paginationPageSize= $scope.reportData.pageSize; + if($scope.reportData.totalRows<14){ + $scope.gridHeight = ($scope.reportData.totalRows+7)*30+'px'; + } else{ + $scope.gridHeight = '400px'; + } + $scope.gridOptions.totalItems = $scope.reportData.totalRows; + $scope.gridOptions.data= $scope.reportData.reportDataRows; + $scope.gridOptions.exporterPdfHeader.text= $scope.reportData.reportName; + + } + $scope.currentReportUrlParams = 'c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'&display_content=Y&r_page='+(paginationOptions.pageNumber-1); + // console.log('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1)); + $http.get('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1)).then( + function(response){ + $scope.reportData = response.data; + if ($scope.reportData.reportTitle) { + $scope.reportData.reportHeading = $scope.reportData.reportTitle; + if ($scope.reportData.reportSubTitle) { + $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle; + } + } + else + $scope.reportData.reportHeading = $scope.reportData.reportName; + + if($scope.reportData.errormessage) { + //console.log($scope.reportData); + var stacktraceFP = $scope.reportData.stacktrace.substring(0, $scope.reportData.stacktrace.indexOf(":")+1); + document.getElementById('errorDiv').innerHTML = stacktraceFP + " " + $scope.reportData.errormessage; + //console.log(document.getElementById('errorDiv').innerHtml); + //console.log(stacktraceFP + " " + $scope.reportData.errormessage); + } + if(!pagination) { + if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){ + // console.log('raptor.htm?action=chart.run&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'display_content=Y&r_page='+(paginationOptions.pageNumber-1)); + $http.get('raptor.htm?action=chart.run&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'display_content=Y&r_page='+(paginationOptions.pageNumber-1)).then( + function(response) { + // console.log(response.data); + $scope.showChart = true; + // console.log('response.data',response.data); + document.getElementById('chartiframe').contentWindow.document.write(response.data); + document.getElementById('chartiframe').contentWindow.document.close(); + }); + } else { + $scope.showChart = false; + } + } + if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields && !$scope.reportData.hideFormFieldsAfterRun){ + $scope.showFormFields = true; + } else { + $scope.showFormFields = false; + } + }); + }; + + var paginationOptions = { + pageNumber: 1, + pageSize: 5, + sort: null + }; + + var correctTotalPaginationTemplate = + //same as normal template, but fixed totals: {{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} + "<div role=\"contentinfo\" class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div role=\"menubar\" class=\"ui-grid-pager-control\"><button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle\"><div class=\"first-bar\"></div></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle prev-triangle\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div class=\"last-triangle next-triangle\"></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div class=\"last-triangle\"><div class=\"last-bar\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\"> {{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}} {{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>"; + + $scope.gridOptions = { + pageNumber: 1, + sort : null, + paginationPageSizes: [5], + paginationPageSize: 5, + paginationTemplate: correctTotalPaginationTemplate, + columnDefs: [], + data: [], + enableGridMenu: true, + enableSelectAll: true, + gridMenuCustomItems : [ + { title : 'All Reports', + action : function($event) { + $window.open('report.htm','_self'); + }, order : 210 }, + { title : 'Edit Report', + action : function($event) { + $window.open($scope.reportEditURL,'_self'); + }, order : 211 }, + { title : 'Export All data as Excel 2007', + action : function($event) { + $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel2007.session','_self'); + }, order : 212 }, + { title : 'Export All data as Excel', + action : function($event) { + $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel.session','_self'); + }, order : 213 }, + { title : 'Export All data as CSV', + action : function($event) { + $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.csv.session','_self'); + }, order : 214 }, + { title : 'Export All data as PDF', + action : function($event) { + $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.pdf.session','_self'); + }, order : 215 } ], + exporterMenuPdf: false, + exporterMenuCsv: false, + exporterCsvFilename: 'myFile.csv', + exporterPdfDefaultStyle: {fontSize: 9}, + exporterPdfTableStyle: {margin: [30, 30, 30, 30]}, + exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'}, + exporterPdfHeader: { text: "My Header", style: 'headerStyle' }, + exporterPdfFooter: function ( currentPage, pageCount ) { + return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' }; + }, + exporterPdfCustomFormatter: function ( docDefinition ) { + docDefinition.styles.headerStyle = { fontSize: 22, bold: true }; + docDefinition.styles.footerStyle = { fontSize: 10, bold: true }; + return docDefinition; + }, + exporterPdfOrientation: 'portrait', + exporterPdfPageSize: 'LETTER', + exporterPdfMaxGridWidth: 500, + exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")), + onRegisterApi: function(gridApi) { + $scope.gridApi = gridApi; + gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { + paginationOptions.pageNumber = newPage; + paginationOptions.pageSize = pageSize; + $scope.runReport(true); + }); + } + }; + + $scope.uiGridRefresh = function(){ + var columnDefsArray = []; + var columnFreezeEndColumn = $scope.reportData.colIdxTobeFreezed; + var doColumnNeedToFreeze = false; + if(columnFreezeEndColumn && columnFreezeEndColumn.length>0) { + doColumnNeedToFreeze = true; + } + $scope.reportData.reportDataColumns.forEach(function(entry) { + var tempColumnDef = { displayName: entry.columnTitle, field: entry.colId, enableSorting: entry.sortable, + sortingAlgorithm: function(a, b) { + return rowSorter.sortAlpha(a.displayValue, b.displayValue); + }, + cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> '+ + ' <div ng-if="!COL_FIELD.drillDownURL || COL_FIELD.drillDownURL==\'\'">{{COL_FIELD.displayValue}}</div>' + + ' <a ng-if="COL_FIELD.drillDownURL && COL_FIELD.drillDownURL!=\'\'" ng-href="{{COL_FIELD.drillDownURL}}&parent___params==={{grid.appScope.currentReportUrlParams}}" >{{COL_FIELD.displayValue}}</a>' + + '</div>'}; + if(entry.columnWidth && entry.columnWidth!='null' && entry.columnWidth!='pxpx' && entry.columnWidth!='nullpx' && entry.columnWidth!='nullpxpx'){ + tempColumnDef['minWidth'] = entry.columnWidth.substring(0, entry.columnWidth.length - 2); + } else { + tempColumnDef['minWidth'] = '100'; + } + if(doColumnNeedToFreeze) { + tempColumnDef['pinnedLeft']= true; + if(columnFreezeEndColumn === entry.colId){ + doColumnNeedToFreeze = false; + } + } + columnDefsArray.push(tempColumnDef); + }); + + $scope.gridOptions.paginationPageSizes= [$scope.reportData.pageSize]; + $scope.gridOptions.paginationPageSize= $scope.reportData.pageSize; + if($scope.reportData.totalRows<14){ + $scope.gridHeight = ($scope.reportData.totalRows+5)*30+'px'; + }else{ + $scope.gridHeight = '400px'; + } + $scope.gridOptions.totalItems = $scope.reportData.totalRows; + $scope.gridOptions.columnDefs= columnDefsArray; + $scope.gridOptions.data= $scope.reportData.reportDataRows; + $scope.gridOptions.exporterPdfHeader.text= $scope.reportData.reportName; + }; + + $scope.$watch("reportData",function(newValue,oldValue) { + if(!$scope.urlParams.hideGrid){ + if($scope.reportData){ + if($scope.reportData.displayData && $scope.reportData.reportDataColumns){ + $scope.showGrid = true; + $scope.uiGridRefresh(); + } + } + } + }); + + $scope.triggerOtherFormFields = function(){ + // console.log("report_run"); + var formFieldsUrl = $scope.getFormFieldSelectedValuesAsURL(); + $http.get('raptor.htm?action=report.formfields.run.container&c_master='+$scope.reportData.reportID+'&'+formFieldsUrl).then( + function(response){ + $scope.reportData = response.data; + }); + }; + $timeout(function() { + $rootScope.isViewRendering = false; + }); +}]); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js new file mode 100644 index 00000000..e1c5e1e8 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js @@ -0,0 +1,186 @@ +appDS2.requires.push('ui.grid'); +appDS2.requires.push('ui.grid.pagination'); +appDS2.requires.push('ui.grid.resizeColumns'); +appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$timeout','uiGridConstants','$modal','$q','$log','raptorReportFactory',function ($scope,$rootScope,$http,$timeout,uiGridConstants,$modal,$q,$log,raptorReportFactory) { + + $scope.getSearchData = function(){ + raptorReportFactory.getSearchData().then(function(data){ + $scope.searchdData = data; + },function(error){ + $log.error("raptorReportFactory: getSearchData failed."); + }); + } + + $scope.getSearchData(); + + $scope.runReport = function(){ + var searchParams = ''; + if($scope.reportId && $scope.reportId!=''){ + searchParams = '&rep_id='+$scope.reportId+'&rep_id_options='+$scope.operatorRepId.index; + } + if($scope.reportName && $scope.reportName!=''){ + searchParams = searchParams+'&rep_name='+$scope.reportName+'&rep_name_options='+$scope.operatorRepName.index; + } + + var pageSearchParameter = ($scope.paginationOptions.pageNumber-1)+searchParams + raptorReportFactory.getSearchDataAtPage(pageSearchParameter).then(function(data){ + $scope.searchdData = data + },function(error){ + $log.error("raptorReportFactory: getSearchDataAtPage failed."); + }); + }; + + + $scope.paginationOptions = { + pageNumber: 1, + pageSize: 5, + sort: null + }; + + var correctTotalPaginationTemplate = + //same as normal template, but fixed totals: {{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} + "<div role=\"contentinfo\" class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div role=\"menubar\" class=\"ui-grid-pager-control\"><button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle\"><div class=\"first-bar\"></div></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle prev-triangle\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div class=\"last-triangle next-triangle\"></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div class=\"last-triangle\"><div class=\"last-bar\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\"> {{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}} {{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>"; + + $scope.gridOptions = { + paginationPageSizes: [5], + paginationPageSize: 5, + paginationTemplate: correctTotalPaginationTemplate, + columnDefs: [], + enableColumnResizing: true, + data: [], + enableGridMenu: true, + enableSelectAll: true, + exporterMenuPdf: false, + exporterMenuCsv: false, + exporterCsvFilename: 'myFile.csv', + exporterPdfDefaultStyle: {fontSize: 9}, + exporterPdfTableStyle: {margin: [30, 30, 30, 30]}, + exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'}, + exporterPdfHeader: { text: "My Header", style: 'headerStyle' }, + exporterPdfFooter: function ( currentPage, pageCount ) { + return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' }; + }, + exporterPdfCustomFormatter: function ( docDefinition ) { + docDefinition.styles.headerStyle = { fontSize: 22, bold: true }; + docDefinition.styles.footerStyle = { fontSize: 10, bold: true }; + return docDefinition; + }, + exporterPdfOrientation: 'portrait', + exporterPdfPageSize: 'LETTER', + exporterPdfMaxGridWidth: 500, + exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")), + onRegisterApi: function(gridApi) { + gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { + $scope.paginationOptions.pageNumber = newPage; + $scope.paginationOptions.pageSize = pageSize; + $scope.runReport(); + }); + } + }; + + + var getPage = function() { + $scope.gridOptions.columnDefs = []; + $scope.searchdData.columns[0].forEach(function(entry) { + if(entry.columnTitle=='Run'){ + $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false, + cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="#/report_run/{{COL_FIELD.drillDownLink.substr(39)}}" class="icon-controls-pointer" style="font-size:20px;"></a></div>' + }); + } else if(entry.columnTitle=='Edit'){ + $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false, + cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD.drillDownLink}}" class="icon-misc-pen" style="font-size:20px;"></a></div>' + }); + } else if(entry.columnTitle=='Delete'){ + $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false, + cellTemplate: '<div class="ui-grid-cell-contents"><a ng-click="grid.appScope.removeReport(COL_FIELD.drillDownLink,row)" class="icon-misc-trash" style="font-size:20px;"></a></div>' + }); + } else if(entry.columnTitle=='Copy'){ + $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false, + cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD.drillDownLink}}" class="icon-documents-copy" style="font-size:20px;"></a></div>' + }); + } else if(entry.columnTitle=='Schedule'){ + } else if(entry.columnTitle=='No'){ + } else { + $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, + enableSorting: true, + cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> <div>{{COL_FIELD.displayValue}}</div> </div>' + }); + } + }); + + $scope.gridOptions.paginationPageSizes= [$scope.searchdData.metaReport.pageSize]; + $scope.gridOptions.paginationPageSize= $scope.searchdData.metaReport.pageSize; + $scope.gridOptions.totalItems = $scope.searchdData.metaReport.totalSize; + + $scope.gridOptions.data = []; + $scope.searchdData.rows[0].forEach(function(entry) { + var localData = {}; + entry.forEach(function(rowData){ + localData[rowData["columnId"]]= rowData["searchresultField"]; + }); + $scope.gridOptions.data.push(localData); + }); + }; + + $scope.$watch("searchdData",function(newValue,oldValue) { + if($scope.searchdData){ + getPage(); + } + }); + + $scope.operatorsRepId = [ + {index: 0, value: 'Equal To', text: 'Equal To', alias:'Equal To'}, + {index: 1, value: 'Less Than', text: 'Less Than', alias:'Less Than'}, + {index: 2, value: 'Greater Than', text: 'Greater Than', alias:'Greater Than'}]; + $scope.operatorRepId = {}; + $scope.operatorRepId.value = $scope.operatorsRepId[0].value; + $scope.operatorRepId.index = $scope.operatorsRepId[0].index; + + $scope.operatorsRepName = [ + {index: 0, value: 'Starts With', text: 'Starts With', alias:'Starts With'}, + {index:1, value: 'Ends With', text: 'Ends With', alias:'Ends With'}, + {index: 2, value: 'Contains', text: 'Contains', alias:'Contains'}]; + + $scope.operatorRepName = {}; + $scope.operatorRepName.value = $scope.operatorsRepName[0].value; + $scope.operatorRepName.index = $scope.operatorsRepName[0].index; + + $scope.removeReport = function(reportDeleteUrl,row) { + var modalInstance = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory', function ($scope, $modalInstance, $http, $log, raptorReportFactory) { + $scope.ok = function() { + raptorReportFactory.getReportDeleteStatus(reportDeleteUrl).then(function(data){ + if (!(data.deleted)) { + $log.error("raptorReportFactory: report removal failed.") + } + $modalInstance.close(); + },function(error){ + $log.error("report removal error.") + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('RefreshGridOptions'); + }, function () { + }); + }; + + $scope.$on('RefreshGridOptions', function(event) { + $scope.getSearchData(); + }); + + $timeout(function() { + $rootScope.isViewRendering = false; + }); + + +}]); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js new file mode 100644 index 00000000..3196b336 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js @@ -0,0 +1,1263 @@ +appDS2.controller('reportStepController', function($scope,$http,$location, $routeParams, $q, $modal,$log,$window, raptorReportFactory, stepFormFactory) { + + $scope.showLoader = true; + // tabs for report wizard steps: + $scope.activeTabsId = 'Definition'; + $scope.addReportUserId = {'id':''}; + $scope.addReportRoleId = {'id':''}; + // For all the dropdown box, please declare the active selection variable in the following manner: + // $scope.selectedOpt = {}; + // $scope.selectedOpt.value = ""; + $scope.getDefinitionById = function(id) { + raptorReportFactory.getDefinitionByReportId(id).then(function(data){ + $scope.loadDefinition(data); + $scope.definitionData = data; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: getSearchData failed."); + $scope.showLoader = false; + }); + } + + $scope.addReportSecurityUser = function(userId) { + raptorReportFactory.addReportSecurityUser(userId).then(function(data){ + $scope.loadSecurityPage(); + },function(error){ + $log.error("raptorReportFactory: addReportSecurityUser failed."); + }); + } + + $scope.removeReportSecurityUser = function(securityUser) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityUser', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityUser) { + $scope.securityUserName = securityUser.name; + $scope.ok = function() { + raptorReportFactory.removeReportSecurityUser(securityUser.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: removeReportSecurityUser failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + securityUser: function(){ + return securityUser; + } + } + }); + modalInstance.result.then(function () { + $scope.loadSecurityPage(); + }, function () { + }); + }; + + + $scope.addReportSecurityRole = function(roleId) { + raptorReportFactory.addReportSecurityRole(roleId).then(function(data){ + $scope.loadSecurityPage(); + },function(error){ + $log.error("raptorReportFactory: addReportSecurityRole failed."); + }); + } + + $scope.removeReportSecurityRole = function(securityRole) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityRole', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityRole) { + $scope.securityRoleName = securityRole.name; + $scope.ok = function() { + raptorReportFactory.removeReportSecurityRole(securityRole.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: removeReportSecurityRole failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + securityRole: function(){ + return securityRole; + } + } + }); + modalInstance.result.then(function () { + $scope.loadSecurityPage(); + }, function () { + }); + } + + $scope.saveReportSecurityInfo = function(userId, isPublic) { + var securityInfo = {'userId':userId+"",'isPublic':isPublic}; + raptorReportFactory.updateReportSecurityInfo(securityInfo).then(function(data){ + $scope.loadSecurityPage(); + },function(error){ + $log.error("raptorReportFactory: updateReportSecurityInfo failed."); + }); + }; + + $scope.createNewDefinition = function() { + raptorReportFactory.createNewDefinition().then(function(data){ + $scope.loadDefinition(data); + $scope.definitionData = data; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: getSearchData failed."); + }); + } + + var initializeCreateReport = function() { + $scope["selectedReportType"] ={}; + $scope.selectedReportType.value ="linear"; + $scope.selectedReportType2 ={}; + $scope.selectedReportType2.value =""; + $scope.selectedDataSource ={}; + $scope.selectedDataSource.value="local"; + $scope.sqlScript = "SELECT "; + $scope.pageSize = {"value":"50"}; + } + + + var loadSqlInSession = function(){ + raptorReportFactory.getSqlInSession().then(function(data){ + $scope.sqlInSessionJSON = data; + $scope.sqlScript = data.query; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: getSearchData failed."); + }); + }; + + initializeCreateReport(); + if ($routeParams.reportMode) { + if ($routeParams.reportMode=="copy") { + raptorReportFactory.copyReportById($routeParams.reportId).then(function(data){ + $scope.$emit('RefreshInsession'); + },function(error){ + $log.error("raptorReportFactory: deleteFormFieldById failed."); + }); + } else if ($routeParams.reportMode=="import") { + $scope.$emit('RefreshInsession'); + } + } else if ($routeParams.reportId) { + $scope.getDefinitionById($routeParams.reportId); + $scope.isEdit = true; + $scope.reportId = $routeParams.reportId; + } else { + $scope.isEdit = false; + $scope.createNewDefinition(); + } + + + $scope.RunCurrentReport = function (){ + $window.location.href = "#/report_run/c_master="+$scope.reportId+"&refresh=Y"; + } + + $scope.deleteFormField = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.tempFieldId = rowData.id; + $scope.ok = function() { + raptorReportFactory.deleteFormFieldById(rowData.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: deleteFormFieldById failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + modalInstance.result.then(function () { + $scope.$emit('RefreshFormField'); + }, function () { + }); + } + + $scope.loadDefinition = function(definitionData) { + $scope.reportId = definitionData.reportId+""; + $scope.reportName = definitionData.reportName; + $scope.reportDescr = definitionData.reportDescr; + $scope.formHelpText = definitionData.formHelpText; + $scope.selectedPageSize = {"value": definitionData.pageSize+''}; + $scope.selectedMaxRowsInExcelCSVDownload = {"value": definitionData.maxRowsInExcelCSVDownload}; + $scope.reportTitle = definitionData.reportTitle; + $scope.reportSubTitle = definitionData.reportSubTitle; + $scope.selectedNumFormCols ={"value": definitionData.numFormCols+''}; + $scope.selectedFrozenColumns={"value": definitionData.frozenColumns+''}; + $scope.selectedDataGridAlign = {"value":definitionData.dataGridAlign+''}; + $scope.emptyMessage = definitionData.emptyMessage+''; + $scope.selectedDataContainerHeight = {"value":definitionData.dataContainerHeight+''}; + $scope.selectedDataContainerWidth = {"value":definitionData.dataContainerWidth+''}; + var displayAreaValue = "null" + for (var i=0; i<3; i++ ) { + if (definitionData.displayArea[i].selected) { + displayAreaValue = definitionData.displayArea[i].name; + } + } + $scope.selectedDisplayArea = {"value":displayAreaValue+""}; + + $scope.hideFormFieldsAfterRunSelected = {"value": definitionData.hideFormFieldsAfterRun} + + $scope.hideFormFieldsSelected = {"value":definitionData.displayOptions[0].selected}; + $scope.hideChartSelected = {"value":definitionData.displayOptions[1].selected}; + $scope.hideReportDataSelected = {"value":definitionData.displayOptions[2].selected}; + $scope.hideExcelSelected = {"value":definitionData.displayOptions[3].selected}; + $scope.hidePdfSelected = {"value":definitionData.displayOptions[4].selected}; + $scope.runtimeColSortDisabled = {"value":definitionData.runtimeColSortDisabled}; + $scope.showLoader = false; + } + + + var setDefinition = function(){ + $scope.updatedDefJson = { + "tabName" : "Definition", + "tabId" : "Def", + "reportId" : ($scope.isEdit?$scope.reportId+'':"-1"), + "reportName" : $scope.reportName, + "reportDescr" : $scope.reportDescr, + "reportType" : "Linear", + "dbInfo" : "local", + "formHelpText" : $scope.formHelpText, + "pageSize" : Number($scope.selectedPageSize.value), + "displayArea" : [ { + "id" : "HOME", + "name" : "HOME", + "selected" : ($scope.selectedDisplayArea.value=="HOME") + }, { + "id" : "CUSTOMER", + "name" : "CUSTOMER", + "selected" : ($scope.selectedDisplayArea.value==="CUSTOMER") + }, { + "id" : "REPORTS", + "name" : "REPORTS", + "selected" : ($scope.selectedDisplayArea.value==="REPORTS") + } ], + "hideFormFieldsAfterRun" : $scope.hideFormFieldsAfterRunSelected.value, + "maxRowsInExcelCSVDownload" : Number($scope.selectedMaxRowsInExcelCSVDownload.value), + "frozenColumns" : Number($scope.selectedFrozenColumns.value), + "dataGridAlign" : $scope.selectedDataGridAlign.value, + "emptyMessage" : $scope.emptyMessage, + "dataContainerHeight" : $scope.selectedDataContainerHeight.value, + "dataContainerWidth" : $scope.selectedDataContainerWidth.value, + "displayOptions" : [ { + "name" : "HideFormFields", + "selected" : $scope.hideFormFieldsSelected.value + }, { + "name" : "HideChart", + "selected" : $scope.hideChartSelected.value + }, { + "name" : "HideReportData", + "selected" : $scope.hideReportDataSelected.value + }, { + "name" : "HideExcel", + "selected" : $scope.hideExcelSelected.value + }, { + "name" : "HidePdf", + "selected" : $scope.hidePdfSelected.value + } ], + "runtimeColSortDisabled" : $scope.runtimeColSortDisabled.value, + "numFormCols" : Number($scope.selectedNumFormCols.value), + "reportTitle" : $scope.reportTitle, + "reportSubTitle" : $scope.reportSubTitle + } + + } + + var updateDefinitionData = function() { + setDefinition(); + raptorReportFactory.updateDefinition($scope.updatedDefJson,$scope.isEdit).then(function(data){ + },function(error){ + $log.error("raptorReportFactory: updateDefinition by Id failed."); + }); + } + + var saveNewDefinitionData = function() { + setDefinition(); + raptorReportFactory.saveNewDefinition($scope.updatedDefJson).then(function(data){ + },function(error){ + $log.error("raptorReportFactory: saveNewDefinition by Id failed."); + }); + } + + $scope.testRunSql = function(){ + var queryJSON = {query: $scope.sqlScript}; + queryJSON = JSON.stringify(queryJSON); + raptorReportFactory.testRunSQL(queryJSON).then(function(data){ + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { + var init = function() { + $scope.isError = false; + if (queriedData.errormessage) { + $scope.isError = true; + $scope.errormessage = queriedData.errormessage; + $scope.stacktrace = queriedData.stacktrace; + } else { + $scope.queryData = queriedData; + } + } + init(); + $scope.close = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + queriedData: function(){ + return data; + } + } + }) + + },function(error){ + $log.error("raptorReportFactory: test run SQL failed."); + }); + } + + + $scope.formFieldVerifySQL= function(sqlScript){ + var queryJSON = {query: sqlScript}; + queryJSON = JSON.stringify(queryJSON); + raptorReportFactory.formFieldVerifySQL(queryJSON).then(function(data){ + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { + var init = function() { + $scope.isError = false; + if (queriedData.errormessage) { + $scope.isError = true; + $scope.errormessage = queriedData.errormessage; + $scope.stacktrace = queriedData.stacktrace; + } else { + $scope.queryData = queriedData; + } + } + init(); + $scope.close = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + queriedData: function(){ + return data; + } + } + }) + + },function(error){ + $log.error("raptorReportFactory: test run SQL failed."); + }); + } + + + /* $scope.selectedDataSource.allowSchedule={}; + $scope.selectedDataSource.allowSchedule.value=""*/ + + var getJsonSrcName = function(stepNum){ + var JsonSrcPrefix = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step" + return JsonSrcPrefix + stepNum +".json"; + } + + $scope.gTabs = [ + { + title: 'Definition', + id: 'Definition', + uniqueId: 'uniqueTab1x', + tabPanelId: 'threetab1x' + }, { + title: 'SQL', + id: 'SQL', + uniqueId: 'uniqueTab2x', + tabPanelId: 'threetab2x', + disabled: (!$scope.isEdit) + }, { + title: 'Columns', + id: 'Columns', + uniqueId: 'uniqueTab3x', + tabPanelId: 'threetab3x', + disabled: (!$scope.isEdit) + }, { + title: 'Form Fields', + id: 'Form Fields', + uniqueId: 'uniqueTab4x', + tabPanelId: 'threetab4x', + disabled: (!$scope.isEdit) + }, { + title: 'Security', + id: 'Security', + uniqueId: 'uniqueTab5x', + tabPanelId: 'threetab5x', + disabled: (!$scope.isEdit) + }, { + title: 'Run', + id: 'Run', + uniqueId: 'uniqueTab6x', + tabPanelId: 'threetab6x', + disabled: (!$scope.isEdit) + } + ]; + + $scope.unhideAllOtherTabs = function(){ + for (var selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) { + $scope.gTabs[selectedTab].disabled = false; + } + } + + $scope.openColumnPopup = function (rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','colData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, colData) { + raptorReportFactory.getColumnEditInfoById(colData.id).then(function(data){ + $scope.columnEditData = data; + $scope.colId = data.colId; +/* $scope.colName = data.colName;*/ + $scope.colName = {'value':data.colName+''}; + $scope.selectedDisplayAlignment = {"value":data.displayAlignment+''}; + $scope.selectedDisplayHeaderAlignment = {"value":data.displayHeaderAlignment+''}; + $scope.sortable = {"value":''+data.sortable}; + $scope.visible = {"value":''+data.visible}; + $scope.drilldownURL = data.drilldownURL; + $scope.drilldownParams = data.drilldownParams; + $scope.drilldownType = data.drilldownType; + $scope.selectedDrillDownReport = {"value":""}; + + + },function(error){ + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + + var init = function() { + + raptorReportFactory.getDrillDownReportList().then(function(data2){ + $scope.drilldownReports = data2; + },function(error){ + $log.error("raptorReportFactory: getDrillDownReportList failed."); + }); + +/* $scope.colTableRowData = colData;*/ + $scope.displayAlignmentOptions = [ + {value:"null", text:""}, + {value:"Left", text:"Left"}, + {value:"Center", text:"Center"}, + {value:"Right", text:"Right"} + ]; + $scope.ynOptions = [ + {value:"true", text:"Yes"}, + {value:"false", text:"No"} + ]; + $scope.drillDownOptions = [ + {value:"drillDownOpt1", text:"drillDownOpt1"}, + {value:"drillDownOpt2", text:"drillDownOpt2"}, + {value:"drillDownOpt3", text:"drillDownOpt3"} + ]; + } + + init(); + $scope.$watch('selectedDrillDownReport.value',function(){ + if ($scope.selectedDrillDownReport) { + $scope.$emit('openDrillDownpage',$scope.selectedDrillDownReport.value); + } + }); + + $scope.save = function() { + var drilldownURL = "";//raptorReportFactory.drillDownPopupOptions + //raptorReportFactory.drillDownPopupOptions.radioGroup + var colInfo = { + "tabId" : "ColEdit", + "tabName" : "Column Edit", + "colId" : $scope.colId, + "colName" : $scope.colName.value, + "displayAlignment" : ($scope.selectedDisplayAlignment.value=="null")?null:$scope.selectedDisplayAlignment.value, + "displayHeaderAlignment" : ($scope.selectedDisplayHeaderAlignment.value=="null")?null:$scope.selectedDisplayHeaderAlignment.value, + "sortable" : ($scope.sortable.value=="true"), + "visible" : ($scope.visible.value=="true"), + "drilldownURL" : raptorReportFactory.drillDownURL, + "drilldownParams" : raptorReportFactory.drillDownParams, + "drilldownType" : "" + } + raptorReportFactory.saveColumnEditInfo(colInfo).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + colData: function(){ + return rowData; + } + } + }); + + modalInstance.result.then(function () { + $scope.$emit('RefreshColumnList'); + }, function () { + }); + }; + + + $scope.throwReportNameMissingError = function () { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-report-name-validation.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', '$log', function ($scope, $modalInstance, $http, $log) { + $scope.close = function() { + $modalInstance.dismiss(); + }; + }] + }); + modalInstance.result.then(function () { + }, function () { + }); + }; + + + $scope.addNewFormField = function () { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory', function ($scope, $modalInstance, $http, $log, raptorReportFactory) { + raptorReportFactory.getFormFieldEditInfoById("add").then(function(data){ + $scope.formFieldEditData = data; + $scope.fieldId = $scope.formFieldEditData.fieldId; + $scope.fieldName ={"value": $scope.formFieldEditData.fieldName}; + $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''}; + $scope.defaultValue = {"value": $scope.formFieldEditData.defaultValue}; + $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL}; + $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL}; + $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''}; + $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''}; + $scope.sqlDefaultValueSelected= {value:false}; + $scope.sqlDefaultValueSelected ={"value":false}; + if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) { + $scope.sqlDefaultValueSelected.value =true; + } + },function(error){ + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + + + $scope.ynOptions = [ + {value:"true", text:"Yes"}, + {value:"false", text:"No"} + ]; + + $scope.verifyFieldValueOptions = [ + {value:"DATE", text:"Date"}, + {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"}, + {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"}, + {value:"HIDDEN", text:"Hidden"} + ] + + $scope.fieldTypeOptions = [ + {value:"TEXT", text:"Text Box"}, + {value:"LIST_BOX", text:"List Box"}, + {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"}, + {value:"HIDDEN", text:"Hidden"} + ]; + + $scope.save = function() { + var formFieldJSON = { + "tabId" : "FormEdit", + "tabName" : "Form Edit", + "fieldId" : $scope.fieldId, + "fieldName" : $scope.fieldName.value, + "fieldType" : $scope.selectedFieldType.value, + "visible" : ($scope.selectedVisible.value=="true"), + "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value), + "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""), + "fieldSQL" :$scope.fieldSqlContent.value, + "validationType" : "NONE", + "predefinedValueList" :null + } + raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }] + }); + modalInstance.result.then(function () { + $scope.$emit('RefreshFormField'); + }, function () { + }); + }; + + $scope.openFormFieldPopup = function (rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','fieldData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, fieldData) { + var init = function() { + raptorReportFactory.getFormFieldEditInfoById(fieldData.id).then(function(data){ + $scope.formFieldEditData = data; + $scope.fieldId = $scope.formFieldEditData.fieldId; + $scope.fieldName = {"value":$scope.formFieldEditData.fieldName}; + $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''}; + $scope.defaultValue = {"value":$scope.formFieldEditData.defaultValue}; + $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL}; + $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL}; + $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''}; + $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''}; + $scope.sqlDefaultValueSelected ={"value":false}; + if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) { + $scope.sqlDefaultValueSelected.value =true; + } + },function(error){ + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + + $scope.ynOptions = [ + {value:"true", text:"Yes"}, + {value:"false", text:"No"} + ]; + + $scope.verifyFieldValueOptions = [ + {value:"DATE", text:"Date"}, + {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"}, + {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"}, + {value:"HIDDEN", text:"Hidden"} + ] + + $scope.fieldTypeOptions = [ + {value:"TEXT", text:"Text Box"}, + {value:"LIST_BOX", text:"List Box"}, + {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"}, + {value:"HIDDEN", text:"Hidden"} + ]; + + } + + init(); + + $scope.save = function() { + var formFieldJSON = { + "tabId" : "FormEdit", + "tabName" : "Form Edit", + "fieldId" : $scope.fieldId, + "fieldName" : $scope.fieldName.value, + "fieldType" : $scope.selectedFieldType.value, + "visible" : ($scope.selectedVisible.value=="true"), + "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value), + "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""), + "fieldSQL" :$scope.fieldSqlContent.value, + "validationType" : "NONE", + "predefinedValueList" :null + } + raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){ + $modalInstance.close(); + },function(error){ + $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }], + resolve:{ + fieldData: function(){ + return rowData; + } + } + }); + + modalInstance.result.then(function () { + $scope.$emit('RefreshFormField'); + }, function () { + }); + }; + + $scope.openDrillDownReportPopup = function (reportId,parentReportId) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-drilldown-edit.html', + sizeClass: 'modal-large', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','reportId', function ($scope, $modalInstance, $http, $log, raptorReportFactory, reportId) { + + $scope.drillDownOptionList =[]; + $scope.selectedvalueradioGroup = {"name":""}; + $scope.selectedChildReportFormField = {"value":""}; + $scope.selectedChildReportColumn = {"value":""}; + $scope.fixedValue = {"value":""}; + $scope.suppressValues = {"value":""}; + + raptorReportFactory.getChildReportFormField(reportId).then(function(data){ + for (var i=0;i<data.length;i++) { + $scope.drillDownOptionList.push( + { + "name": data[i].name, + "id": data[i].id, + "selectedvalueradioGroup":{"name":""}, + "selectedChildReportFormField":{"value":""}, + "selectedChildReportColumn":{"value":""}, + "fixedValue":{"value":""}, + "suppressValues":{"value":""} + } + ) + } + },function(error){ + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + + raptorReportFactory.getChildReportFormField(parentReportId).then(function(data){ + $scope.childReportFF =data; + },function(error){ + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + + raptorReportFactory.getChildReportColumn(parentReportId).then(function(data){ + $scope.childReportCol =data; + },function(error){ + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + + raptorReportFactory.setDrillDownPopupOptions(null); + + $scope.complete = function() { + var drillDownPopupOptions= { + radioGroup : $scope.selectedvalueradioGroup.name, + reportFF: $scope.selectedChildReportFormField.value, + reportCol: $scope.selectedChildReportColumn.value, + fixedValue: $scope.fixedValue.value, + suppressValues: $scope.suppressValues.value + } + var drillDownParams = ""; + var ampStr =""; + for (var i=0;i<$scope.drillDownOptionList.length; i++) { + if (drillDownParams!="") { + ampStr = "&"; + } + if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="fixedValue"){ + drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "="+$scope.drillDownOptionList[i].fixedValue.value; + } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportFF"){ + drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=[!"+$scope.drillDownOptionList[i].selectedChildReportFormField.value + "]"; + } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportCol"){ + drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=["+$scope.drillDownOptionList[i].selectedChildReportColumn.value + "]"; + } + } + raptorReportFactory.setDrillDownPopupOptions(reportId,drillDownParams); + + $modalInstance.close(); + }; + }], + resolve:{ + reportId: function(){ + return reportId; + } + } + }); + + modalInstance.result.then(function () { +/* $scope.$emit('RefreshFormField');*/ + }, function () { + }); +}; + + $scope.$watch('activeTabsId', function (newVal, oldVal) { + if(newVal !== oldVal) { + $scope.showLoader = true; + var selectedTab; + for (selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) { + if ($scope.gTabs[selectedTab].id === newVal) { + $scope.stepNum = selectedTab; +/* stepFormFactory.getStepJSONData(getJsonSrcName($scope.stepNum))*/ + $scope.isColumnStep = false; + $scope.isFormFieldStep = false; + $scope.isSecurityStep = false; + $scope.renderStep(selectedTab+1); + if ($scope.stepNum == 1) { + $scope.showLoader = false; + } + else if ($scope.stepNum == 2) { + loadSqlInSession(); + } else if ($scope.stepNum == 3) { + $scope.isColumnStep = true; + raptorReportFactory.getColumnList().then(function(data){ + $scope.colTableRowData = data; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: get column list failed."); + $scope.showLoader = false;}); + + } else if ($scope.stepNum == 4) { + $scope.isFormFieldStep = true; + // put within then function: + raptorReportFactory.getFormFieldList().then(function(data){ + $scope.formFieldData = data; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: get formfields failed."); + $scope.showLoader = false;}); + } else if ($scope.stepNum == 5) { + $scope.isSecurityStep = true; + $scope.reportOwnerId={'id':''}; + $scope.isPublicOptionList = [ + {'value':'true','text':'Yes'}, + {'value':'false','text':'No'}, + ]; + $scope.loadSecurityPage(); + + } + else if ($scope.stepNum == 6) { + raptorReportFactory.getDefinitionInSession().then(function(data){ + $scope.reportId = data.reportId; + $scope.showLoader = false; + },function(error){ + $log.error("raptorReportFactory: getDefinitionInSession failed."); + $scope.showLoader = false;}); + } + + if ($scope.stepNum>1){ + $scope.unhideAllOtherTabs(); + } + break; + } + } + } + }); + + $scope.loadSecurityPage = function() { + $scope.showLoader = true; + raptorReportFactory.resetSecurityLoadingCounter(); + + //API call 1: + raptorReportFactory.getSecurityReportOwnerList().then(function(data){ + $scope.reportOwnerList = data; + raptorReportFactory.icrementSecurityLoadingCounter(); + if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; + },function(error){ + $log.error("raptorReportFactory: getSecurityReportOwnerList failed."); + }); + + //API call 2: get report role list + raptorReportFactory.getReportRoleList().then(function(data){ + $scope.reportRoleList = data; + raptorReportFactory.icrementSecurityLoadingCounter(); + if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; + },function(error){ + $log.error("raptorReportFactory: getReportRoleList failed."); + }); + + //API call 3: get security page basic info + raptorReportFactory.getReportSecurityInfo().then(function(data){ + $scope.reportSecurityInfo = data; + $scope.reportOwnerId ={id: $scope.reportSecurityInfo.ownerId}; + raptorReportFactory.icrementSecurityLoadingCounter(); + if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; + },function(error){ + $log.error("raptorReportFactory: getReportSecurityInfo failed."); + $scope.showLoader = false;}); + + //API call 4: retrieve security users + raptorReportFactory.getReportSecurityUsers().then(function(data){ + $scope.reportSecurityUsers = data; + for (var i=0; i<$scope.reportSecurityUsers.length;i++) { + $scope.reportSecurityUsers[i]["accessAllowed"] = !$scope.reportSecurityUsers[i]["readOnly"]; + } + raptorReportFactory.icrementSecurityLoadingCounter(); + if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; + },function(error){ + $log.error("raptorReportFactory: reportSecurityUsers failed."); + }); + + //API call 5: retrieve security roles + raptorReportFactory.getReportSecurityRoles().then(function(data){ + $scope.reportSecurityRoles = data; + for (var i=0; i<$scope.reportSecurityRoles.length;i++) { + $scope.reportSecurityRoles[i]["accessAllowed"] = !$scope.reportSecurityRoles[i]["readOnly"]; + } + + raptorReportFactory.icrementSecurityLoadingCounter(); + if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; + },function(error){ + $log.error("raptorReportFactory: reportSecurityRoles failed."); + }); + } + + + $scope.renderStep = function(stepNum){ + var containerElement = angular.element(document.getElementById("stepView")); + containerElement.empty(); + $scope.stepNum = stepNum; + var jsonSrcName = getJsonSrcName(stepNum); + stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); + } + + $scope.toggleUserEditAccessActive = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.rowData = rowData; + $scope.toggleEditAccessStatus = function(rowData) { + raptorReportFactory.toggleUserEditAccess(rowData); + $modalInstance.close(); + }; + + $scope.cancelEditAccessToggle = function(rowData) { + rowData.accessAllowed = ! rowData.accessAllowed; + $modalInstance.dismiss('cancel');} + }], + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + modalInstance.result.then(function () { + + }, function () { + }); + } + + $scope.toggleRoleEditAccessActive = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.rowData = rowData; + $scope.toggleEditAccessStatus = function(rowData) { + raptorReportFactory.toggleRoleEditAccess(rowData); + $modalInstance.close(); + }; + + $scope.cancelEditAccessToggle = function(rowData) { + rowData.accessAllowed = ! rowData.accessAllowed; + $modalInstance.dismiss('cancel');} + }], + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + modalInstance.result.then(function () { + + }, function () { + }); + } + + + + + + // initialize the page at step 1; + $scope.renderStep(1); + + // create a message to display in our view + $scope.allProjects = []; + if(!$routeParams.step && $routeParams.step == "") $routeParams.step = 1; + if($routeParams.proj && $routeParams.proj > 0) + $scope.projid = $routeParams.proj; + if($routeParams.step) + $scope.stepNum = $routeParams.step; + else + $scope.stepNum = 1; + + $scope.jsonSrcName = getJsonSrcName($scope.stepNum); + + $scope.selectAction = function () { + var containerElement = angular.element(document.getElementById("stepView")); + containerElement.empty(); + $scope.project_name = this.prj.projectName; + $scope.stepNum = 1; + var stepNum = $scope.stepNum; + var jsonSrcName = getJsonSrcName(stepNum); + stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); + renderProject(this.prj.id, 1); + }; + + + $scope.createAction = function () { + var containerElement = angular.element(document.getElementById("stepView")); + containerElement.empty(); + $scope.stepNum = 1; + var stepNum = $scope.stepNum; + $scope.jsonSrcName = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step"+$scope.stepNum +".json"; + var jsonSrcName = $scope.jsonSrcName; + stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); + }; + + // select current project + renderProject = function (proj_id, stepNum) { + var userSelectedPrjId = proj_id; + $http({ + method: 'GET', + url: 'get_selected_project_data', + params:{'selectedPrjId':userSelectedPrjId, 'step': stepNum} + }).then(function successCallback(response) { + var selectedproject = response.data; + $scope.projid = userSelectedPrjId; + //$scope.allProjects = projectLists; + //$location.path('/'+userSelectedPrjId+'/'+stepNum); + var div = d3.select("#stepView"); + div.select("[name='proj_id']").text(userSelectedPrjId); + div.select("[name='proj_id']").property("value", userSelectedPrjId); + d3.select("[name='project_id']").property("value", userSelectedPrjId); + var h3Text = div.select("h3").text(); + div.select("h3").text($scope.project_name+ " - " + h3Text); + for (var key in selectedproject) { + if (selectedproject.hasOwnProperty(key)) { + var val = selectedproject[key]; + var formElement = d3.selectAll("[name='" + key + "']"); + if(formElement[0].length > 0) + console.log(formElement.attr("type")); + if(formElement[0].length > 0 && formElement.attr("type") === "radio") { + var formRadio = d3.selectAll("[id='" + key +"_"+val + "']"); + formRadio.property('checked', true); + } + if(formElement[0].length > 0 && formElement.property("type") === "textarea") { + div.select("textarea[name='" + key +"']").property('value', val); + } + if(formElement[0].length > 0 && formElement.attr("type") === "text") { + var formText = d3.selectAll("[name='" + key + "']"); + formText.property("value", val); + } + if(formElement[0].length > 0 && formElement.html().startsWith("<option")) { + var formSelect = d3.selectAll("[name='" + key + "']"); + + var checkOption = function (e) { + if(e.label === val){ + return formSelect.property("selectedIndex", e.index ); + } + }; + + formSelect.selectAll("option").forEach(function(d) {d.forEach(function(optionD) {checkOption(optionD); }) }); + } + + if(formElement[0].length == 0) { + if(key != 'step') { + if( Object.prototype.toString.call( val ) === '[object Array]' ) { + val.forEach(function(d){ + for (var keyCheck in d) { + if (d.hasOwnProperty(keyCheck)) { + var valCheck = d[keyCheck]; + var formCheck = d3.selectAll("[name='" + key + "_"+keyCheck + "']"); + if(valCheck === true) + formCheck.property('checked', true); + } + } + }); + } + } + var formElementOther = d3.selectAll("[name='" + key + "_"+ val + "']"); + if(formElementOther[0].length > 0 && formElementOther.attr("type") === "checkbox") { + var formCheckbox = d3.selectAll("[name='" + key +"_"+val + "']"); + formRadio.property('checked', true); + } + } + } + } + + + + }); + } + + //submit function + $scope.submit = function(){ + let defer = $q.defer(); + + var div = d3.select("#stepView"); + var jsonSrcName = $scope.jsonSrcName; + var stepNum = $scope.stepNum; + var values = ""; + $http({ + method: 'GET', + url: jsonSrcName + }).then(function successCallback(response) { + var json = response.data; + var step = json.step; + if(step > 0) { + var sections = json.content.sections; + sections.forEach(function(d, i) { + var elements = d.elements; + if(elements) { + //elements.forEach(function(element, elementIndex) { + values += "{"; + values += "\"step\""+ ":\"" + step + "\","; + values += "\"proj_id\""+ ":\"" + d3.select('input[name="project_id"]').property("value") + "\","; + + for (elementIndex = 0; elementIndex < elements.length; elementIndex++) { + var element = elements[elementIndex]; + + if(elementIndex > 0) values += ","; + values += "\""+element.name +"\""+ ":" ; + if(element.input === "hidden") { + values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\""; + } + if(element.input === "radio") { + values += "\""+ div.select('input[name="'+element.name+'"]:checked').property("value") +"\""; + } + if(element.input === "checkbox") { + var checkOptions = element.options; + values += "[{"; + checkOptions.forEach(function(d, i) { + // if(document.getElementById("'"+element.name+"_"+d.id+"'") != null) + values += "\""+d.id+"\""+ ":" + div.select('input[name="'+element.name+"_"+d.id+'"]').property("checked") ; + if(i<checkOptions.length-1) { + values += ","; + } + }) + values += "}]"; + } + if(element.input === "text") { + values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\""; + } + if(element.input === "textarea") { + values += "\""+div.select('textarea[name="'+element.name+'"]').node().value +"\""; + } + if(element.input === "select") { + values += "\""+ div.select('select[name="'+element.name+'"]').property("value") + "\""; + } + + }; + values += "}"; + } + }); + } + var valueJSON = JSON.parse(values); + var valueStr = JSON.stringify(valueJSON, null, 4); + $http({method:'POST', url:'save_steps', data: jsonSrcName, params:{'result' : valueStr, 'proj_id' : values.proj_id}}).success(function(data, status) { + if(data.project_name) + $scope.project_name = data.project_name; + div.select("[name='proj_id']").property("value", data.proj_id); + d3.select("[name='project_id']").property("value", data.proj_id); + //$scope.projid = data.proj_id; + valueStr=JSON.stringify(data, null, 4); + defer.resolve(); + //stepNum = Number(stepNum || 0)+1; + //document.getElementById('itestframe').src = data; + + }) + + defer.resolve(); + + }); + // $location.path('/step'+($scope.stepNum+1)); + return defer.promise; + + }; + + //Save function + $scope.save = function() { + if ($scope.stepNum ==1) { + updateDefinitionData(); + } else if($scope.stepNum ==5) { + $scope.saveReportSecurityInfo($scope.reportOwnerId.id,$scope.reportSecurityInfo.isPublic); + } + }; + + //Next function + $scope.next = function(){ + if ($scope.stepNum ==1) { + if ($scope.reportName==="") { + $scope.throwReportNameMissingError(); + return; + } + updateDefinitionData(); + } + $scope.stepNum = $scope.stepNum +1; + $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id; + }; + + //Previous function + $scope.previous = function(){ + $scope.stepNum = $scope.stepNum -1; + $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id; + + }; + + $scope.$on('RefreshInsession', function(event) { + $scope.isEdit = true; + $scope.reportId = -1; + $scope.getDefinitionById(-1); + }); + + $scope.$on('openDrillDownpage', function(event, reportId) { + if (reportId!="") { + $scope.openDrillDownReportPopup(reportId,$scope.reportId); + } + }); + + + $scope.$on('RefreshFormField', function(event) { + raptorReportFactory.getFormFieldList().then(function(data){ + $scope.formFieldData = data; + },function(error){ + $log.error("raptorReportFactory: get formfields failed."); + }); + }); + + $scope.$on('RefreshColumnList', function(event) { + raptorReportFactory.getColumnList().then(function(data){ + $scope.colTableRowData = data; + },function(error){ + $log.error("raptorReportFactory: get column list failed."); + }); + }); + + $scope.getAllProjects = function(){ + $http({ + method: 'GET', + url: 'get_projects' + }).then(function successCallback(response) { + var projectLists = response.data; + $scope.allProjects = projectLists; + }); + } + + // getAllProjects(); + +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/drools-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/drools-controller.js new file mode 100644 index 00000000..1d4659e3 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/drools-controller.js @@ -0,0 +1,53 @@ +appDS2.controller('droolsController', function($scope, $modal, $routeParams, DroolsService, modalService) { + $scope.tableDate=[]; + $scope.resultsString = ""; + $scope.postDroolsBean={ + droolsFile:'', + className:'', + selectedRules:'' + }; + $scope.filenameFromUrl = $routeParams.filename; + if($scope.filenameFromUrl!='' && $scope.filenameFromUrl!='0') + $scope.postDroolsBean.droolsFile = $scope.filenameFromUrl + $scope.execute = function(postDroolsBean) { + if($scope.postDroolsBean.droolsFile=='' ||$scope.postDroolsBean.className=='' || $scope.postDroolsBean.selectedRules=='' ){ + modalService.errorPopUp ("Required fields cannot be empty"); + return; + } + var uuu = "post_drools/execute"; + var postData={postDroolsBean:postDroolsBean}; + DroolsService.executeDrools(postData).then(function(data){ + $scope.resultsString=data.resultsString; + modalService.successPopUp($scope.resultsString); + },function(error){ + modalService.errorPopUp (error); + }); + }; +}); + +appDS2.controller('droolsListController', function($scope, $modal, DroolsService, modalService) { + $scope.tableDate=[]; + $scope.resultsString = ""; + $scope.postDroolsBean=""; + + $scope.getDroolsList = function(){ + DroolsService.getDroolsList().then(function(data){ + var j = data; + $scope.tableData = JSON.parse(j.data); + $scope.buildTable(); + },function(error){ + modalService.errorPopUp (error); + }); + } + + $scope.buildTable = function(){ + 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; + } + } + +}); + diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/nbook-framecontroller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/nbook-framecontroller.js new file mode 100644 index 00000000..ab88aed9 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/nbook-framecontroller.js @@ -0,0 +1,15 @@ +appDS2.config(function($routeProvider) { + $routeProvider + + //.when('/notebook-frame/:id/:key/:value',{ + //.when('/notebook-frame/:nid/:qprms',{ + /*.when('/notebook-frame',{ + templateUrl: 'app/fusion/notebook-integration/scripts/view-models/notebook-frame.html', + controller: 'notebookFrameController' + })*/ + + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-samplePages/notebook-viz.html', + controller: 'notebookFrameController' + }); +})
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebook-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebook-controller.js new file mode 100644 index 00000000..efd22f0f --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebook-controller.js @@ -0,0 +1,37 @@ +appDS2.controller('nbookController', ['$scope', '$location','$window','$http', function ($scope,$location,$window,$http) { + $scope.keyValueList = [{}]; + $scope.submitParameters = function() { + $scope.iframevisibility = false; + $scope.postData = {}; + $scope.additionalqueryParams = {}; + //Use this if there is only one 1 query param key value pair + $scope.additionalqueryParams.paramKey = $scope.qparamKey; + $scope.additionalqueryParams.paramVal = $scope.qparamVal; + var qryStr = ''; + for(var i = 0; i < $scope.keyValueList.length; i++) { + var obj = $scope.keyValueList[i]; + if (obj.qK != undefined && obj.qV != undefined) { + if (qryStr!='') + qryStr = qryStr+'&'+obj.qK+'='+obj.qV; + else + qryStr = obj.qK+'='+obj.qV; + } + } + var queryurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+qryStr; + window.open (queryurl,'_self',false); + } + $scope.addKeyValuePairs = function (kv) { + if ($scope.keyValueList.length < 9) { + $scope.keyValueList.push({ + }); + } else { + document.getElementById("addbtn")["disabled"] = true; + } + } + $scope.removeKeyValuePairs = function (index) { + $scope.keyValueList.splice(index, 1); + if ($scope.keyValueList.length == 8) { + document.getElementById("addbtn")["disabled"] = false; + } + } +}]);
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebookFrameController.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebookFrameController.js new file mode 100644 index 00000000..95489918 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/notebookFrameController.js @@ -0,0 +1,24 @@ +appDS2.controller('notebookFrameController', function ($scope,$location,$window,$http,$routeParams) { + var nid = $window.location.search.substr($window.location.search.indexOf("=")+1); + $scope.additionalqueryParams={}; + if ($window.location.search.substr($window.location.search.indexOf("=")+1)) { + $scope.queryParams = $window.location.search; + if($window.location.search.substring(0, $window.location.search.length-1).indexOf("&")!=-1) { + $scope.notebookparam = $window.location.search.substring($window.location.search.indexOf("?")+1,$window.location.search.indexOf("&")); + $scope.additionalqueryParams = JSON.parse('{"' + decodeURI($scope.queryParams.substr($scope.queryParams.indexOf("&")+1).replace(/&/g, "\",\"").replace(/=/g,"\":\"")) + '"}'); + } + else { + $scope.notebookparam1 = $window.location.search.substr($window.location.search.indexOf("?")+1); + $scope.notebookparam = $scope.notebookparam1.substring(0, $scope.notebookparam1.length - 1); + } + $scope.notebookvalue = $scope.notebookparam.substr($scope.notebookparam.indexOf("=")+1); + } + else { + $scope.notebookvalue = '833c0a69ec1433fbb2f8752af733cf0e'; + } + $http({method:'POST', url:'rNotebookFE/authCr', data: $scope.notebookvalue, params:{'qparams' : $scope.additionalqueryParams}, transformResponse: [function (data) { + // Do whatever you want! + document.getElementById('itestframe').src = data; + return data; + }]}) +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowApp.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowApp.js new file mode 100644 index 00000000..a3496785 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowApp.js @@ -0,0 +1,5 @@ +angular.module('att.abs.helper', []); +angular.module('quantum', []); +//angular.module('ui.bootstrap', []); +appDS2=angular.module("workflowApp", ["ngRoute", 'ngMessages', 'ngCookies', 'b2b.att.tpls', 'ddh.att.tpls','ddh.att.dropdowns', 'ddh.att.switches', 'b2b.att.footer', 'b2b.att.header','gridster','ui.bootstrap']); + diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowController.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowController.js new file mode 100644 index 00000000..f18f00e9 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowController.js @@ -0,0 +1,513 @@ + + +appDS2.controller('workflowsControllerDS2', function($scope, $http, $log, $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 = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-new.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', function ($scope, $modalInstance, $http) { + $scope.workflow = workflowToEdit; + $scope.ok = function() { + if( + $scope.workflow.name== undefined|| $scope.workflow.name == null|| $scope.workflow.name == "" + ||$scope.workflow.workflowKey == undefined ||$scope.workflow.workflowKey==null||$scope.workflow.workflowKey=="" + ||$scope.workflow.runLink==undefined||$scope.workflow.runLink==null||$scope.workflow.runLink=="" + + ) + { + alert("please provide valid entries !"); + } + else{ + + 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)); + $modalInstance.close($scope.workflow); + }); + } + }; + + $scope.cancel = function() { + $modalInstance.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 = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-new.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', function ($scope, $modalInstance, $http) { + $scope.workflow = {}; + $scope.workflow.active = 'true'; + $scope.ok = function() { + if($scope.workflow.name== undefined|| $scope.workflow.name == null|| $scope.workflow.name == "" + ||$scope.workflow.workflowKey == undefined ||$scope.workflow.workflowKey==null||$scope.workflow.workflowKey=="" + ||$scope.workflow.runLink==undefined||$scope.workflow.runLink==null||$scope.workflow.runLink=="" + + ) + { + alert("please provide valid entries !"); + } + else{ + 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)); + $modalInstance.close($scope.workflow); + }); + } + }; +/* console.log(size);*/ + $scope.cancel = function() { + $modalInstance.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 = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-remove.html', + sizeClass: 'modal-small', + controller: ['$scope', '$modalInstance', '$http', function ($scope, $modalInstance, $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 !!!'); + $modalInstance.close(); + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('workflowRemoved'); + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + + }; + + + + $scope.scheduleWorkflow = function(workflowToSchedule){ + var modalInstance = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-schedule.html', + + controller: ['$scope', '$modalInstance', '$http','dateFilter', function ($scope, $modalInstance, $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); + $modalInstance.close(); + + }; + + $scope.saveCronJob = function(cronJobData){ + + console.log('saving cron job data: ' + cronJobData); + var uuu = "workflows/saveCronJob.htm"; + var postData={cronJobDataObj: cronJobData}; + $http.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") + $modalInstance.dismiss(); + }; + }] + }); + + modalInstance.result.then(function () { + $scope.$emit('workflowRemoved'); + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + + }; + + + + + + + + + $scope.previewWorkflow = function(workflowToPreview,modalSize){ + var modalInstance = $modal.open({ + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-preview.html', + sizeClass: 'modal-medium', + controller: ['$scope', '$modalInstance', '$http', function ($scope, $modalInstance, $http) { + $scope.workflowToPreview = workflowToPreview; + console.log('previewWorkFlow invoked'); + console.log($scope.workflowToPreview); + + $scope.cancel = function() { + $modalInstance.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/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowRouting.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowRouting.js new file mode 100644 index 00000000..f6ffe8f1 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-workflows/workflowRouting.js @@ -0,0 +1,8 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .when('/all', { + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-workflows-page/workflow-listing.html', + controller: 'workflowsControllerDS2' + }) +}); + diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/fn-menu-add-popup-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/fn-menu-add-popup-controller.js new file mode 100644 index 00000000..2b3663c0 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/fn-menu-add-popup-controller.js @@ -0,0 +1,339 @@ +var deletefn_menu_popupController = function ($scope,$modal, items,$modalInstance, $http){ + $scope.fnMenuItem=items; + console.log("fnMenuItems",$scope.fnMenuItem); + var ModalInstanceCtrl = function ($scope, $modalInstance, items,AdminMenuService,$http,$modal) { + $scope.fnMenuItem=items; + $scope.save = function (data) { + $modalInstance.close(data); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.deleteFun = function(data){ + $modalInstance.close(data); + } + }; + $scope.successPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + $scope.successModelPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modalpopup.html', + controller: ModalInstanceCtrl, + //sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + $scope.errorPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + $scope.deleteMenuItem= function(fnMenuItem){ + var uuu = "admin_fn_menu/removeMenuItem.htm"; + var postData={fnMenuItem: fnMenuItem}; + $http({ + method :'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData) + + }).then(function(data){ + $scope.successPopUp(); + // $scope.$apply(function(){$scope.fnMenuItem=data.data.fnMenuItem;}); + location.reload(); + },function(data){ + $scope.errorPopUp(); + // console.log(data); + // modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + }); + }/// examine the LeftMenuService +} + 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" + $http({ + method : 'GET', + url : uuu, + dataType: 'json', // data type expected from server + contentType: 'application/json', + //data: JSON.stringify(postData), // data type sent to server + + }).then(function(data){ + //$scope.$apply(function(){ + //$scope.availableRoleFunctions=[];$scope.$apply(); + $scope.parentListSelectData=data.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}); + },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" + $http({ + method : 'GET', + url : uuu, + dataType: 'json', // data type expected from server + contentType: 'application/json', + //data: JSON.stringify(postData), // data type sent to server + + }).then(function(data){ + //$scope.$apply(function(){ + //$scope.availableRoleFunctions=[];$scope.$apply(); + $scope.functionCDselectData=data.data; + //}); + //alert("Update Successful.") ; + //$scope.editRoleFunction = null; + ///$modalInstance.close({functionCDselectData:$scope.functionCDselectData}); + },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)) || + $scope.addFnMenuItem.parentIdAsString == "" || + 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"; + availableFnMenuItem.parentId=parseFloat($scope.addFnMenuItem.parentIdAsString); + availableFnMenuItem.active=('true'==$scope.addFnMenuItem.activeAsString); + availableFnMenuItem.separator=('true'==$scope.addFnMenuItem.separatorAsString); + + + var postData={availableFnMenuItem: availableFnMenuItem}; + + $http({ + method :'POST', + url : uuu, + //dataType: 'json', // data type expected from server + contentType: 'application/json', + data: JSON.stringify(postData), // data type sent to server + }).then(function(data){ + //$scope.$apply(function(){ + $scope.availableFnMenuItems=data.availableFnMenuItems; + //}); + + $modalInstance.close({availableFnMenuItems:$scope.availableRoleFunctions}),function(data){ + alert("Error while saving."); + } + },function(data){ + console.log("Error",data); + }); + $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(); + }; +} + }
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-route.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-route.js new file mode 100644 index 00000000..c82185c0 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-route.js @@ -0,0 +1,19 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .when('/profile/:profileId', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/self_profile.html', + controller: 'selfProfileController' + }) + .when('/self_profile', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/self_profile.html', + controller: 'selfProfileController' + }) + .when('/post_search', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/post.html', + controller: 'postController' + }) + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/profile_searchDS2.html', + controller : "profileSearchCtrlDS2" + }); +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js new file mode 100644 index 00000000..5236001f --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js @@ -0,0 +1,93 @@ +appDS2.controller('profileSearchCtrlDS2', function($scope, $log, $modal, ProfileServiceDS2){ + $scope.showInput = true; + $scope.totalPages1 = 0; + $scope.viewPerPage1 = 8; + $scope.currentPage1 = 1; + $scope.showLoader = false; + + var debug = false; + + $scope.$watch('viewPerPage1', function(val) { + $scope.showLoader = true; + ProfileServiceDS2.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); + $scope.showLoader = false; + },function(error){ + console.log("watch of viewPerPage1 failed"); + reloadPageOnce(); + }); + + }); + + $scope.customHandler = function(num) { + $scope.currentPage1 = num; + $scope.showLoader = true; + ProfileServiceDS2.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); + $scope.showLoader = false; + },function(error){ + console.log("customHandler failed"); + reloadPageOnce(); + }); + + }; + + $scope.editRow = function(profileId){ + window.location = 'userProfile#/profile/' + profileId; + }; + + var ModalInstanceCtrl = function ($scope, $log, $modalInstance, items) { + $scope.msg = items; + + $scope.toggleUserStatus = function(id) { + if (debug) + $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl:toggleUserStatus: data is ' + id); + ProfileServiceDS2.toggleProfileStatus(id); + $modalInstance.close(); + }; + + $scope.cancelUserStatusToggle = function(rowData) { + if (debug) + $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl: cancelUserStatusToggle: data is ' + JSON.stringify(rowData)); + // Undo the toggle of the checkbox + rowData.active = ! rowData.active; + $modalInstance.dismiss('cancel'); + } + + } + + // user activation/deactivation + $scope.toggleProfileActive = function(rowData) { + if (debug) + $log.debug('profileSearchCtrlDS2:toggleProfileActive: id is ' + rowData.id + + ', active is ' + rowData.active); + var toggleType = null; + // The checkbox is already in the desired state, + // so the sense of the "if" is reversed here. + if (rowData.active) + toggleType = "activate"; + else + toggleType = "deactivate"; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + text : toggleType, + rowData : rowData + }; + return message; + } + } + }); + }; + +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/sampleProfileController.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/sampleProfileController.js new file mode 100644 index 00000000..0f02e46f --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/sampleProfileController.js @@ -0,0 +1,22 @@ +appDS2.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('/ase', { + templateUrl: 'app/fusion/ase/index.html' + }) + .when('/self_profile', { + templateUrl: 'app/fusion/scripts/view-models/profile-page/self_profile.html', + controller: 'selfProfileController' + }) + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/DS2-profile-page/profile_searchDS2.html', + controller : "profileSearchCtrlDS2" + }); +}); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/usage-list-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/usage-list-controller.js new file mode 100644 index 00000000..ab229714 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/usage-list-controller.js @@ -0,0 +1,39 @@ +appDS2.controller('usageListControllerDS2', function ($scope,$interval,$http,$modal, 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.successPopUp = function () { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + return ''; + } + } + }); + }; + + $scope.removeSession = function(sessionId) { + + $http.get("usage_list/removeSession?deleteSessionId="+sessionId).success(function(response){ + $scope.users=response; + $scope.successPopUp(); + }); +/* 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;}); + })*/ + + } +});
\ No newline at end of file diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-controller.js new file mode 100644 index 00000000..b2b3a43b --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-controller.js @@ -0,0 +1,408 @@ +appDS2 + .directive( + 'integer', + function() { + return { + require : 'ngModel', + link : function(scope, ele, attr, ctrl) { + ctrl.$parsers.unshift(function(viewValue) { + if (viewValue === '' || viewValue === null + || typeof viewValue === 'undefined') { + return null; + } + return parseInt(viewValue, 10); + }); + } + }; + }) + + .controller( + 'welcomeController', + function($scope, $interval, $http, $modal, $log, ManifestService) { + + $scope.testMsg = "Welcome Page1"; + $scope.gridsterOpts = { + columns : 6, // the width of the grid, in columns + pushing : true, // whether to push other items out of + // the way on move or resize + floating : true, // whether to automatically float + // items up so they stack (you can + // temporarily disable if you are + // adding unsorted items with + // ng-repeat) + width : 'auto', // can be an integer or 'auto'. 'auto' + // scales gridster to be the full width + // of its containing element + colWidth : 'auto', // can be an integer or 'auto'. + // 'auto' uses the pixel width of + // the element divided by 'columns' + rowHeight : 60, // can be an integer or 'match'. Match + // uses the colWidth, giving you square + // widgets. + margins : [ 10, 10 ], // the pixel distance between + // each widget + outerMargin : true, // whether margins apply to outer + // edges of the grid + swapping : true, + draggable : { + enabled : true, // whether dragging items is + // supported + stop : function(event, uiWidget, $element) { + $scope.setCookie(); + } // optional callback fired when item is finished + // dragging + } + + }; + + /* + * $scope.gridsterOpts = { columns: 6, width: 'auto', + * colWidth: '230', rowHeight: '120', margins: [10, 10], + * outerMargin: true, pushing: true, floating: true, + * swapping: true }; + */ + + $scope.toggleMinMax = function(index, tileName) { + if (tileName == '') { + $scope.standardItems[index].max = !$scope.standardItems[index].max; + if ($scope.standardItems[index].max) + $scope.standardItems[index].sizeY = $scope.standardItems[index].maxHeight; + else + $scope.standardItems[index].sizeY = 0; + } else { + $scope.tileTemp = $scope.$eval(tileName); + var tileMax = $parse(tileName + '.max'); + tileMax.assign($scope, !$scope.$eval(tileName).max); + var tileSizeY = $parse(tileName + '.sizeY'); + if ($scope.tileTemp.max) + tileSizeY.assign($scope, + $scope.tileTemp.maxHeight); + else + tileSizeY.assign($scope, 0); + } + }; + + // These map directly to gridsterItem options + // IMPORTANT: Items should be placed in the grid in the + // order in which + // they should appear. + // In most cases the sorting should be by row ASC, col ASC + $scope.standardItems = [ + { + sizeX : 2, + sizeY : 8, + maxHeight : 8, + row : 0, + col : 0, + headerText : 'Dashboard', + max : false + + }, + { + sizeX : 2, + sizeY : 5, + maxHeight : 5, + row : 0, + col : 2, + headerText : 'Donut Chart', + max : false + + },/* + * { sizeX : 1, sizeY : 5, maxHeight : 5, row : + * 0, col : 2, headerText : 'Area Chart', max : + * false }, + */ + { + sizeX : 2, + sizeY : 5, + maxHeight : 5, + row : 8, + col : 0, + headerText : 'Pie Chart', + max : false + }, + /* + * { sizeX : 1, sizeY : 5, maxHeight : 5, row : 8, + * col : 1, headerText : 'Line Chart', max : false }, + */ + { + sizeX : 2, + sizeY : 5, + maxHeight : 5, + row : 8, + col : 4, + headerText : 'Gauges', + max : false + }, + { + sizeX : 2, + sizeY : 8, + maxHeight : 8, + row : 16, + col : 0, + headerText : 'Traffic distribution by day of week', + max : false + }, + { + sizeX : 2, + sizeY : 8, + maxHeight : 8, + row : 16, + col : 2, + headerText : 'Busy hour traffic analysis by day of week', + max : false + }, { + sizeX : 2, + sizeY : 6, + maxHeight : 7, + row : 24, + col : 4, + headerText : 'Additional Samples', + max : false + }, { + sizeX : 2, + sizeY : 8, + maxHeight : 8, + row : 24, + col : 2, + headerText : 'Sticky Notes', + max : false + }, { + sizeX : 6, + sizeY : 10, + maxHeight : 10, + row : 32, + col : 0, + headerText : 'Service Configuration', + max : false + } ]; + + /* + * $.each($scope.standardItems, function(i, a) { + * $scope.toggleMinMax(i, ''); }); + */ + var counter = 0; + angular.forEach($scope.standardItems, function(i, a) { + $scope.toggleMinMax(counter, ''); + counter = counter + 1; + }); + + $scope.activeTabId = 'Monday'; + // for generic tabs + + $scope.selectedTrafficDay = [ { + title : 'Mon', + url : '#Monday' + }, { + title : 'Tue', + url : '#Tuesday' + }, { + title : 'Wed', + url : '#Wednesday' + }, { + title : 'Thu', + url : '#Thursday' + }, { + title : 'Fri', + url : '#Friday' + }, { + title : 'Sat', + url : '#Saturday' + }, { + title : 'Sun', + url : '#Sunday' + } ]; + + $scope.currentSelectedDayTab = '#Monday'; + + $scope.onClickTab1 = function(Daytab) { + $scope.currentSelectedDayTab = Daytab.url; + } + + $scope.isActiveTab1 = function(tabUrl) { + return tabUrl == $scope.currentSelectedDayTab; + } + + $scope.gTabs = [ { + title : 'Monday', + id : 'Monday', + url : '#Monday', + selected : true + }, { + title : 'Tuesday', + id : 'Tuesday', + url : '#Tuesday' + }, { + title : 'Wednesday', + id : 'Wednesday', + url : '#Wednesday' + }, { + title : 'Thursday', + id : 'Thursday', + url : '#Thursday' + }, { + title : 'Friday', + id : 'Friday', + url : '#Friday' + }, { + title : 'Saturday', + id : 'Saturday', + url : '#Saturday' + }, { + title : 'Sunday', + id : 'Sunday', + url : '#Sunday' + } ]; + + $scope.BusyHourTraffic = [ { + title : 'BH SNRC DLSTX - Incoming', + url : '#Incoming' + }, { + title : 'BH SNRC DLSTX - Outgoing', + url : '#Outgoing' + }, { + title : 'BH National - Default', + url : '#Default' + }, { + title : 'BH National - Priority', + url : '#Priority' + }, { + title : 'BH National', + url : '#BHNational' + } + + ]; + + $scope.currentSelectedBusyHourTraffic = '#Incoming'; + + $scope.onClickTab2 = function(TrafficTab) { + $scope.currentSelectedBusyHourTraffic = TrafficTab.url; + } + + $scope.isActiveTab2 = function(tabUrl) { + return tabUrl == $scope.currentSelectedBusyHourTraffic; + } + + $scope.activeTabId2 = 'Incoming'; + // for generic tabs + $scope.gTabs2 = [ { + title : 'BH SNRC DLSTX - Incoming', + id : 'Incoming', + url : '#Incoming', + selected : true + }, { + title : 'BH SNRC DLSTX - Outgoing', + id : 'Outgoing', + url : '#Outgoing' + }, { + title : 'BH National - Default', + id : 'Default', + url : '#Default' + }, { + title : 'BH National - Priority', + id : 'Priority', + url : '#Priority' + }, { + title : 'BH National', + id : 'BHNational', + url : '#BHNational' + } ]; + + $scope.activeTabId3 = 'Incoming'; + // for generic tabs + $scope.gTabs3 = [ { + title : 'BH SNRC DLSTX - Incoming', + id : 'Incoming', + url : '#Incoming', + selected : true + }, { + title : 'BH SNRC DLSTX - Outgoing', + id : 'Outgoing', + url : '#Outgoing' + }, { + title : 'BH National - Default', + id : 'Default', + url : '#Default' + }, { + title : 'BH National - Priority', + id : 'Priority', + url : '#Priority' + }, { + title : 'BH National', + id : 'BHNational', + url : '#BHNational' + } ]; + + /* + * $scope.$watch('activeTabId', function(newVal) { + * alert(newval); $('#'+newval).show(); }, true); + */ + + $scope.toggleEastToWest = function() { + $("#toggle").toggle('slide'); + if ($("#leftIcon").is(":visible")) { + $("#rightIcon").show(); + $("#leftIcon").hide(); + } else if ($("#rightIcon").is(":visible")) { + $("#rightIcon").hide(); + $("#leftIcon").show(); + } + }; + + $scope.group1 = { + open : true + }; + $scope.group2 = { + open : true + }; + $scope.group3 = { + open : true + }; + $scope.group4 = { + open : true + }; + $scope.group5 = { + open : true + }; + $scope.group6 = { + open : true + }; + $scope.group7 = { + open : true + }; + $scope.group71 = { + open : true + }; + $scope.group8 = { + open : true + }; + $scope.group9 = { + open : true + }; + $scope.group10 = { + open : true + }; + $scope.group11 = { + open : true + }; + $scope.group12 = { + open : false + }; + + // Fetch manifest info + $scope.manifest = {}; + ManifestService.getManifest() + .then(function(jsonObj) { + // $log.debug("welcome-controller: getManifest returned " + JSON.stringify(jsonObj)); + if (jsonObj.error) { + $log.error('welcome-controller: failed to get manifest: ' + JSON.stringify(jsonObj)); + } + else { + $scope.manifest=jsonObj; + } + },function(error){ + $log.error("welcome-controller: getManifest failed: " + error); + }); + + + }); diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-route.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-route.js new file mode 100644 index 00000000..8f4b1fdb --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/welcome-route.js @@ -0,0 +1,7 @@ +appDS2.config(function($routeProvider) { + $routeProvider + .otherwise({ + templateUrl: 'app/fusion/scripts/DS2-view-models/welcome-content.html', + controller : "welcomeController" + }); +}); |