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 55a16c189..335f10546 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -699,7 +699,7 @@ items: function() { return { taskId : hist.auditId, - historyId : hist._id, + historyId : hist.auditHistoryId ? hist.auditHistoryId : hist.auditTrailConfig.nodeIdsWithActionLog[0].actionLogId, taskType:hist.auditTrailConfig.executionType }; } @@ -731,22 +731,40 @@ $scope.cancel= function() { $modalInstance.dismiss('cancel'); }; - }]).controller('confirmBotRunCtrl', ['$scope', '$modalInstance', 'items', 'genericServices','toastr', function ($scope, $modalInstance, items, genSevs, toastr) { + }]).controller('confirmBotRunCtrl', ['$scope', '$modalInstance', 'items', 'genericServices','toastr','$modal', function ($scope, $modalInstance, items, genSevs, toastr,$modal) { console.log(items); $scope.botId = items.botId; $scope.isJobRunExecuting = false; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; + 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.runJob = function () { $scope.isJobRunExecuting = true; var param={ url:'/bots/' + items.botId + '/execute' }; genSevs.promisePost(param).then(function (response) { - console.log(response); $modalInstance.close(response.data); - $rootScope.$emit('BOTS_LIBRARY_REFRESH'); helper.botLogModal(items.botId, response.historyId, response.taskType); }, function (error) { diff --git a/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js b/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js index 63e1a58ad..7d8c5666e 100755 --- a/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js @@ -115,7 +115,7 @@ }; pbList.launchInstance = $scope.launchInstance =function($event,pb){ $event.stopPropagation(); - gencSers.lunchBlueprint(pb); + gencSers.launchBlueprint(pb); }; pbList.selectCard = function (cardObj){ pbList[cardObj._id] = !pbList[cardObj._id]; diff --git a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchCtrl.js b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchCtrl.js index 4141b54a0..34287e090 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchCtrl.js @@ -10,7 +10,7 @@ angular.module('workzone.blueprint') .controller('blueprintLaunchCtrl', ['$scope', '$rootScope', '$modalInstance', 'bpItem', 'workzoneServices', 'workzoneEnvironment', 'instanceLogs', function($scope, $rootScope, $modalInstance, bpItem, workzoneServices, workzoneEnvironment, instanceLogs) { console.log(bpItem); - if(bpItem.bp.blueprintType) { + if(bpItem.bp.blueprintType || bpItem.bp.botLinkedSubCategory) { $scope.isBPLogsLoading = true; $scope.isNewInstanceLogsPromise = false; var helper = { @@ -44,9 +44,9 @@ } else{ isSuccess = true; - if (bpItem.bp.blueprintType === 'aws_cf') { + if (bpItem.bp.blueprintType === 'aws_cf' || bpItem.bp.botLinkedSubCategory === 'aws_cf') { msgStr = 'Stack Id : ' + $scope.launchResponse.stackId + '. You can view your stack in cloudformation tab'; - } else if (bpItem.bp.blueprintType === 'azure_arm') { + } else if (bpItem.bp.blueprintType === 'azure_arm' || bpItem.bp.botLinkedSubCategory === 'azure_arm') { msgStr = 'Deployment Id : ' + $scope.launchResponse.armId + '. You can view your deployment in ARM tab'; } else { msgStr = 'Instance Id : '; @@ -80,12 +80,16 @@ versionsList = bpItem.bp.blueprintConfig.infraManagerData.versionsList; versionOptional = versionsList[versionsList.length-1].ver; } + }else{ + versionOptional = bpItem.bp.version ? bpItem.bp.version : 1; } var selectedVersionBpId = bpItem.bp.selectedVersionBpId; var monitorId = bpItem.monitorId; if(bpItem && bpItem.bp && bpItem.bp.selectedVersionBpId){ selectedVersionBpId = bpItem.bp.selectedVersionBpId; - } else { + } else if(bpItem.bp.botType){ + selectedVersionBpId = bpItem.bp.botId; + } else{ selectedVersionBpId = bpItem.bp._id; } var lEnv=null; diff --git a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchParamsCtrl.js b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchParamsCtrl.js index b8b4e9818..ac3dc1a44 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchParamsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchParamsCtrl.js @@ -36,9 +36,9 @@ angular.forEach(envData,function(val){ var orgID,bgID,projID; if(items.organizationId === undefined) { - orgID = (items.orgId)?items.orgId:items.organization.id; - bgID = (items.bgId)?items.bgId:items.businessGroup.id; - projID = (items.projectId)?items.projectId:items.project.id; + orgID = (items.orgId)?items.orgId:items.masterDetails.orgId; + bgID = (items.bgId)?items.bgId:items.masterDetails.bgId; + projID = (items.projectId)?items.projectId:items.masterDetails.projectId; $scope.getMonitorList(orgID); } else { orgID = items.organizationId; @@ -76,7 +76,7 @@ $modalInstance.dismiss('cancel'); }; $scope.launchBP = function() { - if(items.orgId === undefined){ + if(items.orgId === undefined && items.botType === undefined){ var compBlue={ "blueprintId": (items.id)?items.id:items._id, "environmentId": $scope.envSeleted @@ -88,13 +88,14 @@ toastr.error(data.message, 'Error'); }); } else { - if(items.blueprintType === "aws_cf") { + if(items.blueprintType === "aws_cf" || items.botLinkedSubCategory === "aws_cf") { $scope.showCFTInputs = true; - }else if(items.blueprintType === "azure_arm") { + }else if(items.blueprintType === "azure_arm" || items.botLinkedSubCategory === "azure_arm") { $scope.showARMInputs = true; }else if(items.domainNameCheck === true || items.domainNameCheck === "true") { $scope.showBlueprintInputs = true; }else { + console.log("Durgesh"); launchHelper.launch(); } } diff --git a/client/cat3/src/partials/sections/dashboard/workzone/instance/popups/instanceLogsCtrl.js b/client/cat3/src/partials/sections/dashboard/workzone/instance/popups/instanceLogsCtrl.js index 174f5a698..9a5897334 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/instance/popups/instanceLogsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/workzone/instance/popups/instanceLogsCtrl.js @@ -9,6 +9,8 @@ "use strict"; angular.module('workzone.instance') .controller('instanceLogsCtrl', ['$scope', '$rootScope', '$modalInstance', 'items', 'workzoneServices', 'instanceSetting', 'instanceLogs', function($scope, $rootScope , $modalInstance, items, workzoneServices, instanceSetting, instanceLogs) { + console.log(items); + console.log("Durgesh"); $scope.instanceName = items.name; $scope.isInstanceLogsLoading = true; angular.extend($scope, { diff --git a/server/app/model/blueprint/blueprint.js b/server/app/model/blueprint/blueprint.js index 72bfb2e97..a0a243f0c 100755 --- a/server/app/model/blueprint/blueprint.js +++ b/server/app/model/blueprint/blueprint.js @@ -288,15 +288,13 @@ BlueprintSchema.methods.launch = function (opts, callback) { message: "Failed to get env name from env id" }, null); return; - } - ; + }; if (!envName) { callback({ "message": "Unable to find environment name from environment id" }); return; - } - ; + }; configmgmtDao.getChefServerDetails(infraManager.infraManagerId, function (err, chefDetails) { if (err) { logger.error("Failed to getChefServerDetails", err); @@ -304,16 +302,14 @@ BlueprintSchema.methods.launch = function (opts, callback) { message: "Failed to getChefServerDetails" }, null); return; - } - ; + }; if (!chefDetails) { logger.error("No CHef Server Detailed available.", err); callback({ message: "No Chef Server Detailed available" }, null); return; - } - ; + }; var chef = new Chef({ userChefRepoLocation: chefDetails.chefRepoLocation, chefUserName: chefDetails.loginname, diff --git a/server/app/model/bots/bots.js b/server/app/model/bots/bots.js index 8301ab1de..4e03b12de 100644 --- a/server/app/model/bots/bots.js +++ b/server/app/model/bots/bots.js @@ -181,6 +181,10 @@ var BotsSchema = new Schema ({ type: Number, default: 1 }, + domainNameCheck: { + type: Boolean, + default: false + } }); BotsSchema.plugin(mongoosePaginate); @@ -298,7 +302,8 @@ BotsSchema.statics.updateBotsExecutionCount = function updateBotsExecutionCount( BotsSchema.statics.getScheduledBots = function getScheduledBots(callback) { Bots.find({ - isBotScheduled: true + isBotScheduled: true, + isDeleted:false }, function (err, bots) { if (err) { logger.error(err); diff --git a/server/app/model/classes/tasks/taskTypeChef.js b/server/app/model/classes/tasks/taskTypeChef.js index e48aae65c..29975a973 100755 --- a/server/app/model/classes/tasks/taskTypeChef.js +++ b/server/app/model/classes/tasks/taskTypeChef.js @@ -269,7 +269,7 @@ chefTaskSchema.methods.execute = function(userName, baseUrl, choiceParam, appDat }); }); - } else if (tagServer) { + } else if (tagServer !== 'undefined' && tagServer !== null) { logger.debug('in tagServer',tagServer); instancesDao.getInstancesByTagServer(tagServer, function(err, instances) { if (err) { diff --git a/server/app/model/classes/tasks/taskTypeScript.js b/server/app/model/classes/tasks/taskTypeScript.js index e8bf81c8c..492653555 100644 --- a/server/app/model/classes/tasks/taskTypeScript.js +++ b/server/app/model/classes/tasks/taskTypeScript.js @@ -67,9 +67,8 @@ scriptTaskSchema.methods.execute = function(userName, baseUrl, choiceParam, nexu var sudoFlag = this.isSudo; var scriptDetails = this.scriptDetails; var instanceResultList = []; - function getInstances(instanceIds, tagServer, callback) { - if (tagServer) { + if (tagServer !== 'undefined' && tagServer !== null) { logger.debug('in tagServer', tagServer); instancesDao.getInstancesByTagServer(tagServer, function (err, instances) { if (err) { @@ -83,7 +82,6 @@ scriptTaskSchema.methods.execute = function(userName, baseUrl, choiceParam, nexu }); } else { - if (!(instanceIds && instanceIds.length)) { if (typeof onExecute === 'function') { onExecute({ @@ -104,8 +102,6 @@ scriptTaskSchema.methods.execute = function(userName, baseUrl, choiceParam, nexu }); } } - - getInstances(instanceIds, self.botTagServer, function (err, instances) { if (err) { logger.error(err); diff --git a/server/app/routes/v1.0/routes_authentication.js b/server/app/routes/v1.0/routes_authentication.js index a59fa6ad7..8126b3c92 100755 --- a/server/app/routes/v1.0/routes_authentication.js +++ b/server/app/routes/v1.0/routes_authentication.js @@ -37,7 +37,6 @@ var aws = require('aws-sdk'); module.exports.setRoutes = function(app) { app.post('/auth/createldapUser', function(req, res) { if (req.body) { - LDAPUser.getLdapUser(function(err, ldapData) { if (err) { logger.error("Failed to get ldap-user: ", err); diff --git a/server/app/routes/v1.0/routes_d4dMasters.js b/server/app/routes/v1.0/routes_d4dMasters.js index 624450b06..580bfdcb5 100755 --- a/server/app/routes/v1.0/routes_d4dMasters.js +++ b/server/app/routes/v1.0/routes_d4dMasters.js @@ -2736,8 +2736,7 @@ module.exports.setRoutes = function (app, sessionVerification) { logger.error('Hit getting setting wizard error', err); res.send(500); return; - } - if (settingWizards.currentStep && settingWizards.currentStep.name === 'User Configuration') { + }else if (settingWizards.currentStep && settingWizards.currentStep.name === 'User Configuration') { var settingWizardSteps = appConfig.settingWizardSteps; settingWizards.currentStep.nestedSteps[1].isCompleted = true; settingWizards.currentStep.isCompleted = true; @@ -2753,6 +2752,9 @@ module.exports.setRoutes = function (app, sessionVerification) { res.send(200); return; }); + }else{ + res.send(200); + return; } }) } diff --git a/server/app/services/auditTrailService.js b/server/app/services/auditTrailService.js index 1aafa8f3e..ad80b6a43 100644 --- a/server/app/services/auditTrailService.js +++ b/server/app/services/auditTrailService.js @@ -186,7 +186,8 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(callback){ totalNoOfSuccessBots: function(callback){ var query={ auditType:'BOTs', - actionStatus:'success' + actionStatus:'success', + isDeleted:false }; auditTrail.getAuditTrails(query,function(err,data){ if(err){ @@ -200,7 +201,8 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(callback){ totalNoOfRunningBots: function(callback){ var query={ auditType:'BOTs', - actionStatus:'running' + actionStatus:'running', + isDeleted:false }; auditTrail.getAuditTrails(query,function(err,data){ if(err){ @@ -213,7 +215,9 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(callback){ }, totalSavedTimeForBots: function(callback){ var query={ - auditType:'BOTs' + auditType:'BOTs', + actionStatus:'success', + isDeleted:false }; auditTrail.getAuditTrails(query,function(err,botAuditTrail){ if(err){ @@ -241,7 +245,8 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(callback){ totalNoOfFailedBots: function(callback){ var query={ auditType:'BOTs', - actionStatus:'failed' + actionStatus:'failed', + isDeleted:false }; auditTrail.getAuditTrails(query,function(err,data){ if(err){ @@ -267,7 +272,8 @@ auditTrailService.getBOTsSummary = function getBOTsSummary(callback){ auditTrailService.getBotsAuditTrailHistory = function getBotsAuditTrailHistory(botId,callback){ var query={ auditType:'BOTs', - auditId:botId + auditId:botId, + isDeleted:false }; auditTrail.getAuditTrails(query,function(err,data){ if(err){ diff --git a/server/app/services/botsService.js b/server/app/services/botsService.js index 6491532f2..859bbb2b8 100644 --- a/server/app/services/botsService.js +++ b/server/app/services/botsService.js @@ -20,6 +20,7 @@ var bots = require('_pr/model/bots/bots.js'); var async = require("async"); var apiUtil = require('_pr/lib/utils/apiUtil.js'); var taskService = require('_pr/services/taskService.js'); +var tasks = require('_pr/model/classes/tasks/tasks.js'); var auditTrailService = require('_pr/services/auditTrailService.js'); var blueprintService = require('_pr/services/blueprintService.js'); var auditTrail = require('_pr/model/audit-trail/audit-trail.js'); @@ -50,6 +51,8 @@ botsService.createOrUpdateBots = function createOrUpdateBots(botsDetail,linkedCa botLinkedCategory: linkedCategory, botLinkedSubCategory:linkedSubCategory, manualExecutionTime:botsDetail.manualExecutionTime, + version:botsDetail.version, + domainNameCheck:botsDetail.domainNameCheck, createdOn: new Date().getTime() }; bots.getBotsById(botsDetail._id,function(err,data){ @@ -103,6 +106,23 @@ botsService.updateBotsScheduler = function updateBotsScheduler(botId,botObj,call if (botsData[0].isBotScheduled === true) { var catalystSync = require('_pr/cronjobs/catalyst-scheduler/catalystScheduler.js'); catalystSync.executeScheduledBots(); + if(botsData[0].botLinkedCategory === 'Task'){ + tasks.getTaskById(botId,function(err,task){ + if(err){ + logger.error("Error in fetching Task details",err); + }else if(task.isTaskScheduled === true){ + tasks.updateTaskScheduler(botId,function(err,updateData){ + if(err){ + logger.error("Error in Updating Task details",err); + } + }); + if(task.cronJobId && task.cronJobId !== null){ + var cronTab = require('node-crontab'); + cronTab.cancelJob(task.cronJobId); + } + } + }); + } } else if (botsData[0].cronJobId && botsData[0].cronJobId !== null) { var cronTab = require('node-crontab'); cronTab.cancelJob(botsData[0].cronJobId); @@ -279,9 +299,9 @@ botsService.executeBots = function executeBots(botId,reqBody,callback){ function(bots,next){ if(bots.length > 0){ if(bots[0].botLinkedCategory === 'Task'){ - taskService.executeTask(botId,reqBody.userName ? reqBody.userName : 'system',reqBody.hostProtocol ? reqBody.hostProtocol : '', - reqBody.choiceParam ? reqBody.choiceParam : '',reqBody.appData ? reqBody.appData : '',reqBody.paramOptions ? reqBody.paramOptions : '', - reqBody.tagServer ? reqBody.tagServer : '', callback); + taskService.executeTask(botId,reqBody.userName ? reqBody.userName : 'system',reqBody.hostProtocol ? reqBody.hostProtocol : 'undefined', + reqBody.choiceParam ? reqBody.choiceParam : 'undefined',reqBody.appData ? reqBody.appData : 'undefined',reqBody.paramOptions ? reqBody.paramOptions : 'undefined', + reqBody.tagServer ? reqBody.tagServer : 'undefined', callback); }else{ blueprintService.launch(botId,reqBody,callback) } diff --git a/server/app/services/settingsService.js b/server/app/services/settingsService.js index 4eea8841f..73c5a6486 100644 --- a/server/app/services/settingsService.js +++ b/server/app/services/settingsService.js @@ -81,7 +81,10 @@ settingsService.updateProjectData = function updateProjectData(enviornment,callb }; settingsService.trackSettingWizard = function trackSettingWizard(id,orgId,callback){ - if(id === '1'){ + if(orgId === null || orgId === ''){ + callback(null,orgId); + return; + }else if(id === '1'){ settingWizard.removeSettingWizardByOrgId(orgId,function(err,data){ if(err){ callback(err,null); diff --git a/server/app/services/taskService.js b/server/app/services/taskService.js index 795c6f5ee..630d79e4d 100644 --- a/server/app/services/taskService.js +++ b/server/app/services/taskService.js @@ -52,7 +52,8 @@ taskService.getAllServiceDeliveryTask = function getAllServiceDeliveryTask(query var query = { auditType: 'BOTs', actionStatus: queryObj.actionStatus, - auditCategory: 'Task' + auditCategory: 'Task', + isDeleted:false }; var taskIds = []; async.waterfall([