From 26e49ece1cdf424255decf451b8f5c06ce599f45 Mon Sep 17 00:00:00 2001 From: srikanthv02 Date: Tue, 22 Nov 2016 19:38:20 +0530 Subject: [PATCH 1/2] Changes for design --- .../src/factory/chefDataFormatterService.js | 29 --- .../sections/dashboard/design/aDesignCtrl.js | 2 +- .../design/controllers/blueprintCreateCtrl.js | 6 +- .../design/controllers/blueprintListCtrl.js | 18 +- .../design/controllers/createCompositeCtrl.js | 41 ++- .../sections/dashboard/design/design.scss | 35 ++- .../design/services/blueprintListServices.js | 2 +- .../design/view/createComposite.html | 244 +++++++++--------- .../dashboard/design/view/designListView.html | 27 +- .../sections/dashboard/genericServices.js | 4 +- .../popups/blueprintLaunchParamsCtrl.js | 6 +- .../popups/compositeBlueprintInfo.html | 8 +- .../popups/compositeBlueprintInfoCtrl.js | 2 +- .../cloudFormation/cloudFormation.scss | 2 +- .../orchestration/popups/newTaskCtrl.js | 3 +- 15 files changed, 215 insertions(+), 214 deletions(-) diff --git a/client/cat3/src/factory/chefDataFormatterService.js b/client/cat3/src/factory/chefDataFormatterService.js index eca4e1ac9..a95acf332 100644 --- a/client/cat3/src/factory/chefDataFormatterService.js +++ b/client/cat3/src/factory/chefDataFormatterService.js @@ -294,35 +294,6 @@ } return temp; }, - //method to get the runlist array and then assign the className to each value. - findDataForEditValueString: function (list) { - var runlist = list; - - runlist = runlist.split(','); - var temp = []; - if (runlist) { - /*jslint forin: true */ - for (var i = 0; i < runlist.length; i++) { - var className; - if (runlist[i].indexOf('recipe') === 0) { - className = "cookbook"; - } else if (runlist[i].indexOf('role') === 0) { - className = "role"; - } else { - className = "template"; - } - var item = runlist[i]; - temp.push({ - value: item, - className: className, - data: {} - }); - } - }else { - - } - return temp; - }, //formatting the name and removing the default name style coming from server. chefRunlistFormatter: function (list) { var runlist = list; diff --git a/client/cat3/src/partials/sections/dashboard/design/aDesignCtrl.js b/client/cat3/src/partials/sections/dashboard/design/aDesignCtrl.js index 3e0a8d056..a167a9146 100644 --- a/client/cat3/src/partials/sections/dashboard/design/aDesignCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/design/aDesignCtrl.js @@ -114,7 +114,7 @@ organObjectId.buss=$rootScope.organNewEnt.buss.rowid; organObjectId.proj=$rootScope.organNewEnt.proj.rowId; var params; - if(tempType === 'docker' || tempType === 'arm'){ + if(tempType === 'docker' || tempType === 'arm' || tempType === 'composite'){ params = { url: '/organizations/'+organObjectId.org+'/businessgroups/'+organObjectId.buss+'/projects/'+organObjectId.proj+'/blueprintList?pagination='+pagination+'&templateType='+tempType+'&providerType=' }; diff --git a/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintCreateCtrl.js b/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintCreateCtrl.js index 073091688..790e3135c 100755 --- a/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintCreateCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintCreateCtrl.js @@ -73,8 +73,10 @@ $scope.nextEnabled = true; $scope.templateSelected = templateDetail; if($scope.templateSelected.templatescookbooks !== '' && $scope.templateSelected.templatetypename === "SoftwareStack"){ - $scope.chefComponentSelectorList = $scope.templateSelected.templatescookbooks; - $scope.chefrunlist = responseFormatter.findDataForEditValueString($scope.chefComponentSelectorList); + var chefComponentSelector = $scope.templateSelected.templatescookbooks; + var chefRunlist = chefComponentSelector.split(','); + $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(chefRunlist); + $scope.chefrunlist = responseFormatter.chefRunlistFormatter($scope.chefComponentSelectorList); } $scope.dockerDetails = []; //items gives the details of the selected blueprint. 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 62e25655b..d2e548f32 100755 --- a/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/design/controllers/blueprintListCtrl.js @@ -11,7 +11,6 @@ pbList.viewTypeList=true; pbList.selectedCards=[]; pbList.blueprintType=$state.params.templateName; - var treeNames=['Design', $state.params.providerName,$state.params.templateObj.templatetypename]; $rootScope.$emit('treeNameUpdate', treeNames); pbList.createList = function (){ @@ -50,7 +49,7 @@ { name:'Keypair',minWidth:150,field:'blueprintConfig.cloudProviderData.keyPairId',visible: false}, { name:'Subnet',minWidth:150,field:'blueprintConfig.cloudProviderData.subnetId',visible: false}, { name:'Security Group',width:150,field:'blueprintConfig.cloudProviderData.securityGroupIds[0]'}, - { name:'Action',minWidth:150,cellTemplate:' ' + + { name:'Action',minWidth:200,cellTemplate:' ' + '  ' + '  ' + '  '} @@ -84,21 +83,6 @@ }); pbList.blueprintList.list.columnDefs = bpcolumnDefs; - /*pbList.blueprintList.list.columnDefs = [ - { name:'Name',minWidth:150,field:'name' }, - { name:'InstanceOs',minWidth:150,field:'blueprintConfig.cloudProviderData.instanceOS'}, - { name:'vpcId',minWidth:150,field:'blueprintConfig.cloudProviderData.vpcId'}, - { name:'Region',minWidth:150,field:'blueprintConfig.cloudProviderData.region',visible: false}, - { name:'Template Type',minWidth:150,cellTemplate:'
{{grid.appScope.getTemplate(row.entity.templateType)}}
'}, - { name:'Instance Type',minWidth:150,field:'blueprintConfig.cloudProviderData.instanceType'}, - { name:'Keypair',minWidth:150,field:'blueprintConfig.cloudProviderData.keyPairId',visible: false}, - { name:'Subnet',minWidth:150,field:'blueprintConfig.cloudProviderData.subnetId',visible: false}, - { name:'Security Group',width:150,field:'blueprintConfig.cloudProviderData.securityGroupIds[0]'}, - { name:'Action',minWidth:150,cellTemplate:' ' + - '  ' + - '  ' + - '  '} - ];*/ }); } }; diff --git a/client/cat3/src/partials/sections/dashboard/design/controllers/createCompositeCtrl.js b/client/cat3/src/partials/sections/dashboard/design/controllers/createCompositeCtrl.js index 763582dbd..d16febcab 100755 --- a/client/cat3/src/partials/sections/dashboard/design/controllers/createCompositeCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/design/controllers/createCompositeCtrl.js @@ -1,13 +1,14 @@ (function (angular) { "use strict"; angular.module('dashboard.design') - .controller('createCompositeCtrl',['$scope','$rootScope','$state','toastr','blueprintService','genericServices', function ($scope,$rootScope,$state,toastr,bpServ,gencSers) { + .controller('createCompositeCtrl',['$scope','$rootScope','$state','toastr','blueprintService','genericServices','responseFormatter', function ($scope,$rootScope,$state,toastr,bpServ,gencSers,responseFormatter) { var createCBP = this; createCBP.ExBlueprintList=[]; createCBP.SelectedBPList=[]; createCBP.selectBlueprintId=''; createCBP.selectedBPDetails=''; createCBP.compositeBPType='chef'; + $scope.chefrunlist,$scope.cookbookAttributes = []; createCBP.onSubmit =false; createCBP.newEnt={ bpName:'' @@ -36,18 +37,33 @@ createCBP.SelectedBPList.splice(indexArr,1); }; - createCBP.selectBpInfo =function ($event,bpDetails){ + createCBP.selectBpInfo =function ($event,bpDetails,bpType){ $event.stopPropagation(); - gencSers.moreInfo(bpDetails,null); + gencSers.moreInfo(bpDetails,bpType); }; createCBP.editSelectBpInfo =function ($event,bpDetails){ createCBP.selectBlueprintId=bpDetails._id; createCBP.selectedBPDetails=bpDetails; + $scope.cookbookAttributes = []; + if(createCBP.selectedBPDetails.blueprintConfig.infraManagerData.versionsList[0].runlist) { + $scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(createCBP.selectedBPDetails.blueprintConfig.infraManagerData.versionsList[0].runlist); + if(createCBP.selectedBPDetails.blueprintConfig.infraManagerData.versionsList[0].attributes){ + $scope.cookbookAttributes = responseFormatter.formatSavedCookbookAttributes(createCBP.selectedBPDetails.blueprintConfig.infraManagerData.versionsList[0].attributes); + } + $scope.chefrunlist = responseFormatter.chefRunlistFormatter($scope.chefComponentSelectorList); + } + }; + $scope.updateCookbook = function() { + gencSers.editRunlist($scope.chefrunlist,$scope.cookbookAttributes); }; + $rootScope.$on('WZ_ORCHESTRATION_REFRESH_CURRENT', function(event,reqParams) { + $scope.chefrunlist = reqParams.list; + $scope.cookbookAttributes = reqParams.cbAttributes; + }); createCBP.ord =function (){ console.log(createCBP.selectedBpOrder); }; - $rootScope.compositeSave =function (vali) { + $scope.compositeSave =function () { createCBP.onSubmit =true; if(!createCBP.newEnt.bpName || !createCBP.SelectedBPList.length > 0){ return true; @@ -55,8 +71,16 @@ if($rootScope.organObject){ createCBP.newEnt.org =$rootScope.organNewEnt.org.rowid; createCBP.newEnt.buss=$rootScope.organNewEnt.buss.rowid; - createCBP.newEnt.proj=$rootScope.organNewEnt.proj.rowid; - } + createCBP.newEnt.proj=$rootScope.organNewEnt.proj.rowId; + }; + $scope.blueprintList = []; + angular.forEach(createCBP.SelectedBPList, function(val){ + var blueprintObj={ + id: val._id, + attributes: val.blueprintConfig.infraManagerData.versionsList[0].attributes + }; + $scope.blueprintList.push(blueprintObj); + }); var params = { url: '/composite-blueprints/', data:{ @@ -64,13 +88,12 @@ "organizationId":createCBP.newEnt.org, "businessGroupId": createCBP.newEnt.buss, "projectId":createCBP.newEnt.proj, - "blueprints": createCBP.SelectedBPList, - "cloudProviderType": 'aws' + "blueprints": $scope.blueprintList } }; gencSers.promisePost(params).then(function () { toastr.success('Successfully Created.'); - $state.go('dashboard.designSubView',{subItem:$state.params.subItem,view:'list'}); + $state.go('dashboard.design.list',{providerName:$state.params.providerName,templateObj:$state.params.templateObj}); }); }; createCBP.createList(); diff --git a/client/cat3/src/partials/sections/dashboard/design/design.scss b/client/cat3/src/partials/sections/dashboard/design/design.scss index 5e9cd86f9..83b60e1e0 100755 --- a/client/cat3/src/partials/sections/dashboard/design/design.scss +++ b/client/cat3/src/partials/sections/dashboard/design/design.scss @@ -421,4 +421,37 @@ ul.simple-list > li::after { } .show-providers { display: none; -} \ No newline at end of file +} + +fieldset#compBlueprint{ + border: 1px groove #ddd; + padding: 0 1.4em 1.4em 1.4em; + margin: 2em 0 1.5em 0; + -webkit-box-shadow: 0px 0px 0px 0px #000; + box-shadow: 0px 0px 0px 0px #000; + height: 468px; + overflow-y: auto; +} + +fieldset#compBlueprint legend { + font-size: 1.2em; + font-weight: bold; + text-align: left; + border:none; + width:170px; + color: #3a87ad; + margin: 0; +} + +#compBlueprint legend { + display: block; + -webkit-padding-start: 2px; + -webkit-padding-end: 2px; + border: none; + width: auto !important; +} + +.compositeFieldClass { + margin-left: 10px; + width: 98%; +} diff --git a/client/cat3/src/partials/sections/dashboard/design/services/blueprintListServices.js b/client/cat3/src/partials/sections/dashboard/design/services/blueprintListServices.js index 143fd317a..6d6d6be13 100755 --- a/client/cat3/src/partials/sections/dashboard/design/services/blueprintListServices.js +++ b/client/cat3/src/partials/sections/dashboard/design/services/blueprintListServices.js @@ -13,7 +13,7 @@ organObjectId.buss=$rootScope.organNewEnt.buss.rowid; organObjectId.proj=$rootScope.organNewEnt.proj.rowId; var params; - if(tempType === 'docker' || tempType === 'arm'){ + if(tempType === 'docker' || tempType === 'arm' || tempType === 'composite'){ params = { url: '/organizations/'+organObjectId.org+'/businessgroups/'+organObjectId.buss+'/projects/'+organObjectId.proj+'/blueprintList?pagination='+pagination+'&templateType='+tempType+'&providerType=' }; diff --git a/client/cat3/src/partials/sections/dashboard/design/view/createComposite.html b/client/cat3/src/partials/sections/dashboard/design/view/createComposite.html index 854874fd7..0916798ee 100755 --- a/client/cat3/src/partials/sections/dashboard/design/view/createComposite.html +++ b/client/cat3/src/partials/sections/dashboard/design/view/createComposite.html @@ -1,129 +1,127 @@ -
+
- -
- -
- -
+
+ Composite Blueprint:
+
+ +
Please enter Composite Blueprint name! -
-
-
-
-
-
-
-
-
-
-
- -
-
- No Data Found! -
    -
  • - - - {{bp.name}}  {{bp.name}} -
  • -
