[PATCH conductor] BZ#743377 Show deployable status in the pretty view

Imre Farkas ifarkas at redhat.com
Thu Feb 9 14:59:11 UTC 2012


On 02/09/2012 01:52 PM, tsedovic at redhat.com wrote:
> From: Tomas Sedovic<tomas at sedovic.cz>
>
> https://bugzilla.redhat.com/show_bug.cgi?id=743377
>
> The deployment cards on the Monitor page now display a graphical status (with a
> textual fallback for text-only browsers) of the deployment.
>
> This makes it easy for the user to determine the status of the deployments at a
> glance. For more detailed information (e.g. the statuses of individual
> instances), the user still needs to drill down into the deployment in question.
> ---
>   src/app/models/deployment.rb                     |   26 ++++++++----------
>   src/app/stylesheets/layout.scss                  |   31 ++++++++++++++++++++++
>   src/app/views/deployments/_list.html.haml        |    4 +-
>   src/app/views/deployments/_pretty_view.html.haml |    2 +
>   src/app/views/pools/_deployments.html.haml       |    3 ++
>   src/config/locales/en.yml                        |    4 +++
>   6 files changed, 54 insertions(+), 16 deletions(-)
>
> diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
> index 043b2b4..9593645 100644
> --- a/src/app/models/deployment.rb
> +++ b/src/app/models/deployment.rb
> @@ -415,6 +415,16 @@ class Deployment<  ActiveRecord::Base
>       end
>     end
>
> +  def status
> +    if instances.all? {|i| i.state == Instance::STATE_RUNNING}
> +      :running
> +    elsif instances.all? {|i| [Instance::STATE_STOPPED, Instance::STATE_ERROR, Instance::STATE_CREATE_FAILED].include? i.state}
> +      :stopped
> +    else
> +      :pending
> +    end
> +  end
> +
>     # A deployment "starts" when _all_ instances begin to run
>     def start_time
>       if instances.deployed.count == instances.count&&  ev = events.find_by_status_code(:all_running)
> @@ -437,7 +447,8 @@ class Deployment<  ActiveRecord::Base
>     def as_json(options={})
>       json = super(options).merge({
>         :deployable_xml_name =>  deployable_xml.name,
> -      :deployment_state =>  deployment_state,
> +      :status =>  status,
> +      :status_description =>  I18n.t("deployments.status.#{status}"),
>         :instances_count =>  instances.count,
>         :failed_instances_count =>  failed_instances.count,
>         :instances_count_text =>  I18n.t('instances.instances', :count =>  instances.count.to_i),
> @@ -461,19 +472,6 @@ class Deployment<  ActiveRecord::Base
>       json
>     end
>
> -  def deployment_state
> -    unless instances.empty?
> -      return instances.first.state if not instances.empty? and instances.length == 1
> -      oracle = instances.first.state
> -      instances.each do |i|
> -        return STATE_MIXED if i.state != oracle
> -      end
> -      return oracle
> -    else
> -      return
> -    end
> -  end
> -
>     def failed_instances
>       instances.select {|instance| instance.failed?}
>     end
> diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss
> index 9f385fe..dc51b67 100644
> --- a/src/app/stylesheets/layout.scss
> +++ b/src/app/stylesheets/layout.scss
> @@ -2254,6 +2254,21 @@ ul.deployment-array.large{
>
>       }
>
> +    .status {
> +      text-indent: -3000px;
> +      display: block;
> +      background: url('../../images/build_status.png') no-repeat;
> +      width: 18px;
> +      height: 18px;
> +      position: absolute;
> +      bottom: 5px;
> +      right: 5px;
> +
> +&.stopped { background-position: 0px center; }
> +&.pending { background-position: -20px center; }
> +&.running { background-position: -40px center; }
> +    }
> +
>       dl.statistics{
>         margin-top: 8px;
>         ul{list-style: none; margin-left: 12px;}
> @@ -2345,6 +2360,7 @@ ul.deployment-array.small{
>     height: 100%;
>
>     li.deployment{
> +    position: relative;
>       display: table-cell;
>       float: left;
>       border: 1px solid #ccc;
> @@ -2362,6 +2378,21 @@ ul.deployment-array.small{
>         margin-bottom: 14px;
>       }
>
> +    .status {
> +      text-indent: -3000px;
> +      display: block;
> +      background: url('../../images/build_status.png') no-repeat;
> +      width: 18px;
> +      height: 18px;
> +      position: absolute;
> +      bottom: 5px;
> +      right: 5px;
> +
> +&.stopped { background-position: 0px center; }
> +&.pending { background-position: -20px center; }
> +&.running { background-position: -40px center; }
> +    }
> +
>       dl.statistics{
>         ul{list-style: none;}
>         li{@include display_inline_block;}
> diff --git a/src/app/views/deployments/_list.html.haml b/src/app/views/deployments/_list.html.haml
> index 75b7f3d..bbf7b9b 100644
> --- a/src/app/views/deployments/_list.html.haml
> +++ b/src/app/views/deployments/_list.html.haml
> @@ -35,7 +35,7 @@
>       %td= link_to(deployment.name, deployment_path(deployment, :view =>  :filter))
>       %td= deployment.created_at
>       %td= deployment.deployable_xml.name
> -    %td= deployment.deployment_state
> +    %td= deployment.status
>       %td{:class =>  'center'}= deployment.instances.count
>       %td= link_to deployment.pool.name, pool_path(deployment.pool, :view =>  :filter)
>       %td= owner_name(deployment)
> @@ -59,7 +59,7 @@
>         <td><a href="#{deployment_path('replace_id', :view =>  :filter).sub('replace_id', '${id}')}">${name}</a></td>
>         <td>${created_at}</td>
>         <td>${deployable_xml_name}</td>
> -<td>${deployment_state}</td>
> +<td>${status}</td>
>         <td class="center">${instances_count}</td>
>         <td><a href="#{pool_path('replace_id', :view =>  :filter).sub('replace_id', '${pool.id}')}">${pool.name}</a></td>
>         <td>${owner}</td>
> diff --git a/src/app/views/deployments/_pretty_view.html.haml b/src/app/views/deployments/_pretty_view.html.haml
> index 97c586e..f29e8d4 100644
> --- a/src/app/views/deployments/_pretty_view.html.haml
> +++ b/src/app/views/deployments/_pretty_view.html.haml
> @@ -5,6 +5,7 @@
>           %li.deployment
>             %h3.name
>               = link_to deployment.name, deployment_path(deployment)
> +          %span{ :class =>  "status #{deployment.status}", :title =>  deployment.as_json[:status_description]}
>             %dl.statistics
>               %ul
>                 %li.uptime
> @@ -32,6 +33,7 @@
>         <h3 class="name">
>           <a href="#{deployment_path('replace_id').sub('replace_id', '${id}')}">${name}</a>
>         </h3>
> +<span class="status ${status}" title="${status_description}">${status}</span>
>         <dl class="statistics">
>           <ul>
>             <li class="uptime">
> diff --git a/src/app/views/pools/_deployments.html.haml b/src/app/views/pools/_deployments.html.haml
> index 0aa6143..b4aed1d 100644
> --- a/src/app/views/pools/_deployments.html.haml
> +++ b/src/app/views/pools/_deployments.html.haml
> @@ -5,6 +5,8 @@
>           %li.deployment
>             %h3.name
>               = link_to deployment.name, deployment_path(deployment)
> +          %span{ :class =>  "status #{deployment.status}", :title =>  deployment.as_json[:status_description]}
> +            = deployment.status
>             %dl.statistics
>               %ul
>                 %li.right
> @@ -21,6 +23,7 @@
>         <h3 class="name">
>           <a href="#{deployment_path('replace_id').sub('replace_id', '${id}')}">${name}</a>
>         </h3>
> +<span class="status ${status}" title="${status_description}">${status}</span>
>         <dl class="statistics">
>           <ul>
>             <li class="right">
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index 822962d..a30fc28 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -174,6 +174,10 @@ en:
>       confirm_delete: "Are you sure you want to delete this deployment?"
>       list_of_events: List of deployment events
>       state: State
> +    status:
> +      running: All instances are running
> +      pending: Some (but not all) instances are running
> +      stopped: No instances are currently running
>       launch_time_params:
>         configure_launch_time_params: "Configure launch-time parameters for your deployment:"
>         finalize: Finalize

There's a failing spec in spec/models/deployment_spec.rb (the one on 
deployment_state)

After fixing it, feel free to push it.

ACK



More information about the aeolus-devel mailing list