From a2d2366216f7aca4f9bde3e1d36d74122b1bd7d3 Mon Sep 17 00:00:00 2001 From: Divakar Konakalla Date: Wed, 23 Nov 2016 10:55:09 +0530 Subject: [PATCH 1/2] API integration for jenkins logs, added running bots in summary. --- .../dashboard/bots/controller/botLogsCtrl.js | 68 +++++++++++-------- .../sections/dashboard/bots/view/botLogs.html | 13 ++-- .../sections/dashboard/bots/view/library.html | 2 +- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js index 90a449629..1b74e6a96 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js @@ -10,11 +10,15 @@ angular.module('library.bots',[]) .controller('botLogsCtrl',['$scope', '$rootScope', '$http', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', '$timeout', function ($scope, $rootScope, $http, genSevs, workzoneServices, toastr, $modalInstance, items, $timeout) { $scope.actionId = items.hist.actionLogId; - $scope.botName = items.hist.name; + $scope.botName = items.hist.auditTrailConfig.name; $scope.nodeIds = items.hist.auditTrailConfig.nodeIds; $scope.taskType = items.hist.auditTrailConfig.executionType; $scope.nodeIdsWithActionLog = items.hist.auditTrailConfig.nodeIdsWithActionLog; $scope.isBotLogsLoading = true; + if($scope.taskType === 'jenkins') { + $scope.jenkinsActionLogId = items.hist.actionLogId; + $scope.jenkinsBuildNumber = items.hist.auditTrailConfig.jenkinsBuildNumber; + } var helper = { scrollBottom : function () { $timeout(function () { @@ -24,6 +28,9 @@ }, stopPolling: function () { $timeout.cancel(); + }, + formatLogs: function(str) { + return str.replace(/\r?\n/g, "
"); } }; $scope.instanceChange =function(){ @@ -35,35 +42,40 @@ }); }; - var nodeIds = $scope.nodeIds; - var requestObj = { - "instanceIds": nodeIds - }; - var bluePrintJob = false; - workzoneServices.postRetrieveDetailsForInstanceNames(requestObj).then(function (response) { - var _jobInstances = response.data; - //if blueprint job, use blueprintExecutionResults - for (var k = 0; k < $scope.nodeIdsWithActionLog.length; k++) { - for (var l = 0; l < _jobInstances.length; l++) { - if ($scope.nodeIdsWithActionLog[k].nodeId === _jobInstances[l]._id) { - $scope.nodeIdsWithActionLog[k].uiNodeName = _jobInstances[l].name; - console.log($scope.nodeIdsWithActionLog[k].uiNodeName); - } - } + var nodeIds = $scope.nodeIds; + var requestObj = { + "instanceIds": nodeIds + }; + var bluePrintJob = false; + workzoneServices.postRetrieveDetailsForInstanceNames(requestObj).then(function (response) { + var _jobInstances = response.data; + for (var k = 0; k < $scope.nodeIdsWithActionLog.length; k++) { + for (var l = 0; l < _jobInstances.length; l++) { + if ($scope.nodeIdsWithActionLog[k].nodeId === _jobInstances[l]._id) { + $scope.nodeIdsWithActionLog[k].uiNodeName = _jobInstances[l].name; + console.log($scope.nodeIdsWithActionLog[k].uiNodeName); } - $scope.selectedInstance = $scope.nodeIdsWithActionLog[0]; - $scope.instanceChange(); - /*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.isBotLogsLoading = false; - console.log(error); + } + } + $scope.selectedInstance = $scope.nodeIdsWithActionLog[0]; + $scope.instanceChange(); + }, + function (error) { + $scope.isBotLogsLoading = false; + console.log(error); + }); + if($scope.taskType === 'jenkins') { + var url = '/jenkins/' + $scope.jenkinsActionLogId + '/jobs/testmail/builds/' + $scope.jenkinsBuildNumber + '/output'; + $http.get(url).then(function (result) { + if (result.data) { + $scope.jenkinsLogs = helper.formatLogs(result.data.output); + $scope.isBotLogsLoading = false; + } else { + $scope.jenkinsLogs = helper.formatLogs(result.output); + $scope.isBotLogsLoading = false; + } }); + } $scope.cancel = function() { $modalInstance.dismiss('cancel'); diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botLogs.html b/client/cat3/src/partials/sections/dashboard/bots/view/botLogs.html index f4c23519f..9c4f75a5e 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botLogs.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botLogs.html @@ -10,7 +10,7 @@

{{botSummary.totalNoOfBots}}

-

{{botSummary.totalNoOfSuccessBots}}

+

{{botSummary.totalNoOfRunningBots}}

Total
Number of BOTs running

From d885e1ce897d7abbfbb0d57225d1e4bac1ccfd9b Mon Sep 17 00:00:00 2001 From: Divakar Konakalla Date: Wed, 23 Nov 2016 11:49:57 +0530 Subject: [PATCH 2/2] changes. --- .../dashboard/bots/controller/audittrailCtrl.js | 4 +--- .../dashboard/bots/controller/botLogsCtrl.js | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) 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 bbb599063..ec93f489d 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/audittrailCtrl.js @@ -51,9 +51,7 @@ keyboard: false, resolve: { items: function() { - return { - hist - }; + return hist } } }); diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js index 1b74e6a96..7802b2c20 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/botLogsCtrl.js @@ -9,15 +9,14 @@ "use strict"; angular.module('library.bots',[]) .controller('botLogsCtrl',['$scope', '$rootScope', '$http', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', '$timeout', function ($scope, $rootScope, $http, genSevs, workzoneServices, toastr, $modalInstance, items, $timeout) { - $scope.actionId = items.hist.actionLogId; - $scope.botName = items.hist.auditTrailConfig.name; - $scope.nodeIds = items.hist.auditTrailConfig.nodeIds; - $scope.taskType = items.hist.auditTrailConfig.executionType; - $scope.nodeIdsWithActionLog = items.hist.auditTrailConfig.nodeIdsWithActionLog; + $scope.botName = items.auditTrailConfig.name; + $scope.nodeIds = items.auditTrailConfig.nodeIds; + $scope.taskType = items.auditTrailConfig.executionType; + $scope.nodeIdsWithActionLog = items.auditTrailConfig.nodeIdsWithActionLog; $scope.isBotLogsLoading = true; if($scope.taskType === 'jenkins') { - $scope.jenkinsActionLogId = items.hist.actionLogId; - $scope.jenkinsBuildNumber = items.hist.auditTrailConfig.jenkinsBuildNumber; + $scope.jenkinsActionLogId = items.actionLogId; + $scope.jenkinsBuildNumber = items.auditTrailConfig.jenkinsBuildNumber; } var helper = { scrollBottom : function () {