diff --git a/client/cat3/main.html b/client/cat3/main.html index 64a33c60e..2f351c95c 100644 --- a/client/cat3/main.html +++ b/client/cat3/main.html @@ -119,7 +119,6 @@ - diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js index 7c5a1c816..781d016c3 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js @@ -8,19 +8,21 @@ (function (angular) { "use strict"; angular.module('dashboard.bots') - .controller('audittrailCtrl',['$scope', '$rootScope', '$state', 'genericServices', 'confirmbox', 'workzoneServices', 'toastr', 'workzoneUIUtils', '$modal', - function ($scope, $rootScope, $state, genSevs, confirmbox, workzoneServices, toastr, workzoneUIUtils, $modal) { + .controller('audittrailCtrl',['$scope', '$rootScope', '$state', 'genericServices', 'confirmbox', 'workzoneServices', 'toastr', 'workzoneUIUtils', '$modal', 'uiGridOptionsService', '$timeout', + function ($scope, $rootScope, $state, genSevs, confirmbox, workzoneServices, toastr, workzoneUIUtils, $modal, uiGridOptionsService, $timeout) { var treeNames = ['BOTs','Audit Trail']; $rootScope.$emit('treeNameUpdate', treeNames); var audit=this; - audit.gridOptions={ - gridOption:{ - paginationPageSizes: [10, 25, 50, 75], - paginationPageSize: 10, - enableColumnMenus:false, - multiSelect :false, - }, - columnDefs: [ + var botAuditTrailUIGridDefaults = uiGridOptionsService.options(); + $scope.paginationParams = botAuditTrailUIGridDefaults.pagination; + $scope.paginationParams=[]; + $scope.paginationParams.page = 1; + $scope.paginationParams.pageSize = 10; + $scope.paginationParams.sortBy = 'startedOn'; + $scope.paginationParams.sortOrder = 'desc'; + $scope.initGrids = function(){ + $scope.botAuditTrailGridOptions={}; + $scope.botAuditTrailGridOptions.columnDefs = [ { name: 'Start Time',field:'startedOn', cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}', cellTooltip: true}, { name: 'End Time',field:'endedOn', @@ -32,9 +34,9 @@ 'row.entity.botType',cellTooltip: true}, { name: 'BOT Name',displayName: 'BOT Name',field:'auditTrailConfig.name',cellTooltip: true}, { name: 'Status',field:'status', - cellTemplate:'' + - '' + - '', + cellTemplate:'' + + '' + + '', cellTooltip: true}, { name: 'Org',field:'masterDetails.orgName'}, { name: 'BU',field:'masterDetails.bgName'}, @@ -42,12 +44,67 @@ { name: 'Env',field:'masterDetails.envName'}, { name: 'User',field:'user'}, { name: 'Logs',cellTemplate: ''} - ], - data:[] + ] + $scope.botAuditTrailGridOptions.data=[]; + angular.extend($scope.botAuditTrailGridOptions,botAuditTrailUIGridDefaults.gridOption); }; + $scope.initGrids(); + var gridBottomSpace = 40; $scope.gridHeight = workzoneUIUtils.makeTabScrollable('botAuditTrailPage') - gridBottomSpace; + //for server side(external) pagination. + angular.extend($scope.botAuditTrailGridOptions,botAuditTrailUIGridDefaults.gridOption, { + onRegisterApi :function(gridApi) { + $scope.gridApi = gridApi; + gridApi.core.on.sortChanged($scope, function(grid, sortColumns) { + if (sortColumns[0] && sortColumns[0].field && sortColumns[0].sort && sortColumns[0].sort.direction) { + $scope.paginationParams.sortBy = sortColumns[0].field; + $scope.paginationParams.sortOrder = sortColumns[0].sort.direction; + $scope.botAuditTrailGridView(); + } + }); + //Pagination for page and pageSize + gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) { + $scope.paginationParams.page = newPage; + $scope.paginationParams.pageSize = pageSize; + $scope.botAuditTrailGridView(); + }); + }, + }); + /*angular.extend($scope.botAuditTrailGridOptions,botAuditTrailUIGridDefaults.gridOption, { + onRegisterApi :function(gridApi) { + $scope.gridApi = gridApi; + gridApi.core.on.sortChanged($scope, function(grid, sortColumns) { + if (sortColumns[0] && sortColumns[0].field && sortColumns[0].sort && sortColumns[0].sort.direction) { + $scope.paginationParams.sortBy = sortColumns[0].field; + $scope.paginationParams.sortOrder = sortColumns[0].sort.direction; + $scope.botAuditTrailGridView(); + } + }); + //Pagination for page and pageSize + gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) { + console.log(newPage); + $scope.paginationParams.page = newPage; + $scope.paginationParams.pageSize = pageSize; + $scope.botAuditTrailGridView(); + }); + }, + });*/ + /*$scope.setFirstPageView = function(){ + $scope.botAuditTrailGridOptions.paginationCurrentPage = $scope.paginationParams.page = 1; + }; + $scope.setPaginationDefaults = function() { + $scope.paginationParams.sortBy = 'createdOn'; + $scope.paginationParams.sortOrder = 'desc'; + if($scope.paginationParams.page !== 1){ + $scope.setFirstPageView();//if current page is not 1, then ui grid will trigger a call when set to 1. + }else{ + //$scope.init(); + } + }; + $scope.setPaginationDefaults();*/ + $scope.botAuditTrailLogs=function(hist) { var modalInstance = $modal.open({ animation: true, @@ -69,20 +126,26 @@ }; $scope.RefreshBotsAuditTrail = function() { - audit.init(); + $scope.botAuditTrailGridView(); }; - audit.init =function(){ - audit.gridOptions.data=[]; + $scope.botAuditTrailGridView =function(){ + $scope.botAuditTrailGridOptions.data=[]; var param={ - url:'/audit-trail?filterBy=auditType:BOTs' + url:'/audit-trail?filterBy=auditType:BOTs&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (response) { - angular.forEach(response,function () { - audit.gridOptions.data=response.auditTrails; - }); + $timeout(function() { + $scope.botAuditTrailGridOptions.data=response.auditTrails; + $scope.botAuditTrailGridOptions.totalItems = response.metaData.totalRecords; + }, 100); + $scope.isBotAuditTrailPageLoading = false; + }, function(error) { + $scope.isBotAuditTrailPageLoading = false; + console.log(error); + $scope.errorMessage = "No Records found"; }); }; - audit.init(); + $scope.botAuditTrailGridView(); }]); })(angular); \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js index 01283672c..475cf7f27 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js @@ -8,174 +8,174 @@ (function (angular) { "use strict"; angular.module('library.params', []) - .controller('editParamsCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', 'responseFormatter', '$modal', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, responseFormatter, $modal) { - console.log(items); - $scope.botName = items.botName; - $scope.taskType = items.botLinkedSubCategory; - $scope.taggingServerList=[]; - $scope.envOptions=[]; - workzoneServices.getTaggingServer().then(function (topSer) { - $scope.taggingServerList=topSer.data; - }); - $scope.chefAttributesFlag = false; - $scope.scriptParamsFlag = false; - if(items.botConfig && items.botConfig.runlist && items.botConfig.runlist.length) { - $scope.chefAttributesFlag = true; + .controller('editParamsCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', 'responseFormatter', '$modal', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, responseFormatter, $modal) { + console.log(items); + $scope.botName = items.botName; + $scope.taskType = items.botLinkedSubCategory; + $scope.taggingServerList=[]; + $scope.envOptions=[]; + workzoneServices.getTaggingServer().then(function (topSer) { + $scope.taggingServerList=topSer.data; + }); + $scope.chefAttributesFlag = false; + $scope.scriptParamsFlag = false; + if(items.botConfig && items.botConfig.runlist && items.botConfig.runlist.length) { + $scope.chefAttributesFlag = true; + } + if(items.botLinkedSubCategory === 'script' && items.botConfig) { + for (var i=0; i 0) { + $scope.scriptParamsFlag = true; + } } - if(items.botLinkedSubCategory === 'script' && items.botConfig) { - for (var i=0; i 0) { - $scope.scriptParamsFlag = true; + } + $scope.isChefattributesLoading = true; + if (items.botLinkedSubCategory === 'chef' && items.botConfig) { + $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(items.botConfig.runlist); + var nodesList = responseFormatter.chefRunlistFormatter($scope.chefComponentSelectorList); + $scope.chefattributes = []; + $scope.chefattributes = responseFormatter.formatSavedCookbookAttributes(items.botConfig.attributes); + workzoneServices.getCookBookListForOrg(items.masterDetails.orgId).then(function(data){ + var runlist = []; + for (var i = 0; i < nodesList.length; i++) { + if (nodesList[i].className === "cookbook" || nodesList[i].className === "deploy") { + runlist.push(nodesList[i].value); } } - } - $scope.isChefattributesLoading = true; - if (items.botLinkedSubCategory === 'chef' && items.botConfig) { - $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(items.botConfig.runlist); - var nodesList = responseFormatter.chefRunlistFormatter($scope.chefComponentSelectorList); - $scope.chefattributes = []; - $scope.chefattributes = responseFormatter.formatSavedCookbookAttributes(items.botConfig.attributes); - workzoneServices.getCookBookListForOrg(items.masterDetails.orgId).then(function(data){ - var runlist = []; - for (var i = 0; i < nodesList.length; i++) { - if (nodesList[i].className === "cookbook" || nodesList[i].className === "deploy") { - runlist.push(nodesList[i].value); + if (runlist.length > 0) { + workzoneServices.getcookBookAttributes(runlist, data.data.serverId).then(function (response) { + var data; + if (response.data) { + data = response.data; + } else { + data = response; } - } - if (runlist.length > 0) { - workzoneServices.getcookBookAttributes(runlist, data.data.serverId).then(function (response) { - var data; - if (response.data) { - data = response.data; - } else { - data = response; - } - /*Scope apply done to force refresh screen after receiving the AJAX response*/ - $scope.$apply(function () { - if ($scope.chefattributes) { - for (var j = 0; j < data.length; j++) { - for (var attrItem in data[j].attributes) { - if ($scope.chefattributes[attrItem]) { - data[j].attributes[attrItem].default = $scope.chefattributes[attrItem]; - } + /*Scope apply done to force refresh screen after receiving the AJAX response*/ + $scope.$apply(function () { + if ($scope.chefattributes) { + for (var j = 0; j < data.length; j++) { + for (var attrItem in data[j].attributes) { + if ($scope.chefattributes[attrItem]) { + data[j].attributes[attrItem].default = $scope.chefattributes[attrItem]; } } } - $scope.chefattributes = data; - $scope.isChefattributesLoading = false; - }); + } + $scope.chefattributes = data; + $scope.cookbookAttributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes); + $scope.isChefattributesLoading = false; }); + }); + } + }); + } + if (items.botConfig) { + $scope.jenkinsparams = items.botConfig.parameterized; + $scope.scriptparams = items.botConfig.scriptDetails; + } + $scope.parameters=['']; + //var cookbookAttributes = []; + $scope.cookbookAttributes = []; + //var scriptParams = []; + var choiceParam = {}; + //$scope.jenparams = {}; + + var helper = { + botLogModal: function(id,historyId,taskType) { + $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/bots/view/botExecutionLogs.html', + controller: 'botExecutionLogsCtrl as botExecLogCtrl', + backdrop: 'static', + keyboard: false, + resolve: { + items: function() { + return { + taskId: id, + historyId: historyId, + taskType: taskType + }; + } } }); } - if (items.botConfig) { - $scope.jenkinsparams = items.botConfig.parameterized; - $scope.scriptparams = items.botConfig.scriptDetails; - } - $scope.parameters=['']; - var cookbookAttributes = []; - var scriptParams = []; - var choiceParam = {}; - $scope.jenparams = {}; + }; - var helper = { - botLogModal: function(id,historyId,taskType) { - $modal.open({ - animation: true, - templateUrl: 'src/partials/sections/dashboard/bots/view/botExecutionLogs.html', - controller: 'botExecutionLogsCtrl as botExecLogCtrl', - backdrop: 'static', - keyboard: false, - resolve: { - items: function() { - return { - taskId: id, - historyId: historyId, - taskType: taskType - }; - } - } - }); - } - }; + /*if (items.botConfig && items.botConfig.taskType === 'jenkins') { + choiceParam = $scope.jenparams; + }*/ - $scope.add = function() { - $scope.parameters.push(''); - }; + /*$scope.add = function() { + $scope.parameters.push(''); + }; - $scope.removeScriptInputParams = function(paramInput) { - if($scope.parameters.length > 1){ - var idx = $scope.parameters.indexOf(paramInput); - $scope.parameters.splice(idx,1); - }else{ - toastr.error('Cannot delete the row'); - } - }; + $scope.removeScriptInputParams = function(paramInput) { + if($scope.parameters.length > 1){ + var idx = $scope.parameters.indexOf(paramInput); + $scope.parameters.splice(idx,1); + }else{ + toastr.error('Cannot delete the row'); + } + };*/ - $scope.executeBot=function(){ - if (items.botConfig && items.botConfig.taskType === 'script') { - var checkParam = false; - if ($scope.scriptParamsFlag) { - for(var i =0; i<$scope.parameters.length; i++){ - if($scope.parameters[i] === '' || $scope.parameters[i] === null){ - checkParam = false; - toastr.error('Please enter parameters'); - return false; - } else { - checkParam = true; - } + /*$scope.executeBot=function(){ + if (items.botConfig && items.botConfig.taskType === 'script') { + var checkParam = false; + if ($scope.scriptParamsFlag) { + for(var i =0; i<$scope.parameters.length; i++){ + if($scope.parameters[i] === '' || $scope.parameters[i] === null){ + checkParam = false; + toastr.error('Please enter parameters'); + return false; + } else { + checkParam = true; } } - if(checkParam){ - scriptParams = $scope.parameters; - } } - if (items.botConfig && items.botConfig.taskType === 'chef') { - cookbookAttributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes); + if(checkParam){ + scriptParams = $scope.parameters; + } + } + + };*/ + + $scope.executeBot = function(){ + var reqBody = {}; + if (items.botConfig && items.botConfig.taskType === 'jenkins') { + reqBody.choiceParam = $scope.jenparams[params.name]; + } else if (items.botConfig && items.botConfig.taskType === 'chef'){ + reqBody.tagServer = $scope.tagSerSelected; + if ($scope.chefAttributesFlag) { + reqBody.cookbookAttributes = $scope.cookbookAttributes; } - if (items.botConfig && items.botConfig.taskType === 'jenkins') { - choiceParam = $scope.jenparams; + } else if (items.botConfig && items.botConfig.taskType === 'script') { + reqBody.tagServer = $scope.tagSerSelected; + if ($scope.scriptParamsFlag) { + reqBody.scriptParams = $scope.parameters; } - $scope.executeBot(); + } + var param={ + url:'/bots/' + items.botId + '/execute', + data: reqBody }; - - $scope.executeBot = function(){ - var reqBody = {}; - if (items.botConfig && items.botConfig.taskType === 'jenkins') { - reqBody.choiceParam = choiceParam; - } else if (items.botConfig && items.botConfig.taskType === 'chef'){ - reqBody.tagServer = $scope.tagSerSelected; - if ($scope.chefAttributesFlag) { - reqBody.cookbookAttributes = cookbookAttributes; - } - } else if (items.botConfig && items.botConfig.taskType === 'script') { - reqBody.tagServer = $scope.tagSerSelected; - if ($scope.scriptParamsFlag) { - reqBody.scriptParams = scriptParams; - } + genSevs.promisePost(param).then(function (response) { + console.log(response); + $modalInstance.close(response.data); + $rootScope.$emit('BOTS_LIBRARY_REFRESH'); + helper.botLogModal(items.botId, response.historyId, response.taskType); + }, + function (error) { + error = error.responseText || error; + if (error.message) { + toastr.error(error.message); + } else { + toastr.error(error); } - var param={ - url:'/bots/' + items.botId + '/execute', - data: reqBody - }; - genSevs.promisePost(param).then(function (response) { - console.log(response); - $modalInstance.close(response.data); - $rootScope.$emit('BOTS_LIBRARY_REFRESH'); - helper.botLogModal(items.botId, response.historyId, response.taskType); - }, - function (error) { - error = error.responseText || error; - if (error.message) { - toastr.error(error.message); - } else { - toastr.error(error); - } - }); - }; + }); + }; - $scope.cancel= function() { - $modalInstance.dismiss('cancel'); - }; - }]); + $scope.cancel= function() { + $modalInstance.dismiss('cancel'); + }; + }]); })(angular); \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js index 5f767e910..55a16c189 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -8,296 +8,329 @@ (function (angular) { "use strict"; angular.module('dashboard.bots') - .controller('libraryCtrl',['$scope', '$rootScope', '$state', 'genericServices', 'confirmbox', 'toastr', 'workzoneUIUtils', '$modal', 'uiGridOptionsService', '$timeout', function ($scope, $rootScope, $state, genSevs, confirmbox, toastr, workzoneUIUtils, $modal, uiGridOptionsService, $timeout) { - var treeNames = ['BOTs','Library']; - $rootScope.$emit('treeNameUpdate', treeNames); - var lib=this; - $scope.totalBotsSelected = true; - var botLibraryUIGridDefaults = uiGridOptionsService.options(); - $scope.paginationParams = botLibraryUIGridDefaults.pagination; - $scope.paginationParams=[]; - $scope.paginationParams.sortBy = 'createdOn'; - $scope.paginationParams.sortOrder = 'desc'; - console.log($scope.paginationParams.sortBy); - - $scope.initGrids = function(){ - $scope.botLibGridOptions={ - enableFiltering: false - }; - $scope.botLibGridOptions.columnDefs= [ - { name:'Task Type', field:'botLinkedSubCategory' ,cellTemplate:'row.entity.taskType'+ + .controller('libraryCtrl',['$scope', '$rootScope', '$state', 'genericServices', 'confirmbox', 'toastr', 'workzoneUIUtils', '$modal', 'uiGridOptionsService', '$timeout', function ($scope, $rootScope, $state, genSevs, confirmbox, toastr, workzoneUIUtils, $modal, uiGridOptionsService, $timeout) { + var treeNames = ['BOTs','Library']; + $rootScope.$emit('treeNameUpdate', treeNames); + var lib=this; + $scope.totalBotsSelected = true; + var botLibraryUIGridDefaults = uiGridOptionsService.options(); + $scope.paginationParams = botLibraryUIGridDefaults.pagination; + $scope.paginationParams=[]; + $scope.paginationParams.page = 1; + $scope.paginationParams.pageSize = 10; + $scope.paginationParams.sortBy = 'createdOn'; + $scope.paginationParams.sortOrder = 'desc'; + + $scope.initGrids = function(){ + $scope.botLibGridOptions={}; + $scope.botLibGridOptions.columnDefs= [ + { name:'Task Type', field:'botLinkedSubCategory' ,cellTemplate:'row.entity.taskType'+ 'row.entity.botLinkedSubCategory'+ 'row.entity.taskType'+ 'row.entity.botType',cellTooltip: true}, - { name: 'BOT Type',displayName: 'BOT Type',field:'botLinkedCategory',cellTooltip: true}, - { name: 'BOT Name',displayName: 'BOT Name',field:'botName',cellTooltip: true}, - { name: 'Category',field:'botCategory',cellTooltip: true}, - { name: 'description',field:'botDesc',cellTooltip: true}, - { name: 'Org',field:'masterDetails.orgName',cellTooltip: true}, - { name: 'Total Runs',field:'executionCount'}, - { name: 'BOT History',displayName: 'BOT History',cellTemplate:'NA'+ + { name: 'BOT Type',displayName: 'BOT Type',field:'botLinkedCategory',cellTooltip: true}, + { name: 'BOT Name',displayName: 'BOT Name',field:'botName',cellTooltip: true}, + { name: 'Category',field:'botCategory',cellTooltip: true}, + { name: 'description',field:'botDesc',cellTooltip: true}, + { name: 'Org',field:'masterDetails.orgName',cellTooltip: true}, + { name: 'Total Runs',field:'executionCount'}, + { name: 'BOT History',displayName: 'BOT History',cellTemplate:'NA'+ ''}, - { name: 'BOT Info',displayName: 'BOT Info',cellTemplate: - ''}, - { name: 'BOT Action',displayName: 'BOT Action',cellTemplate: + { name: 'BOT Info',displayName: 'BOT Info',cellTemplate: + ''}, + { name: 'BOT Action',displayName: 'BOT Action',cellTemplate: '' + '' + '' + } + ] + $scope.botLibGridOptions.data=[]; + angular.extend($scope.botLibGridOptions,botLibraryUIGridDefaults.gridOption); + }; + $scope.initGrids(); + /*APIs registered are triggered as ui-grid is configured + for server side(external) pagination.*/ + angular.extend($scope.botLibGridOptions,botLibraryUIGridDefaults.gridOption, { + onRegisterApi :function(gridApi) { + $scope.gridApi = gridApi; + gridApi.core.on.sortChanged($scope, function(grid, sortColumns) { + if (sortColumns[0] && sortColumns[0].field && sortColumns[0].sort && sortColumns[0].sort.direction) { + $scope.paginationParams.sortBy = sortColumns[0].field; + $scope.paginationParams.sortOrder = sortColumns[0].sort.direction; + $scope.botLibraryGridView(); } - ] - $scope.botLibGridOptions.data=[]; - angular.extend($scope.botLibGridOptions,botLibraryUIGridDefaults.gridOption); + }); + //Pagination for page and pageSize + gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) { + $scope.paginationParams.page = newPage; + $scope.paginationParams.pageSize = pageSize; + $scope.botLibraryGridView(); + }); + }, + }); + $scope.setFirstPageView = function(){ + $scope.botLibGridOptions.paginationCurrentPage = $scope.paginationParams.page = 1; + }; + $scope.setPaginationDefaults = function() { + $scope.paginationParams.sortBy = 'createdOn'; + $scope.paginationParams.sortOrder = 'desc'; + if($scope.paginationParams.page !== 1){ + $scope.setFirstPageView();//if current page is not 1, then ui grid will trigger a call when set to 1. + }else{ + //$scope.botLibraryGridView(); + } + }; + $scope.setPaginationDefaults(); + $scope.botLibraryGridView = function() { + lib.gridOptions=[]; + var param={ + url:'/bots?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; - $scope.initGrids(); - /*APIs registered are triggered as ui-grid is configured - for server side(external) pagination.*/ - angular.extend($scope.botLibGridOptions,botLibraryUIGridDefaults.gridOption, { - onRegisterApi :function(gridApi) { - $scope.gridApi = gridApi; - gridApi.core.on.sortChanged($scope, function(grid, sortColumns) { - if (sortColumns[0] && sortColumns[0].field && sortColumns[0].sort && sortColumns[0].sort.direction) { - $scope.paginationParams.sortBy = sortColumns[0].field; - $scope.paginationParams.sortOrder = sortColumns[0].sort.direction; - $scope.botLibraryGridView(); - } - }); - //Pagination for page and pageSize - gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) { - $scope.paginationParams.page = newPage; - $scope.paginationParams.pageSize = pageSize; - $scope.botLibraryGridView(); - }); - }, + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + console.log(result); + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + $scope.isBotLibraryPageLoading = false; + }, function(error) { + $scope.isBotLibraryPageLoading = false; + console.log(error); + $scope.errorMessage = "No Records found"; }); - $scope.setPaginationDefaults = function() { - $scope.paginationParams.sortBy = 'createdOn'; - $scope.paginationParams.sortOrder = 'desc'; - /*if($scope.paginationParams.page !== 1){ - $scope.setFirstPageView();//if current page is not 1, then ui grid will trigger a call when set to 1. - }else{ - $scope.botLibraryGridView(); - }*/ - }; - $scope.setPaginationDefaults(); - $scope.botLibraryGridView = function() { - lib.gridOptions=[]; + }; + $scope.botLibraryGridView(); + $scope.searchBotNameCategory = function() { + $scope.searchString = $scope.botLibrarySearch; + lib.gridOptions=[]; + if($scope.totalBotsSelected) { var param={ - url:'/bots?page=1&pageSize=10&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder - }; - genSevs.promiseGet(param).then(function (result) { - $timeout(function() { - console.log(result); - $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; - $scope.botLibGridOptions.data=result.bots; - }, 100); - $scope.isBotLibraryPageLoading = false; - }, function(error) { - $scope.isBotLibraryPageLoading = false; - console.log(error); - $scope.errorMessage = "No Records found"; - }); - }; - $scope.botLibraryGridView(); - $scope.searchBotNameCategory = function() { - $scope.searchString = $scope.botLibrarySearch; - console.log($scope.searchString); - lib.gridOptions=[]; + url:'/bots?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString + } + } else if($scope.runningBotsselected) { var param={ - url:'/bots?page=1&pageSize=10&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder - }; - genSevs.promiseGet(param).then(function (result) { - $timeout(function() { - console.log(result); - $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; - $scope.botLibGridOptions.data=result.bots; - }, 100); - $scope.isBotLibraryPageLoading = false; - }, function(error) { - $scope.isBotLibraryPageLoading = false; - console.log(error); - $scope.errorMessage = "No Records found"; - }); - }; - var gridBottomSpace = 190; - $scope.gridHeight = workzoneUIUtils.makeTabScrollable('botLibraryPage') - gridBottomSpace; - $scope.launchInstance = function(launch){ - console.log(launch.botLinkedCategory); - /*if(launch.launcType === 'task'){ - genSevs.executeTask(launch); - } else if(launch.launcType === 'bp') { - genSevs.launchBlueprint(launch); - }*/ - if(launch.botLinkedCategory === 'Task'){ - genSevs.executeTask(launch); - } else if(launch.botLinkedCategory === 'Blueprint') { - genSevs.launchBlueprint(launch); + url:'/bots?actionStatus=running&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString + } + } else if($scope.failedBotsselected) { + var param={ + url:'/bots?actionStatus=failed&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString } }; - /*$scope.botLogs = function(bot){ - genSevs.botHistory(bot); - };*/ - $scope.botHistory=function(bot) { - var modalInstance = $modal.open({ - animation: true, - templateUrl: 'src/partials/sections/dashboard/bots/view/botHistory.html', - controller: 'botHistoryCtrl', - backdrop : 'static', - size: 'lg', - keyboard: false, - resolve: { - items: function() { - return bot; - } + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + console.log(result); + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + $scope.isBotLibraryPageLoading = false; + }, function(error) { + $scope.isBotLibraryPageLoading = false; + console.log(error); + $scope.errorMessage = "No Records found"; + }); + }; + var gridBottomSpace = 225; + $scope.gridHeight = workzoneUIUtils.makeTabScrollable('botLibraryPage') - gridBottomSpace; + $scope.launchInstance = function(launch){ + console.log(launch.botLinkedCategory); + /*if(launch.launcType === 'task'){ + genSevs.executeTask(launch); + } else if(launch.launcType === 'bp') { + genSevs.launchBlueprint(launch); + }*/ + if(launch.botLinkedCategory === 'Task'){ + genSevs.executeTask(launch); + } else if(launch.botLinkedCategory === 'Blueprint') { + genSevs.launchBlueprint(launch); + } + }; + /*$scope.botLogs = function(bot){ + genSevs.botHistory(bot); + };*/ + $scope.botHistory=function(bot) { + var modalInstance = $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/bots/view/botHistory.html', + controller: 'botHistoryCtrl', + backdrop : 'static', + size: 'lg', + keyboard: false, + resolve: { + items: function() { + return bot; } - }); - modalInstance.result.then(function(selectedItem) { - $scope.selected = selectedItem; - }, function() { - console.log('Modal Dismissed at ' + new Date()); - }); - }; - $scope.botInfo=function(bot) { - var modalInstance = $modal.open({ - animation: true, - templateUrl: 'src/partials/sections/dashboard/bots/view/botInfo.html', - controller: 'botInfoCtrl', - backdrop : 'static', - keyboard: false, - resolve: { - items: function() { - return bot; - } + } + }); + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('Modal Dismissed at ' + new Date()); + }); + }; + $scope.botInfo=function(bot) { + var modalInstance = $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/bots/view/botInfo.html', + controller: 'botInfoCtrl', + backdrop : 'static', + keyboard: false, + resolve: { + items: function() { + return bot; } - }); - modalInstance.result.then(function(selectedItem) { - $scope.selected = selectedItem; - }, function() { - console.log('Modal Dismissed at ' + new Date()); - }); - }; - $scope.botSchedule = function(bot) { - $modal.open({ - templateUrl: 'src/partials/sections/dashboard/bots/view/botSchedule.html', - controller: 'botScheduleCtrl', - backdrop: 'static', - keyboard: false, - resolve: { - items: function () { - return bot - } + } + }); + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('Modal Dismissed at ' + new Date()); + }); + }; + /*$scope.botInfo=function(bot) { + genSevs.newTask(bot); + var modalInstance = $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/workzone/popups/newTask.html', + controller: 'newTaskCtrl', + backdrop : 'static', + size: 'lg', + keyboard: false, + resolve: { + items: function() { + return bot; } - }).result.then(function (chefEventDetails) { - $scope.isEventAvailable = true; - $scope.chefJenkScriptTaskObj = chefEventDetails; - var startTimeMinute,startTimeHour,dayOfWeek,selectedDayOfTheMonth,selectedMonth; - startTimeMinute = $scope.chefJenkScriptTaskObj.startTimeMinute; - startTimeHour = $scope.chefJenkScriptTaskObj.startTime; - dayOfWeek = $scope.chefJenkScriptTaskObj.dayOfWeek; - selectedDayOfTheMonth = $scope.chefJenkScriptTaskObj.selectedDayOfTheMonth; - selectedMonth = $scope.chefJenkScriptTaskObj.monthOfYear; - $scope.type = 'edit'; - $scope._isEventSelected = true; - - $scope.repeatPattern = 'Repeat Every -' + $scope.chefJenkScriptTaskObj.repeats; - $scope.cronDetails = { - cronStartOn : $scope.chefJenkScriptTaskObj.cronStart, - cronEndOn : $scope.chefJenkScriptTaskObj.cronEnd, - cronRepeatEvery : $scope.chefJenkScriptTaskObj.repeatBy, - cronFrequency: $scope.chefJenkScriptTaskObj.repeats, - cronTime: typeof startTimeHour !=='undefined'? startTimeHour : new Date().getHours() + ':' + typeof startTimeMinute !=='undefined'? startTimeMinute:new Date().getMinutes(), - cronDays: $scope.chefJenkScriptTaskObj.dayOfWeek, - cronMonth: $scope.chefJenkScriptTaskObj.monthOfYear + } + }); + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('Modal Dismissed at ' + new Date()); + }); + };*/ + $scope.botSchedule = function(bot) { + $modal.open({ + templateUrl: 'src/partials/sections/dashboard/bots/view/botSchedule.html', + controller: 'botScheduleCtrl', + backdrop: 'static', + keyboard: false, + resolve: { + items: function () { + return bot } - }, function () { - console.log('Dismiss time is ' + new Date()); - }); - }; - $scope.deleteBot = function(bot) { - var modalOptions = { - closeButtonText: 'Cancel', - actionButtonText: 'Delete', - actionButtonStyle: 'cat-btn-delete', - headerText: 'Delete Bot', - bodyText: 'Are you sure you want to delete this bots?' - }; - confirmbox.showModal({}, modalOptions).then(function() { - var param={ - url:'/bots/' + bot.botId - }; - genSevs.promiseDelete(param).then(function (response) { - if (response) { - toastr.success('Successfully deleted'); - if($scope.totalBotsSelected) { - $scope.botLibraryGridView(); - } else if($scope.runningBotsselected) { - $scope.showBotsRunning(); - } else if($scope.failedBotsselected) { - $scope.showFailedBots(); - } else { - $scope.botLibraryGridView(); - } - lib.summary(); - } - }, function(data) { - toastr.error('error:: ' + data.toString()); - }); - }); - }; - $rootScope.$on('BOTS_LIBRARY_REFRESH', function() { - lib.summary(); - $scope.botLibraryGridView(); + } + }).result.then(function (chefEventDetails) { + $scope.isEventAvailable = true; + $scope.chefJenkScriptTaskObj = chefEventDetails; + var startTimeMinute,startTimeHour,dayOfWeek,selectedDayOfTheMonth,selectedMonth; + startTimeMinute = $scope.chefJenkScriptTaskObj.startTimeMinute; + startTimeHour = $scope.chefJenkScriptTaskObj.startTime; + dayOfWeek = $scope.chefJenkScriptTaskObj.dayOfWeek; + selectedDayOfTheMonth = $scope.chefJenkScriptTaskObj.selectedDayOfTheMonth; + selectedMonth = $scope.chefJenkScriptTaskObj.monthOfYear; + $scope.type = 'edit'; + $scope._isEventSelected = true; + + $scope.repeatPattern = 'Repeat Every -' + $scope.chefJenkScriptTaskObj.repeats; + $scope.cronDetails = { + cronStartOn : $scope.chefJenkScriptTaskObj.cronStart, + cronEndOn : $scope.chefJenkScriptTaskObj.cronEnd, + cronRepeatEvery : $scope.chefJenkScriptTaskObj.repeatBy, + cronFrequency: $scope.chefJenkScriptTaskObj.repeats, + cronTime: typeof startTimeHour !=='undefined'? startTimeHour : new Date().getHours() + ':' + typeof startTimeMinute !=='undefined'? startTimeMinute:new Date().getMinutes(), + cronDays: $scope.chefJenkScriptTaskObj.dayOfWeek, + cronMonth: $scope.chefJenkScriptTaskObj.monthOfYear + } + }, function () { + console.log('Dismiss time is ' + new Date()); }); - $scope.RefreshBotsLibrary = function() { - $scope.totalBotsSelected = true; - $scope.runningBotsselected = false; - $scope.failedBotsselected = false; - lib.summary(); - $scope.botLibraryGridView(); - }; - $scope.showBotsRunning = function() { - $scope.runningBotsselected = true; - $scope.totalBotsSelected = false; - $scope.failedBotsselected = false; - lib.gridOptions.data=[]; - var param={ - url:'/bots?actionStatus=running&page=1&pageSize=10&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder - }; - genSevs.promiseGet(param).then(function (result) { - $timeout(function() { - $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; - $scope.botLibGridOptions.data=result.bots; - }, 100); - }); - lib.summary(); + }; + $scope.deleteBot = function(bot) { + var modalOptions = { + closeButtonText: 'Cancel', + actionButtonText: 'Delete', + actionButtonStyle: 'cat-btn-delete', + headerText: 'Delete Bot', + bodyText: 'Are you sure you want to delete this bots?' }; - $scope.showFailedBots = function() { - $scope.failedBotsselected = true; - $scope.runningBotsselected = false; - $scope.totalBotsSelected = false; - lib.gridOptions.data=[]; + confirmbox.showModal({}, modalOptions).then(function() { var param={ - url:'/bots?actionStatus=failed&page=1&pageSize=10&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder + url:'/bots/' + bot.botId }; - genSevs.promiseGet(param).then(function (result) { - $timeout(function() { - $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; - $scope.botLibGridOptions.data=result.bots; - }, 100); + genSevs.promiseDelete(param).then(function (response) { + if (response) { + toastr.success('Successfully deleted'); + if($scope.totalBotsSelected) { + $scope.botLibraryGridView(); + } else if($scope.runningBotsselected) { + $scope.showBotsRunning(); + } else if($scope.failedBotsselected) { + $scope.showFailedBots(); + } else { + $scope.botLibraryGridView(); + } + lib.summary(); + } + }, function(data) { + toastr.error('error:: ' + data.toString()); }); - lib.summary(); + }); + }; + $rootScope.$on('BOTS_LIBRARY_REFRESH', function() { + lib.summary(); + $scope.botLibraryGridView(); + }); + $scope.RefreshBotsLibrary = function() { + $scope.totalBotsSelected = true; + $scope.runningBotsselected = false; + $scope.failedBotsselected = false; + $scope.botLibrarySearch = ''; + lib.summary(); + $scope.botLibraryGridView(); + }; + $scope.showBotsRunning = function() { + $scope.runningBotsselected = true; + $scope.totalBotsSelected = false; + $scope.failedBotsselected = false; + lib.gridOptions.data=[]; + var param={ + url:'/bots?actionStatus=running&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; - lib.summary = function() { - $scope.botSummary=[]; - var param={ - url:'/audit-trail/bots-summary' - }; - genSevs.promiseGet(param).then(function (response) { - $scope.botSummary = response; - $scope.totalSavedTimeForBots = parseInt($scope.botSummary.totalSavedTimeForBots); - }); + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + }); + lib.summary(); + }; + $scope.showFailedBots = function() { + $scope.failedBotsselected = true; + $scope.runningBotsselected = false; + $scope.totalBotsSelected = false; + lib.gridOptions.data=[]; + var param={ + url:'/bots?actionStatus=failed&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + }); lib.summary(); - }]).controller('botInfoCtrl',['$scope', 'items', '$modalInstance', function ($scope, items, $modalInstance) { + }; + lib.summary = function() { + $scope.botSummary=[]; + var param={ + url:'/audit-trail/bots-summary' + }; + genSevs.promiseGet(param).then(function (response) { + $scope.botSummary = response; + $scope.totalSavedTimeForBots = parseInt($scope.botSummary.totalSavedTimeForBots); + }); + }; + lib.summary(); + }]).controller('botInfoCtrl',['$scope', 'items', '$modalInstance', function ($scope, items, $modalInstance) { $scope.botInfo = items; console.log(items); @@ -321,15 +354,15 @@ var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2]; $scope.schedulerStartOn = newdate; var newEndOn = parseInt(items.chefJenkScriptTaskObj.cronEndOn); - var newEndData = new Date(newEndOn).toLocaleDateString(); + var newEndData = new Date(newEndOn).toLocaleDateString(); var datearrayNew = newEndData.split("/"); var newdateEnd = datearrayNew[1] + '/' + datearrayNew[0] + '/' + datearrayNew[2]; $scope.schedulerEndOn = newdateEnd; } else { $scope.schedulerStartOn = items.chefJenkScriptTaskObj.cronStart; - $scope.schedulerEndOn = items.chefJenkScriptTaskObj.cronEnd; + $scope.schedulerEndOn = items.chefJenkScriptTaskObj.cronEnd; } - + $scope.repeatBy = items.chefJenkScriptTaskObj.repeatBy || items.chefJenkScriptTaskObj.cronRepeatEvery.toString(); $scope.repeatsType = items.chefJenkScriptTaskObj.repeats || items.chefJenkScriptTaskObj.cronFrequency; $scope.timeEventType = items.chefJenkScriptTaskObj.startTime; @@ -666,7 +699,7 @@ items: function() { return { taskId : hist.auditId, - historyId : hist.auditHistoryId, + historyId : hist._id, taskType:hist.auditTrailConfig.executionType }; } @@ -698,5 +731,33 @@ $scope.cancel= function() { $modalInstance.dismiss('cancel'); }; - }]); + }]).controller('confirmBotRunCtrl', ['$scope', '$modalInstance', 'items', 'genericServices','toastr', function ($scope, $modalInstance, items, genSevs, toastr) { + console.log(items); + $scope.botId = items.botId; + $scope.isJobRunExecuting = false; + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + $scope.runJob = function () { + $scope.isJobRunExecuting = true; + var param={ + url:'/bots/' + items.botId + '/execute' + }; + genSevs.promisePost(param).then(function (response) { + console.log(response); + $modalInstance.close(response.data); + $rootScope.$emit('BOTS_LIBRARY_REFRESH'); + helper.botLogModal(items.botId, response.historyId, response.taskType); + }, + function (error) { + error = error.responseText || error; + if (error.message) { + toastr.error(error.message); + } else { + toastr.error(error); + } + }); + }; + } + ]); })(angular); \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/audittrail.html b/client/cat3/src/partials/sections/dashboard/bots/view/audittrail.html index 9941d03e9..1a3d347e0 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/audittrail.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/audittrail.html @@ -9,8 +9,10 @@
-
-
+ +
No data Available
+ +
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html b/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html index 20c586642..0a23d5a2b 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html @@ -29,7 +29,7 @@