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 16:35:27 UTC

git commit: AMBARI-3907. Restart message should have correct message for single hosts/components. Additional patch. (Denys Buzhor via akovalenko)

Updated Branches:
  refs/heads/trunk 0afd327c9 -> 964584518


AMBARI-3907. Restart message should have correct message for single hosts/components. Additional patch. (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/96458451
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/96458451
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/96458451

Branch: refs/heads/trunk
Commit: 9645845180412dcf22441e418d772b7e8f913634
Parents: 0afd327
Author: Aleksandr Kovalenko <ol...@ukr.net>
Authored: Thu Nov 28 17:34:33 2013 +0200
Committer: Aleksandr Kovalenko <ol...@ukr.net>
Committed: Thu Nov 28 17:35:01 2013 +0200

----------------------------------------------------------------------
 .../app/templates/main/service/info/configs.hbs |  2 +-
 ambari-web/app/utils/helper.js                  | 92 ++++++++++++--------
 ambari-web/app/views/main/host/summary.js       |  1 -
 3 files changed, 58 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/96458451/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 655ab98..7a22102 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}} {{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}}
+              <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}}  <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="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/96458451/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index 5f7fbbd..22d462e 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -100,41 +100,6 @@ 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}
@@ -405,3 +370,60 @@ App.popover = function(self, options) {
     $(this).trigger('mouseleave');
   });
 }
+
+/*
+ * Helper function for bound property helper registration
+ * @params name {String} - name of helper
+ * @params view {Em.View} - view
+ */
+App.registerBoundHelper = function(name, view) {
+  Em.Handlebars.registerHelper(name, function(property, options) {
+    options.hash.contentBinding = property;
+    return Em.Handlebars.helpers.view.call(this, view, options);
+  });
+}
+
+/*
+ * Return singular or plural word based on Em.I18n property key.
+ *
+ *  Example: {{pluralize hostsCount singular="t:host" plural="t:hosts"}}
+ */
+App.registerBoundHelper('pluralize', Em.View.extend({
+  tagName: 'span',
+  template: Em.Handlebars.compile('{{view.wordOut}}'),
+
+  wordOut: function() {
+    var count, singular, plural;
+    count = this.get('content');
+    singular = this.get('singular');
+    plural = this.get('plural');
+    return this.getWord(count, singular, plural);
+  }.property('content'),
+
+  getWord: function(count, singular, plural) {
+    singular = this.tDetect(singular);
+    plural = this.tDetect(plural);
+    if (singular && plural) {
+      if (count > 1) {
+        return plural;
+      } else {
+        return singular;
+      }
+    }
+  },
+
+  /*
+   * Detect for Em.I18n.t reference call
+   * @params word {String}
+   * return {String}
+  */
+  tDetect: function(word) {
+    var splitted = word.split(':');
+    if (splitted.length > 1 && splitted[0] == 't') {
+      return Em.I18n.t(splitted[1]);
+    } else {
+      return splitted[0];
+    }
+  }
+  })
+)

http://git-wip-us.apache.org/repos/asf/ambari/blob/96458451/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 d281197..96fc740 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -58,7 +58,6 @@ App.MainHostSummaryView = Em.View.extend({
 
   needToRestartMessage: function() {
     var componentsCount, word;
-    this.set('needToRestartComponentsCount', 1);
     componentsCount = this.get('needToRestartComponentsCount');
     if (componentsCount > 1) {
       word = Em.I18n.t('common.components').toLowerCase();