Revision bde92a1e
Added by Timo Goebel almost 6 years ago
.rubocop_todo.yml | ||
---|---|---|
|
||
# Offense count: 604
|
||
Metrics/AbcSize:
|
||
Max: 128
|
||
Max: 132
|
||
|
||
# Offense count: 345
|
||
# Configuration parameters: CountComments, ExcludedMethods.
|
||
... | ... | |
# Offense count: 25
|
||
# Configuration parameters: CountComments.
|
||
Metrics/ModuleLength:
|
||
Max: 441
|
||
Max: 446
|
||
|
||
# Offense count: 10
|
||
# Configuration parameters: CountKeywordArgs.
|
app/helpers/dashboard_helper.rb | ||
---|---|---|
setting.nil? ? true : !setting
|
||
end
|
||
|
||
def host_build_status_icon(host)
|
||
if host.token_expired?
|
||
icon = 'hourglass-o'
|
||
icon_kind = 'fa'
|
||
icon_class = 'text-danger'
|
||
label = _('Token expired')
|
||
elsif host.build_errors.present?
|
||
icon = 'error-circle-o'
|
||
icon_kind = 'pficon'
|
||
icon_class = ''
|
||
label = _('Build errors')
|
||
else
|
||
icon = 'in-progress'
|
||
icon_kind = 'pficon'
|
||
icon_class = ''
|
||
label = _('Build in progress')
|
||
end
|
||
icon_text(icon, '', kind: icon_kind, title: label, class: icon_class)
|
||
end
|
||
|
||
private
|
||
|
||
def origin_setting(origin, name)
|
app/helpers/hosts_helper.rb | ||
---|---|---|
end
|
||
|
||
def build_duration(host)
|
||
return _("N/A") if host.initiated_at.nil? && host.installed_at.nil?
|
||
return _('N/A') if host.initiated_at.nil? || host.installed_at.nil?
|
||
if host.installed_at.nil?
|
||
time_ago_in_words(host.initiated_at, include_seconds: true) + " (in progress)"
|
||
else
|
app/models/host/managed.rb | ||
---|---|---|
|
||
scope :with_compute_resource, -> { where.not(:compute_resource_id => nil, :uuid => nil) }
|
||
|
||
scope :in_build_mode, -> { where(build: true) }
|
||
scope :with_build_errors, -> { where.not(build_errors: nil) }
|
||
|
||
# some shortcuts
|
||
alias_attribute :arch, :architecture
|
||
|
app/services/dashboard/manager.rb | ||
---|---|---|
}
|
||
end,
|
||
{template: 'reports_widget', sizex: 6, sizey: 1, name: N_('Latest Events')},
|
||
{template: 'new_hosts_widget', sizex: 8, sizey: 1, name: N_('New Hosts')}
|
||
{template: 'new_hosts_widget', sizex: 8, sizey: 1, name: N_('New Hosts')},
|
||
{template: 'hosts_in_build_mode_widget', sizex: 8, sizey: 1, name: N_('Hosts in build mode')}
|
||
].flatten.sort_by {|widget| widget['name'] }
|
||
end
|
||
|
app/views/dashboard/_hosts_in_build_mode_widget.html.erb | ||
---|---|---|
<% hosts = @data.hosts.in_build_mode.or(@data.hosts.with_build_errors).includes(:token).preload(:owner).order(created_at: :desc).limit(9) %>
|
||
|
||
<h4 class="header">
|
||
<%= _('Hosts in Build mode or with Build errors') %>
|
||
</h4>
|
||
|
||
<% if hosts.empty? %>
|
||
<p class="ca"><%= icon_text('ok', '', kind: 'pficon') %></span><%= _('No Hosts are in build mode or have build errors.') %></p>
|
||
<% else %>
|
||
<%= render :partial => 'hosts_in_build_mode_widget_host_list', :locals => { :hosts => hosts } %>
|
||
<% end %>
|
app/views/dashboard/_hosts_in_build_mode_widget_host_list.html.erb | ||
---|---|---|
<table class="<%= table_css_classes('table-fixed') %>">
|
||
<thead>
|
||
<th width="40%"><%= _('Host') %></th>
|
||
<th><%= _('Owner') %></th>
|
||
<th><%= _('Build Duration') %></th>
|
||
<th><%= _('Token Expiry') %></th>
|
||
</thead>
|
||
<tbody>
|
||
<% hosts.each do |host| %>
|
||
<tr>
|
||
<td class="ellipsis"><%= host_build_status_icon(host) %> <%= link_to host.name, host_path(host) %></td>
|
||
<td class="hidden-tablet hidden-xs ellipsis"><%= host.owner %></td>
|
||
<td class="hidden-tablet hidden-xs ellipsis"><%= build_duration(host) %></td>
|
||
<td class="hidden-tablet hidden-xs ellipsis"><%= host.token ? date_time_relative_value(host.token.expires) : _('N/A') %></td>
|
||
</tr>
|
||
<% end %>
|
||
</tbody>
|
||
</table>
|
test/unit/dashboard_manager_test.rb | ||
---|---|---|
test '.default_widgets returns built-in widgets' do
|
||
Dashboard::Manager.stubs(:registered_report_orgins).returns(['Puppet'])
|
||
Foreman::Plugin.expects(:all).returns([])
|
||
assert_equal 7, Dashboard::Manager.default_widgets.count
|
||
assert_equal 8, Dashboard::Manager.default_widgets.count
|
||
end
|
||
|
||
test '.default_widgets adds plugin widgets' do
|
Also available in: Unified diff
fixes #22467 - dashboard: list hosts in build mode