diff --git a/client/cat3/main.html b/client/cat3/main.html index d7cfa2ac0..7aee82223 100644 --- a/client/cat3/main.html +++ b/client/cat3/main.html @@ -37,6 +37,8 @@ + + @@ -110,15 +112,17 @@ + - + + diff --git a/client/cat3/src/clientRoutes.js b/client/cat3/src/clientRoutes.js index 778ee4db0..267fc8ff5 100644 --- a/client/cat3/src/clientRoutes.js +++ b/client/cat3/src/clientRoutes.js @@ -36,7 +36,6 @@ function routeConfig($stateProvider, $urlRouterProvider, $httpProvider, modulePe url: "/workzone", templateUrl: "src/partials/sections/dashboard/workzone/workzone.html", controller: "workzoneCtrl", - params:{filterView:{workzone:true}}, onEnter: function () { }, onExit: function () { @@ -58,7 +57,6 @@ function routeConfig($stateProvider, $urlRouterProvider, $httpProvider, modulePe url: "/design", templateUrl: "src/partials/sections/dashboard/design/design.html", controller: "designCtrl as desCtrl", - params:{filterView:{design:true}}, resolve: { auth: ["$q", function ($q) { var deferred = $q.defer(); @@ -76,7 +74,7 @@ function routeConfig($stateProvider, $urlRouterProvider, $httpProvider, modulePe url: "/CM/", templateUrl: "src/partials/sections/dashboard/analytics/analytics.html", controller: "analyticsCtrl as analytic", - params:{filterView:{analytics:true}}, + //params:{filterView:{analytics:true}}, resolve: { auth: ["$q", function ($q) { var deferred = $q.defer(); @@ -95,7 +93,6 @@ function routeConfig($stateProvider, $urlRouterProvider, $httpProvider, modulePe url: "/bots", templateUrl: "src/partials/sections/dashboard/bots/bots.html", controller: "botsCtrl as bts", - params:{filterView:{bots:true}}, resolve: { auth: ["$q", function ($q) { var deferred = $q.defer(); diff --git a/client/cat3/src/main.js b/client/cat3/src/main.js index 55ec51ab8..2720b2867 100644 --- a/client/cat3/src/main.js +++ b/client/cat3/src/main.js @@ -12,7 +12,7 @@ * All modules/feature will be through * */ -var angularApp = angular.module('catapp', ['ui.router','ngTouch','toastr', +var angularApp = angular.module('catapp', ['ui.router','ngTouch','toastr','firebase', 'global.login', 'global.breadcrumb', 'authentication', @@ -28,7 +28,7 @@ var angularApp = angular.module('catapp', ['ui.router','ngTouch','toastr', 'ui.grid.resizeColumns', 'global.uiGridOptions', 'global.messages', - 'ui.grid.selection' + 'ui.grid.selection','ui.grid.cellNav' ]); angularApp.run(['$rootScope', 'auth', '$state', '$stateParams','$http','$window', diff --git a/client/cat3/src/partials/global.scss b/client/cat3/src/partials/global.scss index 74db63c13..2d8ce58b5 100644 --- a/client/cat3/src/partials/global.scss +++ b/client/cat3/src/partials/global.scss @@ -754,6 +754,10 @@ accordion .panel-heading { /* global styles for logs display across workzone ends here*/ /*ui grid css starts here*/ +.editCell .ui-grid-cell-contents { + background: #b3c4c7 !important; + cursor: pointer; +} .ui-grid { font-size: 14px; text-align: center; @@ -1452,3 +1456,9 @@ div::-webkit-scrollbar-thumb transparent 75%, transparent) } +.ui-grid-row.ui-grid-row-selected > [ui-grid-row] > .ui-grid-cell{ + background-color: #E8F1F3 !important; +} +input[type="text"].ui-grid-filter-input{ + color: #000000; +} \ No newline at end of file diff --git a/client/cat3/src/partials/globals/header/header.scss b/client/cat3/src/partials/globals/header/header.scss index e52098f80..b56e0bb1d 100755 --- a/client/cat3/src/partials/globals/header/header.scss +++ b/client/cat3/src/partials/globals/header/header.scss @@ -19,8 +19,8 @@ cursor:pointer; } - .header-selected-item { - color: #40BAF1; + .activeSection i { + color: #40BAF1 !important; } .header-logo-image { diff --git a/client/cat3/src/partials/globals/header/headerDashboard.html b/client/cat3/src/partials/globals/header/headerDashboard.html index 5a07f691f..8a0d8cfc9 100644 --- a/client/cat3/src/partials/globals/header/headerDashboard.html +++ b/client/cat3/src/partials/globals/header/headerDashboard.html @@ -35,7 +35,7 @@
  • - Cloud + CLOUD
  • diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html index e8610f1b3..6c2df7210 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html +++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html @@ -6,10 +6,10 @@
  • - - - - - - - - +
  • +
    +
    + + Resources +
    +
    +
  • diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html index bfef10192..22df9ae4d 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html +++ b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html @@ -5,8 +5,19 @@ Instances -
    No Data Found!
    -
    + + + + + + + + +
    + +
    No Data Found!
    @@ -16,7 +27,8 @@ - + + @@ -24,7 +36,8 @@ - + + @@ -33,3 +46,17 @@
    + \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/discoverySyncResult.html b/client/cat3/src/partials/sections/dashboard/analytics/view/discoverySyncResult.html new file mode 100644 index 000000000..22d991b87 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/analytics/view/discoverySyncResult.html @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryTagMapping.html b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryTagMapping.html index 17680da44..d27b67904 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryTagMapping.html +++ b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryTagMapping.html @@ -11,7 +11,7 @@
    - @@ -33,7 +33,7 @@
    + suggestions-arr="newEnt.businessGroup.tagValues">
    @@ -55,7 +55,7 @@
    - @@ -79,7 +79,7 @@
    + suggestions-arr="newEnt.project.tagValues">
    @@ -99,7 +99,7 @@
    - @@ -120,7 +120,7 @@
    + suggestions-arr="newEnt.environment.tagValues">
    @@ -135,6 +135,9 @@
    + diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/instanceManage.html b/client/cat3/src/partials/sections/dashboard/analytics/view/instanceManage.html new file mode 100644 index 000000000..b7c5466f0 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/analytics/view/instanceManage.html @@ -0,0 +1,118 @@ +
    +
    + + + + +
    +
    diff --git a/client/cat3/src/partials/sections/dashboard/bots/bots.scss b/client/cat3/src/partials/sections/dashboard/bots/bots.scss index 152523d25..ed52f151a 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/bots.scss +++ b/client/cat3/src/partials/sections/dashboard/bots/bots.scss @@ -16,6 +16,10 @@ padding-bottom: 10px; } +.paddingbottom20 { + padding-bottom: 20px; +} + .margintop8 { margin-top: 8px; } @@ -36,115 +40,71 @@ height: 50px; } -#botAuditTrailPage { - .ui-grid-column-menu-button { - display: none; - } +.param-table { + max-height: 400px; + overflow-y: auto; +} + +.bot-info-wrapper { + max-height: 450px; + overflow-y: auto; } #botLibraryPage, #botAuditTrailPage { .page-name { - font-size: 18px; - margin: 5px 0 5px 10px; + font-size: 18px; + margin: 5px 0 5px 10px; + } + + .search-icon { + margin-left: -26px; + cursor: pointer; } .btn-xs { - padding: 1px 5px; - font-size: 12px; + padding: 1px 5px; + font-size: 12px; } .refresh-btn { margin: 2px 10px 0 0; } - .borderTop { - border-top: 1px dashed #ddd; - } -} - -#botLibraryPage { - .summary-container { - width: 100%; - } - - .selected { - height: 92px !important; - margin-top: 14px !important; - } - - .selected-blue { - color: #00c0ef !important; - border: 1px solid #00c0ef !important; + .search-text { + font-weight: normal; } - .selected-green { - color: #00a65a !important; - border: 1px solid #00a65a !important; + .bot-search { + -webkit-appearance: textfield !important; } - .selected-red { - color: #dd4b39 !important; - border: 1px solid #dd4b39 !important; + .borderTop { + border-top: 1px dashed #ddd; } +} - .info-box { - display: block; - min-height: 90px; - background: #fff; +#botLibraryPage { + .summary-container { width: 100%; - box-shadow: 0 1px 1px rgba(0,0,0,0.1); - margin: 15px 0; - border: 1px solid #ccc; - } - - .info-box-content { - padding: 5px 10px; - margin-left: 90px; - } - - .info-box-text { - text-transform: uppercase; } - .info-box-text { - display: block; - font-size: 13px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; + .bot-library-search { + height: 33px; + margin-right: 12px; } - .info-box-number { - display: block; - font-weight: bold; - font-size: 20px; - } - - .info-box-icon { - display: block; - float: left; - height: 88px; - width: 88px; - text-align: center; - font-size: 45px; - line-height: 90px; - background: rgba(0,0,0,0.2); - } - - .bg-aqua { - background-color: #00c0ef !important; - } - - .bg-green { - background-color: #00a65a !important; + .section-bottom-glyph { + position: absolute; + top: 140px; + left: 97px; + font-size: 22px; + display: none; } - .bg-red { - background-color: #dd4b39 !important; + .selected-section { + display: block !important; } -} -#botLibraryPage{ .circle-tile { margin-bottom: 15px; text-align: center; @@ -152,21 +112,22 @@ .circle-tile-heading { position: relative; - width: 80px; - height: 80px; - margin: 10px auto -40px; - border: 3px solid rgba(255,255,255,0.3); + width: 65px; + height: 65px; + margin: 10px auto -35px; + border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 100%; color: #fff; - padding-top: 16px; + padding-top: 15px; transition: all ease-in-out .3s; } .circle-tile-number { - padding: 5px 0 15px; + padding: 5px 0 6px; font-size: 26px; font-weight: 700; line-height: 1; + height: 37px; } .circle-tile-content { @@ -186,6 +147,14 @@ background-color: #00c0ef; } + .dark-blue-glyph { + color: #00c0ef; + } + + .green-glyph { + color: #00a65a; + } + .green { background-color: #00a65a; } @@ -194,10 +163,34 @@ background-color: #f39c12; } - .red { + .redcard { background-color: #e74c3c; } + .redcard-glyph { + color: #e74c3c; + } + + .bg-blue { + background-color: #2980b9; + } + + .bg-blue-glyph { + color: #2980b9; + } + + .font-size-16 { + font-size: 16px; + } + + a.cursor { + padding: 0 5px; + } + + .margin-21 { + margin: 0 20px; + } + #botLibraryPage .selected-blue { border: none !important; } @@ -205,10 +198,21 @@ .ui-grid-cell{ border-right:none !important; } +} - /*global css*/ - .ui-grid .ui-grid-row { - border-bottom: 1px solid #ccc; +#botAuditTrailPage { + .bot-audit-trail-search { + height: 31px; + margin: 6px 9px 0 0px; + } + + .ui-grid-column-menu-button { + display: none; } } + +/*global css*/ +.ui-grid .ui-grid-row { + border-bottom: 1px solid #ccc; +} \ No newline at end of file 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..f8aa58063 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,55 @@ { name: 'Env',field:'masterDetails.envName'}, { name: 'User',field:'user'}, { name: 'Logs',cellTemplate: ''} - ], - data:[] + ] + $scope.botAuditTrailGridOptions.data=[]; + angular.extend($scope.botAuditTrailGridOptions,botAuditTrailUIGridDefaults.gridOption); }; - var gridBottomSpace = 40; + $scope.initGrids(); + + var gridBottomSpace = 80; $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(); + }); + }, + }); + + $scope.searchBotAuditTrailName = function() { + $scope.searchString = $scope.botAuditTrailSearch; + $scope.botAuditTrailGridOptions.data=[]; + var param={ + url:'/audit-trail?filterBy=auditType:BOTs&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString + }; + genSevs.promiseGet(param).then(function (result) { + console.log(result); + $timeout(function() { + $scope.botAuditTrailGridOptions.totalItems = result.metaData.totalRecords; + $scope.botAuditTrailGridOptions.data=result.auditTrails; + }, 100); + $scope.isBotAuditTrailPageLoading = false; + }, function(error) { + $scope.isBotAuditTrailPageLoading = false; + toastr.error(error); + $scope.errorMessage = "No Records found"; + }); + }; + $scope.botAuditTrailLogs=function(hist) { var modalInstance = $modal.open({ animation: true, @@ -69,20 +114,27 @@ }; $scope.RefreshBotsAuditTrail = function() { - audit.init(); + $scope.botAuditTrailGridView(); + $scope.botAuditTrailSearch = ''; }; - 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; + toastr.error(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/botChefLogCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/botChefLogCtrl.js new file mode 100644 index 000000000..f92b18c22 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/botChefLogCtrl.js @@ -0,0 +1,160 @@ +/* Copyright (C) Relevance Lab Private Limited- All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Relevance UI Team, + * Aug 2015 + */ + +(function (angular) { + "use strict"; + angular.module('dashboard.bots') + .controller('botChefLogCtrl', ['$q', '$scope', 'workzoneServices', '$timeout', 'orchestrationSetting', 'toastr','genericServices', function ($q, $scope, workzoneServices, $timeout, orchestrationSetting, toastr,genSevs) { + /*This controller can be invoked from either of two flows - Chef Log History Item Logs OR Chef Task Execute + items object will contain only taskId and historyId. */ + var items = $scope.parentItemDetail; + + $scope.isInstanceListLoading = true; + angular.extend($scope, { + logListInitial: [], + logListDelta: [], + cancel: function () { + helper.stopPolling(); + } + }); + // broadcast the cancel function to the parent controller + $scope.$on('closeWindow', function() { + $scope.$parent.close = $scope.cancel(); + }); + var chefLogData = { + chefHistoryItem: {}, + nodeIdsWithActionLog: {} + }; + var timerObject; + var helper = { + lastTimeStamp: '', + getlastTimeStamp: function (logObj) { + if (logObj instanceof Array && logObj.length) { + var lastTime = logObj[logObj.length - 1].timestamp; + return lastTime; + } + }, + scrollBottom : function () { + $timeout(function () { + var elm = angular.element(".logsArea"); + elm.scrollTop(elm[0].scrollHeight); + }, 100); + }, + logsPolling: function () { + timerObject = $timeout(function () { + workzoneServices.getChefJobLogs($scope.selectedInstance.nodeId, $scope.selectedInstance.actionLogId, helper.lastTimeStamp).then(function (resp) { + if (resp.data.length) { + var logData = { + logs: resp.data, + fullLogs: false + }; + helper.lastTimeStamp = helper.getlastTimeStamp(logData.logs); + $scope.logListDelta.push.apply($scope.logListDelta, logData.logs); + helper.scrollBottom(); + } + helper.logsPolling(); + }); + }, orchestrationSetting.orchestrationLogsPollerInterval); + }, + stopPolling: function () { + $timeout.cancel(timerObject); + } + }; + var selectFirstInstance = function (firstInstance) { + $scope.selectedInstance = firstInstance; + chefLogData.instanceChange(); + }; + var resetAll = function(){ + $scope.isInstanceListLoading = true; + chefLogData.chefHistoryItem = {}; + chefLogData.nodeIdsWithActionLog = {}; + helper.stopPolling(); //Ensuring polling is stopped, eventhough the scope values for instance id and actionlog id are updated on change + helper.lastTimeStamp = ''; + }; + var init = function () { + //get the details of one chef history entry + var param = { + url : '/bots/' + items.taskId + '/bots-history/' + items.historyId + } + genSevs.promiseGet(param).then(function (response) { + chefLogData.createInstanceList(response); + }); + }; + chefLogData.createInstanceList = function (historyItem) { + var nodeIds =historyItem.nodeIds ? historyItem.nodeIds : historyItem.auditTrailConfig.nodeIds ; + var nodeIdWithActionLogs = []; + var requestObj = { + "instanceIds": nodeIds + }; + workzoneServices.postRetrieveDetailsForInstanceNames(requestObj).then(function (response) { + var _jobInstances = response.data; + var nodeIdsWithActionId = historyItem.nodeIdsWithActionLog ? historyItem.nodeIdsWithActionLog : historyItem.auditTrailConfig.nodeIdsWithActionLog; + for (var k = 0; k < nodeIdsWithActionId.length; k++) { + for (var l = 0; l < _jobInstances.length; l++) { + if (nodeIdsWithActionId[k].nodeId === _jobInstances[l]._id) { + nodeIdsWithActionId[k].uiNodeName = _jobInstances[l].name; + } + } + } + nodeIdWithActionLogs = nodeIdsWithActionId; + chefLogData.chefHistoryItem = historyItem; //saved as we need timestamps from the historyItem + chefLogData.nodeIdsWithActionLog = nodeIdWithActionLogs; //this can now be used to show instance dropdown + if (chefLogData.nodeIdsWithActionLog[0]) { + $scope.isInstanceListLoading = false; + selectFirstInstance(chefLogData.nodeIdsWithActionLog[0]); + } + }, function (error) { + $scope.isInstanceListLoading = false; + toastr.error(error); + $scope.errorMessage = ""; + }) + }; + chefLogData.instanceChange = function () { + $scope.isLogsLoading = true; + helper.stopPolling(); //Ensuring polling is stopped, eventhough the scope values for instance id and actionlog id are updated on change + helper.lastTimeStamp = ''; + if (chefLogData.chefHistoryItem.startedOn && chefLogData.chefHistoryItem.endedOn) { + var urlParams = ''; + urlParams = 'timestamp=' + chefLogData.chefHistoryItem.startedOn + '×tampEnded=' + chefLogData.chefHistoryItem.endedOn; + var param = { + url : "/instances/" + $scope.selectedInstance.nodeId + '/actionLogs/' + $scope.selectedInstance.actionLogId + + '/logs?' + urlParams + } + genSevs.promiseGet(param).then(function (response) { + $scope.isLogsLoading = false; + var logData = { + logs: response, + fullLogs: true + }; + $scope.logListInitial = logData.logs; + helper.scrollBottom(); + }); + + } else if (chefLogData.chefHistoryItem.startedOn && !chefLogData.chefHistoryItem.endedOn) { + var urlParams = 'timestamp=' + chefLogData.chefHistoryItem.startedOn; + var param = { + url : "/instances/" + $scope.selectedInstance.nodeId + '/actionLogs/' + $scope.selectedInstance.actionLogId + + '/logs?' + urlParams + } + genSevs.promiseGet(param).then(function (response) { + $scope.isLogsLoading = false; + helper.lastTimeStamp = helper.getlastTimeStamp(response) || chefLogData.chefHistoryItem.startedOn; + helper.logsPolling(); + var logData = { + logs: response, + fullLogs: true + }; + $scope.logListInitial = logData.logs; + helper.scrollBottom(); + }); + } + }; + init(); + return chefLogData; + } + ]); +})(angular); \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/botExecutionLogsCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/botExecutionLogsCtrl.js new file mode 100644 index 000000000..c59de9054 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/botExecutionLogsCtrl.js @@ -0,0 +1,23 @@ +/* Copyright (C) Relevance Lab Private Limited- All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Relevance UI Team, + * Aug 2015 + */ + +(function (angular) { + "use strict"; + angular.module('dashboard.bots') + .controller('botExecutionLogsCtrl', ['$q', '$scope', '$timeout', 'items','$modalInstance', function ($q, $scope, $timeout, items,$modalInstance) { + $scope.parentItemDetail=items; + var botExecLogCtrl={}; + botExecLogCtrl.taskLogType=items.taskType; + botExecLogCtrl.cancelAll=function(){ + $scope.$broadcast ('closeWindow'); + $modalInstance.dismiss('cancel'); + return $scope.close; + }; + return botExecLogCtrl; + } + ]); +})(angular); 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 29be3d631..1f938fed8 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js @@ -8,9 +8,9 @@ (function (angular) { "use strict"; angular.module('library.params', []) - .controller('editParamsCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', 'responseFormatter', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, responseFormatter) { - $scope.botName = items.name; - $scope.taskType = items.taskType; + .controller('editParamsCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', 'responseFormatter', '$modal', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, responseFormatter, $modal) { + $scope.botName = items.botName; + $scope.taskType = items.botLinkedSubCategory; $scope.taggingServerList=[]; $scope.envOptions=[]; workzoneServices.getTaggingServer().then(function (topSer) { @@ -18,23 +18,29 @@ }); $scope.chefAttributesFlag = false; $scope.scriptParamsFlag = false; - if(items.taskConfig.runlist && items.taskConfig.runlist.length) { + if(items.botConfig && items.botConfig.runlist && items.botConfig.runlist.length) { $scope.chefAttributesFlag = true; } - if(items.taskType === 'script') { - for (var i=0; i 0) { + if(items.botLinkedSubCategory === 'script' && items.botConfig) { + for (var i=0; i 0) { $scope.scriptParamsFlag = true; } } } $scope.isChefattributesLoading = true; - if (items.taskType === 'chef') { - $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(items.taskConfig.runlist); + + $scope.totalCount = 0; + $scope.countInit = function() { + return $scope.totalCount++; + } + + if (items.botLinkedSubCategory === 'chef') { + $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(items.botConfig.runlist); var nodesList = responseFormatter.chefRunlistFormatter($scope.chefComponentSelectorList); $scope.chefattributes = []; - $scope.chefattributes = responseFormatter.formatSavedCookbookAttributes(items.taskConfig.attributes); - workzoneServices.getCookBookListForOrg(items.orgId).then(function(data){ + $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") { @@ -61,56 +67,71 @@ } } $scope.chefattributes = data; + $scope.cookbookAttributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes); $scope.isChefattributesLoading = false; }); }); } }); } - - $scope.jenkinsparams = items.taskConfig.parameterized; - $scope.scriptparams = items.taskConfig.scriptDetails; + 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 = {}; - $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'); + 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 + }; + } + } + }); } }; $scope.executeBot=function(){ - if (items.taskConfig.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 (items.botConfig && items.botConfig.taskType === 'script') { + /*for(var i = 0; i < $scope.scriptparams.length; i++){ + var scriptObj = {}; + var scriptParamList = []; + if($scope.scriptparams[i].scriptParameters.length > 0){ + for(var j = 0; j<$scope.scriptparams[i].scriptParameters.length;j++){ + scriptParamList.push($scope.scriptparams[i].scriptParameters[j].paramVal); + } + if($scope.scriptparams[i].scriptParameters.length === scriptParamList.length){ + scriptObj[$scope.scriptparams[i].scriptId] = scriptParamList; + scriptParams.push(scriptObj); } + }else{ + scriptObj[$scope.scriptparams[i].scriptId] = []; + scriptParams.push(scriptObj); } - } - if(checkParam){ - scriptParams = $scope.parameters; - } + }*/ + + scriptParams = $scope.scriptparams; } - if (items.taskConfig.taskType === 'chef') { + if (items.botConfig && items.botConfig.taskType === 'chef') { cookbookAttributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes); } - if (items.taskConfig.taskType === 'jenkins') { + if (items.botConfig && items.botConfig.taskType === 'jenkins') { choiceParam = $scope.jenparams; } $scope.executeTask(); @@ -118,26 +139,30 @@ $scope.executeTask = function(){ var reqBody = {}; - if (items.taskConfig.taskType === 'jenkins') { + if (items.botConfig && items.botConfig.taskType === 'jenkins') { reqBody.choiceParam = choiceParam; - } else if (items.taskConfig.taskType === 'chef'){ + } else if (items.botConfig && items.botConfig.taskType === 'chef'){ reqBody.tagServer = $scope.tagSerSelected; if ($scope.chefAttributesFlag) { reqBody.cookbookAttributes = cookbookAttributes; } - } else if (items.taskConfig.taskType === 'script') { + } else if (items.botConfig && items.botConfig.taskType === 'script') { reqBody.tagServer = $scope.tagSerSelected; if ($scope.scriptParamsFlag) { reqBody.scriptParams = scriptParams; } } - workzoneServices.runTask(items._id, reqBody).then( - function (response) { - $modalInstance.close(response.data); - $rootScope.$emit('BOTS_LIBRARY_REFRESH'); - $rootScope.$emit('WZ_ORCHESTRATION_REFRESH_CURRENT'); - }, - function (error) { + var param={ + url:'/bots/' + items.botId + '/execute', + data: reqBody + }; + genSevs.promisePost(param).then(function (response) { + $modalInstance.close(response.data); + $rootScope.$emit('BOTS_LIBRARY_REFRESH'); + helper.botLogModal(items.botId, response.historyId, response.taskType); + }, + function (error) { + if(error) { error = error.responseText || error; if (error.message) { toastr.error(error.message); @@ -145,7 +170,7 @@ toastr.error(error); } } - ); + }); }; $scope.cancel= function() { diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/jenkinsLogCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/jenkinsLogCtrl.js new file mode 100644 index 000000000..de0df9032 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/jenkinsLogCtrl.js @@ -0,0 +1,94 @@ +/* Copyright (C) Relevance Lab Private Limited- All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Relevance UI Team, + * Aug 2015 + */ + +(function(angular) { + "use strict"; + angular.module('dashboard.bots') + /*.service('orchestrationSetting', [function() { + return { + orchestrationLogsPollerInterval: 5000 + }; + }])*/ + .controller('jenkinsLogCtrl', ['$scope', 'workzoneServices', '$interval', 'orchestrationSetting', '$controller','$timeout', function($scope, workzoneServices, $interval, orchestrationSetting, $controller,$timeout) { + var items = $scope.parentItemDetail; + $scope.getJenkinsHistoryDetails = {}; + angular.extend($scope, { + logs: {}, + timerObject: '', + cancel: function() { + helper.stopPolling(); + } + }); + var resetAll = function(){ + $scope.getJenkinsHistoryDetails = {}; + helper.stopPolling(); + }; + var init = function(){ + workzoneServices.getTaskHistoryItem(items.taskId, items.historyId).then(function(response) { + $scope.getJenkinsHistoryDetails = response.data; //to store the response so that the jenkinsServerID,jobName and buildNumber can be passed to fetch the logs. + $scope.getJenkinsLogDetails(response.data); + }); + }; + var helper = { + eventsPolling: function() { + $scope.timerObject = $interval(function() { + workzoneServices.getJenkinsLogs($scope.getJenkinsHistoryDetails.jenkinsServerId, $scope.getJenkinsHistoryDetails.jobName, $scope.getJenkinsHistoryDetails.buildNumber) + .then(function(response) { + if (response.data) { + $scope.logs.output = helper.formatLogs(response.data.output); + } else { + $scope.logs.output = helper.formatLogs(response.output); + } + + }, function(error) { + $scope.logs = error.data.message; + }); + }, orchestrationSetting.orchestrationLogsPollerInterval); + }, + stopPolling: function() { + $interval.cancel($scope.timerObject); + }, + formatLogs: function(str) { + return str.replace(/\r?\n/g, "
    "); + } + }; + $scope.getJenkinsLogDetails = function(historyItem) { + $scope.isJenkinsLogLoading = true; + $timeout(function(){ + workzoneServices.getJenkinsLogs(historyItem.jenkinsServerId, historyItem.jobName, historyItem.buildNumber).then(function(response) { + $scope.isJenkinsLogLoading = false; + if (response.data) { + $scope.logs.output = helper.formatLogs(response.data.output); + } else { + $scope.logs.output = helper.formatLogs(response.output); + } + helper.eventsPolling(); + + }, function(error) { + $scope.isJenkinsLogLoading = false; + $scope.logs = error.data.message; + //removed the error helper method as it was failing. Need to test this part again. + }); + }, 10000); + }; + init(); + // on task change event in the parent controller + $scope.$on('parentChangeCompTask', function (event, args) { + items = args; + resetAll(); + init(); + }); + $scope.$on('$destroy', function() { + $interval.cancel($scope.timerObject); + }); + // broadcast the cancel function to the parent controller + $scope.$on('closeWindow', function() { + $scope.$parent.close = $scope.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 3b622b85a..cec610bc3 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -8,52 +8,154 @@ (function (angular) { "use strict"; angular.module('dashboard.bots') - .controller('libraryCtrl',['$scope', '$rootScope', '$state', 'genericServices', 'confirmbox', 'toastr', 'workzoneUIUtils', '$modal', function ($scope, $rootScope, $state, genSevs, confirmbox, toastr, workzoneUIUtils, $modal) { + .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; - lib.gridOptions={ - gridOption:{ - paginationPageSizes: [10, 25, 50, 75], - paginationPageSize: 10, - enableColumnMenus:false, - multiSelect :false, - }, - columnDefs: [ - { name:'Task Type', field:'taskType' ,cellTemplate:'row.entity.taskType'+ - 'row.entity.taskType'+ - 'row.entity.taskType'+ - 'row.entity.botType',cellTooltip: true}, - { name: 'BOT Type',displayName: 'BOT Type',field:'botType',cellTooltip: true}, - { name: 'BOT Name',displayName: 'BOT Name',field:'name',cellTooltip: 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:'shortDesc',cellTooltip: true}, + { name: 'description',field:'botDesc',cellTooltip: true}, + { name: 'Organization',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 Action',width:200,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(); + } + }); + //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 + }; + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + $scope.isBotLibraryPageLoading = false; + }, function(error) { + $scope.isBotLibraryPageLoading = false; + toastr.error(error); + $scope.errorMessage = "No Records found"; + }); + }; + $scope.botLibraryGridView(); + $scope.searchBotNameCategory = function() { + $scope.searchString = $scope.botLibrarySearch; + lib.gridOptions=[]; + if($scope.totalBotsSelected) { + var param={ + 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?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 } - ], - data:[] + }; + genSevs.promiseGet(param).then(function (result) { + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + $scope.isBotLibraryPageLoading = false; + }, function(error) { + $scope.isBotLibraryPageLoading = false; + toastr.error(error); + $scope.errorMessage = "No Records found"; + }); }; - var gridBottomSpace = 250; + var gridBottomSpace = 265; $scope.gridHeight = workzoneUIUtils.makeTabScrollable('botLibraryPage') - gridBottomSpace; $scope.launchInstance = function(launch){ - if(launch.launcType === 'task'){ + if(launch.botLinkedCategory === 'Task'){ genSevs.executeTask(launch); - } else if(launch.launcType === 'bp') { - genSevs.lunchBlueprint(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({ @@ -74,7 +176,8 @@ console.log('Modal Dismissed at ' + new Date()); }); }; - $scope.botSchedule = function() { + + $scope.botSchedule = function(bot) { $modal.open({ templateUrl: 'src/partials/sections/dashboard/bots/view/botSchedule.html', controller: 'botScheduleCtrl', @@ -82,39 +185,17 @@ keyboard: false, resolve: { items: function () { - return { - chefJenkScriptTaskObj:$scope.chefJenkScriptTaskObj, - type:$scope.type - } + 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; + }).result.then(function () { - $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.deleteBotTask = function(task) { + + $scope.deleteBot = function(bot) { var modalOptions = { closeButtonText: 'Cancel', actionButtonText: 'Delete', @@ -124,52 +205,23 @@ }; confirmbox.showModal({}, modalOptions).then(function() { var param={ - url:'/tasks/serviceDelivery/' + task._id + url:'/bots/' + bot.botId }; genSevs.promiseDelete(param).then(function (response) { if (response) { toastr.success('Successfully deleted'); - if($scope.totalBotsSelected) { - lib.init(); - } else if($scope.runningBotsselected) { - $scope.showBotsRunning(); - } else if($scope.failedBotsselected) { - $scope.showFailedBots(); - } else { - lib.init(); - } lib.summary(); - } - }, function(data) { - toastr.error('error:: ' + data.toString()); - }); - }); - }; - $scope.deleteBotBP = function(blueprint) { - 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:'/blueprints/serviceDelivery/' + blueprint._id - }; - genSevs.promiseDelete(param).then(function (response) { - if (response) { - toastr.success('Successfully deleted'); if($scope.totalBotsSelected) { - lib.init(); + $scope.botLibraryGridView(); } else if($scope.runningBotsselected) { $scope.showBotsRunning(); + } else if($scope.scheduledBotsSelected) { + $scope.showScheduledBots(); } else if($scope.failedBotsselected) { $scope.showFailedBots(); } else { - lib.init(); + $scope.botLibraryGridView(); } - lib.summary(); } }, function(data) { toastr.error('error:: ' + data.toString()); @@ -178,27 +230,45 @@ }; $rootScope.$on('BOTS_LIBRARY_REFRESH', function() { lib.summary(); - lib.init(); + $scope.botLibraryGridView(); }); $scope.RefreshBotsLibrary = function() { + $scope.botLibrarySearch = ''; + lib.summary(); + if($scope.totalBotsSelected) { + $scope.botLibraryGridView(); + } else if($scope.runningBotsselected) { + $scope.showBotsRunning(); + } else if($scope.scheduledBotsSelected) { + $scope.showScheduledBots(); + } else if($scope.failedBotsselected) { + $scope.showFailedBots(); + } else { + $scope.botLibraryGridView(); + } + }; + $scope.showAllBots = function() { $scope.totalBotsSelected = true; $scope.runningBotsselected = false; $scope.failedBotsselected = false; + $scope.scheduledBotsSelected = false; lib.summary(); - lib.init(); + $scope.botLibraryGridView(); }; $scope.showBotsRunning = function() { $scope.runningBotsselected = true; $scope.totalBotsSelected = false; $scope.failedBotsselected = false; + $scope.scheduledBotsSelected = false; lib.gridOptions.data=[]; var param={ - url:'/tasks?serviceDeliveryCheck=true&actionStatus=running' + url:'/bots?actionStatus=running&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (result) { - angular.forEach(result,function (val) { - lib.gridOptions.data.push(val); - }); + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); }); lib.summary(); }; @@ -206,14 +276,33 @@ $scope.failedBotsselected = true; $scope.runningBotsselected = false; $scope.totalBotsSelected = false; + $scope.scheduledBotsSelected = false; lib.gridOptions.data=[]; var param={ - url:'/tasks?serviceDeliveryCheck=true&actionStatus=failed' + 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) { - angular.forEach(result,function (val) { - lib.gridOptions.data.push(val); - }); + $timeout(function() { + $scope.botLibGridOptions.totalItems = result.metaData.totalRecords; + $scope.botLibGridOptions.data=result.bots; + }, 100); + }); + lib.summary(); + }; + $scope.showScheduledBots = function() { + $scope.failedBotsselected = false; + $scope.runningBotsselected = false; + $scope.totalBotsSelected = false; + $scope.scheduledBotsSelected = true; + lib.gridOptions.data=[]; + var param={ + url:'/bots?filterBy=isBotScheduled:true&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(); }; @@ -228,74 +317,63 @@ }); }; lib.summary(); - lib.init =function(){ - lib.gridOptions.data=[]; - var param={ - url:'/blueprints?serviceDeliveryCheck=true' - }; - genSevs.promiseGet(param).then(function (result) { - angular.forEach(result,function (val) { - angular.extend(val,{launcType:'bp'}); - lib.gridOptions.data.push(val); - }); - }); - var param2={ - url:'/tasks?serviceDeliveryCheck=true' - }; - genSevs.promiseGet(param2).then(function (resultTask) { - angular.forEach(resultTask,function (val) { - angular.extend(val,{launcType:'task'}); - lib.gridOptions.data.push(val); - }); - }); - }; - lib.init(); }]).controller('botInfoCtrl',['$scope', 'items', '$modalInstance', function ($scope, items, $modalInstance) { $scope.botInfo = items; - console.log(items); $scope.cancel= function() { $modalInstance.dismiss('cancel'); }; }]).controller('botScheduleCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', '$timeout', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, $timeout) { - console.log(items); + if(items.isBotScheduled === true){ + $scope._isEventSelected = true; + $scope.isScheduled = true; + }else{ + $scope._isEventSelected = false; + $scope.isScheduled = false; + } + $scope.scheduleDeatils = items; + $scope.botId = items.botId; $scope.defaultSelection = function() { $scope.repeatsType = 'Minutes';//default selection. $scope.schedulerStartOn=moment(new Date()).format('MM/DD/YYYY'); $scope.schedulerEndOn=moment(new Date()).format('MM/DD/YYYY'); }; - if(items.type !== 'new'){ - if(items.chefJenkScriptTaskObj !==undefined){ - if(items.chefJenkScriptTaskObj.cronStartOn && items.chefJenkScriptTaskObj.cronEndOn) { - var newStartOn = parseInt(items.chefJenkScriptTaskObj.cronStartOn); - var newDate = new Date(newStartOn).toLocaleDateString(); - var datearray = newDate.split("/"); - var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2]; - $scope.schedulerStartOn = newdate; - var newEndOn = parseInt(items.chefJenkScriptTaskObj.cronEndOn); - 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.repeatBy = items.chefJenkScriptTaskObj.repeatBy || items.chefJenkScriptTaskObj.cronRepeatEvery.toString(); - $scope.repeatsType = items.chefJenkScriptTaskObj.repeats || items.chefJenkScriptTaskObj.cronFrequency; - $scope.timeEventType = items.chefJenkScriptTaskObj.startTime; - $scope.timeEventMinute = items.chefJenkScriptTaskObj.startTimeMinute; - $scope.weekOfTheDay = items.chefJenkScriptTaskObj.dayOfWeek; - $scope.currentDate = items.chefJenkScriptTaskObj.startDate; - $scope.selectedDayOfTheMonth = items.chefJenkScriptTaskObj.selectedDayOfTheMonth; - $scope.selectedMonth = items.chefJenkScriptTaskObj.monthOfYear; + $scope.selectBotCheckbox = function(){ + if($scope.isScheduled === true || $scope.isScheduled === 'true') { + $scope._isEventSelected = true; + }else{ + $scope._isEventSelected = false; + } + } + if(items.botScheduler){ + if(items.botScheduler.cronStartOn && items.botScheduler.cronEndOn) { + var newStartOn = parseInt(items.botScheduler.cronStartOn); + var newDate = new Date(newStartOn).toLocaleDateString(); + var datearray = newDate.split("/"); + var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2]; + $scope.schedulerStartOn = newdate; + var newEndOn = parseInt(items.botScheduler.cronEndOn); + var newEndData = new Date(newEndOn).toLocaleDateString(); + var datearrayNew = newEndData.split("/"); + var newdateEnd = datearrayNew[1] + '/' + datearrayNew[0] + '/' + datearrayNew[2]; + $scope.schedulerEndOn = newdateEnd; } else { - $scope.defaultSelection(); + $scope.schedulerStartOn = items.botScheduler.cronStartOn; + $scope.schedulerEndOn = items.botScheduler.cronEndOn; } + + $scope.repeatBy = items.botScheduler.repeatBy || items.botScheduler.cronRepeatEvery.toString(); + $scope.repeatsType = items.botScheduler.repeats || items.botScheduler.cronFrequency; + $scope.timeEventType = items.botScheduler.timeEventHour || (items.botScheduler.cronHour && items.botScheduler.cronHour !==null) ? items.botScheduler.cronHour.toString() : ''; + $scope.timeEventMinute = items.botScheduler.timeEventMinute || (items.botScheduler.cronMinute && items.botScheduler.cronMinute !==null) ? items.botScheduler.cronMinute.toString() : ''; + $scope.weekOfTheDay = items.botScheduler.weekOfTheDay || (items.botScheduler.cronWeekDay && items.botScheduler.cronWeekDay !==null) ?items.botScheduler.cronWeekDay.toString(): ''; + $scope.selectedDayOfTheMonth = items.botScheduler.selectedDayOfTheMonth || (items.botScheduler.cronDate && items.botScheduler.cronDate !==null) ?items.botScheduler.cronDate.toString() : ''; + $scope.selectedMonth = items.botScheduler.selectedMonth || (items.botScheduler.cronMonth && items.botScheduler.cronMonth !==null) ? items.botScheduler.cronMonth.toString() : ''; + /*$scope.currentDate = items.botScheduler.startDate;*/ } else { $scope.defaultSelection(); } + $scope.dateChange= function () { var startDate = Date.parse($scope.schedulerStartOn); @@ -305,7 +383,7 @@ } else { $scope.validDateRange=false; } - + }; $scope.repeatCount = function(max, step) { @@ -319,30 +397,401 @@ $scope.isDaySelected = { flag:true } - + $scope.daysOfWeek = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]; $scope.monthOfYear = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; - $scope.cancel = function() { - $modalInstance.dismiss('cancel'); - }; + $scope.ok=function(){ $scope.eventParams = { - repeats: $scope.repeatsType, - repeatBy: $scope.repeatBy, - cronStart: $scope.schedulerStartOn, - cronEnd: $scope.schedulerEndOn, - startTime: $scope.timeEventType, - startTimeMinute: $scope.timeEventMinute, - dayOfWeek: $scope.weekOfTheDay, - selectedDayOfTheMonth: $scope.selectedDayOfTheMonth, - monthOfYear: $scope.selectedMonth + cronFrequency: $scope.repeatsType, + cronRepeatEvery: $scope.repeatBy, + cronStartOn: $scope.schedulerStartOn, + cronEndOn: $scope.schedulerEndOn, + cronHour: $scope.timeEventType, + cronMinute: $scope.timeEventMinute, + cronWeekDay: $scope.weekOfTheDay, + cronDate: $scope.selectedDayOfTheMonth, + cronMonth: $scope.selectedMonth }; - $modalInstance.close($scope.eventParams); + var reqBody = null; + if($scope.isScheduled === true || $scope.isScheduled === 'true'){ + reqBody = { + botScheduler:$scope.eventParams, + isBotScheduled:true + } + }else{ + reqBody = { + botScheduler:{}, + isBotScheduled:false + } + } + var param={ + url:'/bots/' + $scope.botId + '/scheduler', + data: reqBody + }; + genSevs.promisePut(param).then(function (response) { + if(response){ + toastr.success('BOTs Scheduler successfully updated'); + $rootScope.$emit('BOTS_LIBRARY_REFRESH'); + $modalInstance.dismiss('cancel'); + } + }); }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; - }]); + }]).controller('botHistoryCtrl',["items", '$scope', '$modalInstance', '$modal', '$timeout', 'uiGridOptionsClient', 'genericServices', 'workzoneServices', + function(items, $scope, $modalInstance, $modal, $timeout, uiGridOptionsClient, genSevs, workzoneServices){ + //UI Grid for chef Task starts + $scope.botHistory = items; + $scope.botId = items.botId; + $scope.taskHistoryChefData = []; + var gridOptionsChef = uiGridOptionsClient.options().gridOption; + $scope.taskHistoryChefGridOptions = gridOptionsChef; + + $scope.initChefGrids = function(){ + $scope.taskHistoryChefGridOptions.data='taskHistoryChefData'; + $scope.taskHistoryChefGridOptions.columnDefs = [ + { name:'Status',field:'status',cellTemplate:'
    {{row.entity.status}}
    ', cellTooltip: true}, + { name:'User',field:'user',cellTooltip: true}, + { name:'Logs',width: 70, + cellTemplate:'
    '}, + { name:'Start Time',field:'startedOn',cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}', sort:{ direction: 'desc'}, cellTooltip: true}, + { name:'End Time',field:'timestampEnded',cellTemplate:'{{row.entity.endedOn | timestampToLocaleTime}}', cellTooltip: true}, + { name:'Execution Time',cellTemplate:'{{grid.appScope.getExecutionTime(row.entity.endedOn,row.entity.startedOn)}} mins'}, + { name:'Manual Time',cellTemplate: '{{row.entity.auditTrailConfig.manualExecutionTime}} mins', cellTooltip: true}, + { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + + 'NA', cellTooltip: true} + ]; + }; + angular.extend($scope, { + taskHistoryChefListView: function() { + $scope.taskHistoryChefData = []; + var param={ + url:'/bots/' + $scope.botId + '/bots-history' + }; + genSevs.promiseGet(param).then(function (response) { + $timeout(function() { + if(response.botHistory){ + $scope.taskHistoryChefData = response.botHistory; + $scope.ischefTaskHistoryPageLoading = false; + }else if(response){ + $scope.taskHistoryChefData = response; + $scope.ischefTaskHistoryPageLoading = false; + } + },100); + }, function(){ + $scope.errorMessage = "No Chef History Records found"; + $scope.ischefTaskHistoryPageLoading = false; + }); + }, + getExecutionTime: function(endTime, startTime) { + $scope.executionTimeinMS = endTime-startTime; + $scope.executionTime = $scope.executionTimeinMS/(60000); + return +(Math.round($scope.executionTime + "e+1") + "e-1"); + }, + getSavedTime: function(endTime, startTime) { + var executionTime = $scope.getExecutionTime(endTime, startTime); + $scope.savedTime = items.manualExecutionTime-executionTime; + return $scope.savedTime; + } + }); + $scope.initchef = function(){ + $scope.initChefGrids(); + $scope.taskHistoryChefListView(); + $scope.getExecutionTime(); + $scope.getSavedTime(); + }; + //UI Grid for chef Task ends + + //UI Grid for jenkins Task starts + $scope.taskHistoryJenkinsData = []; + var gridOptionsJenkins = uiGridOptionsClient.options().gridOption; + $scope.taskHistoryJenkinsGridOptions = gridOptionsJenkins; + + $scope.initJenkinsGrids = function(){ + $scope.taskHistoryJenkinsGridOptions.data='taskHistoryJenkinsData'; + $scope.taskHistoryJenkinsGridOptions.columnDefs = [ + { name:'Job Number',field:'auditTrailConfig.jenkinsBuildNumber',cellTemplate:'{{row.entity.auditTrailConfig.jenkinsBuildNumber}}', sort:{ direction: 'desc'}, cellTooltip: true}, + { name:'Job Output',cellTemplate:'',cellTooltip: true}, + { name:'Log Info',width: 90,cellTemplate:'',cellTooltip: true}, + { name:'Status',field:'status',cellTemplate:'
    {{row.entity.status.toUpperCase()}}
    '}, + { name:'Start Time',field:'startedOn',cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}',cellTooltip: true}, + { name:'End Time',field:'endedOn',cellTemplate:'{{row.entity.endedOn | timestampToLocaleTime}}',cellTooltip: true}, + { name:'Execution Time',cellTemplate:'{{grid.appScope.getExecutionTime(row.entity.endedOn,row.entity.startedOn)}} mins'}, + { name:'Manual Time',cellTemplate: '{{row.entity.auditTrailConfig.manualExecutionTime}} mins', cellTooltip: true}, + { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + + 'NA', cellTooltip: true} + ]; + }; + angular.extend($scope, { + taskHistoryJenkinsListView: function() { + $scope.taskHistoryJenkinsData = []; + var param={ + url:'/bots/' + $scope.botId + '/bots-history' + }; + genSevs.promiseGet(param).then(function (response) { + $timeout(function() { + if(response.botHistory){ + $scope.taskHistoryJenkinsData = response.botHistory; + $scope.isjenkinsTaskHistoryPageLoading = false; + }else if(response){ + $scope.taskHistoryJenkinsData = response; + console.log($scope.taskHistoryJenkinsData); + $scope.isjenkinsTaskHistoryPageLoading = false; + } + },100); + }, function(){ + $scope.errorMessage = "No Jenkins History Records found"; + $scope.isjenkinsTaskHistoryPageLoading = false; + }); + }, + }); + $scope.initjenkins = function(){ + $scope.initJenkinsGrids(); + $scope.taskHistoryJenkinsListView(); + $scope.getExecutionTime(); + $scope.getSavedTime(); + }; + //UI Grid for jenkins Task ends + + //UI Grid for script Task starts + $scope.taskHistoryScriptData = []; + var gridOptionsScript = uiGridOptionsClient.options().gridOption; + $scope.taskHistoryScriptGridOptions = gridOptionsScript; + + $scope.initScriptGrids = function(){ + $scope.taskHistoryScriptGridOptions.data='taskHistoryScriptData'; + $scope.taskHistoryScriptGridOptions.columnDefs = [ + { name:'Status',field:'status',cellTemplate:'
    {{row.entity.status}}
    ', cellTooltip: true}, + { name:'User',field:'user',cellTooltip: true}, + { name:'Logs',width: 70, + cellTemplate:'
    '}, + { name:'Start Time',field:'startedOn',cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}', sort:{ direction: 'desc'}, cellTooltip: true}, + { name:'End Time',field:'endedOn',cellTemplate:'{{row.entity.endedOn | timestampToLocaleTime}}', cellTooltip: true}, + { name:'Execution Time',cellTemplate:'{{grid.appScope.getExecutionTime(row.entity.endedOn,row.entity.startedOn)}} mins'}, + { name:'Manual Time',cellTemplate: '{{row.entity.auditTrailConfig.manualExecutionTime}} mins', cellTooltip: true}, + { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + + 'NA', cellTooltip: true} + ]; + }; + angular.extend($scope, { + taskHistoryScriptListView: function() { + $scope.taskHistoryScriptData = []; + var param={ + url:'/bots/' + $scope.botId + '/bots-history' + }; + genSevs.promiseGet(param).then(function (response) { + $timeout(function() { + if(response.botHistory){ + $scope.taskHistoryScriptData = response.botHistory; + $scope.isscriptTaskHistoryPageLoading = false; + }else if(response){ + $scope.taskHistoryScriptData = response; + $scope.isscriptTaskHistoryPageLoading = false; + } + },100); + }, function(){ + $scope.errorMessage = "No Script History Records found"; + $scope.isscriptTaskHistoryPageLoading = false; + }); + }, + }); + $scope.initscript = function(){ + $scope.initScriptGrids(); + $scope.taskHistoryScriptListView(); + $scope.getExecutionTime(); + $scope.getSavedTime(); + }; + //UI Grid for script Task ends + + //UI Grid for Blueprint starts + $scope.botHistoryBlueprintData = []; + var gridOptionsScript = uiGridOptionsClient.options().gridOption; + $scope.botHistoryBlueprintGridOptions = gridOptionsScript; + + $scope.initBlueprintGrids = function(){ + $scope.botHistoryBlueprintGridOptions.data='botHistoryBlueprintData'; + $scope.botHistoryBlueprintGridOptions.columnDefs = [ + { name:'Status',field:'status',cellTemplate:'
    {{row.entity.status}}
    ', cellTooltip: true}, + { name:'User',field:'user',cellTooltip: true}, + { name:'Logs',width: 70, + cellTemplate:'
    '}, + { name:'Start Time',field:'startedOn',cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}', sort:{ direction: 'desc'}, cellTooltip: true}, + { name:'End Time',field:'timestampEnded',cellTemplate:'{{row.entity.timestampEnded | timestampToLocaleTime}}', cellTooltip: true}, + { name:'Execution Time',cellTemplate:'{{grid.appScope.getExecutionTime(row.entity.endedOn,row.entity.startedOn)}} mins'}, + { name:'Manual Time',cellTemplate: '{{row.entity.auditTrailConfig.manualExecutionTime}} mins', cellTooltip: true}, + { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + + 'NA', cellTooltip: true} + ]; + }; + angular.extend($scope, { + botHistoryBlueprintListView: function() { + $scope.botHistoryBlueprintData = []; + var param={ + url:'/bots/' + $scope.botId + '/bots-history' + }; + genSevs.promiseGet(param).then(function (response) { + $timeout(function() { + if(response.botHistory){ + $scope.botHistoryBlueprintData = response.botHistory; + $scope.isBlueprintBotHistoryPageLoading = false; + }else if(response){ + $scope.botHistoryBlueprintData = response; + $scope.isBlueprintBotHistoryPageLoading = false; + } + },100); + }, function(){ + $scope.errorMessage = "No Script History Records found"; + $scope.isBlueprintBotHistoryPageLoading = false; + }); + }, + }); + $scope.initblueprint = function(){ + $scope.initBlueprintGrids(); + $scope.botHistoryBlueprintListView(); + $scope.getExecutionTime(); + $scope.getSavedTime(); + }; + //UI Grid for Blueprint ends + + $scope.bot=items; + switch ($scope.bot.botLinkedSubCategory){ + case 'chef' : + $scope.ischefTaskHistoryPageLoading = true; + $scope.isjenkinsTaskHistoryPageLoading = false; + $scope.isscriptTaskHistoryPageLoading = false; + $scope.isBlueprintBotHistoryPageLoading = false; + $scope.initchef(); + break; + case 'jenkins' : + $scope.ischefTaskHistoryPageLoading = false; + $scope.isjenkinsTaskHistoryPageLoading = true; + $scope.isscriptTaskHistoryPageLoading = false; + $scope.isBlueprintBotHistoryPageLoading = false; + $scope.initjenkins(); + break; + case 'script': + $scope.ischefTaskHistoryPageLoading = false; + $scope.isjenkinsTaskHistoryPageLoading = false; + $scope.isscriptTaskHistoryPageLoading = true; + $scope.isBlueprintBotHistoryPageLoading = false; + $scope.initscript(); + break; + case 'instance_launch': + case 'aws_cf': + case 'docker': + case 'azure_launch': + $scope.ischefTaskHistoryPageLoading = false; + $scope.isjenkinsTaskHistoryPageLoading = false; + $scope.isscriptTaskHistoryPageLoading = false; + $scope.isBlueprintBotHistoryPageLoading = true; + $scope.initblueprint(); + break; + } + + $scope.historyLogs=function(hist) { + console.log(hist); + if(hist.auditTrailConfig && (hist.auditTrailConfig.executionType == 'chef') || (hist.auditTrailConfig.executionType == 'jenkins') || (hist.auditTrailConfig.executionType == 'script')) { + var modalInstance = $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 : hist.auditId, + historyId : hist.auditHistoryId ? hist.auditHistoryId : hist.auditTrailConfig.nodeIdsWithActionLog[0] && hist.auditTrailConfig.nodeIdsWithActionLog[0].actionLogId, + taskType:hist.auditTrailConfig.executionType + }; + } + } + }); + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('Modal Dismissed at ' + new Date()); + }); + } else { + var modalInstance = $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/workzone/instance/popups/instanceLogs.html', + controller: 'cpActionHistoryLogCtrl', + backdrop : 'static', + keyboard: false, + resolve: { + items: function() { + return { + actionHistoryData : hist, + cpInstance: hist + }; + } + } + }); + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('Modal Dismissed at ' + new Date()); + }); + }; + } + + $scope.cancel= function() { + $modalInstance.dismiss('cancel'); + }; + } + ]).controller('confirmBotRunCtrl', ['$scope', '$modal', '$modalInstance', 'items', 'genericServices','toastr', '$rootScope', function ($scope, $modal, $modalInstance, items, genSevs, toastr, $rootScope) { + $scope.botId = items.botId; + $scope.isJobRunExecuting = false; + + 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 + }; + } + } + }); + } + }; + + $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) { + $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..ea1254eac 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,19 @@
    -
    -
    + + + +
    No data Available
    + +
    \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botExecutionLogs.html b/client/cat3/src/partials/sections/dashboard/bots/view/botExecutionLogs.html new file mode 100644 index 000000000..8a6fc9461 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botExecutionLogs.html @@ -0,0 +1,31 @@ +
    + + + + + +
    \ 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 new file mode 100644 index 000000000..0a23d5a2b --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html @@ -0,0 +1,43 @@ +
    + + + + + +
    \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botHistoryLogs.html b/client/cat3/src/partials/sections/dashboard/bots/view/botHistoryLogs.html new file mode 100644 index 000000000..6d38934e3 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botHistoryLogs.html @@ -0,0 +1,43 @@ +
    + + + + + +
    diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botInfo.html b/client/cat3/src/partials/sections/dashboard/bots/view/botInfo.html index a82e48010..36f44ca01 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botInfo.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botInfo.html @@ -2,94 +2,158 @@ diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html b/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html index 014c1901b..855fe5333 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html @@ -4,21 +4,34 @@ ×
    +