-
-
-
-
-
-
-
-
- - Selected Blueprints   Please select blueprint. -
-
-
    -
  • - - - - {{(+createCBP.SelectedBPList.indexOf(selectedp)) +1}}{{selectedp.name}}  {{selectedp.name}} -
  • -
- -
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ No Data Found! +
    +
  • + + + {{bp.name}}  {{bp.name}} +
  • +
+
+
+
+
+
+
+
+
+ + Selected Blueprints   Please select blueprint. +
+
+
    +
  • + + + + {{(+createCBP.SelectedBPList.indexOf(selectedp)) +1}}{{selectedp.name}}  {{selectedp.name}} +
  • +
+
+
+
-
-
-
- - - -
- - - - - Edit attribute of Composed Roles and Cookbooks - -
-
- - +
+
+
+
+ + + +
+ + + + + Edit attribute of Composed Roles and Cookbooks + +
+
+ + -
- \ No newline at end of file +
+
+
+
+ + +
+ + +
+ + +
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/design/view/designListView.html b/client/cat3/src/partials/sections/dashboard/design/view/designListView.html index 6db72d8db..080d882f9 100755 --- a/client/cat3/src/partials/sections/dashboard/design/view/designListView.html +++ b/client/cat3/src/partials/sections/dashboard/design/view/designListView.html @@ -4,21 +4,18 @@ {{state.params.templateObj.templatetypename}} blueprints
- - - - + +

