Revision c45a0014
Added by Ohad Levy over 12 years ago
- ID c45a0014cee4b8a530ab25beb9a7b1eb5cd7b037
app/controllers/application_controller.rb | ||
---|---|---|
render :text => 'Invalid query', :status => 400 and return
|
||
end
|
||
|
||
def not_found
|
||
def not_found(exception = nil)
|
||
logger.debug "not found: #{exception}" if exception
|
||
respond_to do |format|
|
||
format.html { render "common/404", :status => 404 }
|
||
format.json { head :status => 404}
|
app/controllers/hosts_controller.rb | ||
---|---|---|
end
|
||
|
||
def puppetrun
|
||
return deny_access unless Setting[:puppetrun]
|
||
if GW::Puppet.run @host.name
|
||
notice "Successfully executed, check log files for more details"
|
||
else
|
app/helpers/application_helper.rb | ||
---|---|---|
# Display a link if user is authorized, otherwise a string
|
||
# +name+ : String to be displayed
|
||
# +options+ : Hash containing
|
||
# :enable_link : Boolean indicating whether the link is to be displayed
|
||
# :controller : String or Symbol representing the controller
|
||
# :auth_action : String or Symbol representing the action to be used for authorization checks
|
||
# +html_options+ : Hash containing html options for the link or span
|
||
def link_to_if_authorized(name, options = {}, html_options = {})
|
||
enable_link = options.has_key?(:enable_link) ? options.delete(:enable_link) : true
|
||
enable_link = html_options.has_key?(:disabled) ? !html_options[:disabled] : true
|
||
auth_action = options.delete :auth_action
|
||
if enable_link
|
||
link_to_if authorized_for(options[:controller] || params[:controller], auth_action || options[:action]), name, options, html_options
|
||
else
|
||
content_tag(:span, name, {:class => "entry"}.merge(html_options))
|
||
link_to_function name, 'void()', html_options
|
||
end
|
||
end
|
||
|
||
... | ... | |
# :controller : String or Symbol representing the controller
|
||
# :auth_action : String or Symbol representing the action to be used for authorization checks
|
||
# +html_options+ : Hash containing html options for the link or span
|
||
def display_link_if_authorized(name, options = {}, html_options = nil)
|
||
def display_link_if_authorized(name, options = {}, html_options = {})
|
||
auth_action = options.delete :auth_action
|
||
if authorized_for(options[:controller] || params[:controller], auth_action || options[:action])
|
||
enable_link = html_options.has_key?(:disabled) ? !html_options[:disabled] : true
|
||
if enable_link and authorized_for(options[:controller] || params[:controller], auth_action || options[:action])
|
||
link_to(name, options, html_options)
|
||
else
|
||
""
|
app/helpers/hosts_helper.rb | ||
---|---|---|
return nil if record.last_report.nil?
|
||
time = time_ago_in_words(record.last_report.getlocal)
|
||
report_icon(record) +
|
||
link_to_if_authorized(time, hash_for_host_report_path(:host_id => record.to_param, :id => "last", :enable_link => @last_reports[record.id]))
|
||
link_to_if_authorized(time, hash_for_host_report_path(:host_id => record.to_param, :id => "last"), :disabled => !@last_reports[record.id])
|
||
end
|
||
|
||
# method that reformat the hostname column by adding the status icons
|
app/models/setting.rb | ||
---|---|---|
scoped_search :on => :category, :complete_value => :true
|
||
scoped_search :on => :description, :complete_value => :true
|
||
|
||
def self.per_page; 20; end # can't use our own settings
|
||
|
||
def self.[](name)
|
||
if record = first(:conditions => {:name => name.to_s})
|
||
record.value
|
app/views/hosts/index.html.erb | ||
---|---|---|
</div>
|
||
<%= multiple_actions_select %>
|
||
<% end -%>
|
||
<%= display_link_if_authorized "New Host", hash_for_new_host_path %>
|
||
<%= link_to_if_authorized "New Host", hash_for_new_host_path %>
|
||
</span>
|
||
<%= render 'list', :hosts => @hosts, :header => @title || "Hosts" %>
|
||
<script>
|
app/views/hosts/show.html.erb | ||
---|---|---|
<%= icon(@host.os) + @host.to_label %>
|
||
</div>
|
||
<span class="title_action">
|
||
<%= display_link_if_authorized "Edit", hash_for_edit_host_path(:id => @host), :title => "Edit your host" %>
|
||
<%= display_link_if_authorized "Facts", hash_for_host_facts_path(:host_id => @host), :title => "Browse host facts" %>
|
||
<%= display_link_if_authorized "Reports", hash_for_host_reports_path(:host_id => @host), :title => "Browse host reports" %>
|
||
<%= link_to_if_authorized "Edit", hash_for_edit_host_path(:id => @host), :title => "Edit your host" %>
|
||
<%= link_to_if_authorized "Facts", hash_for_host_facts_path(:host_id => @host), :title => "Browse host facts" %>
|
||
<%= link_to_if_authorized "Reports", hash_for_host_reports_path(:host_id => @host), :title => "Browse host reports" %>
|
||
<%= link_to "YAML", externalNodes_host_path(:id => @host), :title => "Puppet external nodes YAML dump" %>
|
||
<% unless @host.build -%>
|
||
<%= display_link_if_authorized "Build", hash_for_setBuild_host_path(:id => @host).merge(:enable_link => @host.can_be_build?),
|
||
<%= link_to_if_authorized "Build", hash_for_setBuild_host_path(:id => @host), :disabled => !@host.can_be_build?,
|
||
:title => "Enable rebuild on next host boot",
|
||
:confirm => "Rebuild #{@host} on next reboot?\nThis would also delete all of its current facts and reports" %>
|
||
<% else -%>
|
||
<%= display_link_if_authorized "Cancel Build", hash_for_cancelBuild_host_path(:id => @host).merge(:enable_link => !@host.can_be_build?),
|
||
<%= link_to_if_authorized "Cancel Build", hash_for_cancelBuild_host_path(:id => @host),:disabled => @host.can_be_build?,
|
||
:title => "Cancel build request for this host" %>
|
||
<% end -%>
|
||
<%= display_link_if_authorized "Run puppet", hash_for_puppetrun_host_path(:id => @host).merge(:auth_action => :edit, :enable_link => Setting[:puppetrun]),
|
||
<%= link_to_if_authorized "Run puppet", hash_for_puppetrun_host_path(:id => @host).merge(:auth_action => :edit), :disabled => !Setting[:puppetrun],
|
||
:title => "Trigger a puppetrun on a node; requires that puppet run is enabled" %>
|
||
<%= display_link_if_authorized "All Puppet Classes", hash_for_storeconfig_klasses_host_path(:id => @host).merge(:auth_action => :read, :enable_link => @host.resources.count > 0),
|
||
<%= link_to_if_authorized "All Puppet Classes", hash_for_storeconfig_klasses_host_path(:id => @host).merge(:auth_action => :read), :disabled => @host.resources.count == 0,
|
||
:title => "Show all host puppet classes, requires storeconfigs" %>
|
||
<%= display_link_if_authorized "Delete", hash_for_host_path(:id => @host, :auth_action => :destroy), :confirm => 'Are you sure?', :method => :delete %>
|
||
<%= link_to_if_authorized "Delete", hash_for_host_path(:id => @host, :auth_action => :destroy), :confirm => 'Are you sure?', :method => :delete %>
|
||
</span>
|
||
|
||
<table>
|
||
... | ... | |
<%= form_tag @host, :id => 'days_filter', :method => :get %>
|
||
<p>Reports from the last
|
||
<%= select(nil, 'range', 1..days_ago(@host.reports.first.reported_at),
|
||
{ :selected => @range }, { :onchange =>"$('#days_filter').submit();$(this).disable();" }) %>
|
||
{ :selected => @range }, { :onchange =>"$('#days_filter').submit();$(this).disabled();" }) %>
|
||
days - <%= @host.reports.recent(@range.days.ago).count %> reports found
|
||
</p>
|
||
<% end -%>
|
Also available in: Unified diff
fixes #1167 - some setting values are ignored