Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed API call to pass in region number get list of repos/playbooks #1354

Merged
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
@@ -1,4 +1,4 @@
ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalogItemFormId', 'miqService', 'postService', 'API', 'catalogItemDataFactory', function($scope, catalogItemFormId, miqService, postService, API, catalogItemDataFactory) {
ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalogItemFormId', 'currentRegion', 'miqService', 'postService', 'API', 'catalogItemDataFactory', function($scope, catalogItemFormId, currentRegion, miqService, postService, API, catalogItemDataFactory) {
var vm = this;
var sort_options = "&sort_by=name&sort_order=ascending"
var init = function() {
Expand Down Expand Up @@ -39,6 +39,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
getRemoveResourcesTypes();
vm.provisioning_cloud_type = '';
vm.retirement_cloud_type = '';
vm.currentRegion = currentRegion;
vm.formId = catalogItemFormId;
vm.afterGet = false;
vm.model = "catalogItemModel";
Expand Down Expand Up @@ -260,7 +261,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
})

// list of repositories
API.get("/api/configuration_script_sources?collection_class=ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource&expand=resources&attributes=id,name" + sort_options).then(function(data) {
API.get("/api/configuration_script_sources?collection_class=ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource&expand=resources&attributes=id,name&filter[]=region_number=" + vm.currentRegion + sort_options).then(function(data) {
vm.repositories = data.resources;
vm._retirement_repository = _.find(vm.repositories, {id: vm.catalogItemModel.retirement_repository_id});
vm._provisioning_repository = _.find(vm.repositories, {id: vm.catalogItemModel.provisioning_repository_id});
Expand Down Expand Up @@ -326,8 +327,8 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog

// get playbooks for selected repository
vm.repositoryChanged = function(prefix, id) {
API.get("/api/configuration_script_sources/" + id + "?attributes=configuration_script_payloads" + sort_options).then(function (data) {
vm[prefix + '_playbooks'] = data.configuration_script_payloads;
API.get("/api/configuration_script_sources/" + id + "/configuration_script_payloads?expand=resources&filter[]=region_number=" + vm.currentRegion + sort_options).then(function (data) {
vm[prefix + '_playbooks'] = data.resources;
// if repository has changed
if (id !== vm.catalogItemModel[prefix + '_repository_id']) {
vm.catalogItemModel[prefix + '_playbook_id'] = '';
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,9 @@ def ot_show

def ansible_playbook?
prov_type = params[:st_prov_type] ? params[:st_prov_type] : @record.prov_type
prov_type == "generic_ansible_playbook"
ansible_playbook = prov_type == "generic_ansible_playbook"
@current_region = MiqRegion.my_region.region if ansible_playbook
ansible_playbook
end
helper_method :ansible_playbook?

Expand Down
1 change: 1 addition & 0 deletions app/views/catalog/_st_angular_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@

:javascript
ManageIQ.angular.app.value('catalogItemFormId', '#{@record.id || "new"}');
ManageIQ.angular.app.value('currentRegion', '#{@current_region}');
miq_bootstrap('#form_div');

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('catalogItemFormController', function() {
var $scope, $controller, postService;
var $scope, $controller, currentRegion, postService;

beforeEach(module('ManageIQ'));

Expand Down Expand Up @@ -46,6 +46,7 @@ describe('catalogItemFormController', function() {

$controller = _$controller_('catalogItemFormController', {
$scope: $scope,
currentRegion: currentRegion,
catalogItemFormId: 1000000000001
});
}));
Expand Down