Skip to content

Commit

Permalink
Fix minor toolbar buttons and received data
Browse files Browse the repository at this point in the history
  • Loading branch information
ZitaNemeckova committed Mar 8, 2017
1 parent a0fcaad commit 37f074f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$http', '$scope',
};

$scope.cancelClicked = function() {
getBack();
getBack('Action canceled by user.', 'warning');
};

$scope.resetClicked = function() {
Expand All @@ -46,28 +46,31 @@ ManageIQ.angular.app.controller('repositoryFormController', ['$http', '$scope',
};

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

$scope.addClicked = function() {
API.post('/api/configuration_script_sources', vm.repositoryModel)
.then(getBack)
.catch(miqService.handleFailure);
// TODO send all info
//API.post('/api/configuration_script_sources/', {name: vm.repositoryModel.name, description: vm.repositoryModel.description})
// .then(getBack)
// .catch(miqService.handleFailure);
getBack('Repository added', 'success');
};

function getRepositoryFormData(response) {
var data = response.data;
var data = response;
Object.assign(vm.repositoryModel, data);
vm.modelCopy = angular.copy( vm.repositoryModel );
vm.afterGet = true;
miqService.sparkleOff();
}

function getBack() {
// TODO add flash message
window.location.href = '/ansible_repository/show_list';
function getBack(message, level) {
window.location.href = '/ansible_repository/show_list' + '?message=' + message + '&level=' + level;
}

init();
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/directives/checkchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ ManageIQ.angular.app.directive('checkchange', ['miqService', function(miqService
ctrl.$parsers.push(function(value) {
miqService.miqFlashClear();

debugger;
if (value == modelCopy()[ctrl.$name]) {
scope.angularForm[scope['formchange_' + ctrl.$name]].$setPristine();
}
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/services/miq_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ ManageIQ.angular.app.service('miqService', ['$timeout', '$document', '$q', '$log
}

this.saveable = function(form) {
debugger;
return form.$valid && form.$dirty;
};

Expand Down
30 changes: 24 additions & 6 deletions app/controllers/ansible_repository_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ def self.model
ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource
end

def get_session_data
@center_toolbar = 'ansible_repositories'
super
end

def button
if params[:pressed] == "embedded_configuration_script_source_edit"
binding.pry
id = from_cid(params[:miq_grid_checks])
javascript_redirect :action => 'edit', :id => id
elsif params[:pressed] == "embedded_configuration_script_source_add"
javascript_redirect :action => 'new'
elsif params[:pressed] == "embedded_configuration_script_source_delete"
binding.pry
ids = params[:miq_grid_checks].split(',')
ids.each do |id|
ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource.delete(from_cid(id).to_i)
end
# TODO nicer way?
add_flash(_('Selected repositories were deleted'), :success)
show_list
replace_gtl_main_div
end
end

Expand All @@ -49,6 +52,21 @@ def display_playbooks
nested_list("ansible_playbook", ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook)
end

def show
@center_toolbar = 'ansible_repository'
super
end

def show_list
@center_toolbar = 'ansible_repositories'
# TODO remove adding stuff
if params[:message].present?
add_flash(params[:message], params[:level].to_sym)
ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource.create(:name => 'dummy Repository', :description => "Couldn't save your repository :P ")
end
super
end

private

def textual_group_list
Expand Down
8 changes: 0 additions & 8 deletions app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,6 @@ def inventory_group_center_tb
end
end

def ansible_repository_center_tb
"ansible_repository_center_tb"
end

def ansible_repositories_center_tb
"ansible_repositories_center_tb"
end

def unassigned_configuration_profile_node(nodes)
configuration_profile_center_tb if nodes[2] == "unassigned"
end
Expand Down

0 comments on commit 37f074f

Please sign in to comment.