No Data Found!
-
+
@@ -29,9 +26,9 @@
- - - + + +
@@ -39,7 +36,7 @@
-
+
@@ -50,14 +47,6 @@
  • {{blueprint.name}}
  • - - - - - - - -
  • diff --git a/client/cat3/src/partials/sections/dashboard/genericServices.js b/client/cat3/src/partials/sections/dashboard/genericServices.js index 79ee2c411..2d26f668a 100644 --- a/client/cat3/src/partials/sections/dashboard/genericServices.js +++ b/client/cat3/src/partials/sections/dashboard/genericServices.js @@ -91,7 +91,7 @@ }; genericServices.moreInfo= function(blueprintObj,bpType){ - if(bpType === 'compBlueInfo'){ + if(bpType === 'composite'){ $modal.open({ animation: true, templateUrl: 'src/partials/sections/dashboard/workzone/blueprint/popups/compositeBlueprintInfo.html', @@ -100,7 +100,7 @@ keyboard: false, resolve: { items: function() { - return blueprintObj ; + return blueprintObj; } } }); 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 21fa0fb2c..4ef3b348c 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 @@ -23,13 +23,13 @@ }); genericServices.getTreeNew().then(function (envData) { angular.forEach(envData,function(val){ - if(val.rowid === items.orgId){ + if(val.rowid === items.orgId || val.rowid === items.organizationId){ $scope.orgSeleted=val.name; angular.forEach(val.businessGroups,function(busval){ - if(busval.rowid === items.bgId){ + if(busval.rowid === items.bgId || busval.rowid === items.businessGroupId){ $scope.busSeleted=busval.name; angular.forEach(busval.projects,function(projval){ - if(projval.rowId === items.projectId){ + if(projval.rowId === items.projectId || projval.rowId === items.projectId){ $scope.projSeleted=projval.name; $scope.envOptions=projval.environments; if(workzoneEnvironment.getEnvParams() && workzoneEnvironment.getEnvParams().env){ diff --git a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/compositeBlueprintInfo.html b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/compositeBlueprintInfo.html index 53e7670cd..8a0613a5a 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/compositeBlueprintInfo.html +++ b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/popups/compositeBlueprintInfo.html @@ -1,7 +1,7 @@
    diff --git a/client/cat3/src/partials/sections/dashboard/genericServices.js b/client/cat3/src/partials/sections/dashboard/genericServices.js index 2d26f668a..754495528 100644 --- a/client/cat3/src/partials/sections/dashboard/genericServices.js +++ b/client/cat3/src/partials/sections/dashboard/genericServices.js @@ -163,11 +163,11 @@ headerText: 'Delete Blueprint', bodyText: 'Are you sure you want to delete this blueprint?' }; - if(bpType === 'compositeBlueprint'){ + if(bpType === 'composite'){ confirmbox.showModal({}, modalOptions).then(function() { - workSvs.deleteCompsiteBlueprint(blueprintObj).success(function() { - angular.element('#'+blueprintObj).hide(); + workSvs.deleteCompsiteBlueprint(blueprintObj._id).success(function() { toastr.success('Successfully deleted'); + $rootScope.$emit('BP_BLUEPRINTS_REFRESH_CURRENT'); }).error(function(data) { toastr.error(data.message, 'Error'); }); @@ -177,6 +177,7 @@ workSvs.deleteBlueprint(blueprintObj._id).success(function() { angular.element('#'+blueprintObj._id).hide(); toastr.success('Successfully deleted'); + $rootScope.$emit('BP_BLUEPRINTS_REFRESH_CURRENT'); }).error(function(data) { toastr.error(data.message, 'Error'); }); diff --git a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/blueprint.html b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/blueprint.html index 3d5794062..60f9adecc 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/blueprint/blueprint.html +++ b/client/cat3/src/partials/sections/dashboard/workzone/blueprint/blueprint.html @@ -277,7 +277,7 @@
    - +
    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 a2fdf4c12..ee04b891a 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 @@ -9,131 +9,136 @@ "use strict"; angular.module('workzone.blueprint') .controller('blueprintLaunchCtrl', ['$scope', '$rootScope', '$modalInstance', 'bpItem', 'workzoneServices', 'workzoneEnvironment', 'instanceLogs', function($scope, $rootScope, $modalInstance, bpItem, workzoneServices, workzoneEnvironment, instanceLogs) { - console.log(bpItem); - $scope.isBPLogsLoading = true; - $scope.isNewInstanceLogsPromise = false; - var helper = { - showNewInstanceLogs: function(newInstanceId){ - var promise = instanceLogs.showInstanceLogs(newInstanceId); - $scope.isNewInstanceLogsPromise = true; - promise.then(function(resolveMessage) { - console.log(resolveMessage); - },function(rejectMessage) { - console.log(rejectMessage); - $scope.logsErrorMessage = rejectMessage; - },function(notifyMessage) { - if(notifyMessage.fullLogs) { - $scope.logListInitial = notifyMessage.logs; - $scope.isInstanceLogsLoading = false; - } else { - if(notifyMessage.logs.length){ - $scope.logListDelta.push.apply($scope.logListDelta, notifyMessage.logs); + console.log(bpItem); + if(bpItem.bp.blueprintType) { + $scope.isBPLogsLoading = true; + $scope.isNewInstanceLogsPromise = false; + var helper = { + showNewInstanceLogs: function(newInstanceId){ + var promise = instanceLogs.showInstanceLogs(newInstanceId); + $scope.isNewInstanceLogsPromise = true; + promise.then(function(resolveMessage) { + console.log(resolveMessage); + },function(rejectMessage) { + console.log(rejectMessage); + $scope.logsErrorMessage = rejectMessage; + },function(notifyMessage) { + if(notifyMessage.fullLogs) { + $scope.logListInitial = notifyMessage.logs; + $scope.isInstanceLogsLoading = false; + } else { + if(notifyMessage.logs.length){ + $scope.logListDelta.push.apply($scope.logListDelta, notifyMessage.logs); + } } - } - instanceLogs.scrollBottom(); - }); - } - }; - var messageHelper = { - launchMessage:function(){ - var msgStr = '', isSuccess=false; - if($scope.launchResponse.error){ - isSuccess = false; - msgStr = $scope.launchResponse.error; + instanceLogs.scrollBottom(); + }); } - else{ - isSuccess = true; - if (bpItem.bp.blueprintType === 'aws_cf') { - msgStr = 'Stack Id : ' + $scope.launchResponse.stackId + '. You can view your stack in cloudformation tab'; - } else if (bpItem.bp.blueprintType === 'azure_arm') { - msgStr = 'Deployment Id : ' + $scope.launchResponse.armId + '. You can view your deployment in ARM tab'; - } else { - msgStr = 'Instance Id : '; - msgStr += $scope.launchResponse.id.join(','); - msgStr += '. You can monitor logs from the Launched Instances.'; + }; + var messageHelper = { + launchMessage:function(){ + var msgStr = '', isSuccess=false; + if($scope.launchResponse.error){ + isSuccess = false; + msgStr = $scope.launchResponse.error; + } + else{ + isSuccess = true; + if (bpItem.bp.blueprintType === 'aws_cf') { + msgStr = 'Stack Id : ' + $scope.launchResponse.stackId + '. You can view your stack in cloudformation tab'; + } else if (bpItem.bp.blueprintType === 'azure_arm') { + msgStr = 'Deployment Id : ' + $scope.launchResponse.armId + '. You can view your deployment in ARM tab'; + } else { + msgStr = 'Instance Id : '; + msgStr += $scope.launchResponse.id.join(','); + msgStr += '. You can monitor logs from the Launched Instances.'; + } } + return { + message: msgStr, + isSuccess:isSuccess + }; } - return { - message: msgStr, - isSuccess:isSuccess - }; - } - }; + }; - angular.extend($scope, { - logListInitial: [], - logListDelta: [], - cancel: function() { - if($scope.isNewInstanceLogsPromise){ - instanceLogs.stopLogsPolling(); + angular.extend($scope, { + logListInitial: [], + logListDelta: [], + cancel: function() { + if($scope.isNewInstanceLogsPromise){ + instanceLogs.stopLogsPolling(); + } + $modalInstance.dismiss('cancel'); } - $modalInstance.dismiss('cancel'); - } - }); - - var envParams = workzoneEnvironment.getEnvParams(); - var versionsList = []; - var versionOptional; + }); - if(bpItem.bp.blueprintConfig.infraManagerData && bpItem.bp.blueprintConfig.infraManagerData.versionsList){ - versionsList = bpItem.bp.blueprintConfig.infraManagerData.versionsList; - versionOptional = versionsList[versionsList.length-1].ver; - } - var selectedVersionBpId = bpItem.bp.selectedVersionBpId; - if(bpItem && bpItem.bp && bpItem.bp.selectedVersionBpId){ - selectedVersionBpId = bpItem.bp.selectedVersionBpId; - } else { - selectedVersionBpId = bpItem.bp._id; - } - var lEnv=null; - if(envParams && envParams.env){ - lEnv=envParams.env; - } - if(bpItem.launchEnv){ - lEnv=bpItem.launchEnv; - } - workzoneServices.launchBlueprint(selectedVersionBpId, versionOptional, lEnv, bpItem.stackName,bpItem.domainName,bpItem.tagServer).then(function(bpLaunchResponse) { - $scope.isBPLogsLoading = false; - var launchingInstance; - if(bpLaunchResponse.data.id && bpLaunchResponse.data.id.length>0){ - launchingInstance = bpLaunchResponse.data; - }else if(bpLaunchResponse.data.stackId || bpLaunchResponse.data.armId){ - launchingInstance = bpLaunchResponse.data; + var envParams = workzoneEnvironment.getEnvParams(); + var versionsList = []; + var versionOptional; + if(bpItem.bp.blueprintConfig){ + if(bpItem.bp.blueprintConfig.infraManagerData && bpItem.bp.blueprintConfig.infraManagerData.versionsList){ + versionsList = bpItem.bp.blueprintConfig.infraManagerData.versionsList; + versionOptional = versionsList[versionsList.length-1].ver; + } } - $scope.launchResponse = launchingInstance; - $scope.launchMessage = messageHelper.launchMessage(); - //Show logs and poll them, if only one id in array. For CFT, no polling, no id in response. It will be stackId. - if($scope.launchResponse.id && $scope.launchResponse.id.length===1){ - helper.showNewInstanceLogs($scope.launchResponse.id[0]); - $scope.isNewInstanceLogsPromise = true; + var selectedVersionBpId = bpItem.bp.selectedVersionBpId; + if(bpItem && bpItem.bp && bpItem.bp.selectedVersionBpId){ + selectedVersionBpId = bpItem.bp.selectedVersionBpId; + } else { + selectedVersionBpId = bpItem.bp._id; } - //event to update the instance tab when blueprint is launched. - $rootScope.$emit('WZ_INSTANCES_SHOW_LATEST'); - //event to update the Cloud Formation tab when blueprint is launched. - if(bpLaunchResponse.data.stackId) { - $rootScope.$emit('WZ_CFT_SHOW_LATEST'); - //event to update the AzureARM tab when blueprint is launched. - } else if(bpLaunchResponse.data.armId) { - $rootScope.$emit('WZ_AzureARM_SHOW_LATEST'); + var lEnv=null; + if(envParams && envParams.env){ + lEnv=envParams.env; + } + if(bpItem.launchEnv){ + lEnv=bpItem.launchEnv; } - },function(bpLaunchError) { - $scope.isBPLogsLoading = false; - var message = "Server Behaved Unexpectedly"; + workzoneServices.launchBlueprint(selectedVersionBpId, versionOptional, lEnv, bpItem.stackName,bpItem.domainName,bpItem.tagServer).then(function(bpLaunchResponse) { + $scope.isBPLogsLoading = false; + var launchingInstance; + if(bpLaunchResponse.data.id && bpLaunchResponse.data.id.length>0){ + launchingInstance = bpLaunchResponse.data; + }else if(bpLaunchResponse.data.stackId || bpLaunchResponse.data.armId){ + launchingInstance = bpLaunchResponse.data; + } + $scope.launchResponse = launchingInstance; + $scope.launchMessage = messageHelper.launchMessage(); + //Show logs and poll them, if only one id in array. For CFT, no polling, no id in response. It will be stackId. + if($scope.launchResponse.id && $scope.launchResponse.id.length===1){ + helper.showNewInstanceLogs($scope.launchResponse.id[0]); + $scope.isNewInstanceLogsPromise = true; + } + //event to update the instance tab when blueprint is launched. + $rootScope.$emit('WZ_INSTANCES_SHOW_LATEST'); + //event to update the Cloud Formation tab when blueprint is launched. + if(bpLaunchResponse.data.stackId) { + $rootScope.$emit('WZ_CFT_SHOW_LATEST'); + //event to update the AzureARM tab when blueprint is launched. + } else if(bpLaunchResponse.data.armId) { + $rootScope.$emit('WZ_AzureARM_SHOW_LATEST'); + } + },function(bpLaunchError) { + $scope.isBPLogsLoading = false; + var message = "Server Behaved Unexpectedly"; - if(bpLaunchError){ - message = bpLaunchError; - } - if(bpLaunchError.data){ - message = bpLaunchError.data; - } - if (bpLaunchError.data && bpLaunchError.data.message) { - message = bpLaunchError.data.message; - }else if(bpLaunchError.responseText){ - message = bpLaunchError.responseText; - } - $scope.launchResponse = {error:message}; - $scope.launchMessage = messageHelper.launchMessage(); - }); + if(bpLaunchError){ + message = bpLaunchError; + } + if(bpLaunchError.data){ + message = bpLaunchError.data; + } + if (bpLaunchError.data && bpLaunchError.data.message) { + message = bpLaunchError.data.message; + }else if(bpLaunchError.responseText){ + message = bpLaunchError.responseText; + } + $scope.launchResponse = {error:message}; + $scope.launchMessage = messageHelper.launchMessage(); + }); + } else { + + } } ]); })(angular); \ No newline at end of file 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 4ef3b348c..d7db20466 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 @@ -8,7 +8,7 @@ (function(angular){ "use strict"; angular.module('workzone.blueprint') - .controller('blueprintLaunchParamsCtrl', ['$scope', '$modalInstance', 'items','workzoneServices','genericServices','workzoneEnvironment', function($scope, $modalInstance, items,workzoneServices,genericServices,workzoneEnvironment) { + .controller('blueprintLaunchParamsCtrl', ['$scope', '$modalInstance', 'toastr', 'items','workzoneServices','genericServices','workzoneEnvironment', function($scope, $modalInstance, toastr, items,workzoneServices,genericServices,workzoneEnvironment) { console.log(items); var launchHelper = { launch : function(){ @@ -23,13 +23,23 @@ }); genericServices.getTreeNew().then(function (envData) { angular.forEach(envData,function(val){ - if(val.rowid === items.orgId || val.rowid === items.organizationId){ + 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; + } else { + orgID = items.organizationId; + bgID = items.businessGroupId; + projID = items.projectId; + } + if(val.rowid === orgID){ $scope.orgSeleted=val.name; angular.forEach(val.businessGroups,function(busval){ - if(busval.rowid === items.bgId || busval.rowid === items.businessGroupId){ + if(busval.rowid === bgID){ $scope.busSeleted=busval.name; angular.forEach(busval.projects,function(projval){ - if(projval.rowId === items.projectId || projval.rowId === items.projectId){ + if(projval.rowId === projID){ $scope.projSeleted=projval.name; $scope.envOptions=projval.environments; if(workzoneEnvironment.getEnvParams() && workzoneEnvironment.getEnvParams().env){ @@ -53,14 +63,27 @@ $modalInstance.dismiss('cancel'); }; $scope.launchBP = function() { - if(items.blueprintType === "aws_cf") { - $scope.showCFTInputs = true; - }else if(items.blueprintType === "azure_arm") { - $scope.showARMInputs = true; - }else if(items.domainNameCheck === true || items.domainNameCheck === "true") { - $scope.showBlueprintInputs = true; - }else { - launchHelper.launch(); + if(items.orgId === undefined){ + var compBlue={ + "blueprintId": (items.id)?items.id:items._id, + "environmentId": $scope.envSeleted + }; + workzoneServices.launchCompsiteBlueprint(compBlue).success(function() { + toastr.success('Successfully launched composite blueprint'); + return false; + }).error(function(data) { + toastr.error(data.message, 'Error'); + }); + } else { + if(items.blueprintType === "aws_cf") { + $scope.showCFTInputs = true; + }else if(items.blueprintType === "azure_arm") { + $scope.showARMInputs = true; + }else if(items.domainNameCheck === true || items.domainNameCheck === "true") { + $scope.showBlueprintInputs = true; + }else { + launchHelper.launch(); + } } }; $scope.cftSubmitHandler = function(){