From: Tomas Sedovic tomas@sedovic.cz
https://bugzilla.redhat.com/show_bug.cgi?id=767100
The uptime output was too long when the value exceeded 1 day. Moreover, it was not using i18n which made it untranslatable.
Now it uses standard I18n values for displaying time difference, which incidentally makes the output long enough to fit into the pretty view deployment boxes.
The boxes are a bit wider, too. That will hopefully make the translators' jobs a bit easier. --- src/app/helpers/application_helper.rb | 33 +++++++++++++++++++-------------- src/app/stylesheets/layout.scss | 4 ++-- src/config/locales/en.yml | 5 +++++ 3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb index 654013c..9e24112 100644 --- a/src/app/helpers/application_helper.rb +++ b/src/app/helpers/application_helper.rb @@ -112,21 +112,26 @@ module ApplicationHelper title.split(' ').join('_').downcase end
- def count_uptime(time) - if time - result_string = [] - - seconds = time % 60 - time = (time - seconds) / 60 - minutes = time % 60 - time = (time - minutes) / 60 - hours = time % 24 - time = (time - hours) / 24 - days = time % 7 - - result_string<< "#{days.to_i} #{(days.to_i > 1 ? 'days' : 'day')}" if days != 0 - result_string<<"#{"%02d"%hours.to_i}:#{"%02d"%minutes.to_i}:#{"%02d"%seconds.to_i}" - result_string.join(", ") + def count_uptime(delta_seconds) + if delta_seconds + seconds = delta_seconds.to_i + minutes = seconds / 60 + hours = minutes / 60 + days = hours / 24 + months = days / 31 + + case + when months > 0 + I18n.t('datetime.distance_in_words.x_months', :count => months) + when days > 0 + I18n.t('datetime.distance_in_words.x_days', :count => days) + when hours > 0 + I18n.t('datetime.distance_in_words.x_hours', :count => hours) + when minutes > 0 + I18n.t('datetime.distance_in_words.x_minutes', :count => minutes) + else + I18n.t('datetime.distance_in_words.x_seconds', :count => seconds) + end else "N/A" end diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss index 18a7c53..5417d36 100644 --- a/src/app/stylesheets/layout.scss +++ b/src/app/stylesheets/layout.scss @@ -2176,7 +2176,7 @@ $font-family-primary: Helvetica, Arial, "Lucida Grande", sans-serif; /* todo: move this elsewhere */
$deployment-large-height: 154px; -$deployment-large-width: 154px; +$deployment-large-width: 166px; $deployment-large-padding: 8px;
ul.deployment-array.large{ @@ -2240,7 +2240,7 @@ ul.deployment-array.large{ }
li.deployment + li.deployment{ - margin-left: 38px; + margin-left: 23px; }
li.deployment.pending, li.deployment.alert, li.deployment.failure{ diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index 94e9873..a996011 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -1,5 +1,10 @@ en: dashboard: Dashboard + datetime: + distance_in_words: + x_hours: + one: 1 hour + other: %{count} hours users: users_groups: "Users & Groups" return_to: "Return to:"
From: Tomas Sedovic tomas@sedovic.cz
--- src/app/controllers/deployments_controller.rb | 4 ++-- src/app/controllers/pools_controller.rb | 6 +++--- src/app/models/deployment.rb | 1 + src/app/views/deployments/_pretty_view.html.haml | 8 ++++---- src/app/views/pools/_deployments.html.haml | 4 ++-- src/app/views/pools/_pretty_list.html.haml | 2 +- src/app/views/pools/_scoreboard_index.html.haml | 2 +- src/app/views/pools/_scoreboard_show.html.haml | 2 +- src/app/views/settings/self_service.html.haml | 2 +- src/config/locales/en.yml | 4 +++- 10 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/app/controllers/deployments_controller.rb b/src/app/controllers/deployments_controller.rb index 8245dd1..5c31830 100644 --- a/src/app/controllers/deployments_controller.rb +++ b/src/app/controllers/deployments_controller.rb @@ -165,7 +165,7 @@ class DeploymentsController < ApplicationController @view = 'pretty_view_show' end #TODO add links to real data for history, permissions, services - @tabs = [{:name => t('instances.instances'), :view => @view, :id => 'instances', :count => @deployment.instances.count}, + @tabs = [{:name => t('instances.instances.other'), :view => @view, :id => 'instances', :count => @deployment.instances.count}, #{:name => 'Services', :view => @view, :id => 'services'}, #{:name => 'History', :view => 'history', :id => 'history'}, {:name => t('properties'), :view => 'properties', :id => 'properties'} @@ -332,7 +332,7 @@ class DeploymentsController < ApplicationController { :name => t("pools.index.deployed_on"), :sortable => false }, { :name => t("deployables.index.base_deployable"), :sortable => false }, { :name => t("deployables.index.state"), :sortable => false }, - { :name => t("instances.instances"), :class => 'center', :sortable => false }, + { :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.pool"), :sortable => false }, { :name => t("pools.index.owner"), :sortable => false }, { :name => t("providers.provider"), :sortable => false } diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb index 37f238e..76c6d5a 100644 --- a/src/app/controllers/pools_controller.rb +++ b/src/app/controllers/pools_controller.rb @@ -39,7 +39,7 @@ class PoolsController < ApplicationController if filter_view? @tabs = [{:name => "#{t'pools.pools'}", :view => 'list', :id => 'pools'}, {:name => "#{t'deployments.deployments'}", :view => 'deployments/list', :id => 'deployments'}, - {:name => "#{t'instances.instances'}", :view => 'instances/list', :id => 'instances'}, + {:name => "#{t'instances.instances.other'}", :view => 'instances/list', :id => 'instances'}, ] details_tab_name = params[:details_tab].blank? ? 'pools' : params[:details_tab] @details_tab = @tabs.find {|t| t[:id] == details_tab_name} || @tabs.first[:name].downcase @@ -239,7 +239,7 @@ class PoolsController < ApplicationController { :name => '', :class => 'alert', :sortable => false }, { :name => t("pools.index.pool_name"), :sort_attr => :name }, { :name => t("deployments.deployments"), :class => 'center', :sortable => false }, - { :name => t("instances.instances"), :class => 'center', :sortable => false }, + { :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.index.pending"), :class => 'center', :sortable => false }, { :name => t("pools.index.failed"), :class => 'center', :sortable => false }, { :name => t("quota_used"), :class => 'center', :sortable => false }, @@ -253,7 +253,7 @@ class PoolsController < ApplicationController { :name => t("pools.index.deployed_on"), :sortable => false }, { :name => t("deployables.index.base_deployable"), :sortable => false }, { :name => t("deployables.index.state"), :sortable => false }, - { :name => t("instances.instances"), :class => 'center', :sortable => false }, + { :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.pool"), :sortable => false }, { :name => t("pools.index.owner"), :sortable => false }, { :name => t("providers.provider"), :sortable => false } diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb index 4842645..52880c0 100644 --- a/src/app/models/deployment.rb +++ b/src/app/models/deployment.rb @@ -401,6 +401,7 @@ class Deployment < ActiveRecord::Base :deployable_xml_name => deployable_xml.name, :deployment_state => deployment_state, :instances_count => instances.count, + :instances_count_text => I18n.t('instances.instances', :count => instances.count.to_i), :uptime => ApplicationHelper.count_uptime(uptime_1st_instance), :global_uptime => ApplicationHelper.count_uptime(uptime_all), :pool => { diff --git a/src/app/views/deployments/_pretty_view.html.haml b/src/app/views/deployments/_pretty_view.html.haml index 9f9af4f..97c586e 100644 --- a/src/app/views/deployments/_pretty_view.html.haml +++ b/src/app/views/deployments/_pretty_view.html.haml @@ -11,10 +11,10 @@ %dt.uptime=t'uptime' %dd= count_uptime(deployment.uptime_1st_instance) %li.instances - %dt.instances.count=t'instances.instances' + %dt.instances.count=t'instances.instances.other' %dd = deployment.instances.count || 0 - %span.inline-label=t'instances.instances' + %span.inline-label=t('instances.instances', :count => deployment.instances.count.to_i) %li.provider %dt.instances.count=t'providers.provider' %dd= deployment.provider.provider_type.name unless deployment.provider.blank? @@ -39,9 +39,9 @@ <dd>${uptime}</dd> </li> <li class="instances"> - <dt class="instances count">#{t'instances.instances'}</dt> + <dt class="instances count">#{t'instances.instances.other'}</dt> <dd>${instances_count} - <span class="inline-label">#{t'instances.instances'}</span> + <span class="inline-label">${instances_count_text}</span> </dd> </li> <li class="provider"> diff --git a/src/app/views/pools/_deployments.html.haml b/src/app/views/pools/_deployments.html.haml index af0b8b8..3f98bde 100644 --- a/src/app/views/pools/_deployments.html.haml +++ b/src/app/views/pools/_deployments.html.haml @@ -9,7 +9,7 @@ %dl.statistics %ul %li.right - %dt.instances.count= t 'instances.instances' + %dt.instances.count= t 'instances.instances.other' %dd= deployment.instances.count || 0
%li.left @@ -27,7 +27,7 @@ <dl class="statistics"> <ul> <li class="right"> - <dt class="instances count">#{t 'instances.instances'}</dt> + <dt class="instances count">#{t 'instances.instances.other'}</dt> <dd>${instances_count}</dd> </li> <li class="left"> diff --git a/src/app/views/pools/_pretty_list.html.haml b/src/app/views/pools/_pretty_list.html.haml index ac2af4d..e31b8b6 100644 --- a/src/app/views/pools/_pretty_list.html.haml +++ b/src/app/views/pools/_pretty_list.html.haml @@ -14,7 +14,7 @@ %dt=t 'deployments.deployments' %dd.count.deployment= pool.deployments.count %li - %dt=t 'instances.instances' + %dt=t 'instances.instances.other' %dd.count.instance= pool.instances.count %dd.count.instance.pending= pool.instances.select {|i| i.state == Instance::STATE_PENDING }.length %dd.count.instance.failure= pool.instances.select {|i| i.state == Instance::STATE_ERROR || i.state == Instance::STATE_CREATE_FAILED }.length diff --git a/src/app/views/pools/_scoreboard_index.html.haml b/src/app/views/pools/_scoreboard_index.html.haml index f264dd5..0781bdb 100644 --- a/src/app/views/pools/_scoreboard_index.html.haml +++ b/src/app/views/pools/_scoreboard_index.html.haml @@ -9,7 +9,7 @@ %dt= t("deployments.deployments") %dd.count.deployment= @statistics[:deployments] %li - %dt= t("instances.instances") + %dt= t("instances.instances.other") %dd.count.instance= @statistics[:instances] %dd.count.instance.pending= @statistics[:instances_pending] %dd.count.instance.failure= @statistics[:instances_failed] diff --git a/src/app/views/pools/_scoreboard_show.html.haml b/src/app/views/pools/_scoreboard_show.html.haml index 8bba937..9f457b3 100644 --- a/src/app/views/pools/_scoreboard_show.html.haml +++ b/src/app/views/pools/_scoreboard_show.html.haml @@ -8,7 +8,7 @@ %dt=t'deployments.deployments' %dd.count.deployment= @statistics[:deployments] %li - %dt=t'instances.instances' + %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] diff --git a/src/app/views/settings/self_service.html.haml b/src/app/views/settings/self_service.html.haml index 2ed2be3..2567883 100644 --- a/src/app/views/settings/self_service.html.haml +++ b/src/app/views/settings/self_service.html.haml @@ -17,7 +17,7 @@ = hidden_field :self_service_default_quota, :id %p %label - =t 'instances.instances' + =t 'instances.instances.other' = t('.quota') + ":" = text_field :self_service_default_quota, :maximum_running_instances, :class => 'grid_5' %fieldset.options diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index a996011..ac47e5d 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -272,7 +272,9 @@ en: preset_filters: all_deployments: All Deployments instances: - instances: Instances + instances: + one: Instance + other: Instances reboot: Reboot instance: Instance none_selected: "You must select one or more instances to stop."
On 01/02/2012 05:50 PM, tsedovic@redhat.com wrote:
From: Tomas Sedovictomas@sedovic.cz
src/app/controllers/deployments_controller.rb | 4 ++-- src/app/controllers/pools_controller.rb | 6 +++--- src/app/models/deployment.rb | 1 + src/app/views/deployments/_pretty_view.html.haml | 8 ++++---- src/app/views/pools/_deployments.html.haml | 4 ++-- src/app/views/pools/_pretty_list.html.haml | 2 +- src/app/views/pools/_scoreboard_index.html.haml | 2 +- src/app/views/pools/_scoreboard_show.html.haml | 2 +- src/app/views/settings/self_service.html.haml | 2 +- src/config/locales/en.yml | 4 +++- 10 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/app/controllers/deployments_controller.rb b/src/app/controllers/deployments_controller.rb index 8245dd1..5c31830 100644 --- a/src/app/controllers/deployments_controller.rb +++ b/src/app/controllers/deployments_controller.rb @@ -165,7 +165,7 @@ class DeploymentsController< ApplicationController @view = 'pretty_view_show' end #TODO add links to real data for history, permissions, services
- @tabs = [{:name => t('instances.instances'), :view => @view, :id => 'instances', :count => @deployment.instances.count},
- @tabs = [{:name => t('instances.instances.other'), :view => @view, :id => 'instances', :count => @deployment.instances.count}, #{:name => 'Services', :view => @view, :id => 'services'}, #{:name => 'History', :view => 'history', :id => 'history'}, {:name => t('properties'), :view => 'properties', :id => 'properties'}
@@ -332,7 +332,7 @@ class DeploymentsController< ApplicationController { :name => t("pools.index.deployed_on"), :sortable => false }, { :name => t("deployables.index.base_deployable"), :sortable => false }, { :name => t("deployables.index.state"), :sortable => false },
{ :name => t("instances.instances"), :class => 'center', :sortable => false },
{ :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.pool"), :sortable => false }, { :name => t("pools.index.owner"), :sortable => false }, { :name => t("providers.provider"), :sortable => false }
diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb index 37f238e..76c6d5a 100644 --- a/src/app/controllers/pools_controller.rb +++ b/src/app/controllers/pools_controller.rb @@ -39,7 +39,7 @@ class PoolsController< ApplicationController if filter_view? @tabs = [{:name => "#{t'pools.pools'}", :view => 'list', :id => 'pools'}, {:name => "#{t'deployments.deployments'}", :view => 'deployments/list', :id => 'deployments'},
{:name => "#{t'instances.instances'}", :view => 'instances/list', :id => 'instances'},
{:name => "#{t'instances.instances.other'}", :view => 'instances/list', :id => 'instances'}, ] details_tab_name = params[:details_tab].blank? ? 'pools' : params[:details_tab] @details_tab = @tabs.find {|t| t[:id] == details_tab_name} || @tabs.first[:name].downcase
@@ -239,7 +239,7 @@ class PoolsController< ApplicationController { :name => '', :class => 'alert', :sortable => false }, { :name => t("pools.index.pool_name"), :sort_attr => :name }, { :name => t("deployments.deployments"), :class => 'center', :sortable => false },
{ :name => t("instances.instances"), :class => 'center', :sortable => false },
{ :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.index.pending"), :class => 'center', :sortable => false }, { :name => t("pools.index.failed"), :class => 'center', :sortable => false }, { :name => t("quota_used"), :class => 'center', :sortable => false },
@@ -253,7 +253,7 @@ class PoolsController< ApplicationController { :name => t("pools.index.deployed_on"), :sortable => false }, { :name => t("deployables.index.base_deployable"), :sortable => false }, { :name => t("deployables.index.state"), :sortable => false },
{ :name => t("instances.instances"), :class => 'center', :sortable => false },
{ :name => t("instances.instances.other"), :class => 'center', :sortable => false }, { :name => t("pools.pool"), :sortable => false }, { :name => t("pools.index.owner"), :sortable => false }, { :name => t("providers.provider"), :sortable => false }
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb index 4842645..52880c0 100644 --- a/src/app/models/deployment.rb +++ b/src/app/models/deployment.rb @@ -401,6 +401,7 @@ class Deployment< ActiveRecord::Base :deployable_xml_name => deployable_xml.name, :deployment_state => deployment_state, :instances_count => instances.count,
:instances_count_text => I18n.t('instances.instances', :count => instances.count.to_i), :uptime => ApplicationHelper.count_uptime(uptime_1st_instance), :global_uptime => ApplicationHelper.count_uptime(uptime_all), :pool => {
diff --git a/src/app/views/deployments/_pretty_view.html.haml b/src/app/views/deployments/_pretty_view.html.haml index 9f9af4f..97c586e 100644 --- a/src/app/views/deployments/_pretty_view.html.haml +++ b/src/app/views/deployments/_pretty_view.html.haml @@ -11,10 +11,10 @@ %dt.uptime=t'uptime' %dd= count_uptime(deployment.uptime_1st_instance) %li.instances
%dt.instances.count=t'instances.instances'
%dt.instances.count=t'instances.instances.other' %dd = deployment.instances.count || 0
%span.inline-label=t'instances.instances'
%span.inline-label=t('instances.instances', :count => deployment.instances.count.to_i) %li.provider %dt.instances.count=t'providers.provider' %dd= deployment.provider.provider_type.name unless deployment.provider.blank?
@@ -39,9 +39,9 @@ <dd>${uptime}</dd> </li> <li class="instances"> -<dt class="instances count">#{t'instances.instances'}</dt> +<dt class="instances count">#{t'instances.instances.other'}</dt> <dd>${instances_count} -<span class="inline-label">#{t'instances.instances'}</span> +<span class="inline-label">${instances_count_text}</span> </dd> </li> <li class="provider"> diff --git a/src/app/views/pools/_deployments.html.haml b/src/app/views/pools/_deployments.html.haml index af0b8b8..3f98bde 100644 --- a/src/app/views/pools/_deployments.html.haml +++ b/src/app/views/pools/_deployments.html.haml @@ -9,7 +9,7 @@ %dl.statistics %ul %li.right
%dt.instances.count= t 'instances.instances'
%dt.instances.count= t 'instances.instances.other' %dd= deployment.instances.count || 0 %li.left
@@ -27,7 +27,7 @@ <dl class="statistics"> <ul> <li class="right"> -<dt class="instances count">#{t 'instances.instances'}</dt> +<dt class="instances count">#{t 'instances.instances.other'}</dt> <dd>${instances_count}</dd> </li> <li class="left"> diff --git a/src/app/views/pools/_pretty_list.html.haml b/src/app/views/pools/_pretty_list.html.haml index ac2af4d..e31b8b6 100644 --- a/src/app/views/pools/_pretty_list.html.haml +++ b/src/app/views/pools/_pretty_list.html.haml @@ -14,7 +14,7 @@ %dt=t 'deployments.deployments' %dd.count.deployment= pool.deployments.count %li
%dt=t 'instances.instances'
%dt=t 'instances.instances.other' %dd.count.instance= pool.instances.count %dd.count.instance.pending= pool.instances.select {|i| i.state == Instance::STATE_PENDING }.length %dd.count.instance.failure= pool.instances.select {|i| i.state == Instance::STATE_ERROR || i.state == Instance::STATE_CREATE_FAILED }.length
diff --git a/src/app/views/pools/_scoreboard_index.html.haml b/src/app/views/pools/_scoreboard_index.html.haml index f264dd5..0781bdb 100644 --- a/src/app/views/pools/_scoreboard_index.html.haml +++ b/src/app/views/pools/_scoreboard_index.html.haml @@ -9,7 +9,7 @@ %dt= t("deployments.deployments") %dd.count.deployment= @statistics[:deployments] %li
%dt= t("instances.instances")
%dt= t("instances.instances.other") %dd.count.instance= @statistics[:instances] %dd.count.instance.pending= @statistics[:instances_pending] %dd.count.instance.failure= @statistics[:instances_failed]
diff --git a/src/app/views/pools/_scoreboard_show.html.haml b/src/app/views/pools/_scoreboard_show.html.haml index 8bba937..9f457b3 100644 --- a/src/app/views/pools/_scoreboard_show.html.haml +++ b/src/app/views/pools/_scoreboard_show.html.haml @@ -8,7 +8,7 @@ %dt=t'deployments.deployments' %dd.count.deployment= @statistics[:deployments] %li
%dt=t'instances.instances'
%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]
diff --git a/src/app/views/settings/self_service.html.haml b/src/app/views/settings/self_service.html.haml index 2ed2be3..2567883 100644 --- a/src/app/views/settings/self_service.html.haml +++ b/src/app/views/settings/self_service.html.haml @@ -17,7 +17,7 @@ = hidden_field :self_service_default_quota, :id %p %label
=t 'instances.instances'
=t 'instances.instances.other' = t('.quota') + ":" = text_field :self_service_default_quota, :maximum_running_instances, :class => 'grid_5' %fieldset.options
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index a996011..ac47e5d 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -272,7 +272,9 @@ en: preset_filters: all_deployments: All Deployments instances:
- instances: Instances
- instances:
one: Instance
other: Instances reboot: Reboot instance: Instance none_selected: "You must select one or more instances to stop."
Self-ack & pushed.
On Jan 2, 2012, at 5:50 PM, tsedovic@redhat.com wrote:
From: Tomas Sedovic tomas@sedovic.cz
https://bugzilla.redhat.com/show_bug.cgi?id=767100
The uptime output was too long when the value exceeded 1 day. Moreover, it was not using i18n which made it untranslatable.
Now it uses standard I18n values for displaying time difference, which incidentally makes the output long enough to fit into the pretty view deployment boxes.
The boxes are a bit wider, too. That will hopefully make the translators' jobs a bit easier.
Dunno if it's related, but Deltacloud provide 'launch_time' attribute for each instance. Might be useful here :-)
Also if you want to just show this uptime in Conductor, I would recommend looking at "http://mifo.sk/jquery.cuteTime.min.js". This library transforms:
<time pubdate='pubdate'>2011-08-10T12:00:00+00:00</time>
to '4 months ago' :-)
-- Michal
src/app/helpers/application_helper.rb | 33 +++++++++++++++++++-------------- src/app/stylesheets/layout.scss | 4 ++-- src/config/locales/en.yml | 5 +++++ 3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb index 654013c..9e24112 100644 --- a/src/app/helpers/application_helper.rb +++ b/src/app/helpers/application_helper.rb @@ -112,21 +112,26 @@ module ApplicationHelper title.split(' ').join('_').downcase end
- def count_uptime(time)
- if time
result_string = []
seconds = time % 60
time = (time - seconds) / 60
minutes = time % 60
time = (time - minutes) / 60
hours = time % 24
time = (time - hours) / 24
days = time % 7
result_string<< "#{days.to_i} #{(days.to_i > 1 ? 'days' : 'day')}" if days != 0
result_string<<"#{"%02d"%hours.to_i}:#{"%02d"%minutes.to_i}:#{"%02d"%seconds.to_i}"
result_string.join(", ")
- def count_uptime(delta_seconds)
- if delta_seconds
seconds = delta_seconds.to_i
minutes = seconds / 60
hours = minutes / 60
days = hours / 24
months = days / 31
case
when months > 0
I18n.t('datetime.distance_in_words.x_months', :count => months)
when days > 0
I18n.t('datetime.distance_in_words.x_days', :count => days)
when hours > 0
I18n.t('datetime.distance_in_words.x_hours', :count => hours)
when minutes > 0
I18n.t('datetime.distance_in_words.x_minutes', :count => minutes)
else
I18n.t('datetime.distance_in_words.x_seconds', :count => seconds)
else "N/A" endend
diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss index 18a7c53..5417d36 100644 --- a/src/app/stylesheets/layout.scss +++ b/src/app/stylesheets/layout.scss @@ -2176,7 +2176,7 @@ $font-family-primary: Helvetica, Arial, "Lucida Grande", sans-serif; /* todo: move this elsewhere */
$deployment-large-height: 154px; -$deployment-large-width: 154px; +$deployment-large-width: 166px; $deployment-large-padding: 8px;
ul.deployment-array.large{ @@ -2240,7 +2240,7 @@ ul.deployment-array.large{ }
li.deployment + li.deployment{
- margin-left: 38px;
margin-left: 23px; }
li.deployment.pending, li.deployment.alert, li.deployment.failure{
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index 94e9873..a996011 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -1,5 +1,10 @@ en: dashboard: Dashboard
- datetime:
- distance_in_words:
x_hours:
one: 1 hour
users: users_groups: "Users & Groups" return_to: "Return to:"other: %{count} hours
-- 1.7.6.4
------------------------------------------------------ Michal Fojtik, mfojtik@redhat.com Deltacloud API: http://deltacloud.org
On 01/03/2012 12:28 PM, Michal Fojtik wrote:
On Jan 2, 2012, at 5:50 PM, tsedovic@redhat.com wrote:
From: Tomas Sedovictomas@sedovic.cz
https://bugzilla.redhat.com/show_bug.cgi?id=767100
The uptime output was too long when the value exceeded 1 day. Moreover, it was not using i18n which made it untranslatable.
Now it uses standard I18n values for displaying time difference, which incidentally makes the output long enough to fit into the pretty view deployment boxes.
The boxes are a bit wider, too. That will hopefully make the translators' jobs a bit easier.
Dunno if it's related, but Deltacloud provide 'launch_time' attribute for each instance. Might be useful here :-)
Nice one. I think we're using our own timer (once Deltacloud reports to us that the instance is running) to avoid timing issues and to take care of things like downtime, etc.
But it's good to know. This will come in handy when we allow importing already running instances into Conductor.
Also if you want to just show this uptime in Conductor, I would recommend looking at "http://mifo.sk/jquery.cuteTime.min.js". This library transforms:
<time pubdate='pubdate'>2011-08-10T12:00:00+00:00</time>
to '4 months ago' :-)
Thanks, it looks neat. We need to be able to work with disabled javascript as well, though.
And it's better to have all the i18n in one place (config/locales/*.yml) rather than in two (the config dir and this plugin).
-- Michal
src/app/helpers/application_helper.rb | 33 +++++++++++++++++++-------------- src/app/stylesheets/layout.scss | 4 ++-- src/config/locales/en.yml | 5 +++++ 3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb index 654013c..9e24112 100644 --- a/src/app/helpers/application_helper.rb +++ b/src/app/helpers/application_helper.rb @@ -112,21 +112,26 @@ module ApplicationHelper title.split(' ').join('_').downcase end
- def count_uptime(time)
- if time
result_string = []
seconds = time % 60
time = (time - seconds) / 60
minutes = time % 60
time = (time - minutes) / 60
hours = time % 24
time = (time - hours) / 24
days = time % 7
result_string<< "#{days.to_i} #{(days.to_i> 1 ? 'days' : 'day')}" if days != 0
result_string<<"#{"%02d"%hours.to_i}:#{"%02d"%minutes.to_i}:#{"%02d"%seconds.to_i}"
result_string.join(", ")
- def count_uptime(delta_seconds)
- if delta_seconds
seconds = delta_seconds.to_i
minutes = seconds / 60
hours = minutes / 60
days = hours / 24
months = days / 31
case
when months> 0
I18n.t('datetime.distance_in_words.x_months', :count => months)
when days> 0
I18n.t('datetime.distance_in_words.x_days', :count => days)
when hours> 0
I18n.t('datetime.distance_in_words.x_hours', :count => hours)
when minutes> 0
I18n.t('datetime.distance_in_words.x_minutes', :count => minutes)
else
I18n.t('datetime.distance_in_words.x_seconds', :count => seconds)
else "N/A" endend
diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss index 18a7c53..5417d36 100644 --- a/src/app/stylesheets/layout.scss +++ b/src/app/stylesheets/layout.scss @@ -2176,7 +2176,7 @@ $font-family-primary: Helvetica, Arial, "Lucida Grande", sans-serif; /* todo: move this elsewhere */
$deployment-large-height: 154px; -$deployment-large-width: 154px; +$deployment-large-width: 166px; $deployment-large-padding: 8px;
ul.deployment-array.large{ @@ -2240,7 +2240,7 @@ ul.deployment-array.large{ }
li.deployment + li.deployment{
- margin-left: 38px;
margin-left: 23px; }
li.deployment.pending, li.deployment.alert, li.deployment.failure{
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index 94e9873..a996011 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -1,5 +1,10 @@ en: dashboard: Dashboard
- datetime:
- distance_in_words:
x_hours:
one: 1 hour
users: users_groups: "Users& Groups" return_to: "Return to:"other: %{count} hours
-- 1.7.6.4
Michal Fojtik, mfojtik@redhat.com Deltacloud API: http://deltacloud.org
aeolus-devel@lists.fedorahosted.org