From: Michal Fojtik <[email protected]> https://issues.apache.org/jira/browse/DTACLOUD-208
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/deltacloud/helpers/deltacloud_helper.rb | 11 +++++++++++ server/views/hardware_profiles/index.html.haml | 2 +- server/views/hardware_profiles/index.xml.haml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb index ed3e57d..5806d15 100644 --- a/server/lib/deltacloud/helpers/deltacloud_helper.rb +++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb @@ -266,6 +266,17 @@ module Deltacloud::Helpers end end + def order_hardware_profiles(profiles) + #have to deal with opaque hardware profiles + uncomparables = profiles.select{|x| x.cpu.nil? or x.memory.nil? } + if uncomparables.empty? + profiles.sort_by{|a| [a.cpu.default, a.memory.default] } + else + (profiles - uncomparables).sort_by{|a| [a.cpu.default, a.memory.default] } + uncomparables + end + end + + private def hardware_property_unit(prop) u = ::Deltacloud::HardwareProfile::unit(prop) diff --git a/server/views/hardware_profiles/index.html.haml b/server/views/hardware_profiles/index.html.haml index 59d43eb..011e80f 100644 --- a/server/views/hardware_profiles/index.html.haml +++ b/server/views/hardware_profiles/index.html.haml @@ -3,7 +3,7 @@ %div{ :'data-role' => :content, :'data-theme' => 'c'} %ul{ :'data-role' => :listview, :'data-inset' => :true } - - for profile in @hardware_profiles + - for profile in order_hardware_profiles(@hardware_profiles) %li{ :'data-theme' => 'c'} %a{ :href => hardware_profile_url(profile.name)} %img{ :class => 'ui-link-thumb', :src => '/images/profile.png'} diff --git a/server/views/hardware_profiles/index.xml.haml b/server/views/hardware_profiles/index.xml.haml index 25e0496..9292c5b 100644 --- a/server/views/hardware_profiles/index.xml.haml +++ b/server/views/hardware_profiles/index.xml.haml @@ -1,4 +1,4 @@ !!! XML %hardware_profiles - - @hardware_profiles.each do |prof| + - order_hardware_profiles(@hardware_profiles).each do |prof| = haml :'hardware_profiles/show', :locals => { :@hardware_profile => prof, :partial => true } -- 1.7.10.1
