Project

General

Profile

« Previous | Next » 

Revision 159a7a62

Added by Ohad Levy almost 12 years ago

  • ID 159a7a62755e8a1a2831e27918c0145cca4cacb4

[UI] - convert all bulk operations into buttons

View differences:

app/helpers/hosts_helper.rb
def multiple_actions_select
actions = [
['Select Actions', ''],
['Change Group', select_multiple_hostgroup_hosts_path],
['Change Environment', select_multiple_environment_hosts_path],
['Edit Parameters', multiple_parameters_hosts_path],
['Delete Hosts', multiple_destroy_hosts_path],
['Disable Notifications', multiple_disable_hosts_path],
['Enable Notifications', multiple_enable_hosts_path],
['Change Group', select_multiple_hostgroup_hosts_path, 'pencil'],
['Change Environment', select_multiple_environment_hosts_path, 'chevron-right'],
['Edit Parameters', multiple_parameters_hosts_path, 'edit'],
['Delete Hosts', multiple_destroy_hosts_path, 'trash'],
['Disable Notifications', multiple_disable_hosts_path, 'eye-close'],
['Enable Notifications', multiple_enable_hosts_path, 'bullhorn'],
]
actions.insert(1, ['Build Hosts', multiple_build_hosts_path]) if SETTINGS[:unattended]
actions << ['Run Puppet', multiple_puppetrun_hosts_path] if Setting[:puppetrun]
actions.insert(1, ['Build Hosts', multiple_build_hosts_path, 'fast-forward']) if SETTINGS[:unattended]
actions << ['Run Puppet', multiple_puppetrun_hosts_path, 'play'] if Setting[:puppetrun]
content_tag :span, :id => 'submit_multiple', :class => 'fl' do
actions.map do |action|
link_to(icon_text(action[2]), action[1], :title => action[0])
end.join(' ').html_safe
end
select_tag "Multiple Actions", options_for_select(actions), :id => "Submit_multiple",
:class => "medium", :title => "Perform Actions on multiple hosts"
end
def date ts=nil
app/views/hosts/multiple_parameters.html.erb
<% else -%>
<%= form_tag update_multiple_parameters_hosts_path({:host_ids => params[:host_ids]}) do %>
<% for param in @parameters %>
<div class="clearfix">
<%= label_tag :name, param.name %>
<div class=input>
<%= text_field :name, param.name, :class => "input-xxlarge" %>
</div>
</div>
<%= text_field :name, param.name, :class => "input-xxlarge", :placeholder => param.name %>
<% end %>
<% end %>
<% end %>
public/javascripts/host_checkbox.js
}
function toggle_actions() {
var dropdown = $("#Submit_multiple");
var dropdown = $("#submit_multiple a");
if ($.foremanSelectedHosts.length == 0) {
dropdown.addClass("disabled");
dropdown.attr('disabled', 'disabled')
dropdown.addClass("disabled hide");
dropdown.attr('disabled', 'disabled');
} else {
dropdown.removeClass("disabled");
dropdown.removeClass("disabled hide");
dropdown.removeAttr('disabled');
}
}
......
// updates the form URL based on the action selection
$(function() {
$('#Submit_multiple').change(function(){
if ($.foremanSelectedHosts.length == 0 || $(this).val()==''){ return false }
var title = $('#Submit_multiple option:selected').text() + " - The following hosts are about to be changed";
$('#submit_multiple a').click(function(){
if ($.foremanSelectedHosts.length == 0) { return false }
var title = $(this).attr('data-original-title') + ' - The following hosts are about to be changed';
var url = $(this).attr('href') + "?" + $.param({host_ids: $.foremanSelectedHosts});
$('#confirmation-modal .modal-header h3').text(title);
$('#confirmation-modal .modal-body').empty().append("<img class='modal-loading' src='/images/spinner.gif'>");
$('#confirmation-modal').modal({show: "true", backdrop: "static"});
$("#confirmation-modal .modal-body").load(url + " #content",
function(response, status, xhr) {
$("#loading").hide();
$('#submit_multiple').val('');
});
return false;
});
$('#confirmation-modal .btn-primary').click(function(){
......
$('#confirmation-modal').modal('hide');
});
$("#confirmation-modal").bind('shown', function () {
var url = $('#Submit_multiple').val() + "?" + $.param({host_ids: $.foremanSelectedHosts});
$("#confirmation-modal .modal-body").load(url + " #content",
function(response, status, xhr) {
$("#loading").hide();
$('#Submit_multiple').val('');
});
});
});
function update_counter(id) {
public/stylesheets/style.css
}
table .span0{float:none;width:20px;margin-left:0;}
#Submit_multiple{ margin-bottom: 0px !important;}
.inputs-list{
margin-left:0;margin-bottom:18px;list-style:none;display: inline;

Also available in: Unified diff