From: Jiri Tomasek <jtomasek(a)redhat.com>
---
src/app/controllers/deployments_controller.rb | 2 +-
src/app/controllers/pools_controller.rb | 5 +++--
src/app/models/deployment.rb | 4 ++++
src/app/models/instance.rb | 4 ++++
src/app/models/pool.rb | 3 ++-
src/app/views/deployments/_alerts_show.html.haml | 8 ++++----
src/app/views/deployments/_list.html.haml | 2 +-
src/app/views/instances/_list.html.haml | 7 +++----
src/app/views/pools/_alerts_index.html.haml | 8 ++++----
src/app/views/pools/_alerts_show.html.haml | 15 +++++++++++++++
src/app/views/pools/_list.html.haml | 6 +++---
src/app/views/pools/_scoreboard_index.html.haml | 4 ++--
src/app/views/pools/_scoreboard_show.html.haml | 4 ++--
src/app/views/pools/show.html.haml | 5 +----
14 files changed, 49 insertions(+), 28 deletions(-)
create mode 100644 src/app/views/pools/_alerts_show.html.haml
diff --git a/src/app/controllers/deployments_controller.rb
b/src/app/controllers/deployments_controller.rb
index bfd5a25..a03ea4d 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -156,7 +156,7 @@ class DeploymentsController < ApplicationController
require_privilege(Privilege::VIEW, @deployment)
init_new_deployment_attrs
save_breadcrumb(deployment_path(@deployment, :viewstate => viewstate_id),
@deployment.name)
- @failed_instances = @deployment.instances.select {|instance| instance.state ==
Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}
+ @failed_instances = @deployment.failed_instances
if filter_view?
@view = 'instances/list'
params[:instances_preset_filter] = "other_than_stopped" unless
params[:instances_preset_filter]
diff --git a/src/app/controllers/pools_controller.rb
b/src/app/controllers/pools_controller.rb
index 76c6d5a..779c1d3 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -286,13 +286,14 @@ class PoolsController < ApplicationController
def statistics
instances = current_user.owned_instances
- @failed_instances = instances.select {|instance| instance.state ==
Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}
+ failed_instances = instances.select {|instance| instance.state ==
Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}
@statistics = {
:pools_in_use => @user_pools.select { |pool|
pool.instances.pending.count > 0 || pool.instances.deployed.count > 0 }.count,
:deployments => current_user.deployments.count,
:instances => instances.count,
:instances_pending => instances.select {|instance| instance.state ==
Instance::STATE_NEW || instance.state == Instance::STATE_PENDING}.count,
- :instances_failed => @failed_instances.count,
+ :instances_failed => failed_instances,
+ :instances_failed_count => failed_instances.count,
:user_available_quota => current_user.quota.maximum_running_instances,
:user_running_instances => current_user.quota.running_instances,
:user_used_percentage => current_user.quota.percentage_used
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 52880c0..d9ab8d7 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -434,6 +434,10 @@ class Deployment < ActiveRecord::Base
end
end
+ def failed_instances
+ instances.select {|instance| instance.state == Instance::STATE_CREATE_FAILED ||
instance.state == Instance::STATE_ERROR}
+ end
+
PRESET_FILTERS_OPTIONS = []
private
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index b9605cc..3e5e4d9 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -314,6 +314,10 @@ class Instance < ActiveRecord::Base
(state == STATE_CREATE_FAILED) or (state == STATE_STOPPED and not restartable?)
end
+ def failed?
+ state == Instance::STATE_CREATE_FAILED || state == Instance::STATE_ERROR
+ end
+
def requires_config_server?
not instance_config_xml.nil? or assembly_xml.requires_config_server?
end
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 977e61e..ad9d58c 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -94,7 +94,8 @@ class Pool < ActiveRecord::Base
instances.pending.count + instances.failed.count),
:instances_deployed => instances.deployed.count,
:instances_pending => instances.pending.count,
- :instances_failed => instances.failed.count,
+ :instances_failed => instances.failed,
+ :instances_failed_count => instances.failed.count,
:used_quota => quota.running_instances,
:quota_percent => number_to_percentage(quota.percentage_used,
:precision => 0),
diff --git a/src/app/views/deployments/_alerts_show.html.haml
b/src/app/views/deployments/_alerts_show.html.haml
index 4bd68c8..f850c6c 100644
--- a/src/app/views/deployments/_alerts_show.html.haml
+++ b/src/app/views/deployments/_alerts_show.html.haml
@@ -1,11 +1,11 @@
- if @failed_instances.count > 0
- %section.content-section.alerts
+ %section.content-section.alerts.collapse_entity
%header
%h2=t 'alerts_label'
- %span.label.badge.alert.count= @failed_instances.length
+ %span.label.badge.alert.count= @failed_instances.count
.section-controls
- -#%a.collapse{'href'=>'#'} Collapse
- .content.collapsible.closed
+ = link_to t("providers.edit.toggle_alerts"), "#", :class
=> 'collapse alerts' unless @statistics[:instances_failed].blank?
+ .content.collapsible
%dl.alerts
%ul
- @failed_instances.each do |inst|
diff --git a/src/app/views/deployments/_list.html.haml
b/src/app/views/deployments/_list.html.haml
index b40d168..079e156 100644
--- a/src/app/views/deployments/_list.html.haml
+++ b/src/app/views/deployments/_list.html.haml
@@ -30,7 +30,7 @@
%td{:class => 'checkbox'}
- selected = params[:select] == 'all'
= check_box_tag "deployments_selected[]", deployment.id, selected, :id
=> "deployment_checkbox_#{deployment.id}"
- %td{:class => 'alert'}= #there will be icons (belongs to mockups)
+ %td{:class => 'alert'}= deployment.failed_instances.present? ?
image_tag("sb_icon_instance_failure.png") : ""
%td= link_to(deployment.name, deployment)
%td= deployment.created_at
%td= deployment.deployable_xml.name
diff --git a/src/app/views/instances/_list.html.haml
b/src/app/views/instances/_list.html.haml
index 6b5a21a..5df8063 100644
--- a/src/app/views/instances/_list.html.haml
+++ b/src/app/views/instances/_list.html.haml
@@ -28,7 +28,7 @@
%td{:class => 'checkbox'}
- selected = params[:select] == 'all'
= check_box_tag "instance_selected[]", instance.id, selected, :id =>
"instance_checkbox_#{instance.id}"
- %td{:class => 'alert'}
+ %td{:class => 'alert'}= instance.failed? ?
image_tag("sb_icon_instance_failure.png") : ""
%td= link_to instance.name, instance_path(instance)
%td= instance.public_addresses
%td= instance.state
@@ -43,9 +43,8 @@
%script#instanceTemplate{ :type => 'text/x-jquery-tmpl' }
:plain
<tr>
- <td class="checkbox"><input type="checkbox"
id="instance_checkbox_${id}"
- name="instance_selected[]"
value="${id}"></td>
- <td class="alert" />
+ <td class="checkbox"><input type="checkbox"
id="instance_checkbox_${id}" name="instance_selected[]"
value="${id}"></td>
+ <td class="alert"></td>
<td><a
href="#{instance_path('replace_id').sub('replace_id',
'${id}')}">${name}</a></td>
<td>${public_addresses}</td>
<td>${state}</td>
diff --git a/src/app/views/pools/_alerts_index.html.haml
b/src/app/views/pools/_alerts_index.html.haml
index 46acf5f..2831e81 100644
--- a/src/app/views/pools/_alerts_index.html.haml
+++ b/src/app/views/pools/_alerts_index.html.haml
@@ -1,14 +1,14 @@
-- if @failed_instances.count > 0
+- if @statistics[:instances_failed_count] > 0
%section.content-section.alerts.collapse_entity
%header
%h2=t "alerts_label"
- %span.label.badge.alert.count= @failed_instances.length
+ %span.label.badge.alert.count= @statistics[:instances_failed_count]
.section-controls
- = link_to t("providers.edit.toggle_alerts"), "#", :class
=> 'collapse alerts' unless @failed_instances.blank?
+ = link_to t("providers.edit.toggle_alerts"), "#", :class
=> 'collapse alerts' unless @statistics[:instances_failed].blank?
.content.collapsible
%dl.alerts
%ul
- - @failed_instances.each do |inst|
+ - @statistics[:instances_failed].each do |inst|
%li.alert
%dt.subject.critical= inst.name
%dd.type=t "alerts.instance_failure"
diff --git a/src/app/views/pools/_alerts_show.html.haml
b/src/app/views/pools/_alerts_show.html.haml
new file mode 100644
index 0000000..bb3f865
--- /dev/null
+++ b/src/app/views/pools/_alerts_show.html.haml
@@ -0,0 +1,15 @@
+- if @statistics[:instances_failed_count] > 0
+ %section.content-section.alerts.collapse_entity
+ %header
+ %h2=t 'alerts_label'
+ %span.label.badge.alert.count= @statistics[:instances_failed_count]
+ .section-controls
+ = link_to t("providers.edit.toggle_alerts"), "#", :class
=> 'collapse alerts' unless @statistics[:instances_failed].blank?
+ .content.collapsible
+ %dl.alerts
+ %ul
+ - @statistics[:instances_failed].each do |inst|
+ %li.alert
+ %dt.subject.critical= inst.name
+ %dd.type=t 'alerts.instance_failure'
+ %dd.desc= "#{inst.last_error.blank? ? inst.state :
inst.last_error}"
diff --git a/src/app/views/pools/_list.html.haml b/src/app/views/pools/_list.html.haml
index 6022d44..f1714fb 100644
--- a/src/app/views/pools/_list.html.haml
+++ b/src/app/views/pools/_list.html.haml
@@ -25,12 +25,12 @@
%tr{:class => cycle('nostripe','stripe')}
%td{:class => 'checkbox'}
%input{:name => "pools_selected[]", :type => "checkbox",
:value => pool.id, :id => "pool_checkbox_#{pool.id}" }
- %td{:class => 'alert'}= #there will be icons (belongs to mockups)
+ %td{:class => 'alert'}= (@statistics[:instances_failed] &
pool.instances).present? ? image_tag("sb_icon_instance_failure.png") :
""
%td= link_to(pool.name, pool)
%td{:class => 'center'}= pool.deployments.count
%td{:class => 'center'}= pool.statistics[:total_instances]
%td{:class => 'center'}= pool.statistics[:instances_pending]
- %td{:class => 'center'}= pool.statistics[:instances_failed]
+ %td{:class => 'center'}= pool.statistics[:instances_failed_count]
%td{:class => 'center'}= pool.statistics[:quota_percent]
%td= link_to(pool.pool_family.name, pool.pool_family)
@@ -44,7 +44,7 @@
<td class="center">${deployments_count}</td>
<td class="center">${statistics.total_instances}</td>
<td class="center">${statistics.instances_pending}</td>
- <td class="center">${statistics.instances_failed}</td>
+ <td class="center">${statistics.instances_failed_count}</td>
<td class="center">${statistics.quota_percent}</td>
<td><a
href="#{pool_family_path('replace_id').sub('replace_id',
'${pool_family.id}')}">${pool_family.name}</a></td>
</tr>
diff --git a/src/app/views/pools/_scoreboard_index.html.haml
b/src/app/views/pools/_scoreboard_index.html.haml
index 0781bdb..24a6689 100644
--- a/src/app/views/pools/_scoreboard_index.html.haml
+++ b/src/app/views/pools/_scoreboard_index.html.haml
@@ -12,12 +12,12 @@
%dt= t("instances.instances.other")
%dd.count.instance= @statistics[:instances]
%dd.count.instance.pending= @statistics[:instances_pending]
- %dd.count.instance.failure= @statistics[:instances_failed]
+ %dd.count.instance.failure= @statistics[:instances_failed_count]
%li
%ul.subgroup
%li
%dt= t("alerts_label")
- %dd.count.alert= @statistics[:instances_failed]
+ %dd.count.alert= @statistics[:instances_failed_count]
%li
%dt
= t("user")
diff --git a/src/app/views/pools/_scoreboard_show.html.haml
b/src/app/views/pools/_scoreboard_show.html.haml
index 9f457b3..78c6dd5 100644
--- a/src/app/views/pools/_scoreboard_show.html.haml
+++ b/src/app/views/pools/_scoreboard_show.html.haml
@@ -11,12 +11,12 @@
%dt=t'instances.instances.other'
%dd.count.instance= @statistics[:instances_deployed]
%dd.count.instance.pending= @statistics[:instances_pending]
- %dd.count.instance.failure= @statistics[:instances_failed]
+ %dd.count.instance.failure= @statistics[:instances_failed_count]
%li
%ul.subgroup
%li
%dt=t'alerts_label'
- %dd.count.alert 0
+ %dd.count.alert= @statistics[:instances_failed_count]
%li
%dt=t'updates'
%dd.count.update 0
diff --git a/src/app/views/pools/show.html.haml b/src/app/views/pools/show.html.haml
index 6f3fb8b..fbefa94 100644
--- a/src/app/views/pools/show.html.haml
+++ b/src/app/views/pools/show.html.haml
@@ -1,11 +1,8 @@
= render :partial => 'layouts/nav_history'
= render :partial => 'header_show'
= render :partial => 'scoreboard_show'
+= render :partial => 'alerts_show'
--# TODO - Alerts aren't implemented just yet
--#= render :partial => 'alerts'
-
--# TODO: %w(Deployments History Properties Permissions) links/tabs, plus filter
links/icons, go here
%section.content-section
%header#tab-container-1
%nav.faceted
--
1.7.7.4