[PATCH conductor 1/5] deployable details page styles, deployable details image section errors

Tomas Sedovic tsedovic at redhat.com
Mon Dec 12 14:19:47 UTC 2011


On 12/12/2011 01:25 PM, jtomasek at redhat.com wrote:
> From: Jiri Tomasek<jtomasek at redhat.com>
>
> ---
>   src/app/controllers/deployables_controller.rb |    4 +-
>   src/app/helpers/deployables_helper.rb         |   13 +++++++
>   src/app/models/deployable.rb                  |   28 ++++++++--------
>   src/app/stylesheets/layout.scss               |   27 +++++++++++++--
>   src/app/views/deployables/show.html.haml      |   45 +++++++++++--------------
>   src/config/locales/en.yml                     |    6 +++
>   src/public/images/build_status.png            |  Bin 0 ->  1182 bytes
>   7 files changed, 79 insertions(+), 44 deletions(-)
>   create mode 100644 src/app/helpers/deployables_helper.rb
>   create mode 100644 src/public/images/build_status.png
>
> diff --git a/src/app/controllers/deployables_controller.rb b/src/app/controllers/deployables_controller.rb
> index 3f6116a..e7726bd 100644
> --- a/src/app/controllers/deployables_controller.rb
> +++ b/src/app/controllers/deployables_controller.rb
> @@ -56,8 +56,8 @@ class DeployablesController<  ApplicationController
>       @providers = Provider.all
>       @catalogs_options = Catalog.list_for_user(current_user, Privilege::VIEW).select {|c| !@deployable.catalogs.include?(c)}
>       add_permissions_inline(@deployable)
> -    @image_details = @deployable.get_image_details
> -    @image_details.each do |assembly|
> +    @images_details = @deployable.get_image_details
> +    @images_details.each do |assembly|
>         assembly.keys.each do |key|
>           flash[:error] = assembly[key] if key.to_s =~ /^error\w+/
>         end
> diff --git a/src/app/helpers/deployables_helper.rb b/src/app/helpers/deployables_helper.rb
> new file mode 100644
> index 0000000..2c9ad8e
> --- /dev/null
> +++ b/src/app/helpers/deployables_helper.rb
> @@ -0,0 +1,13 @@
> +module DeployablesHelper
> +  def image_ready?(assembly)
> +    if @missing_images.empty?
> +      "image is ready"
> +    else
> +      if @missing_images.include?(assembly[:image_uuid])
> +        "Image specified in xml does not exist"
> +      else
> +        "image is ready"
> +      end
> +    end
> +  end
> +end
> diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
> index a148543..f5eb873 100644
> --- a/src/app/models/deployable.rb
> +++ b/src/app/models/deployable.rb
> @@ -108,32 +108,32 @@ class Deployable<  ActiveRecord::Base
>
>     #get details of image for deployable#show
>     def get_image_details
> -    stored_xml = Nokogiri::XML(xml)
> -    result_array ||= []
> -    stored_xml.xpath("//assembly").each do |assembly|
> -      if assembly.attr('name')
> -        assembly_hash ||= {:name =>  assembly.attr('name')}
> +    deployable_xml = DeployableXML.new(xml)
> +    assemblies_array ||= []
> +    deployable_xml.assemblies.each do |assembly|
> +      if assembly.name
> +        assembly_hash ||= {:name =>  assembly.name}
>         else
>           assembly_hash ||= {:error_name =>  I18n.t('deployables.error.attribute_not_exist')}
>         end
> -      if assembly.attr('hwp')
> -        hwp_name = stored_xml.xpath("//assembly").attr('hwp').value
> +      assembly_hash[:image_uuid] = assembly.image_id
> +      if assembly.hwp
> +        hwp_name = assembly.hwp
>           hwp = HardwareProfile.find_by_name(hwp_name)
>           if hwp
> -          assembly_hash[:hwp] = {:name =>  hwp_name}
> -          assembly_hash[:hwp][:hdd] = hwp.storage.value
> -          assembly_hash[:hwp][:ram] = hwp.memory.value
> -          assembly_hash[:hwp][:arch] = hwp.architecture.value
> +          assembly_hash[:hwp_name] = hwp.name
> +          assembly_hash[:hwp_hdd] = hwp.storage.value
> +          assembly_hash[:hwp_ram] = hwp.memory.value
> +          assembly_hash[:hwp_arch] = hwp.architecture.value
>           else
>             assembly_hash[:error_hwp] = I18n.t('deployables.error.hwp_not_exists', :name =>  hwp_name)
>           end
>         else
>           assembly_hash[:error_hwp] = I18n.t('deployables.error.attribute_not_exist')
>         end
> -      result_array<<  assembly_hash
> +      assemblies_array<<  assembly_hash
>       end
> -    #returned value [{:name =>  'assembly1',{:hwp =>  {...}}, {:error =>  "msg"}, {assembly3} ..]
> -    result_array
> +    assemblies_array
>     end
>
>     def build_status(images, account)
> diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss
> index 9d67a87..d75ef69 100644
> --- a/src/app/stylesheets/layout.scss
> +++ b/src/app/stylesheets/layout.scss
> @@ -2397,12 +2397,28 @@ ul.instances-array{
>
>   table.light_table{
>     margin: 10px;
> -  td,th{ padding: 10px; }
> +  td,th{ padding: 5px 10px; vertical-align: middle;}
>     th{border-bottom: 1px solid #CCCCCC;}
>     td:first-child, th:first-child{padding-left: 0px;}
>     td:last-child, th:last-child{padding-right: 0px;}
>   }
>
> +div.build_status{
> +  float: right;
> +  .build_status_icon{
> +    display: inline-block;
> +    vertical-align: middle;
> +    width: 18px; height: 18px;
> +    margin-left: 10px;
> +
> +&.not_built{ background: transparent url(../../images/build_status.png) no-repeat left center; }
> +&.building{ background: transparent url(../../images/spinner.gif) no-repeat center center; }
> +&.not_pushed{ background: transparent url(../../images/build_status.png) no-repeat center center; }
> +&.pushing{ background: transparent url(../../images/spinner.gif) no-repeat center center; }
> +&.pushed{ background: transparent url(../../images/build_status.png) no-repeat right center; }
> +  }
> +}
> +
>   /************************************************************************** */
>   /********************************************* Launch from catalog elements */
>   /************************************************************************** */
> @@ -2499,9 +2515,13 @@ ul.catalog_pretty {
>     margin: 10px 0px 10px 0px;
>     li{
>       list-style-type: none;
> -
>       &:not(:first-child){border-top: 1px solid #ccc;}
>
> +&:first-child div.summary{ -webkit-border-radius: 7px 7px 0px 0px; -moz-border-radius: 7px 7px 0px 0px; border-radius: 7px 7px 0px 0px; }
> +&:last-child div.summary{ -webkit-border-radius: 0px 0px 7px 7px; -moz-border-radius: 0px 0px 7px 7px; border-radius: 0px 0px 7px 7px; }
> +&:last-child div.details{ -webkit-border-radius: 0px 0px 7px 7px; -moz-border-radius: 0px 0px 7px 7px; border-radius: 0px 0px 7px 7px; }
> +&:only-child div.summary{ -webkit-border-radius: 7px 7px 7px 7px; -moz-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; }
> +&:only-child div.details{ -webkit-border-radius: 0px 0px 7px 7px; -moz-border-radius: 0px 0px 7px 7px; border-radius: 0px 0px 7px 7px; }
>       div.summary{
>         padding: 10px;
>         background-color: #efefef;
> @@ -2537,8 +2557,9 @@ ul.catalog_pretty {
>       div.details.collapsible{
>         background: #eee;
>         border-top: 1px solid #ccc;
> +      padding: 10px;
>         table{
> -        margin: 10px 10px 10px 42px;
> +        margin: 0px 0px 0px 32px;
>           td,th{ padding: 10px; }
>           td:first-child, th:first-child{padding-left: 0px;}
>           td:last-child, th:last-child{padding-right: 0px;}
> diff --git a/src/app/views/deployables/show.html.haml b/src/app/views/deployables/show.html.haml
> index f89ac19..c367633 100644
> --- a/src/app/views/deployables/show.html.haml
> +++ b/src/app/views/deployables/show.html.haml
> @@ -24,21 +24,21 @@
>               %th.align-center=t'.ram'
>               %th.align-center=t'.arch'
>           %tbody
> -          - @image_details.each do |assembly|
> +          - @images_details.each do |assembly|
>               %tr
> -              %td image ready
> +              %td= image_ready?(assembly)
>                 - if assembly.has_key?(:name)
>                   %td
>                     %strong=assembly[:name]
>                 -else
>                   %td=assembly[:error_name]
> -              -if assembly.has_key?(:hwp)
> -                %td=assembly[:hwp][:name]
> -                %td.align-center=assembly[:hwp][:hdd]
> -                %td.align-center=assembly[:hwp][:ram]
> -                %td.align-center=assembly[:hwp][:arch]
> +              -if assembly.has_key?(:hwp_name)
> +                %td=assembly[:hwp_name]
> +                %td.align-center=assembly[:hwp_hdd]
> +                %td.align-center=assembly[:hwp_ram]
> +                %td.align-center=assembly[:hwp_arch]
>                 -else
> -                %td Not exist in DB
> +                %td{:colspan =>  4}= assembly[:error_hwp]
>
>   %section.admin-content-section
>     - if @missing_images.empty?
> @@ -53,23 +53,18 @@
>
>         %ul#providers-list.catalog_pretty
>           - @build_results.each do |provider_type, results|
> -          %li.collapse_entity
> -            .summary
> -              .info
> -                %h2= provider_type
> -              .controls
> -                = link_to t(".details"),"#", :class =>  "collapse"
> -            .details.collapsible
> -              %table
> -                %tr
> -                  %th=t'.provider'
> -                  %th=t'.account'
> -                  %th.align-center=t'.status'
> -                - results.each do |result|
> -                  %tr
> -                    %td= result[:provider]
> -                    %td= result[:account]
> -                    %td.align-center= result[:status]
> +          - results.each do |result|
> +            %li
> +              .summary
> +                .info
> +                  %h2= provider_type
> +                  %span= result[:provider]
> +                  |
> +                  %span= result[:account]
> +                .controls
> +                  .build_status
> +                    %span= t("catalog_entries.build_statuses_descriptions.#{result[:status]}")
> +                    %div{:class =>  "build_status_icon #{result[:status]}"}
>     - else
>       %header
>         %h2= t('.build')
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index 4dab401..8b0f2d4 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -653,6 +653,12 @@ en:
>           deleted: Catalog entry deleted.
>       preset_filters:
>         all_catalog_entries: All Catalog Entries
> +    build_statuses_descriptions:
> +      not_built: "Images are not Built"
> +      building: "Images are being built."
> +      not_pushed: "Some of the images are not pushed"
> +      pushing: "Images are being pushed."
> +      pushed: "All Images are pushed and recent."
>     catalogs:
>       catalogs: Catalogs
>       new_catalog: New Catalog
> diff --git a/src/public/images/build_status.png b/src/public/images/build_status.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..5fca76b0ca151514ad349e36d9d8052f3de48f8e
> GIT binary patch
> literal 1182
> zcmV;P1Y!G$P)<h;3K|Lk000e1NJLTq0024w000sQ1^@s63PjCw00004b3#c}2nYxW
> zd<bNS00009a7bBm000XT000XT0n*)m`~Uy|9CSrkbW?9;ba!ELWdK2BZ(?O2Mrm?o
> zcW-iQb09-gHF34$HUIzs7IZ~ebVG7wVRUJ4ZXi@?ZDjy4F)uSPFEKG)yq8S?00Z_(
> zL_t(oh0T{wPa8)Vho2dHjlI~0xJ`Cd2&$B}7le!oRdda)0yRy1ujE{i&$;K+e1}MI
> zsH5I7Qb2rxNR28Gf1);#dTA)AS<=L&#E!k|-RS{#<u%4 at svdZy_u%#HGw*L^ezP-z
> zuGrYv7zK)_neY002PgyO+1c3|fKn>dKnQUuc_GT?=H{K#h9mTkBcM1lGq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L0dT4eWheo4;<2ZPp=Pw}=i3GZ?6OYIJ*X~`vemxj{zp%^53+?6m`}-HV291x8
> w_q|qKCZ6bSad2=j(8YFaY;2&5@@3)u3tzAnL|D+P4gdfE07*qoM6N<$f>&NT at Bjb+
>
> literal 0
> HcmV?d00001
>

ACK to the series.

One nit: the Catalogs icon on the Deployable Details page under Chrome 
cut off a bit at the bottom. It renders fine on Firefox, though.

Thomas
-- 
No trees were killed to send this message, but a large number of 
electrons were terribly inconvenienced.



More information about the aeolus-devel mailing list