Module: Katello::Concerns::SmartProxyHelperExtensions
- Defined in:
- app/helpers/katello/concerns/smart_proxy_helper_extensions.rb
Instance Method Summary collapse
- #boolean_to_icon(boolean) ⇒ Object
- #disks(storage) ⇒ Object
- #download_policies ⇒ Object
- #humanize_bytes(bytes) ⇒ Object
- #kb_to_actual(number) ⇒ Object
- #storage_warning(available) ⇒ Object
Instance Method Details
#boolean_to_icon(boolean) ⇒ Object
22 23 24 25 26 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 22 def boolean_to_icon(boolean) boolean = ::Foreman::Cast.to_bool(boolean) icon = boolean ? 'ok' : 'error-circle-o' icon_text(icon, '', :kind => 'pficon') end |
#disks(storage) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 4 def disks(storage) storage.map do |values| values['header'] = values['description'] values['available_percent'] = 100 - values['percentage'] values['size_status'] = storage_warning(values['free']) values end end |
#download_policies ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 28 def download_policies policies = [ { :name => _("On Demand"), :label => ::Katello::RootRepository::DOWNLOAD_ON_DEMAND }, { :name => _("Immediate"), :label => ::Katello::RootRepository::DOWNLOAD_IMMEDIATE }, { :name => _("Streamed"), :label => SmartProxy::DOWNLOAD_STREAMED }, { :name => _("Inherit from Repository"), :label => SmartProxy::DOWNLOAD_INHERIT } ] policies.map { |p| OpenStruct.new(p) } end |
#humanize_bytes(bytes) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 13 def humanize_bytes(bytes) mb = bytes / 1024 / 1024 if mb < 1000 "#{mb} MB" else "#{mb / 1024} GB" end end |
#kb_to_actual(number) ⇒ Object
63 64 65 66 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 63 def kb_to_actual(number) # Convert number from kb to mb to any size number_to_human_size(number.to_i * 1024) end |
#storage_warning(available) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/helpers/katello/concerns/smart_proxy_helper_extensions.rb', line 51 def storage_warning(available) gb_size = available.to_i / 1_073_741_824 case gb_size when 0..1 "danger" when 2..10 "warning" else "success" end end |