Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
workzoneServices.getTaggingServer().then(function (topSer) {
$scope.taggingServerList=topSer.data;
});
$scope.chefAttributesFlag = false;
$scope.scriptParamsFlag = false;
if(items.taskConfig.attributes && items.taskConfig.attributes.length) {
$scope.chefAttributesFlag = true;
}
if(items.taskType === 'script') {
for (var i=0; i<items.taskConfig.scriptDetails.length; i++) {
if(items.taskConfig.scriptDetails[i].scriptParameters.length > 0) {
$scope.scriptParamsFlag = true;
}
}
}
$scope.isChefattributesLoading = true;
if (items.taskType === 'chef') {
$scope.chefComponentSelectorList = responseFormatter.findDataForEditValue(items.taskConfig.runlist);
Expand Down Expand Up @@ -55,37 +67,39 @@
$scope.scriptparams = items.taskConfig.scriptDetails;
$scope.parameters=[''];
var taskData={};
var attributes = [];
var scriptDetails = [];
var cookbookAttributes = [];
var scriptParams = [];
var choiceParam = {}, key;
var tagServer = "";
$scope.tagSerSelected;
$scope.add = function() {
$scope.parameters.push('');
};

$scope.removeScriptInputParams = function(paramInput) {
if($scope.parameters.length > 1){
var idx = $scope.parameters.indexOf(paramInput);
$scope.parameters.splice(idx,1);
}else{
toastr.error('Cannot delete the row');
}
}

$scope.executeBot=function(){
var taskData={};
var taggedServer = $scope.tagSerSelected;
//var taskData={};
if (items.taskConfig.taskType === 'script') {
var checkParam = false;
for(var i =0; i<$scope.parameters.length; i++){
if($scope.parameters[i] === '' || $scope.parameters[i] === null){
checkParam = false;
toastr.error('Please enter parameters');
return false;
} else {
checkParam = true;
}
if ($scope.scriptParamsFlag) {
checkParam = true;
}
if(checkParam){
//$modalInstance.close($scope.parameters);
scriptDetails = $scope.parameters;
taggedServer = taggedServer;
}
scriptParams = $scope.parameters;
}
}
if (items.taskConfig.taskType === 'chef') {
//taskJSON.runlist = responseFormatter.formatSelectedChefRunList($scope.chefrunlist);
attributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes);
taggedServer = taggedServer;
cookbookAttributes = responseFormatter.formatSelectedCookbookAttributes($scope.chefattributes);

}
if (items.taskConfig.taskType === 'jenkins') {
for(var i=0;i<$scope.jenkinsparams.length;i++){
Expand All @@ -97,17 +111,24 @@
};

$scope.executeTask = function(taskData){
if (items.taskConfig.taskType === 'jenkins') {
var reqBody = choiceParam;
var reqBody = {};
if (items.taskConfig.taskType === 'jenkins') {
reqBody.choiceParams = choiceParam;
} else if (items.taskConfig.taskType === 'chef'){
var reqBody = attributes;
reqBody.tagServer = $scope.tagSerSelected;
if ($scope.chefAttributesFlag) {
reqBody.cookbookAttributes = cookbookAttributes;
}
} else if (items.taskConfig.taskType === 'script') {
var reqBody = scriptDetails;
reqBody.tagServer = $scope.tagSerSelected;
if ($scope.scriptParamsFlag) {
reqBody.scriptParams = scriptParams;
}
}
workzoneServices.runTask(items._id, reqBody).then(
function (response) {
$modalInstance.close(response.data);
helper.orchestrationLogModal(task._id, response.data.historyId, task.taskType);
$rootScope.$emit('BOTS_LIBRARY_REFRESH');
$rootScope.$emit('WZ_ORCHESTRATION_REFRESH_CURRENT');
},
function (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
});
});
};

$rootScope.$on('BOTS_LIBRARY_REFRESH', function() {
lib.init();
});
lib.init =function(){
lib.gridOptions.data=[];
var param={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h4 class="modal-title"> <i class="fa fa-share-square-o"></i>&nbsp;&nbsp;Execute

<div class="modal-body">
<fieldset>
<div class="col-lg-12 col-md-12 paddingbottom10">
<div class="col-lg-12 col-md-12 paddingbottom10" ng-hide="taskType === 'jenkins'">
<div class="col-lg-2 col-md-2 no-padding">
<label for="" class="margintop8">Tag Server:</label>
</div>
Expand All @@ -17,7 +17,7 @@ <h4 class="modal-title"> <i class="fa fa-share-square-o"></i>&nbsp;&nbsp;Execute
</select>
</div>
</div>
<div class="col-lg-12 col-md-12" ng-show="taskType === 'chef'">
<div class="col-lg-12 col-md-12" ng-show="taskType === 'chef' && chefAttributesFlag">
<h4 style="margin-top: 0px;">Edit Parameters:</h4>
<loading size="large" name="isChefattributesLoading" type="block" align="center"></loading>
<table class="table table-bordered text-center" ng-show="!isChefattributesLoading">
Expand All @@ -31,14 +31,14 @@ <h4 style="margin-top: 0px;">Edit Parameters:</h4>
<tbody ng-repeat="attr in chefattributes">
<tr ng-repeat="(key, value) in attr.attributes">
<td>
<input type="text" ng-model="attr.cookbookName" class="form-control">
<span>{{attr.cookbookName}}</span>
</td>
<td>
<input type="text" ng-model="value.display_name" class="form-control">
{{value.display_name}}
</td>
<td>
<td style="text-align: left">
<input type="text" class="cookbook-edit-text" ng-model="value.default" ng-if="!value.choice.length" />
<select ng-if="value.choice.length" class="cookbook-edit-text" ng-options="choice for choice in value.choice" ng-model="value.default" ng-disabled="!isAttributesEditable"></select>
<select ng-if="value.choice.length" class="cookbook-edit-text" ng-options="choice for choice in value.choice" ng-model="value.default"></select>
</td>
</tr>
</tbody>
Expand All @@ -56,7 +56,7 @@ <h4 style="margin-top: 0px;">Edit Parameters:</h4>
<tbody>
<tr ng-repeat="params in jenkinsparams">
<td>
<input type="text" ng-model="params.name" class="form-control">
<span style="vertical-align: -webkit-baseline-middle;">{{params.name}}</span>
</td>
<td>
<input type="text" ng-model="params.defaultValue" class="form-control">
Expand All @@ -65,7 +65,7 @@ <h4 style="margin-top: 0px;">Edit Parameters:</h4>
</tbody>
</table>
</div>
<div class="col-lg-12 col-md-12" ng-show="taskType === 'script'">
<div class="col-lg-12 col-md-12" ng-if="taskType === 'script' && scriptParamsFlag">
<h4 style="margin-top: 0px;">Add Parameters:</h4>
<div class="parameter-section">
<div class="col-lg-12 col-md-12 margintop15">
Expand All @@ -74,12 +74,14 @@ <h4 style="margin-top: 0px;">Add Parameters:</h4>
<tr>
<th class="headParamTable">Key</th>
<th class="headParamTable">Value</th>
<th class="headParamTable">Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="param in parameters track by $index">
<td class="booleanParam"><label class="control-label" for="choiceName">Parameter {{$index+1}}:<span class="red">*</span></label></td>
<td><input id="value" type="text" class="form-control" name="value" ng-model="parameters[$index]"></td>
<td><button ng-show="$index>0" class="scriptParamsDelete" title="Delete Row" type="button" ng-click="removeScriptInputParams(parameters[$index]);"><i class=" fa fa-trash-o"></i></button></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -116,4 +118,8 @@ <h4 style="margin-top: 0px;">Add Parameters:</h4>
.margintop8 {
margin-top: 8px;
}

.cookbook-edit-text {
background: #fff;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
};

genericServices.executeTask =function(task) {
if ((task.taskConfig.parameterized && task.taskConfig.parameterized.length) || (task.taskConfig.attributes && task.taskConfig.attributes.length) || (task.taskConfig.scriptDetails && task.taskConfig.scriptDetails.length)) {
if ((task.taskConfig.parameterized && task.taskConfig.parameterized.length) || (task.taskType === 'chef') || (task.taskType === 'script')) {
$modal.open({
animation: true,
templateUrl: 'src/partials/sections/dashboard/bots/view/editParams.html',
Expand Down