Skip to content

Commit

Permalink
Fix adding credential to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ZitaNemeckova committed Mar 27, 2017
1 parent 3c4b3c4 commit 4a4c362
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$scope', 'reposito
scm_type: 'git',
manager_resource: {},
scm_url: '',
scm_credentials: null,
authentication_id: null,
scm_branch: '',
scm_clean: false,
scm_delete_on_update: false,
Expand All @@ -28,7 +28,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$scope', 'reposito
$scope.newRecord = repositoryId === 'new';

vm.scm_credentials = [{name: __('Select credentials'), value: null}];
API.get('/api/authentications?collection_class=ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ScmCredential&expand=resources')
API.get('/api/authentications?collection_class=ManageIQ::Providers::EmbeddedAutomationManager::Authentication&expand=resources')
.then(getCredentials)
.catch(miqService.handleFailure);

Expand All @@ -44,6 +44,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$scope', 'reposito
};

$scope.cancelClicked = function() {
miqSparkleOn();
var message = $scope.newRecord ? __('Add of Repository cancelled by user.') : sprintf(__('Edit of Repository \"%s\" cancelled by user.'), vm.repositoryModel.name);
var url = '/ansible_repository/show_list' + '?flash_msg=' + message + '&escape=true&flash_warning=true&flash_error=false';
window.location.href = url;
Expand All @@ -56,15 +57,17 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$scope', 'reposito
};

$scope.saveClicked = function() {
miqSparkleOn();
API.put('/api/configuration_script_sources/' + repositoryId, vm.repositoryModel)
.then(getBack)
.catch(miqService.handleFailure);
};

$scope.addClicked = function() {
miqSparkleOn();
API.post('/api/configuration_script_sources/', vm.repositoryModel)
.then(getBack)
.catch(miqService.handleFailure);
.then(getBack)
.catch(miqService.handleFailure);
};

var getRepositoryFormData = function(response) {
Expand Down Expand Up @@ -102,7 +105,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$scope', 'reposito

var getCredentials = function(response) {
response.resources.forEach( function(resource) {
vm.scm_credentials.push({name: resource.name, value: resource.href});
vm.scm_credentials.push({name: resource.name, value: resource.id});
});
};

Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/directives/url_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ManageIQ.angular.app.directive('urlValidation', function() {
};

var validUrl = function(s) {
debugger;
return s.substring(0, 8) === 'https://' || s.substring(0, 7) === 'http://';
};
}
Expand Down
5 changes: 1 addition & 4 deletions app/views/ansible_repository/_repository_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
%label.col-md-2.control-label
= _('SCM credentials')
.col-md-8
%select{'ng-model' => 'vm.repositoryModel.scm_credentials',
%select{'ng-model' => 'vm.repositoryModel.authentication_id',
'ng-options' => 'scm_credential.value as scm_credential.name for scm_credential in vm.scm_credentials'}
.form-group
%label.col-md-2.control-label
Expand Down Expand Up @@ -90,6 +90,3 @@
:javascript
ManageIQ.angular.app.value('repositoryId', '#{@id}');
miq_bootstrap('#form_div');
$("#form-div").submit(function (e) {
miqSparkleOn();
});

0 comments on commit 4a4c362

Please sign in to comment.