From 61e99a5f57497762076d0f36c59abdff4b625076 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Fri, 13 Jan 2017 14:47:05 +0530 Subject: [PATCH 01/66] GIT Hub Implementation --- .../catalyst-scheduler/catalystScheduler.js | 2 +- server/app/lib/utils/apiUtil.js | 4 +- server/app/model/bots/{ => 1.0}/bots.js | 0 server/app/model/bots/1.1/bots.js | 296 ++++++++++++++++++ server/app/model/classes/tasks/tasks.js | 2 +- server/app/routes/v1.0/routes_blueprints.js | 2 +- server/app/services/auditTrailService.js | 2 +- server/app/services/blueprintService.js | 2 +- server/app/services/botsService.js | 2 +- server/app/services/schedulerService.js | 2 +- server/app/services/taskService.js | 2 +- 11 files changed, 306 insertions(+), 10 deletions(-) rename server/app/model/bots/{ => 1.0}/bots.js (100%) create mode 100644 server/app/model/bots/1.1/bots.js diff --git a/server/app/cronjobs/catalyst-scheduler/catalystScheduler.js b/server/app/cronjobs/catalyst-scheduler/catalystScheduler.js index d05439767..1165a3906 100644 --- a/server/app/cronjobs/catalyst-scheduler/catalystScheduler.js +++ b/server/app/cronjobs/catalyst-scheduler/catalystScheduler.js @@ -1,7 +1,7 @@ var logger = require('_pr/logger')(module); var instancesDao = require('_pr/model/classes/instance/instance'); var taskDao = require('_pr/model/classes/tasks/tasks.js'); -var botsDao = require('_pr/model/bots/bots.js'); +var botsDao = require('_pr/model/bots/1.0/bots.js'); var schedulerService = require('_pr/services/schedulerService'); var async = require('async'); var cronTab = require('node-crontab'); diff --git a/server/app/lib/utils/apiUtil.js b/server/app/lib/utils/apiUtil.js index 24326b86e..de6590ec7 100644 --- a/server/app/lib/utils/apiUtil.js +++ b/server/app/lib/utils/apiUtil.js @@ -231,10 +231,10 @@ var ApiUtil = function() { }; var filterBy={}; if(data.filterBy) { - var a = data.filterBy.split(" "); + var a = data.filterBy.split(","); for (var i = 0; i < a.length; i++) { var b = a[i].split(":"); - var c = b[1].split(","); + var c = b[1].split(" "); if (c.length > 1) { filterBy[b[0]] = {'$in': c}; } else { diff --git a/server/app/model/bots/bots.js b/server/app/model/bots/1.0/bots.js similarity index 100% rename from server/app/model/bots/bots.js rename to server/app/model/bots/1.0/bots.js diff --git a/server/app/model/bots/1.1/bots.js b/server/app/model/bots/1.1/bots.js new file mode 100644 index 000000000..49d2a79eb --- /dev/null +++ b/server/app/model/bots/1.1/bots.js @@ -0,0 +1,296 @@ +/* + Copyright [2016] [Relevance Lab] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +var mongoose = require('mongoose'); +var logger = require('_pr/logger')(module); +var ObjectId = require('mongoose').Types.ObjectId; +var mongoosePaginate = require('mongoose-paginate'); +var Schema = mongoose.Schema; + +var BotsSchema = new Schema ({ + name: { + type: String, + trim: true, + required: true + }, + type: { + type: String, + trim: true, + required: true + }, + category: { + type: String, + trim: true, + required: true + }, + description: { + type: String, + trim: true, + required: true + }, + orgId:{ + type: String, + trim: true, + required: true + }, + yamlDocId:{ + type: String, + trim: true, + required: false + }, + manualExecutionTime: { + type: Number, + default: 10 + }, + executionCount: { + type: Number, + default: 0 + }, + isScheduled: { + type: Boolean, + default: false + }, + scheduler:{ + cronStartOn: { + type: String, + required: false, + trim: true + }, + cronEndOn: { + type: String, + required: false, + trim: true + }, + cronPattern: { + type: String, + required: false, + trim: true + }, + cronRepeatEvery: { + type: Number, + required: false + }, + cronFrequency: { + type: String, + required: false, + trim: true + }, + cronMinute:{ + type: Number, + required: false, + trim: true + }, + cronHour:{ + type: Number, + required: false + }, + cronWeekDay:{ + type: Number, + required: false + }, + cronDate:{ + type: Number, + required: false + }, + cronMonth:{ + type: String, + required: false, + trim: true + }, + cronYear:{ + type: Number, + required: false + } + }, + cronJobId:{ + type: String, + required: false, + trim: true + }, + createdOn:{ + type: Number, + default: Date.now() + }, + isDeleted: { + type: Boolean, + default: false + } +}); +BotsSchema.plugin(mongoosePaginate); + + +BotsSchema.statics.createNew = function(botsDetail,callback){ + var botsData = new Bots(botsDetail); + botsData.save(function(err, data) { + if (err) { + logger.error("createNew Failed", err, data); + callback(err,null); + return; + } + callback(null,data); + return; + }); +} +BotsSchema.statics.updateBotsDetail = function(botId,botsDetail,callback){ + Bots.update({botId:botId},{$set:botsDetail},{upsert:false}, function(err, updateBotDetail) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + } + return callback(null, updateBotDetail); + }); +}; + +BotsSchema.statics.getBotsList = function(botsQuery,callback){ + botsQuery.queryObj.isDeleted = false; + Bots.paginate(botsQuery.queryObj, botsQuery.options, function(err, botsList) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + } + return callback(null, botsList); + }); +}; + +BotsSchema.statics.getBotsById = function(botId,callback){ + Bots.find({botId:botId}, function(err, bots) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + }else if(bots.length > 0){ + return callback(null, bots); + }else{ + return callback(null, []); + } + }); +}; + +BotsSchema.statics.getAllBots = function(callback){ + Bots.find({isDeleted:false}, function(err, bots) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + }else if(bots.length > 0){ + return callback(null, bots); + }else{ + return callback(null, []); + } + }); +}; + +BotsSchema.statics.removeBotsById = function(botId,callback){ + Bots.remove({botId:botId}, function(err, bots) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + }else { + return callback(null, bots); + } + }); +}; + +BotsSchema.statics.removeSoftBotsById = function(botId,callback){ + Bots.update({botId:botId},{$set:{isDeleted:true}}, function(err, bots) { + if (err) { + logger.error(err); + var error = new Error('Internal server error'); + error.status = 500; + return callback(error); + }else { + return callback(null, bots); + } + }); +}; + +BotsSchema.statics.updateBotsExecutionCount = function updateBotsExecutionCount(botId,count,callback) { + Bots.update({ + botId: botId, + }, { + $set: { + executionCount: count + } + }, { + upsert: false + }, function (err, data) { + if (err) { + callback(err, null); + return; + } + callback(null, data); + }); +}; + +BotsSchema.statics.getScheduledBots = function getScheduledBots(callback) { + Bots.find({ + isBotScheduled: true, + isDeleted:false + }, function (err, bots) { + if (err) { + logger.error(err); + return callback(err, null); + } + return callback(null, bots); + }) +} + +BotsSchema.statics.updateCronJobIdByBotId = function updateCronJobIdByBotId(botId, cronJobId, callback) { + Bots.update({ + "_id": new ObjectId(botId), + }, { + $set: { + cronJobId: cronJobId + } + }, { + upsert: false + }, function (err, data) { + if (err) { + callback(err, null); + return; + } + callback(null, data); + }); +}; + +BotsSchema.statics.updateBotsScheduler = function updateBotsScheduler(botId, callback) { + Bots.update({ + "_id": new ObjectId(botId), + }, { + $set: { + isBotScheduled: false + } + }, { + upsert: false + }, function (err, data) { + if (err) { + callback(err, null); + return; + } + callback(null, data); + }); +}; + +var Bots = mongoose.model('bots', BotsSchema); +module.exports = Bots; diff --git a/server/app/model/classes/tasks/tasks.js b/server/app/model/classes/tasks/tasks.js index 9b87b7a7f..b168536a4 100755 --- a/server/app/model/classes/tasks/tasks.js +++ b/server/app/model/classes/tasks/tasks.js @@ -30,7 +30,7 @@ var mongoosePaginate = require('mongoose-paginate'); var ApiUtils = require('_pr/lib/utils/apiUtil.js'); var Schema = mongoose.Schema; var auditTrailService = require('_pr/services/auditTrailService'); -var bots = require('_pr/model/bots/bots.js'); +var bots = require('_pr/model/bots/1.0/bots.js'); var Cryptography = require('_pr/lib/utils/cryptography'); var appConfig = require('_pr/config'); diff --git a/server/app/routes/v1.0/routes_blueprints.js b/server/app/routes/v1.0/routes_blueprints.js index 7198da90b..c4860b5d5 100755 --- a/server/app/routes/v1.0/routes_blueprints.js +++ b/server/app/routes/v1.0/routes_blueprints.js @@ -24,7 +24,7 @@ var credentialcryptography = require('_pr/lib/credentialcryptography'); var fs = require('fs'); var blueprintService = require('_pr/services/blueprintService.js'); var auditTrailService = require('_pr/services/auditTrailService'); -var bots = require('_pr/model/bots/bots.js'); +var bots = require('_pr/model/bots/1.0/bots.js'); var botsService = require('_pr/services/botsService.js'); module.exports.setRoutes = function(app, sessionVerificationFunc) { diff --git a/server/app/services/auditTrailService.js b/server/app/services/auditTrailService.js index c6c3930c5..7f255f007 100644 --- a/server/app/services/auditTrailService.js +++ b/server/app/services/auditTrailService.js @@ -19,7 +19,7 @@ var instanceAuditTrail = require('_pr/model/audit-trail/instance-audit-trail.js' var botAuditTrail = require('_pr/model/audit-trail/bot-audit-trail.js'); var containerAuditTrail = require('_pr/model/audit-trail/container-audit-trail.js'); var auditTrail = require('_pr/model/audit-trail/audit-trail.js'); -var bots = require('_pr/model/bots/bots.js');; +var bots = require('_pr/model/bots/1.0/bots.js');; const errorType = 'auditTrailService'; diff --git a/server/app/services/blueprintService.js b/server/app/services/blueprintService.js index 88b74aa22..5e8c7055a 100644 --- a/server/app/services/blueprintService.js +++ b/server/app/services/blueprintService.js @@ -33,7 +33,7 @@ var AWSKeyPair = require('_pr/model/classes/masters/cloudprovider/keyPair.js'); var auditTrail = require('_pr/model/audit-trail/audit-trail.js'); var usersDao = require('_pr/model/users.js'); var auditTrailService = require('_pr/services/auditTrailService'); -var bots = require('_pr/model/bots/bots.js'); +var bots = require('_pr/model/bots/1.0/bots.js'); var botsService = require('_pr/services/botsService.js'); var ObjectId = require('mongoose').Types.ObjectId; var uuid = require('node-uuid'); diff --git a/server/app/services/botsService.js b/server/app/services/botsService.js index 4dc732a6b..4ef646c3c 100644 --- a/server/app/services/botsService.js +++ b/server/app/services/botsService.js @@ -16,7 +16,7 @@ */ var logger = require('_pr/logger')(module); -var bots = require('_pr/model/bots/bots.js'); +var bots = require('_pr/model/bots/1.0/bots.js'); var async = require("async"); var apiUtil = require('_pr/lib/utils/apiUtil.js'); var taskService = require('_pr/services/taskService.js'); diff --git a/server/app/services/schedulerService.js b/server/app/services/schedulerService.js index e4d0c5801..f4492bb91 100644 --- a/server/app/services/schedulerService.js +++ b/server/app/services/schedulerService.js @@ -41,7 +41,7 @@ var botsService = require('_pr/services/botsService.js'); var gcpProviderModel = require('_pr/model/v2.0/providers/gcp-providers'); var GCP = require('_pr/lib/gcp.js'); var crontab = require('node-crontab'); -var botsDao = require('_pr/model/bots/bots.js'); +var botsDao = require('_pr/model/bots/1.0/bots.js'); schedulerService.executeSchedulerForInstances = function executeSchedulerForInstances(instance,callback) { logger.debug("Instance Scheduler is started for Instance. "+instance.platformId); diff --git a/server/app/services/taskService.js b/server/app/services/taskService.js index 106c8d95d..3b31241fb 100644 --- a/server/app/services/taskService.js +++ b/server/app/services/taskService.js @@ -16,7 +16,7 @@ var logger = require('_pr/logger')(module); var taskDao = require('_pr/model/classes/tasks/tasks.js'); -var bots = require('_pr/model/bots/bots.js'); +var bots = require('_pr/model/bots/1.0/bots.js'); var masterUtil = require('_pr/lib/utils/masterUtil.js'); var d4dModelNew = require('_pr/model/d4dmasters/d4dmastersmodelnew.js'); var TaskHistory = require('_pr/model/classes/tasks/taskHistory'); From 014611168ef872213e4b4158d675e3d27bdd8ffb Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Fri, 13 Jan 2017 15:08:29 +0530 Subject: [PATCH 02/66] GIT Hub Implementation --- .../private/ajax/Settings/githubList.html | 521 ++---------------- client/htmls/private/css/catalyst.css | 36 +- client/htmls/private/js/githubList.js | 497 +++++++++++++++++ server/app/model/github/github.js | 77 ++- server/app/routes/v1.0/routes_d4dMasters.js | 42 +- server/app/routes/v1.0/routes_github.js | 313 ++++++++++- server/app/services/auditTrailService.js | 61 +- server/app/services/botsService.js | 3 +- server/app/services/gitHubService.js | 244 ++++++-- server/app/services/instanceService.js | 2 +- server/app/validators/gitHubValidator.js | 10 +- server/install.js | 3 +- server/package.json | 4 +- 13 files changed, 1225 insertions(+), 588 deletions(-) create mode 100644 client/htmls/private/js/githubList.js diff --git a/client/htmls/private/ajax/Settings/githubList.html b/client/htmls/private/ajax/Settings/githubList.html index bf46d1d9b..b60d04e7e 100644 --- a/client/htmls/private/ajax/Settings/githubList.html +++ b/client/htmls/private/ajax/Settings/githubList.html @@ -1,9 +1,12 @@ +
@@ -26,12 +29,12 @@
- + - - - + + + @@ -62,13 +65,13 @@ - - - + + @@ -77,13 +76,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParametersValues
BOT Name{{botInfo.botName}}
Task Type:{{botInfo.botLinkedSubCategory}}
Blueprint Type + + + + + + +
Bot Type{{botInfo.botType}}
BOT Category{{botInfo.botCategory}}
BOT Description{{botInfo.botDesc}}
Runlist + +
Attribute{{$index+1}}{{attribs.name}}
Attribute{{botInfo.botConfig.attributes[0].name}}
Job Name{{botInfo.botConfig.jobName}}
Job URL{{botInfo.botConfig.jobURL}}
Bot Parameter Type{{botInfo.botConfig.parameterized[0].parameterName}}
Bot Parameter Name{{botInfo.botConfig.parameterized[0].name}}
Bot Parameter Values{{botInfo.botConfig.parameterized[0].defaultValue}}
Bot Parameter Description{{botInfo.botConfig.parameterized[0].description}}
Script Type Name{{botInfo.botConfig.scriptTypeName}}
Script Parameter Description{{botInfo.botConfig.scriptDetails[0].scriptParameters[0].paramDesc}}
Script Parameter{{$index+1}} Description{{desc.paramDesc}}
+
+
+
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/readme.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/readme.html new file mode 100644 index 000000000..5cbce112b --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/readme.html @@ -0,0 +1,11 @@ + + +
+ + +
+ +
+
diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/report.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/report.html new file mode 100644 index 000000000..0b9022453 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/report.html @@ -0,0 +1,29 @@ + + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
No Data Found
+
+
+
diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/schedule.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/schedule.html new file mode 100644 index 000000000..762f510d0 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/schedule.html @@ -0,0 +1,141 @@ + + +
+ + +
+
+ + + + +
+
+
diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/settings.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/settings.html new file mode 100644 index 000000000..f1fae24d5 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/settings.html @@ -0,0 +1,13 @@ + + +
+ + +
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet turpis nec justo aliquet malesuada. Donec fringilla, nibh a efficitur accumsan, sapien lacus sodales ante, et finibus mi tortor id augue. Fusce facilisis non quam at consectetur. Sed sit amet sem eu lacus efficitur sodales. Mauris ut ligula eu dui rhoncus consectetur. Integer aliquet risus dolor, sit amet aliquet tellus lacinia et. Nullam eleifend tincidunt erat quis sodales. Duis pretium ultrices urna sed malesuada. Duis tristique, quam et placerat bibendum, tellus nisl luctus metus, vitae vulputate lectus ligula vitae enim. Sed ac eros non augue mollis semper. Phasellus tellus tellus, mollis at lacinia et, malesuada eget leo. Sed ex magna, consequat eget nibh vitae, gravida gravida nulla. Vivamus hendrerit molestie felis, vitae congue sem sodales vitae.

+ +

Vivamus id lorem semper, sagittis elit eget, hendrerit velit. In ac urna et sem feugiat sollicitudin. Integer dapibus sem eu erat pellentesque porttitor. Sed ornare mi et pretium fermentum. Quisque ornare odio eu massa vehicula, a fermentum ante condimentum. Fusce at rutrum erat. Maecenas lacinia egestas quam ut faucibus. Praesent elementum felis viverra velit fermentum, et iaculis nunc consequat. Quisque tincidunt justo vel fringilla tincidunt. Suspendisse suscipit, dolor id bibendum efficitur, ex est semper ligula, at condimentum lacus nulla at lectus. Nunc bibendum felis sit amet tellus finibus pulvinar. In hac habitasse platea dictumst. Fusce a urna tempus, fringilla justo non, viverra ante. Fusce nunc erat, porttitor vel eros a, consectetur tincidunt odio.

+ +

Cras aliquam magna et massa posuere posuere. Nunc scelerisque auctor purus, eget porta tortor volutpat sed. Donec ut congue lectus. Aliquam erat volutpat. Etiam quis eros in velit vulputate mollis. Aliquam metus metus, maximus sit amet tempor sed, fringilla vitae purus. Nam dictum eget velit sed lobortis. In non nisi dictum, fringilla mi congue, tincidunt massa. Integer accumsan viverra lectus. Duis sem purus, accumsan nec gravida in, consectetur sed felis. Maecenas dapibus eros vel magna auctor interdum. Cras aliquam nisi tincidunt, gravida lectus vel, laoreet metus. Integer dapibus, elit in mollis auctor, est ex accumsan lorem, vel consequat libero ligula eget sem. Fusce imperdiet purus non convallis tristique. Sed maximus nulla at nibh mollis ornare ut sed dolor.

+
+
diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botsDescription.html b/client/cat3/src/partials/sections/dashboard/bots/view/botsDescription.html new file mode 100644 index 000000000..02a09ccb6 --- /dev/null +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botsDescription.html @@ -0,0 +1,82 @@ + + +
+
+ BOTs Description  + +
+
+
+
+
+
+ +
+
{{templateSelected.botName}}
+
+ +
+
{{templateSelected.botDesc}}
+
+
+ + + +
+ +
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/library.html b/client/cat3/src/partials/sections/dashboard/bots/view/library.html index 683e46691..401a2d0fb 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/library.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/library.html @@ -1,123 +1,194 @@ - +
-
- BOTs Library  - - - - -
-
- -
-
-
-
-
-
- -
-
-
-
- Total BOTs -
-
- {{botSummary.totalNoOfBots}} -
- -
-
-
-
-
-
-
- -
-
-
-
- Running BOTs -
-
- {{botSummary.totalNoOfRunningBots}} -
- -
-
-
- -
-
-
-
- -
-
-
-
- Time saved -
-
- {{totalSavedTimeForBots}} mins -
-
-
-
-
-
-
-
- -
-
-
-
- Scheduled BOTs -
-
- {{botSummary.totalNoOfScheduledBots}} -
- -
-
-
-
-
-
-
- -
-
-
-
- Failed BOTs -
-
- {{botSummary.totalNoOfFailedBots}} -
- -
-
-
-
-
+
+ BOTs Library  + + + + +
+
+ + + + +
+
+
+
+ +
+ Total + {{botSummary.totalNoOfBots}} +
+
+
+
+
+ +
+ Running + {{botSummary.totalNoOfRunningBots}} +
+
+
+
+
+ +
+ Scheduled + {{botSummary.totalNoOfScheduledBots}} +
+
+
+
+
+ +
+ Time Saved + {{totalSavedTimeForBots}} mins +
+
+
+
+
+ +
+ Failed + {{botSummary.totalNoOfFailedBots}} +
+
+
+ +
+
+ + - + +
+
+ + + + + +
+
{{statusBar}}
+
+
+ -
- No data Available -
-
-
+ +
+ No data Available +
+
+ + \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/workzone/workzone.scss b/client/cat3/src/partials/sections/dashboard/workzone/workzone.scss index 31191d43b..8df53d459 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/workzone.scss +++ b/client/cat3/src/partials/sections/dashboard/workzone/workzone.scss @@ -150,19 +150,3 @@ } } } -// grid view tab class -.hide-grid { - margin: 0px auto !important; - padding: 0px !important; - visibility: hidden; - height: 0px !important; - overflow: hidden; -} -.show-grid-tab { - visibility: visible; - height: auto; -} -.show-grid { - visibility: inherit; - height: auto; -} \ No newline at end of file From 4c16d0918d9d5cc05d8144950ff6e685e1b4afe5 Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Fri, 27 Jan 2017 16:41:41 +0530 Subject: [PATCH 22/66] menu changed --- .../sections/dashboard/analytics/analytics.js | 4 ++-- .../analytics/controller/capacityReportCtrl.js | 14 -------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js index 1a0485f26..59beeae48 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js @@ -153,7 +153,7 @@ $scope.getProviders(orgs[0].rowid); }); if (!$rootScope.stateParams.view) { - $state.go('dashboard.analytics.capacityReport'); + $state.go('dashboard.analytics.cost'); } analytic.tabShow=function(chat,report){ analytic.tabShowChat=chat; @@ -288,7 +288,7 @@ $rootScope.filterNewEnt.resources=$scope.selectedResources; }; if (!$rootScope.stateParams.view && $rootScope.organObject) { - $state.go('dashboard.analytics.capacityReport'); + $state.go('dashboard.analytics.cost'); } }]); })(angular); diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js index 57dbfb6f7..166d3404e 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js @@ -37,19 +37,6 @@ capRept.serviceCapacity=result.capacity.AWS; //capRept.serviceType=Object.keys(capRept.serviceCapacity.services)[0]; capRept.serviceType='EC2'; - if(result.splitUpCapacities && Object.keys(result.splitUpCapacities).length >0) { - angular.forEach(result.splitUpCapacities, function (val, key) { - var a=key.replace(/([A-Z])/g, ' $1').replace(/^./, function(str) { - return str.toUpperCase(); - }); - $rootScope.splitUpCapacities.push({id:key,val:a}); - }); - if( $rootScope.splitUpCapacities && $rootScope.splitUpCapacities.length >0) { - $scope.$emit('CHANGE_splitUp', $rootScope.splitUpCapacities[0].id); - capRept.splitUp = $rootScope.splitUpCapacities[0].val; - capRept.createLable(result, $rootScope.splitUpCapacities[0].id); - } - } capRept.createList(); }); @@ -172,7 +159,6 @@ gridApi.grid.registerRowsProcessor($scope.singleFilter, 200); $scope.gridApi = gridApi; }; - if(capRept.serviceType === 'EC2' && fltrObj && fltrObj.provider && fltrObj.provider.id) { if($rootScope.organNewEnt.instanceType === 'Managed') { $scope.colArray.push('bgName','projectName','environmentName'); From 60c4d67c0328d74680eb9a00755aeb561ceaaf26 Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Mon, 30 Jan 2017 11:38:12 +0530 Subject: [PATCH 23/66] added month name in cost field --- .../dashboard/analytics/controller/capacityReportCtrl.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js index 166d3404e..8bbac67f6 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/capacityReportCtrl.js @@ -82,6 +82,9 @@ $scope.chefConfig=function (id) { genSevs.editRunlist(id); }; + $scope.monthNames = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; + + $scope.currentMonth = $scope.monthNames[new Date().getMonth()]; capRept.createList = function () { capRept.filterValue=''; capRept.listGrid=[]; @@ -107,7 +110,7 @@ }, { name: 'cost', - displayName: 'Cost', + displayName: 'Cost ( '+$scope.currentMonth+' )', cellTemplate: '' }, { @@ -132,7 +135,7 @@ }, { name: 'cost', - displayName: 'Cost', + displayName: 'Cost ( '+$scope.currentMonth+' )', cellTemplate: '' }, { @@ -151,7 +154,7 @@ {name: 'bucketOwnerName', field: 'bucketOwnerName', cellTooltip: true}, {name: 'bucketSize', field: 'bucketSize', displayName:'Bucket Size (MB)', cellTooltip: true}, - {name: 'cost', displayName: 'Cost',cellTemplate: ''}, + {name: 'cost', displayName: 'Cost ( '+$scope.currentMonth+' )',cellTemplate: ''}, {name: 'Action', cellTooltip: true,cellTemplate:" "} ]; } From 8bd98ebd98edf9b0ec05cb882845b937f4d41435 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Mon, 30 Jan 2017 18:19:46 +0530 Subject: [PATCH 24/66] Add LastRunTime field for BOTs --- server/app/model/bots/bots.js | 4 ++++ server/app/services/blueprintService.js | 12 ++++++------ server/app/services/taskService.js | 6 +++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/server/app/model/bots/bots.js b/server/app/model/bots/bots.js index 2736a74cc..49724d9e8 100644 --- a/server/app/model/bots/bots.js +++ b/server/app/model/bots/bots.js @@ -108,6 +108,10 @@ var BotsSchema = new Schema ({ type: Number, default: 0 }, + lastRunTime: { + type: Number, + default: Date.now() + }, isBotScheduled: { type: Boolean, default: false diff --git a/server/app/services/blueprintService.js b/server/app/services/blueprintService.js index d7c78bada..6e014f799 100644 --- a/server/app/services/blueprintService.js +++ b/server/app/services/blueprintService.js @@ -238,12 +238,12 @@ blueprintService.launch = function launch(blueprintId,reqBody, callback) { logger.error(err); }else if(botData.length > 0){ var botExecutionCount = botData[0].executionCount + 1; - bots.updateBotsExecutionCount(blueprint._id,botExecutionCount,function(err,data){ - if(err){ - logger.error("Error while updating Bot Execution Count"); - } - }); - bots.updateBotsDetail(blueprint._id,{runTimeParams:reqBody},function(err,data){ + var botUpdateObj = { + executionCount:botExecutionCount, + lastRunTime:new Date().getTime(), + runTimeParams:reqBody + } + bots.updateBotsDetail(blueprint._id,botUpdateObj,function(err,data){ if(err){ logger.error("Error while updating Bots Configuration"); } diff --git a/server/app/services/taskService.js b/server/app/services/taskService.js index 106c8d95d..fc7c35af8 100644 --- a/server/app/services/taskService.js +++ b/server/app/services/taskService.js @@ -215,7 +215,11 @@ taskService.executeTask = function executeTask(taskId, user, hostProtocol, choic logger.error("Error while updating Task Execution Count"); } }); - bots.updateBotsExecutionCount(task._id, botExecutionCount, function (err, data) { + var botUpdateObj = { + executionCount:botExecutionCount, + lastRunTime:new Date().getTime() + } + bots.updateBotsDetail(task._id, botUpdateObj, function (err, data) { if (err) { logger.error("Error while updating Bot Execution Count"); } From af1d14102aa22d6149e13663eedcc7ab979318f0 Mon Sep 17 00:00:00 2001 From: srikanthv02 Date: Mon, 30 Jan 2017 18:45:52 +0530 Subject: [PATCH 25/66] Removed commented code --- .../sections/dashboard/bots/tabs/param.html | 87 ------------------- 1 file changed, 87 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/param.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/param.html index 3f77a1007..312af503b 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/tabs/param.html +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/param.html @@ -16,93 +16,6 @@ {{botParams.type}} {{botParams.default}} - From 19c52bd82827ed04f00d5539a86e3af58c90c44e Mon Sep 17 00:00:00 2001 From: srikanthv02 Date: Mon, 30 Jan 2017 22:28:38 +0530 Subject: [PATCH 26/66] Last Run added in bots list, sorting as per last run and history pagination changed --- .../dashboard/bots/controller/libraryCtrl.js | 84 ++++++++++--------- .../dashboard/bots/view/botHistory.html | 10 +-- 2 files changed, 51 insertions(+), 43 deletions(-) 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 59624ca07..bdfbf14fd 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -43,6 +43,7 @@ { name: 'description',field:'botDesc',cellTooltip: true}, { name: 'BOT Created From',displayName: 'BOT Created From',field:'botLinkedCategory',cellTooltip: true}, { name: 'Organization',field:'masterDetails.orgName',cellTooltip: true}, + { name: 'Last Run',field:'lastRunTime ',cellTemplate:'{{row.entity.lastRunTime | timestampToLocaleTime}}', cellTooltip: true}, { name: 'Total Runs',field:'executionCount'}, { name: 'BOT Action',width:200,displayName: 'BOT Action',cellTemplate: // ''+ @@ -83,7 +84,7 @@ $scope.botLibGridOptions.paginationCurrentPage = $scope.paginationParams.page = 1; }; $scope.setPaginationDefaults = function() { - $scope.paginationParams.sortBy = 'createdOn'; + $scope.paginationParams.sortBy = 'lastRunTime'; $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. @@ -551,17 +552,25 @@ $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; - }]).controller('botHistoryCtrl',["items", '$scope', '$modalInstance', '$modal', '$timeout', 'uiGridOptionsClient', 'genericServices', - function(items, $scope, $modalInstance, $modal, $timeout, uiGridOptionsClient, genSevs){ + }]).controller('botHistoryCtrl',["items", '$scope', '$modalInstance', '$modal', '$timeout', 'uiGridOptionsService', 'genericServices', + function(items, $scope, $modalInstance, $modal, $timeout, uiGridOptionsService, genSevs){ //UI Grid for chef Task starts + $scope.botHistory = items; $scope.botId = items.botId; $scope.taskHistoryChefData = []; - var gridOptionsChef = uiGridOptionsClient.options().gridOption; - $scope.taskHistoryChefGridOptions = gridOptionsChef; + $scope.paginationParams = []; + var botLibraryUIGridDefaults = uiGridOptionsService.options(); + $scope.paginationParams = botLibraryUIGridDefaults.pagination; + + $scope.paginationParams.page = 1; + $scope.paginationParams.pageSize = 10; + $scope.paginationParams.sortBy = 'startedOn'; + $scope.paginationParams.sortOrder = 'desc'; + $scope.initChefGrids = function(){ - $scope.taskHistoryChefGridOptions.data='taskHistoryChefData'; + $scope.taskHistoryChefGridOptions = {}; $scope.taskHistoryChefGridOptions.columnDefs = [ { name:'Status',field:'status',cellTemplate:'
{{row.entity.status}}
', cellTooltip: true}, { name:'User',field:'user',cellTooltip: true}, @@ -574,20 +583,23 @@ { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + 'NA', cellTooltip: true} ]; + $scope.taskHistoryChefGridOptions.data = []; + angular.extend($scope.taskHistoryChefGridOptions,botLibraryUIGridDefaults.gridOption); }; angular.extend($scope, { taskHistoryChefListView: function() { - $scope.taskHistoryChefData = []; var param={ - url:'/bots/' + $scope.botId + '/bots-history' + url:'/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (response) { $timeout(function() { if(response.botHistory){ - $scope.taskHistoryChefData = response.botHistory; + $scope.taskHistoryChefGridOptions.totalItems = response.metaData.totalRecords; + $scope.taskHistoryChefGridOptions.data = response.botHistory; $scope.ischefTaskHistoryPageLoading = false; }else if(response){ - $scope.taskHistoryChefData = response; + $scope.taskHistoryChefGridOptions.data = response; + $scope.taskHistoryChefGridOptions = response; $scope.ischefTaskHistoryPageLoading = false; } },100); @@ -616,12 +628,8 @@ //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={}; $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}, @@ -634,21 +642,23 @@ { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + 'NA', cellTooltip: true} ]; + $scope.taskHistoryJenkinsGridOptions.data = []; + angular.extend($scope.taskHistoryJenkinsGridOptions,botLibraryUIGridDefaults.gridOption); }; angular.extend($scope, { taskHistoryJenkinsListView: function() { - $scope.taskHistoryJenkinsData = []; var param={ - url:'/bots/' + $scope.botId + '/bots-history' + url:'/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (response) { $timeout(function() { if(response.botHistory){ - $scope.taskHistoryJenkinsData = response.botHistory; + $scope.taskHistoryJenkinsGridOptions.totalItems = response.metaData.totalRecords; + $scope.taskHistoryJenkinsGridOptions.data = response.botHistory; $scope.isjenkinsTaskHistoryPageLoading = false; }else if(response){ - $scope.taskHistoryJenkinsData = response; - console.log($scope.taskHistoryJenkinsData); + $scope.taskHistoryJenkinsGridOptions.data = response; + $scope.taskHistoryJenkinsGridOptions = response; $scope.isjenkinsTaskHistoryPageLoading = false; } },100); @@ -667,12 +677,8 @@ //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 = {}; $scope.taskHistoryScriptGridOptions.columnDefs = [ { name:'Status',field:'status',cellTemplate:'
{{row.entity.status}}
', cellTooltip: true}, { name:'User',field:'user',cellTooltip: true}, @@ -685,20 +691,23 @@ { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + 'NA', cellTooltip: true} ]; + $scope.taskHistoryScriptGridOptions.data = []; + angular.extend($scope.taskHistoryScriptGridOptions,botLibraryUIGridDefaults.gridOption); }; angular.extend($scope, { taskHistoryScriptListView: function() { - $scope.taskHistoryScriptData = []; var param={ - url:'/bots/' + $scope.botId + '/bots-history' + url:'/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (response) { $timeout(function() { if(response.botHistory){ - $scope.taskHistoryScriptData = response.botHistory; + $scope.taskHistoryScriptGridOptions.totalItems = response.metaData.totalRecords; + $scope.taskHistoryScriptGridOptions.data = response.botHistory; $scope.isscriptTaskHistoryPageLoading = false; }else if(response){ - $scope.taskHistoryScriptData = response; + $scope.taskHistoryScriptGridOptions.data = response; + $scope.taskHistoryScriptGridOptions = response; $scope.isscriptTaskHistoryPageLoading = false; } },100); @@ -717,12 +726,8 @@ //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 = {}; $scope.botHistoryBlueprintGridOptions.columnDefs = [ { name:'Status',field:'status',cellTemplate:'
{{row.entity.status}}
', cellTooltip: true}, { name:'User',field:'user',cellTooltip: true}, @@ -735,20 +740,23 @@ { name:'Saved Time',cellTemplate:'{{grid.appScope.getSavedTime(row.entity.endedOn,row.entity.startedOn)}} mins' + 'NA', cellTooltip: true} ]; + $scope.botHistoryBlueprintGridOptions.data = []; + angular.extend($scope.botHistoryBlueprintGridOptions,botLibraryUIGridDefaults.gridOption); }; angular.extend($scope, { botHistoryBlueprintListView: function() { - $scope.botHistoryBlueprintData = []; var param={ - url:'/bots/' + $scope.botId + '/bots-history' + url:'/bots/' + $scope.botId + '/bots-history?page=' + $scope.paginationParams.page +'&pageSize=' + $scope.paginationParams.pageSize +'&sortBy=' + $scope.paginationParams.sortBy +'&sortOrder=' + $scope.paginationParams.sortOrder }; genSevs.promiseGet(param).then(function (response) { $timeout(function() { if(response.botHistory){ - $scope.botHistoryBlueprintData = response.botHistory; + $scope.botHistoryBlueprintGridOptions.totalItems = response.metaData.totalRecords; + $scope.botHistoryBlueprintGridOptions.data = response.botHistory; $scope.isBlueprintBotHistoryPageLoading = false; }else if(response){ - $scope.botHistoryBlueprintData = response; + $scope.botHistoryBlueprintGridOptions.data = response.botHistory; + $scope.botHistoryBlueprintGridOptions = response.botHistory; $scope.isBlueprintBotHistoryPageLoading = false; } },100); diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html b/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html index 0a23d5a2b..26a34898d 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botHistory.html @@ -14,24 +14,24 @@