From 87961f21adb1689af4bd19792010ea1fb88aeff9 Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Thu, 20 Oct 2016 14:24:42 +0530 Subject: [PATCH] Added API with launch --- client/cat3/src/partials/global.scss | 6 + .../sections/dashboard/bots/bots.html | 2 +- .../dashboard/bots/controller/libraryCtrl.js | 28 +++- .../sections/dashboard/bots/view/library.html | 5 +- .../sections/dashboard/genericServices.js | 125 ++++++++++++++++++ 5 files changed, 157 insertions(+), 9 deletions(-) diff --git a/client/cat3/src/partials/global.scss b/client/cat3/src/partials/global.scss index d5b0a1221..c47e73659 100644 --- a/client/cat3/src/partials/global.scss +++ b/client/cat3/src/partials/global.scss @@ -1163,4 +1163,10 @@ option.script { } .loading-body{ opacity: 0.4; +} +#bots .control-panel-button { + border-radius: 11px; + padding: 2px 5px; + width: 25px; + height: 25px; } \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/bots/bots.html b/client/cat3/src/partials/sections/dashboard/bots/bots.html index f2dec4d06..a98ad80e9 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/bots.html +++ b/client/cat3/src/partials/sections/dashboard/bots/bots.html @@ -6,7 +6,7 @@ -
+
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 e28d40b6d..2a41dd92a 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -13,23 +13,37 @@ multiSelect :false, }, columnDefs: [ - { name: 'type'}, - { name: 'name'}, - { name: 'description'}, + { name: 'type',field:'botType'}, + { name: 'name',field:'name'}, + { name: 'description',field:'shortDesc'}, { name: 'run Bot' }, { name: 'history' }, { name: 'last run'}, - { name: 'bot Action'} + { name: 'bot Action',cellTemplate:''} ], - data:[{},{}] + data:[] }; + $scope.launchInstance = function(lunch){ + if(lunch.botType === 'Task'){ + genSevs.executeTask(lunch); + } else if(lunch.botType === 'blueprint') { + genSevs.lunchBlueprint(lunch); + } + }; lib.int =function(){ + lib.gridOptions.data=[]; var param={ - url:'/config-data/bot-type' + url:'/blueprints/serviceDelivery' }; genSevs.promiseGet(param).then(function (result) { - + angular.extend(lib.gridOptions.data,result); + }); + var param2={ + url:'/tasks/serviceDelivery' + }; + genSevs.promiseGet(param2).then(function (resultTask) { + angular.extend(lib.gridOptions.data,resultTask); }); }; lib.int(); 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 32fc54891..0e6c80888 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/library.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/library.html @@ -1,2 +1,5 @@
-
\ No newline at end of file +
+
+ No data Available +
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/genericServices.js b/client/cat3/src/partials/sections/dashboard/genericServices.js index 82401b9f7..767fe9470 100644 --- a/client/cat3/src/partials/sections/dashboard/genericServices.js +++ b/client/cat3/src/partials/sections/dashboard/genericServices.js @@ -102,6 +102,24 @@ } }; + genericServices.log=function(id,historyId,taskType) { + $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/workzone/orchestration/popups/orchestrationLog.html', + controller: 'orchestrationLogCtrl as orchLogCtrl', + backdrop: 'static', + keyboard: false, + resolve: { + items: function() { + return { + taskId: id, + historyId: historyId, + taskType: taskType + }; + } + } + }); + }; genericServices.removeBlueprint= function(blueprintObj, bpType) { var modalOptions = { closeButtonText: 'Cancel', @@ -130,6 +148,113 @@ }); } }; + + genericServices.executeTask =function(task) { + if (task.taskConfig.parameterized && task.taskConfig.parameterized.length) { + $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/workzone/orchestration/popups/runParamConfig.html', + controller: 'runParamConfigCtrl', + backdrop: 'static', + keyboard: false, + resolve: { + items: function() { + return angular.extend([], task.taskConfig.parameterized); + } + } + }).result.then(function(selectedItems) { + var choiceParam = {}; + var p = selectedItems; + for (var i = 0; i < p.length; i++) { + choiceParam[p[i].name] = p[i].defaultValue[0]; + } + workSvs.runTask(task._id, { + "choiceParam": choiceParam + }).then(function(response) { + helper.orchestrationLogModal(task._id, response.data.historyId, task.taskType); + $rootScope.$emit('WZ_ORCHESTRATION_REFRESH_CURRENT'); + }); + }, function() { + console.log("Dismiss at " + new Date()); + }); + } else { + $modal.open({ + animation: true, + templateUrl: 'src/partials/sections/dashboard/workzone/orchestration/popups/confirmJobRun.html', + controller: 'confirmJobRunCtrl', + backdrop: 'static', + keyboard: false, + resolve: { + items: function() { + return task._id; + } + } + }).result.then(function(response) { + genericServices.log(task._id,response.historyId,task.taskType); + if(response.blueprintMessage){ + $rootScope.$emit('WZ_INSTANCES_SHOW_LATEST'); + } + $rootScope.$emit('WZ_ORCHESTRATION_REFRESH_CURRENT'); + }, function() { + $rootScope.$emit('WZ_ORCHESTRATION_REFRESH_CURRENT'); + }); + } + } + genericServices.lunchBlueprint=function(blueprintObj) { + $modal.open({ + animate: true, + templateUrl: "src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunchParams.html", + controller: "blueprintLaunchParamsCtrl", + backdrop : 'static', + keyboard: false, + resolve: { + items: function() { + return blueprintObj; + } + } + }) + .result.then(function(bpObj) { + if (bpObj.bp.blueprintType === "docker") { + $modal.open({ + animate: true, + templateUrl: "src/partials/sections/dashboard/workzone/blueprint/popups/dockerLaunchParams.html", + controller: "dockerLaunchParamsCtrl", + backdrop: 'static', + keyboard: false, + size: 'lg', + resolve: { + items: function() { + return bpObj.bp; + } + } + }).result.then(function() { + console.log('The modal close is not getting invoked currently. Goes to cancel handler'); + }, function() { + console.log('Cancel Handler getting invoked'); + }); + }else{ + $modal.open({ + animate: true, + templateUrl: "src/partials/sections/dashboard/workzone/blueprint/popups/blueprintLaunch.html", + controller: "blueprintLaunchCtrl", + backdrop: 'static', + keyboard: false, + resolve: { + bpItem: function() { + return bpObj; + } + } + }) + .result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + + }); + } + }, function() { + + }); + }; /*genericServices.editRunlist = function(chefRunlist, chefAttribute) { $modal.open({ templateUrl: 'src/partials/sections/dashboard/workzone/orchestration/popups/orchestrationUpdateChefRunlist.html',