Skip to content

Commit

Permalink
[webui] Colored buildresult for incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
saschpe committed Jan 24, 2012
1 parent cb8c8e8 commit 3ce14d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/webui/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,27 @@ def requests(opts)
end
end

def buildresults(view = 'summary')
return Buildresult.find_cached(:project => self.name, :view => view)
end

def build_succeeded?
states = {}
buildresults().each('result') do |result|
result.each('summary') do |summary|
summary.each('statuscount') do |statuscount|
states[statuscount.value('code')] ||= 0
states[statuscount.value('code')] += statuscount.value('count').to_i()
end
end
end
return false unless states.keys # No buildresult is bad
#bad, good = 0, 0
states.each do |state, count|
return false if ['broken', 'failed', 'unresolvable'].include?(state)
#good += 1 if ['succeeded', 'disabled', 'locked'].include?(state)
end
return true
end

end
7 changes: 5 additions & 2 deletions src/webui/app/views/shared/_incidents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
</td>
<td>
<% buildresult_css_id = "incident_#{valid_xml_id(incident.value('name'))}_results" %>
<%= link_to(image_tag('icons/information.png', :alt => 'Build results', :title => 'Build results', :id => buildresult_css_id), :action => :show, :project => incident.value('name')) %>
<% if incident.build_succeeded? %>
<%= link_to(image_tag('icons/accept.png', :alt => 'Build results', :title => 'Build results', :id => buildresult_css_id), :action => :show, :project => incident.value('name')) %>
<% else %>
<%= link_to(image_tag('icons/exclamation.png', :alt => 'Build results', :title => 'Build results', :id => buildresult_css_id), :action => :show, :project => incident.value('name')) %>
<% end %>
<% javascript_tag do %>
setup_buildresult_tooltip('<%= buildresult_css_id %>', '<%= url_for :controller => 'project', :action => 'buildresult', :project => incident.value('name') %>');
<% end %>
Expand All @@ -91,7 +95,6 @@
<% if incident.is_locked? %>
<%= image_tag('icons/accept.png', :alt => 'Locked', :title => 'Locked') %>
<% else %>
<%# image_tag('icons/exclamation.png', :alt => 'Not locked', :title => 'Not locked') %>
-
<% end %>
</td>
Expand Down

0 comments on commit 3ce14d1

Please sign in to comment.