You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2013/11/28 13:16:33 UTC
git commit: AMBARI-3907. Restart message should have correct message
for single hosts/components. (Denys Buzhor via akovalenko)
Updated Branches:
refs/heads/trunk 3d404d8ef -> 33bf2302c
AMBARI-3907. Restart message should have correct message for single hosts/components. (Denys Buzhor via akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/33bf2302
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/33bf2302
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/33bf2302
Branch: refs/heads/trunk
Commit: 33bf2302c7eeb76d251146fe2859c6315ae0d5e9
Parents: 3d404d8
Author: Aleksandr Kovalenko <ol...@ukr.net>
Authored: Thu Nov 28 14:15:44 2013 +0200
Committer: Aleksandr Kovalenko <ol...@ukr.net>
Committed: Thu Nov 28 14:15:44 2013 +0200
----------------------------------------------------------------------
ambari-web/app/messages.js | 2 +-
.../app/templates/main/service/info/configs.hbs | 2 +-
ambari-web/app/utils/helper.js | 38 +++++++++++++++++++-
ambari-web/app/views/main/host/summary.js | 12 +++++--
ambari-web/app/views/main/service/menu.js | 16 +++++++--
5 files changed, 62 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/33bf2302/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 693dfca..3d9eb34 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1324,7 +1324,7 @@ Em.I18n.translations = {
'hosts.host.summary.addComponent':'Add Component',
'hosts.host.details.hostActions':'Host Actions',
- 'hosts.host.details.needToRestart':'Host needs {0} components restarted',
+ 'hosts.host.details.needToRestart':'Host needs {0} {1} restarted',
'hosts.host.details.needToRestart.button':'Restart components',
'hosts.host.details.needToRestart.stopButton':'Stop Components',
'hosts.host.details.needToRestart.startButton':'Start Components',
http://git-wip-us.apache.org/repos/asf/ambari/blob/33bf2302/ambari-web/app/templates/main/service/info/configs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/configs.hbs b/ambari-web/app/templates/main/service/info/configs.hbs
index b87321f..655ab98 100644
--- a/ambari-web/app/templates/main/service/info/configs.hbs
+++ b/ambari-web/app/templates/main/service/info/configs.hbs
@@ -23,7 +23,7 @@
{{#if App.isAdmin}}
<div>
<div class="alert alert-warning clearfix">
- <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}} <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{t common.components}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{t dashboard.services.hosts}}</a> {{t services.service.config.restartService.needToRestartEnd}}
+ <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}} <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount "t:common.component" "t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount "t:common.host" "t:common.hosts"}}</a> {{t services.service.config.restartService.needToRestartEnd}}
<button {{bindAttr class=":btn :restart-components :pull-right view.startComponentsIsDisabled::btn-success view.startComponentsIsDisabled:disabled" }} {{action restartComponents target="controller"}}>
{{t hosts.host.details.needToRestart.startButton}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/33bf2302/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index f86a2be..5f7fbbd 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -99,6 +99,42 @@ Em.Handlebars.registerHelper('highlight', function (property, words, fn) {
return new Em.Handlebars.SafeString(property);
})
+
+/*
+ * Return singular or plural word based on Em.I18n property key.
+ * @param count - integer count property *required
+ * @param singular - singular version of word, for example "t:common.host" *required
+ * @param plural - plural version of word *required
+ * @return {String}
+ *
+ * Example: {{pluralize hostsCount "t:host" "t:hosts"}}
+ */
+Em.Handlebars.registerHelper('pluralize', function(count, singular, plural, fn) {
+ var context = (fn.contexts && fn.contexts[0]) || this;
+ count = Em.Handlebars.getPath(context, count, fn);
+
+ tDetect = function(word, keyOnly) {
+ var splitted = word.split(':');
+ if (splitted.length > 1 && splitted[0] == 't') {
+ if (keyOnly) {
+ return splitted[1];
+ }
+ return Em.I18n.t(splitted[1]);
+ } else {
+ return splitted[0];
+ }
+ }
+ singular = tDetect(singular);
+ plural = tDetect(plural);
+ if (singular && plural) {
+ if (count > 1) {
+ return plural;
+ } else {
+ return singular;
+ }
+ }
+});
+
/**
* Replace {i} with argument. where i is number of argument to replace with
* @return {String}
@@ -368,4 +404,4 @@ App.popover = function(self, options) {
self.on("remove", function () {
$(this).trigger('mouseleave');
});
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/33bf2302/ambari-web/app/views/main/host/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js
index ea7bee8..d281197 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -57,7 +57,15 @@ App.MainHostSummaryView = Em.View.extend({
}.property('sortedComponents.@each.workStatus'),
needToRestartMessage: function() {
- return Em.I18n.t('hosts.host.details.needToRestart').format(this.get('needToRestartComponentsCount'));
+ var componentsCount, word;
+ this.set('needToRestartComponentsCount', 1);
+ componentsCount = this.get('needToRestartComponentsCount');
+ if (componentsCount > 1) {
+ word = Em.I18n.t('common.components').toLowerCase();
+ } else {
+ word = Em.I18n.t('common.component').toLowerCase();
+ }
+ return Em.I18n.t('hosts.host.details.needToRestart').format(this.get('needToRestartComponentsCount'), word);
}.property('needToRestartComponentsCount'),
/**
@@ -480,4 +488,4 @@ App.MainHostSummaryView = Em.View.extend({
}
return "";
}.property('content.lastHeartBeatTime')
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/33bf2302/ambari-web/app/views/main/service/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/menu.js b/ambari-web/app/views/main/service/menu.js
index f7cf9d5..4dfa693 100644
--- a/ambari-web/app/views/main/service/menu.js
+++ b/ambari-web/app/views/main/service/menu.js
@@ -80,7 +80,7 @@ App.MainServiceMenuView = Em.CollectionView.extend({
}.property('App.router.clusterController.alerts'),
refreshRestartRequiredMessage: function() {
- var restarted, componentsCount, hostsCount, message;
+ var restarted, componentsCount, hostsCount, message, tHosts, tComponents;
restarted = this.get('content.restartRequiredHostsAndComponents');
componentsCount = 0;
hostsCount = 0;
@@ -89,8 +89,18 @@ App.MainServiceMenuView = Em.CollectionView.extend({
hostsCount++;
componentsCount += restarted[host].length;
}
- message += componentsCount + ' ' + Em.I18n.t('common.components') + ' ' + Em.I18n.t('on') + ' ' +
- hostsCount + ' ' + Em.I18n.t('common.hosts') + ' ' + Em.I18n.t('services.service.config.restartService.needToRestartEnd');
+ if (hostsCount > 1) {
+ tHosts = Em.I18n.t('common.hosts');
+ } else {
+ tHosts = Em.I18n.t('common.host');
+ }
+ if (componentsCount > 1) {
+ tComponents = Em.I18n.t('common.components');
+ } else {
+ tComponents = Em.I18n.t('common.component');
+ }
+ message += componentsCount + ' ' + tComponents + ' ' + Em.I18n.t('on') + ' ' +
+ hostsCount + ' ' + tHosts + ' ' + Em.I18n.t('services.service.config.restartService.needToRestartEnd');
this.set('restartRequiredMessage', message);
}.observes('content.restartRequiredHostsAndComponents')
})