Skip to content

Commit b2c38d5

Browse files
authored
Merge pull request #1215 from RLOpenCatalyst/dev
Dev
2 parents a7358a7 + 396bb4e commit b2c38d5

File tree

7 files changed

+149
-29
lines changed

7 files changed

+149
-29
lines changed
1.96 KB
Loading

client/cat3/src/partials/sections/dashboard/bots/controller/botHistoryCtrl.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
});
1818

1919
if($scope.templateSelected) {
20-
items = $scope.templateSelected;
20+
items = $scope.templateSelected;
2121
}
22-
22+
2323
$scope.botDetail = items;
2424
$scope.botId = items.botId;
2525

@@ -68,10 +68,17 @@
6868

6969
angular.extend($scope, {
7070
taskHistoryListView : function() {
71-
$scope.taskHistoryData.data = [];
72-
var param = {
73-
url: '/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder
74-
};
71+
var param = null;
72+
if($scope.botDetail.serviceNowCheck == true){
73+
param = {
74+
url: '/bots/' + $scope.botId + '/bots-history?serviceNowCheck=true&page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder
75+
};
76+
}else{
77+
param = {
78+
url: '/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder
79+
};
80+
}
81+
$scope.taskHistoryData.data = [];
7582
genSevs.promiseGet(param).then(function(response) {
7683
$timeout(function() {
7784
if (response.botHistory) {

client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,14 @@
181181
});
182182
};
183183
// $scope.botLibraryGridView();
184-
$scope.botTemplateClick = function(templateDetail) {
184+
$scope.botTemplateClick = function(templateDetail, serviceNowCheck) {
185185
templateDetail.selected = true;
186-
$scope.nextEnabled = true;
187186
$rootScope.templateSelected = templateDetail;
187+
if($scope.scheduledBotsSelected) {
188+
serviceNowCheck = true;
189+
$rootScope.templateSelected.serviceNowCheck = true;
190+
}
191+
$scope.nextEnabled = true;
188192
$rootScope.$emit('BOTS_TEMPLATE_SELECTED',templateDetail);
189193
};
190194

@@ -224,7 +228,7 @@
224228
} else if($scope.scheduledBotsSelected) {
225229
var param={
226230
inlineLoader: true,
227-
url:'/bots?filterBy=isBotScheduled:true&page=' + pageNumber +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString
231+
url:'/bots?serviceNowCheck=true&page=' + pageNumber +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder+'&search=' + $scope.searchString
228232
};
229233
} else if($scope.failedBotsselected) {
230234
var param={
@@ -358,6 +362,11 @@
358362
};
359363

360364
$scope.botHistory=function(bot) {
365+
var serviceNowCheck;
366+
if($scope.scheduledBotsSelected) {
367+
serviceNowCheck = true;
368+
bot.serviceNowCheck = true;
369+
}
361370
$rootScope.templateSelected = bot;
362371
var modalInstance = $modal.open({
363372
animation: true,
@@ -569,7 +578,7 @@
569578
}
570579
var param={
571580
inlineLoader:true,
572-
url:'/bots?filterBy=isBotScheduled:true&page=' + $scope.botLibGridOptions.paginationCurrentPage +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder
581+
url:'/bots?serviceNowCheck=true&page=' + $scope.botLibGridOptions.paginationCurrentPage +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder
573582
};
574583
genSevs.promiseGet(param).then(function (result) {
575584
if($scope.isCardViewActive){

client/cat3/src/partials/sections/dashboard/bots/view/library.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<loading size="medium" name="isBotDetailsLoading" type="inline" classes='white' class="ng-scope"></loading>
6666
<span ng-if="!isBotDetailsLoading">{{botSummary.totalNoOfBots}}</span>
6767
</div>
68-
<div class="circle-tile-description text-faded">
68+
<div class="circle-tile-description text-faded" title="Total BOTs">
6969
Total BOTs
7070
</div>
7171
<span class="glyphicon glyphicon-triangle-bottom section-bottom-glyph dark-blue-glyph selected-section" ng-class="{'selected-section':totalBotsSelected}"></span>
@@ -85,7 +85,7 @@
8585
<loading size="medium" name="isBotDetailsLoading" type="inline" classes='white' class="ng-scope"></loading>
8686
<span ng-if="!isBotDetailsLoading">{{botSummary.totalNoOfRunningBots}}</span>
8787
</div>
88-
<div class="circle-tile-description text-faded">
88+
<div class="circle-tile-description text-faded" title="Running BOTs">
8989
Running BOTs
9090
</div>
9191
<span class="glyphicon glyphicon-triangle-bottom section-bottom-glyph green-glyph" ng-class="{'selected-section':runningBotsselected}"></span>
@@ -103,7 +103,7 @@
103103
<loading size="medium" name="isBotDetailsLoading" type="inline" classes='white' class="ng-scope"></loading>
104104
<span ng-if="!isBotDetailsLoading">{{botSummary.totalSavedTimeForBots.hours ? botSummary.totalSavedTimeForBots.hours : 0}}h {{botSummary.totalSavedTimeForBots.minutes ? botSummary.totalSavedTimeForBots.minutes : 0}}m </span>
105105
</div>
106-
<div class="circle-tile-description text-faded">
106+
<div class="circle-tile-description text-faded" title="Time Saved">
107107
Time saved
108108
</div>
109109
</div>
@@ -113,16 +113,16 @@
113113
<div class="circle-tile cursor">
114114
<div ng-click="showScheduledBots('resetPage')">
115115
<div class="circle-tile-heading bg-blue">
116-
<i class="fa fa-calendar fa-2x white"></i>
116+
<i class="fa fa-power-off fa-2x white"></i>
117117
</div>
118118
</div>
119119
<div class="circle-tile-content bg-blue" ng-click="showScheduledBots('resetPage')">
120120
<div class="circle-tile-number text-faded ng-binding">
121121
<loading size="medium" name="isBotDetailsLoading" type="inline" classes='white' class="ng-scope"></loading>
122-
<span ng-if="!isBotDetailsLoading">{{botSummary.totalNoOfScheduledBots}}</span>
122+
<span ng-if="!isBotDetailsLoading">{{botSummary.totalNoOfServiceNowTickets}}</span>
123123
</div>
124-
<div class="circle-tile-description text-faded">
125-
Scheduled BOTs
124+
<div class="circle-tile-description text-faded" title="Tickets Resolved">
125+
Tickets Resolved
126126
</div>
127127
<span class="glyphicon glyphicon-triangle-bottom section-bottom-glyph bg-blue-glyph" ng-class="{'selected-section':scheduledBotsSelected}"></span>
128128
</div>
@@ -140,7 +140,7 @@
140140
<loading size="medium" name="isBotDetailsLoading" type="inline" classes='white' class="ng-scope"></loading>
141141
<span ng-if="!isBotDetailsLoading">{{botSummary.totalNoOfFailedBots}}</span>
142142
</div>
143-
<div class="circle-tile-description text-faded">
143+
<div class="circle-tile-description text-faded" title="Failed BOTs">
144144
Failed BOTs
145145
</div>
146146
<span class="glyphicon glyphicon-triangle-bottom section-bottom-glyph redcard-glyph" ng-class="{'selected-section':failedBotsselected}"></span>
@@ -184,7 +184,7 @@
184184
<loading size="large" name="isBotLibraryPageLoading" type="block" align="center"></loading>
185185
<div class="col-lg-4 col-md-4 col-sm-6" ng-show="isCardViewActive" ng-repeat="botsDetails in botLibGridOptions.data">
186186
<div class="agent-card grid-card hoverable col-lg-12 col-md-12 col-xs-12">
187-
<a class="appnav" ng-click="botTemplateClick(botsDetails)" ui-sref="dashboard.bots.botsDescription">
187+
<a class="appnav" ng-click="botTemplateClick(botsDetails,false)" ui-sref="dashboard.bots.botsDescription">
188188
<div class="image-cell two-tone-11">
189189
<img class="highlight" alt="{{botsDetails.botCategory}}" ng-src="{{botsDetails.imagePath}}">
190190
</div>

server/app/routes/v1.0/routes_bots.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ module.exports.setRoutes = function(app, sessionVerificationFunc) {
2323
app.all('/bots/*', sessionVerificationFunc);
2424

2525
app.get('/bots',function(req,res){
26-
var actionStatus = null;
26+
var actionStatus = null,serviceNowCheck = false;
2727
if(req.query.actionStatus && req.query.actionStatus !== null){
2828
actionStatus = req.query.actionStatus;
2929
}
30-
botsService.getBotsList(req.query,actionStatus, function(err,data){
30+
if(req.query.serviceNowCheck && req.query.serviceNowCheck !== null && req.query.serviceNowCheck === 'true'){
31+
serviceNowCheck = true;
32+
}
33+
botsService.getBotsList(req.query,actionStatus,serviceNowCheck, function(err,data){
3134
if (err) {
3235
return res.status(500).send(err);
3336
} else {
@@ -48,7 +51,11 @@ module.exports.setRoutes = function(app, sessionVerificationFunc) {
4851
});
4952

5053
app.get('/bots/:botId/bots-history',function(req,res){
51-
botsService.getBotsHistory(req.params.botId,req.query, function(err,data){
54+
var serviceNowCheck = false;
55+
if(req.query.serviceNowCheck && req.query.serviceNowCheck !== null && req.query.serviceNowCheck === 'true'){
56+
serviceNowCheck = true;
57+
}
58+
botsService.getBotsHistory(req.params.botId,req.query, serviceNowCheck,function(err,data){
5259
if (err) {
5360
return res.status(500).send(err);
5461
} else {

server/app/services/auditTrailService.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(queryParam,BOTSchema,
195195
totalNoOfBots: function(callback){
196196
callback(null, botsList.length);
197197
},
198-
totalNoOfSuccessBots: function(callback){
198+
/* totalNoOfSuccessBots: function(callback){
199199
var query = {
200200
auditType: BOTSchema,
201201
actionStatus: 'success',
@@ -217,8 +217,8 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(queryParam,BOTSchema,
217217
callback(null, botsIds.length);
218218
}
219219
});
220-
},
221-
totalNoOfScheduledBots: function(callback){
220+
},*/
221+
/*totalNoOfScheduledBots: function(callback){
222222
var scheduleBotsIds = [];
223223
if(botsList.length > 0) {
224224
for (var j = 0; j < botsList.length; j++) {
@@ -230,6 +230,21 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(queryParam,BOTSchema,
230230
}else{
231231
callback(null,scheduleBotsIds.length);
232232
}
233+
},*/
234+
totalNoOfServiceNowTickets: function(callback){
235+
var query={
236+
auditType:BOTSchema,
237+
actionStatus:'success',
238+
isDeleted:false,
239+
user:'servicenow'
240+
};
241+
auditTrail.getAuditTrails(query, function(err,botsAudits){
242+
if(err){
243+
callback(err,null);
244+
}else {
245+
callback(null,botsAudits.length);
246+
}
247+
});
233248
},
234249
totalNoOfRunningBots: function(callback){
235250
var query={

server/app/services/botsService.js

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ botsService.updateBotsScheduler = function updateBotsScheduler(botId,botObj,call
165165
});
166166
}
167167

168-
botsService.getBotsList = function getBotsList(botsQuery,actionStatus,callback) {
168+
botsService.getBotsList = function getBotsList(botsQuery,actionStatus,serviceNowCheck,callback) {
169169
var reqData = {};
170170
async.waterfall([
171171
function(next) {
@@ -200,19 +200,50 @@ botsService.getBotsList = function getBotsList(botsQuery,actionStatus,callback)
200200
bots.getBotsList(queryObj, next);
201201
}
202202
});
203-
}else{
203+
}else if(serviceNowCheck === true){
204+
var query = {
205+
auditType: 'BOTs',
206+
actionStatus: 'success',
207+
user: 'servicenow',
208+
isDeleted:false
209+
};
210+
var botsIds = [];
211+
auditTrail.getAuditTrails(query, function(err,botsAudits){
212+
if(err){
213+
next(err,null);
214+
}else if (botsAudits.length > 0) {
215+
for (var i = 0; i < botsAudits.length; i++) {
216+
if (botsIds.indexOf(botsAudits[i].auditId) < 0) {
217+
botsIds.push(botsAudits[i].auditId);
218+
}
219+
}
220+
queryObj.queryObj.botId = {$in:botsIds};
221+
bots.getBotsList(queryObj, next);
222+
} else {
223+
queryObj.queryObj.botId = null;
224+
bots.getBotsList(queryObj, next);
225+
}
226+
});
227+
} else{
204228
bots.getBotsList(queryObj, next);
205229
}
206230
},
207231
function(botList, next) {
208232
filterScriptBotsData(botList,next);
209233
},
234+
function(botList, next) {
235+
if(serviceNowCheck=== true){
236+
filterDataForServiceNow(botList,next);
237+
}else{
238+
next(null,botList);
239+
}
240+
},
210241
function(filterBotList, next) {
211242
apiUtil.paginationResponse(filterBotList, reqData, next);
212243
}
213244
],function(err, results) {
214245
if (err){
215-
logger.error(err);
246+
logger.error(JSON.stringify(err));
216247
callback(err,null);
217248
return;
218249
}
@@ -273,7 +304,7 @@ botsService.removeBotsById = function removeBotsById(botId,callback){
273304
});
274305
}
275306

276-
botsService.getBotsHistory = function getBotsHistory(botId,botsQuery,callback){
307+
botsService.getBotsHistory = function getBotsHistory(botId,botsQuery,serviceNowCheck,callback){
277308
var reqData = {};
278309
async.waterfall([
279310
function(next) {
@@ -287,6 +318,9 @@ botsService.getBotsHistory = function getBotsHistory(botId,botsQuery,callback){
287318
function(queryObj, next) {
288319
queryObj.queryObj.auditId = botId;
289320
queryObj.queryObj.auditType = 'BOTs';
321+
if(serviceNowCheck === true){
322+
queryObj.queryObj.user = 'servicenow';
323+
}
290324
auditTrail.getAuditTrailList(queryObj,next)
291325
},
292326
function(auditTrailList, next) {
@@ -597,6 +631,54 @@ function getExecutionTime(endTime, startTime) {
597631
return totalSeconds;
598632
}
599633

634+
function filterDataForServiceNow(botList,callback){
635+
if(botList.docs.length > 0){
636+
var resultList = [];
637+
for(var i = 0; i < botList.docs.length; i++){
638+
(function(bot){
639+
var query={
640+
auditType:'BOTs',
641+
actionStatus:'success',
642+
isDeleted:false,
643+
user:'servicenow',
644+
auditId:bot.botId
645+
};
646+
auditTrail.getAuditTrails(query, function(err,botsAudits){
647+
if(err){
648+
logger.error(err);
649+
}
650+
bot.executionCount = botsAudits.length;
651+
var totalTimeInSeconds = 0;
652+
for (var m = 0; m < botsAudits.length; m++) {
653+
if (botsAudits[m].endedOn && botsAudits[m].endedOn !== null
654+
&& botsAudits[m].auditTrailConfig.manualExecutionTime
655+
&& botsAudits[m].auditTrailConfig.manualExecutionTime !== null) {
656+
var executionTime = getExecutionTime(botsAudits[m].endedOn, botsAudits[m].startedOn);
657+
totalTimeInSeconds = totalTimeInSeconds + ((botsAudits[m].auditTrailConfig.manualExecutionTime * 60) - executionTime);
658+
}
659+
}
660+
var totalTimeInMinutes = Math.round(totalTimeInSeconds / 60);
661+
var result = {
662+
hours: Math.floor(totalTimeInMinutes / 60),
663+
minutes: totalTimeInMinutes % 60
664+
}
665+
bot.savedTime = result;
666+
resultList.push(bot);
667+
if(resultList.length === botList.docs.length){
668+
botList.docs = resultList;
669+
callback(null,botList);
670+
return;
671+
}
672+
673+
});
674+
})(botList.docs[i]);
675+
}
676+
677+
}else{
678+
callback(null,botList);
679+
}
680+
}
681+
600682

601683

602684

0 commit comments

Comments
 (0)