Browse Source

AMBARI-14176. Apply App.* supported macros (onechiporenko)

Oleg Nechiporenko 9 years ago
parent
commit
35b28f01e9
76 changed files with 256 additions and 737 deletions
  1. 2 6
      ambari-web/app/controllers/application.js
  2. 1 3
      ambari-web/app/controllers/global/cluster_controller.js
  3. 2 6
      ambari-web/app/controllers/global/update_controller.js
  4. 2 6
      ambari-web/app/controllers/main.js
  5. 1 3
      ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
  6. 1 3
      ambari-web/app/controllers/main/alerts/alert_instances_controller.js
  7. 2 6
      ambari-web/app/controllers/main/alerts/definition_details_controller.js
  8. 4 5
      ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js
  9. 1 3
      ambari-web/app/controllers/main/host/host_alerts_controller.js
  10. 2 6
      ambari-web/app/controllers/main/service.js
  11. 1 3
      ambari-web/app/controllers/main/service/info/configs.js
  12. 8 3
      ambari-web/app/controllers/main/service/info/summary.js
  13. 1 3
      ambari-web/app/controllers/wizard/step8_controller.js
  14. 1 3
      ambari-web/app/mixins/common/configs/enhanced_configs.js
  15. 1 3
      ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
  16. 2 6
      ambari-web/app/mixins/main/service/configs/config_overridable.js
  17. 1 3
      ambari-web/app/mixins/wizard/assign_master_components.js
  18. 1 3
      ambari-web/app/mixins/wizard/wizardProgressPageView.js
  19. 2 6
      ambari-web/app/models/alerts/alert_config.js
  20. 5 5
      ambari-web/app/models/alerts/alert_definition.js
  21. 1 3
      ambari-web/app/models/alerts/alert_group.js
  22. 1 3
      ambari-web/app/models/configs/config_group.js
  23. 1 3
      ambari-web/app/models/configs/objects/service_config_property.js
  24. 1 3
      ambari-web/app/models/configs/theme/tab.js
  25. 1 3
      ambari-web/app/models/host.js
  26. 1 3
      ambari-web/app/models/stack_version/repository_version.js
  27. 1 71
      ambari-web/app/models/user.js
  28. 2 6
      ambari-web/app/utils/hosts.js
  29. 3 9
      ambari-web/app/utils/polling.js
  30. 2 6
      ambari-web/app/views/common/assign_master_components_view.js
  31. 1 3
      ambari-web/app/views/common/chart/linear.js
  32. 2 6
      ambari-web/app/views/common/chart/linear_time.js
  33. 1 3
      ambari-web/app/views/common/chart/pie.js
  34. 1 3
      ambari-web/app/views/common/configs/config_history_flow.js
  35. 1 3
      ambari-web/app/views/common/configs/service_configs_by_category_view.js
  36. 1 3
      ambari-web/app/views/common/form/manage_credentials_form_view.js
  37. 5 15
      ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js
  38. 1 3
      ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
  39. 2 8
      ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js
  40. 1 3
      ambari-web/app/views/common/progress_bar_view.js
  41. 1 3
      ambari-web/app/views/common/widget/gauge_widget_view.js
  42. 1 3
      ambari-web/app/views/main/admin/highAvailability/progress_view.js
  43. 4 12
      ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
  44. 2 6
      ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
  45. 3 6
      ambari-web/app/views/main/dashboard/widget.js
  46. 1 3
      ambari-web/app/views/main/dashboard/widgets.js
  47. 3 3
      ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js
  48. 5 3
      ambari-web/app/views/main/dashboard/widgets/hdfs_links.js
  49. 1 3
      ambari-web/app/views/main/dashboard/widgets/node_managers_live.js
  50. 3 5
      ambari-web/app/views/main/dashboard/widgets/text_widget.js
  51. 1 3
      ambari-web/app/views/main/host/configs.js
  52. 1 3
      ambari-web/app/views/main/host/configs_service.js
  53. 1 3
      ambari-web/app/views/main/host/configs_service_menu.js
  54. 1 3
      ambari-web/app/views/main/host/details.js
  55. 13 35
      ambari-web/app/views/main/host/details/host_component_view.js
  56. 1 3
      ambari-web/app/views/main/host/metrics.js
  57. 1 3
      ambari-web/app/views/main/host/stack_versions_view.js
  58. 6 11
      ambari-web/app/views/main/host/summary.js
  59. 3 11
      ambari-web/app/views/main/menu.js
  60. 2 6
      ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js
  61. 1 3
      ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js
  62. 2 6
      ambari-web/app/views/main/service/info/summary.js
  63. 15 4
      ambari-web/app/views/main/service/service.js
  64. 3 6
      ambari-web/app/views/main/service/services/flume.js
  65. 9 37
      ambari-web/app/views/main/service/services/hbase.js
  66. 42 71
      ambari-web/app/views/main/service/services/hdfs.js
  67. 27 80
      ambari-web/app/views/main/service/services/yarn.js
  68. 1 4
      ambari-web/app/views/main/service/widgets/create/expression_view.js
  69. 1 3
      ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js
  70. 1 3
      ambari-web/app/views/wizard/step3_view.js
  71. 13 19
      ambari-web/app/views/wizard/step9_view.js
  72. 5 5
      ambari-web/test/controllers/application_test.js
  73. 2 6
      ambari-web/test/controllers/main/service_test.js
  74. 2 2
      ambari-web/test/controllers/main_test.js
  75. 3 108
      ambari-web/test/models/user_test.js
  76. 4 7
      ambari-web/test/views/main/dashboard/widgets_test.js

+ 2 - 6
ambari-web/app/controllers/application.js

@@ -41,13 +41,9 @@ App.ApplicationController = Em.Controller.extend(App.UserPref, {
     return name.length > 13 ? name.substr(0, 10) + "..." : name;
   }.property('clusterName'),
 
-  isClusterDataLoaded: function() {
-    return App.router.get('clusterController.isLoaded') && App.router.get('loggedIn');
-  }.property('App.router.clusterController.isLoaded','App.router.loggedIn'),
+  isClusterDataLoaded: Em.computed.and('App.router.clusterController.isLoaded','App.router.loggedIn'),
 
-  isExistingClusterDataLoaded: function () {
-    return App.router.get('clusterInstallCompleted') && this.get('isClusterDataLoaded');
-  }.property('App.router.clusterInstallCompleted', 'isClusterDataLoaded'),
+  isExistingClusterDataLoaded: Em.computed.and('App.router.clusterInstallCompleted', 'isClusterDataLoaded'),
 
   /**
    * Determines if "Exit" menu-item should be shown

+ 1 - 3
ambari-web/app/controllers/global/cluster_controller.js

@@ -52,9 +52,7 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
 
   isServiceContentFullyLoaded: Em.computed.and('isServiceMetricsLoaded', 'isComponentsStateLoaded', 'isComponentsConfigLoaded'),
 
-  clusterName: function () {
-    return App.get('clusterName');
-  }.property('App.clusterName'),
+  clusterName: Em.computed.alias('App.clusterName'),
 
   updateLoadStatus: function (item) {
     var loadList = this.get('dataLoadList');

+ 2 - 6
ambari-web/app/controllers/global/update_controller.js

@@ -23,13 +23,9 @@ App.UpdateController = Em.Controller.extend({
   isUpdated: false,
   cluster: null,
   isWorking: false,
-  updateAlertInstances: function() {
-    return this.get('isWorking') && !App.get('router.mainAlertInstancesController.isUpdating');
-  }.property('isWorking', 'App.router.mainAlertInstancesController.isUpdating'),
+  updateAlertInstances: Em.computed.and('isWorking', '!App.router.mainAlertInstancesController.isUpdating'),
   timeIntervalId: null,
-  clusterName: function () {
-    return App.router.get('clusterController.clusterName');
-  }.property('App.router.clusterController.clusterName'),
+  clusterName: Em.computed.alias('App.router.clusterController.clusterName'),
 
   /**
    * keys which should be preloaded in order to filter hosts by host-components

+ 2 - 6
ambari-web/app/controllers/main.js

@@ -39,13 +39,9 @@ App.MainController = Em.Controller.extend({
     }
   }.observes('App.router.clusterController.clusterName, App.router.clusterInstallCompleted', 'App.router.clusterController.isLoaded'),
 
-  isClusterDataLoaded: function(){
-    return App.router.get('clusterController.isLoaded');
-  }.property('App.router.clusterController.isLoaded'),
+  isClusterDataLoaded: Em.computed.alias('App.router.clusterController.isLoaded'),
 
-  clusterDataLoadedPercent: function(){
-    return App.router.get('clusterController.clusterDataLoadedPercent');
-  }.property('App.router.clusterController.clusterDataLoadedPercent'),
+  clusterDataLoadedPercent: Em.computed.alias('App.router.clusterController.clusterDataLoadedPercent'),
   /**
    * run all processes and cluster's data loading
    */

+ 1 - 3
ambari-web/app/controllers/main/admin/kerberos/step2_controller.js

@@ -56,9 +56,7 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend(App.KDCCred
     return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
   }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked', 'testConnectionInProgress'),
 
-  hostNames: function () {
-    return App.get('allHostNames');
-  }.property('App.allHostNames'),
+  hostNames: Em.computed.alias('App.allHostNames'),
 
   serviceConfigTags: [],
 

+ 1 - 3
ambari-web/app/controllers/main/alerts/alert_instances_controller.js

@@ -242,9 +242,7 @@ App.MainAlertInstancesController = Em.Controller.extend({
          * Number of all critical and warning alert instances
          * @type {Boolean}
          */
-        filteredCount: function () {
-          return App.router.get('mainAlertDefinitionsController.unhealthyAlertInstancesCount');
-        }.property('alertsNumber'),
+        filteredCount: Em.computed.alias('App.router.mainAlertDefinitionsController.unhealthyAlertInstancesCount'),
 
         content: function () {
           return this.get('controller.unhealthyAlertInstances');

+ 2 - 6
ambari-web/app/controllers/main/alerts/definition_details_controller.js

@@ -263,9 +263,7 @@ App.MainAlertDefinitionDetailsController = Em.Controller.extend({
    * Define if label or configs are in edit mode
    * @type {Boolean}
    */
-  isEditing: function () {
-    return this.get('editing.label.isEditing') || App.router.get('mainAlertDefinitionConfigsController.canEdit');
-  }.property('editing.label.isEditing', 'App.router.mainAlertDefinitionConfigsController.canEdit'),
+  isEditing: Em.computed.or('editing.label.isEditing', 'App.router.mainAlertDefinitionConfigsController.canEdit'),
 
   /**
    * If some configs or label are changed and user navigates away, show this popup with propose to save changes
@@ -282,9 +280,7 @@ App.MainAlertDefinitionDetailsController = Em.Controller.extend({
       primary: Em.I18n.t('common.save'),
       secondary: Em.I18n.t('common.discard'),
       third: Em.I18n.t('common.cancel'),
-      disablePrimary: function () {
-        return App.router.get('mainAlertDefinitionDetailsController.editing.label.isError') || App.router.get('mainAlertDefinitionConfigsController.hasErrors');
-      }.property('App.router.mainAlertDefinitionDetailsController.editing.label.isError', 'App.router.mainAlertDefinitionConfigsController.hasErrors'),
+      disablePrimary: Em.computed.or('App.router.mainAlertDefinitionDetailsController.editing.label.isError', 'App.router.mainAlertDefinitionConfigsController.hasErrors'),
       onPrimary: function () {
         self.saveLabelAndConfigs();
         self.set('forceTransition', true);

+ 4 - 5
ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js

@@ -510,12 +510,11 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
           }
         }.observes('controller.inputFields.retypeSMTPPassword.value', 'controller.inputFields.SMTPPassword.value'),
 
-        setParentErrors: function () {
-          var hasErrors = this.get('nameError') || this.get('emailToError') || this.get('emailFromError') ||
-            this.get('smtpPortError') || this.get('hostError') || this.get('portError') || this.get('passwordError');
-          this.set('parentView.hasErrors', hasErrors);
-        }.observes('nameError', 'emailToError', 'emailFromError', 'smtpPortError', 'hostError', 'portError', 'passwordError'),
+        someErrorExists: Em.computed.or('nameError', 'emailToError', 'emailFromError', 'smtpPortError', 'hostError', 'portError', 'passwordError'),
 
+        setParentErrors: function () {
+          this.set('parentView.hasErrors', this.get('someErrorExists'));
+        }.observes('someErrorExists'),
 
         groupsSelectView: Em.Select.extend({
           attributeBindings: ['disabled'],

+ 1 - 3
ambari-web/app/controllers/main/host/host_alerts_controller.js

@@ -21,9 +21,7 @@ var App = require('app');
 App.MainHostAlertsController = Em.ArrayController.extend({
   name: 'mainHostAlertsController',
 
-  selectedHost: function () {
-    return App.get('router.mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  selectedHost: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   /**
    * List of all <code>App.AlertInstance</code> by Host

+ 2 - 6
ambari-web/app/controllers/main/service.js

@@ -83,16 +83,12 @@ App.MainServiceController = Em.ArrayController.extend({
    * Should "Refresh All"-button be disabled
    * @type {bool}
    */
-  isRestartAllRequiredDisabled: function () {
-    return !this.get('content').someProperty('isRestartRequired');
-  }.property('content.@each.isRestartRequired'),
+  isRestartAllRequiredDisabled: Em.computed.everyBy('content', 'isRestartRequired', false),
 
   /**
    * @type {bool}
    */
-  isStartStopAllClicked: function () {
-    return (App.router.get('backgroundOperationsController').get('allOperationsCount') !== 0);
-  }.property('App.router.backgroundOperationsController.allOperationsCount'),
+  isStartStopAllClicked: Em.computed.notEqual('App.router.backgroundOperationsController.allOperationsCount', 0),
 
   /**
    * Callback for <code>start all service</code> button

+ 1 - 3
ambari-web/app/controllers/main/service/info/configs.js

@@ -121,9 +121,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
         && !this.get('isCompareMode') && App.isAccessible('MANAGER') && !this.get('isHostsConfigsPage');
   }.property('selectedVersion', 'isCompareMode', 'currentDefaultVersion', 'selectedConfigGroup.isDefault'),
 
-  serviceConfigs: function () {
-    return App.config.get('preDefinedServiceConfigs');
-  }.property('App.config.preDefinedServiceConfigs'),
+  serviceConfigs: Em.computed.alias('App.config.preDefinedServiceConfigs'),
 
   /**
    * Number of errors in the configs in the selected service (only for AdvancedTab if App supports Enhanced Configs)

+ 8 - 3
ambari-web/app/controllers/main/service/info/summary.js

@@ -100,11 +100,16 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
   ],
 
   /**
+   * Some widget has type `GRAPH`
+   *
    * @type {boolean}
    */
-  showTimeRangeControl: function () {
-    return !this.get('isServiceWithEnhancedWidgets') || this.get('widgets').filterProperty('widgetType', 'GRAPH').length > 0;
-  }.property('isServiceWithEnhancedWidgets', 'widgets.length'),
+  someWidgetGraphExists: Em.computed.someBy('widgets', 'widgetType', 'GRAPH'),
+
+  /**
+   * @type {boolean}
+   */
+  showTimeRangeControl: Em.computed.or('!isServiceWithEnhancedWidgets', 'someWidgetGraphExists'),
 
   /**
    * Set initial Ranger plugins data

+ 1 - 3
ambari-web/app/controllers/wizard/step8_controller.js

@@ -72,9 +72,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
    * True if Kerberos is installed on the cluster and the kdc_type on the server is set to "none"
    * @type {Boolean}
    */
-  isManualKerberos: function () {
-    return App.get('router.mainAdminKerberosController.kdc_type') === 'none';
-  }.property('App.router.mainAdminKerberosController.kdc_type'),
+  isManualKerberos: Em.computed.equal('App.router.mainAdminKerberosController.kdc_type', 'none'),
 
   showDownloadCsv: function () {
     return !!App.get('router.mainAdminKerberosController.kdc_type')

+ 1 - 3
ambari-web/app/mixins/common/configs/enhanced_configs.js

@@ -40,9 +40,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    * flag is true when Ambari changes some of the dependent properties
    * @type {boolean}
    */
-  hasChangedDependencies: function() {
-    return App.get('isClusterSupportsEnhancedConfigs') && this.get('isControllerSupportsEnhancedConfigs') && this.get('changedProperties.length') > 0;
-  }.property('changedProperties.length'),
+  hasChangedDependencies: Em.computed.and('App.isClusterSupportsEnhancedConfigs', 'isControllerSupportsEnhancedConfigs', 'changedProperties.length'),
 
   /**
    * defines is block with changed dependent configs should be shown

+ 1 - 3
ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js

@@ -33,9 +33,7 @@ App.KDCCredentialsControllerMixin = Em.Mixin.create({
    *
    * @type {boolean}
    */
-  isStorePersisted: function() {
-    return App.get('isCredentialStorePersistent');
-  }.property('App.isCredentialStorePersistent'),
+  isStorePersisted: Em.computed.alias('App.isCredentialStorePersistent'),
 
   /**
    * List of required UI-only properties needed for storing KDC credentials

+ 2 - 6
ambari-web/app/mixins/main/service/configs/config_overridable.js

@@ -185,9 +185,7 @@ App.ConfigOverridable = Em.Mixin.create({
         selectConfigGroupRadioButton: Em.Checkbox.extend({
           tagName: 'input',
           attributeBindings: ['type', 'checked', 'disabled'],
-          checked: function () {
-            return this.get('parentView.parentView.optionSelectConfigGroup');
-          }.property('parentView.parentView.optionSelectConfigGroup'),
+          checked: Em.computed.alias('parentView.parentView.optionSelectConfigGroup'),
           type: 'radio',
           disabled: false,
           click: function () {
@@ -203,9 +201,7 @@ App.ConfigOverridable = Em.Mixin.create({
         createConfigGroupRadioButton: Em.Checkbox.extend({
           tagName: 'input',
           attributeBindings: ['type', 'checked'],
-          checked: function () {
-            return !this.get('parentView.parentView.optionSelectConfigGroup');
-          }.property('parentView.parentView.optionSelectConfigGroup'),
+          checked: Em.computed.not('parentView.parentView.optionSelectConfigGroup'),
           type: 'radio',
           click: function () {
             this.set('parentView.parentView.optionSelectConfigGroup', false);

+ 1 - 3
ambari-web/app/mixins/wizard/assign_master_components.js

@@ -137,9 +137,7 @@ App.AssignMasterComponents = Em.Mixin.create({
    * Master components which could be assigned to multiple hosts
    * @type {string[]}
    */
-  multipleComponents: function () {
-    return App.get('components.multipleMasters');
-  }.property('App.components.multipleMasters'),
+  multipleComponents: Em.computed.alias('App.components.multipleMasters'),
 
   /**
    * Master components which could be assigned to multiple hosts

+ 1 - 3
ambari-web/app/mixins/wizard/wizardProgressPageView.js

@@ -94,9 +94,7 @@ App.wizardProgressPageViewMixin = Em.Mixin.create({
       this.onStatus();
     },
 
-    barWidth: function () {
-      return 'width: ' + this.get('content.progress') + '%;';
-    }.property('content.progress'),
+    barWidth: Em.computed.format('width: {0}%;', 'content.progress'),
 
     onStatus: function () {
       var linkClass = !!this.get('content.requestIds.length') ? 'active-link' : 'active-text';

+ 2 - 6
ambari-web/app/models/alerts/alert_config.js

@@ -452,9 +452,7 @@ App.AlertConfigProperties = {
     label: 'JMX/Ganglia Metrics',
     displayType: 'textArea',
     classNames: 'alert-config-text-area',
-    apiProperty: function () {
-      return this.get('isJMXMetric') ? 'source.jmx.property_list' : 'source.ganglia.property_list'
-    }.property('isJMXMetric'),
+    apiProperty: Em.computed.ifThenElse('isJMXMetric', 'source.jmx.property_list', 'source.ganglia.property_list'),
     apiFormattedValue: function () {
       return this.get('value').split(',\n');
     }.property('value')
@@ -465,9 +463,7 @@ App.AlertConfigProperties = {
     label: 'Format String',
     displayType: 'textArea',
     classNames: 'alert-config-text-area',
-    apiProperty: function () {
-      return this.get('isJMXMetric') ? 'source.jmx.value' : 'source.ganglia.value'
-    }.property('isJMXMetric')
+    apiProperty: Em.computed.ifThenElse('isJMXMetric', 'source.jmx.value', 'source.ganglia.value')
   })
 
 };

+ 5 - 5
ambari-web/app/models/alerts/alert_definition.js

@@ -191,11 +191,11 @@ App.AlertDefinition = DS.Model.extend({
     return text;
   }.property('summary'),
 
-  isHostAlertDefinition: function () {
-    var serviceID = (this.get('service')._id === "AMBARI"),
-        component = (this.get('componentName') === "AMBARI_AGENT");
-    return serviceID && component;
-  }.property('service', 'componentName'),
+  isAmbariService: Em.computed.equal('service._id', 'AMBARI'),
+
+  isAmbariAgentComponent: Em.computed.equal('componentName', 'AMBARI_AGENT'),
+
+  isHostAlertDefinition: Em.computed.and('isAmbariService', 'isAmbariAgentComponent'),
 
   typeIconClass: function () {
     var typeIcons = this.get('typeIcons'),

+ 1 - 3
ambari-web/app/models/alerts/alert_group.js

@@ -66,9 +66,7 @@ App.AlertGroup = DS.Model.extend({
   /**
    * @type {string}
    */
-  displayNameDefinitions: function () {
-    return this.get('displayName') + ' (' + this.get('definitions.length') + ')';
-  }.property('displayName', 'definitions.length'),
+  displayNameDefinitions: Em.computed.format('{0} ({1})', 'displayName', 'definitions.length'),
 
   isAddDefinitionsDisabled: Em.computed.alias('default')
 

+ 1 - 3
ambari-web/app/models/configs/config_group.js

@@ -112,9 +112,7 @@ App.ServiceConfigGroup = DS.Model.extend({
   /**
    *
    */
-  displayNameHosts: function () {
-    return this.get('displayName') + ' (' + this.get('hosts.length') + ')';
-  }.property('displayName', 'hosts.length'),
+  displayNameHosts: Em.computed.format('{0} ({1})', 'displayName', 'hosts.length'),
 
   /**
    * Provides hosts which are available for inclusion in

+ 1 - 3
ambari-web/app/models/configs/objects/service_config_property.js

@@ -112,9 +112,7 @@ App.ServiceConfigProperty = Em.Object.extend({
   /**
    * Placeholder used for configs with input type text
    */
-  placeholder: function () {
-    return this.get('placeholderText') || this.get('savedValue');
-  }.property('savedValue', 'placeholderText'),
+  placeholder: Em.computed.firstNotBlank('placeholderText', 'savedValue'),
 
   retypedPassword: '',
   description: '',

+ 1 - 3
ambari-web/app/models/configs/theme/tab.js

@@ -47,9 +47,7 @@ App.Tab = DS.Model.extend({
    * @type {String}
    * @property headingClass
    */
-  headingClass: function() {
-    return '.' + this.get('id');
-  }.property('id'),
+  headingClass: Em.computed.format('.{0}', 'id'),
 
   /**
    * tooltip message.

+ 1 - 3
ambari-web/app/models/host.js

@@ -105,9 +105,7 @@ App.Host = DS.Model.extend({
    */
   disksMounted: Em.computed.alias('diskInfo.length'),
 
-  coresFormatted: function() {
-    return this.get('cpu') + ' (' + this.get('cpuPhysical') + ')';
-  }.property('cpu', 'cpuPhysical'),
+  coresFormatted: Em.computed.format('{0} ({1})', 'cpu', 'cpuPhysical'),
 
   /**
    * API return diskTotal and diskFree. Need to save their different

+ 1 - 3
ambari-web/app/models/stack_version/repository_version.js

@@ -42,9 +42,7 @@ App.RepositoryVersion = DS.Model.extend({
   /**
    * @type {Array}
    */
-  notInstalledHosts: function () {
-    return this.get('stackVersion.notInstalledHosts') || App.get('allHostNames');
-  }.property('stackVersion.notInstalledHosts'),
+  notInstalledHosts: Em.computed.firstNotBlank('stackVersion.notInstalledHosts', 'App.allHostNames'),
 
   /**
    * @type {Array}

+ 1 - 71
ambari-web/app/models/user.js

@@ -43,79 +43,9 @@ App.User = DS.Model.extend({
   isLdap: Em.computed.equal('userType', 'LDAP')
 });
 
-App.EditUserForm = App.Form.extend({
-  className:App.User,
-  object:function () {
-    return App.router.get('mainAdminUserEditController.content');
-  }.property('App.router.mainAdminUserEditController.content'),
-
-  fieldsOptions:[
-    { name:"userName", displayName:"Username" },
-    { name:"old_password", displayName:"Current Password", displayType:"password", isRequired: false },
-    { name:"new_password", displayName:"New Password", displayType:"password",  isRequired: false },
-    { name:"new_passwordRetype", displayName:"Retype New Password", displayType:"password", isRequired: false },
-    { name:"admin", displayName:"Admin", displayType:"checkbox", isRequired:false },
-    { name:"isLdap", displayName:"Type", isRequired:false, isHidden:true }
-  ],
-  fields:[],
-  disableUsername:function () {
-    this.getField("userName").set("disabled", "disabled");
-  }.observes('object'),
-  disableAdminCheckbox:function () {
-    var object = this.get('object');
-    if (object) {
-      if (object.get('userName') == App.get('router').getLoginName()) {
-        this.getField("admin").set("disabled", true);
-      } else {
-        this.getField("admin").set("disabled", false);
-      }
-    }
-  }.observes('object'),
-
-  isValid:function () {
-
-    var isValid = this._super();
-
-    var newPass = this.get('field.new_password');
-    var oldPass = this.get('field.old_password');
-    var passRetype = this.get('field.new_passwordRetype');
-
-    if (!validator.empty(newPass.get('value'))) {
-      if(validator.empty(oldPass.get('value'))){
-        oldPass.set('errorMessage', this.t('admin.users.editError.requiredField'));
-        isValid = false;
-      }
-      if (newPass.get('value') != passRetype.get('value')) {
-        passRetype.set('errorMessage', this.t('admin.users.createError.passwordValidation'));
-        isValid = false;
-      }
-    }
-
-    return isValid;
-  },
-
-  save: function () {
-    var object = this.get('object');
-    var formValues = {};
-    $.each(this.get('fields'), function () {
-      formValues[this.get('name')] = this.get('value');
-    });
-
-    $.each(formValues, function (k, v) {
-      object.set(k, v);
-    });
-
-    //App.store.commit();
-    this.set('result', 1);
-
-    return true;
-  }
-});
 App.CreateUserForm = App.Form.extend({
   className:App.User,
-  object:function () {
-    return App.router.get('mainAdminUserCreateController.content');
-  }.property('App.router.mainAdminUserCreateController.content'),
+  object: Em.computed.alias('App.router.mainAdminUserCreateController.content'),
 
   fieldsOptions:[
     { name:"userName", displayName:"Username", toLowerCase: function(){var v = this.get('value'); this.set('value', v.toLowerCase())}.observes('value') },

+ 2 - 6
ambari-web/app/utils/hosts.js

@@ -74,9 +74,7 @@ module.exports = {
         this.hide();
       },
 
-      disablePrimary: function () {
-        return !this.get('isLoaded');
-      }.property('isLoaded'),
+      disablePrimary: Em.computed.not('isLoaded'),
 
       onSecondary: function () {
         callback(null);
@@ -124,9 +122,7 @@ module.exports = {
 
         filterComponent: null,
 
-        isDisabled: function () {
-          return !this.get('parentView.isLoaded');
-        }.property('parentView.isLoaded'),
+        isDisabled: Em.computed.not('parentView.isLoaded'),
 
         didInsertElement: function() {
           var defaultFilterColumn = this.get('filterColumns').findProperty('selected');

+ 3 - 9
ambari-web/app/utils/polling.js

@@ -39,17 +39,11 @@ App.Poll = Em.Object.extend(App.ReloadPopupMixin, {
   mockDataPrefix: '/data/wizard/deploy/5_hosts',
   currentTaskId: null,
 
-  barWidth: function () {
-    return 'width: ' + this.get('progress') + '%;';
-  }.property('progress'),
+  barWidth: Em.computed.format('width: {0}%;', 'progress'),
 
-  isCompleted: function () {
-    return (this.get('isError') || this.get('isSuccess'));
-  }.property('isError', 'isSuccess'),
+  isCompleted: Em.computed.or('isError', 'isSuccess'),
 
-  showLink: function () {
-    return (this.get('isPolling') === true && this.get('isStarted') === true);
-  }.property('isPolling', 'isStarted'),
+  showLink: Em.computed.or('isPolling', 'isStarted'),
 
   start: function () {
     if (Em.isNone(this.get('requestId'))) {

+ 2 - 6
ambari-web/app/views/common/assign_master_components_view.js

@@ -151,9 +151,7 @@ App.AddControlView = Em.View.extend({
    * DOM node class attribute
    * @type {string}
    */
-  uniqueId: function() {
-    return this.get('componentName') + '-add';
-  }.property('componentName'),
+  uniqueId: Em.computed.format('{0}-add', 'componentName'),
 
   /**
    * Current component name
@@ -184,9 +182,7 @@ App.RemoveControlView = Em.View.extend({
    * DOM node class attribute
    * @type {string}
    */
-  uniqueId: function() {
-    return this.get('componentName') + '-' + this.get('serviceComponentId') + '-remove';
-  }.property('componentName', 'serviceComponentId'),
+  uniqueId: Em.computed.format('{0}-{1}-remove', 'componentName', 'serviceComponentId'),
 
   classNameBindings: ['uniqueId'],
 

+ 1 - 3
ambari-web/app/views/common/chart/linear.js

@@ -38,9 +38,7 @@ App.ChartLinearView = Em.View.extend({
     this.appendSvg();
   },
 
-  selector:function () {
-    return '#' + this.get('elementId');
-  }.property('elementId'),
+  selector: Em.computed.format('#{0}', 'elementId'),
 
   appendSvg:function () {
     var thisChart = this;

+ 2 - 6
ambari-web/app/views/common/chart/linear_time.js

@@ -167,9 +167,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
    */
   seriesTemplate: null,
 
-  _containerSelector: function () {
-    return '#' + this.get('id') + '-container';
-  }.property('id'),
+  _containerSelector: Em.computed.format('#{0}-container', 'id'),
 
   _popupSelector: Em.computed.concat('', '_containerSelector', 'popupSuffix'),
 
@@ -915,9 +913,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
         titleId: null,
         titleClass: null,
 
-        isReady: function () {
-          return this.get('parentView.graph.isPopupReady');
-        }.property('parentView.graph.isPopupReady'),
+        isReady: Em.computed.alias('parentView.graph.isPopupReady'),
 
         didInsertElement: function () {
           var popupBody = this;

+ 1 - 3
ambari-web/app/views/common/chart/pie.js

@@ -49,9 +49,7 @@ App.ChartPieView = Em.View.extend({
     this.appendSvg();
   },
 
-  selector:function () {
-    return '#' + this.get('elementId');
-  }.property('elementId'),
+  selector: Em.computed.format('#{0}', 'elementId'),
 
   appendSvg:function () {
 

+ 1 - 3
ambari-web/app/views/common/configs/config_history_flow.js

@@ -65,9 +65,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
     return App.ServiceConfigVersion.find().filterProperty('serviceName', this.get('serviceName'));
   }.property('serviceName'),
 
-  showCompareVersionBar: function() {
-    return !Em.isNone(this.get('compareServiceVersion'));
-  }.property('compareServiceVersion'),
+  showCompareVersionBar: Em.computed.bool('compareServiceVersion'),
 
   isSaveDisabled: Em.computed.or('controller.isSubmitDisabled', '!controller.versionLoaded', '!controller.isPropertiesChanged'),
 

+ 1 - 3
ambari-web/app/views/common/configs/service_configs_by_category_view.js

@@ -514,9 +514,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
           },
           bodyClass: Em.View.extend({
             fileName: siteFileName,
-            notMisc: function () {
-              return serviceName !== 'MISC';
-            }.property(),
+            notMisc: serviceName !== 'MISC',
             templateName: require('templates/common/configs/addPropertyWindow'),
             controllerBinding: 'App.router.mainServiceInfoConfigsController',
             serviceConfigObj: serviceConfigObj,

+ 1 - 3
ambari-web/app/views/common/form/manage_credentials_form_view.js

@@ -36,9 +36,7 @@ App.ManageCredentialsFormView = Em.View.extend({
    * Status of persistent storage. Returns <code>true</code> if persistent storage is available.
    * @type {boolean}
    */
-  storePersisted: function() {
-    return App.get('isCredentialStorePersistent');
-  }.property('App.isCredentialStorePersistent'),
+  storePersisted: Em.computed.alias('App.isCredentialStorePersistent'),
 
   /**
    * Disable checkbox if persistent storage not available

+ 5 - 15
ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js

@@ -40,9 +40,7 @@ App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary) {
       templateName: require('templates/common/modal_popups/confirmation_feedback')
     }),
     query: Em.Object.create({status: "INIT"}),
-    primary: function () {
-      return bodyMessage? bodyMessage.confirmButton : Em.I18n.t('ok');
-    }.property('bodyMessage'),
+    primary: bodyMessage? bodyMessage.confirmButton : Em.I18n.t('ok'),
     onPrimary: function () {
       this.set('query.status', "INIT");
       this.set('disablePrimary', true);
@@ -51,19 +49,11 @@ App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary) {
       this.hide();
       primary(this.get('query'), this.get('runMmOperation'));
     },
-    statusMessage: function () {
-      return bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure');
-    }.property('bodyMessage'),
-    additionalWarningMsg: function () {
-      return bodyMessage? bodyMessage.additionalWarningMsg : null;
-    }.property('bodyMessage'),
-    putInMaintenance: function () {
-      return bodyMessage ? bodyMessage.putInMaintenance : null;
-    }.property('bodyMessage'),
+    statusMessage: bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure'),
+    additionalWarningMsg: bodyMessage? bodyMessage.additionalWarningMsg : null,
+    putInMaintenance: bodyMessage ? bodyMessage.putInMaintenance : null,
     runMmOperation: false,
-    turnOnMmMsg: function () {
-      return bodyMessage ? bodyMessage.turnOnMmMsg : null;
-    }.property('bodyMessage'),
+    turnOnMmMsg: bodyMessage ? bodyMessage.turnOnMmMsg : null,
     watchStatus: function() {
       if (this.get('query.status') === "SUCCESS") {
         this.hide();

+ 1 - 3
ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js

@@ -42,9 +42,7 @@ App.showInvalidKDCPopup = function (ajaxOpt, message) {
      * Status of persistent storage. Returns <code>true</code> if persistent storage is available.
      * @type {boolean}
      */
-    storePersisted: function() {
-      return App.get('isCredentialStorePersistent');
-    }.property('App.isCredentialStorePersistent'),
+    storePersisted: Em.computed.alias('App.isCredentialStorePersistent'),
 
     /**
      * Disable checkbox if persistent storage not available

+ 2 - 8
ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js

@@ -28,19 +28,13 @@ App.showManageCredentialsPopup = function () {
     primary: Em.I18n.t('common.save'),
 
     thirdClass: 'pull-left btn-danger',
-    third: function() {
-      return this.get('formView.isRemovable') ?
-        Em.I18n.t('common.remove') :
-        null;
-    }.property('formView.isRemovable'),
+    third: Em.computed.ifThenElse('formView.isRemovable', Em.I18n.t('common.remove'), null),
 
     isCredentialsRemoved: false,
 
     disablePrimary: Em.computed.alias('formView.isSubmitDisabled'),
 
-    formView: function() {
-      return this.get('childViews').findProperty('viewName', 'manageCredentialsForm');
-    }.property(),
+    formView: Em.computed.findBy('childViews', 'viewName', 'manageCredentialsForm'),
 
     onPrimary: function() {
       var self = this;

+ 1 - 3
ambari-web/app/views/common/progress_bar_view.js

@@ -43,9 +43,7 @@ App.ProgressBarView = Em.View.extend({
    * string format: width:<number>%;
    * @type {string}
    */
-  progressWidth: function () {
-    return "width:" + this.get('progress') + "%;";
-  }.property('progress'),
+  progressWidth: Em.computed.format('width:{0}%;', 'progress'),
 
   /**
    * @type {string}

+ 1 - 3
ambari-web/app/views/common/widget/gauge_widget_view.js

@@ -81,9 +81,7 @@ App.GaugeWidgetView = Em.View.extend(App.WidgetMixin, {
 
     errorThreshold: Em.computed.alias('parentView.content.properties.error_threshold'),
 
-    id: function() {
-      return 'gauge-widget-' + this.get('parentView.content.id');
-    }.property('parentView.content.id'),
+    id: Em.computed.format('gauge-widget-{0}', 'parentView.content.id'),
 
     existCenterText: true,
     centerTextColor: Em.computed.alias('contentColor'),

+ 1 - 3
ambari-web/app/views/main/admin/highAvailability/progress_view.js

@@ -88,9 +88,7 @@ App.HighAvailabilityProgressPageView = Em.View.extend(App.wizardProgressPageView
       });
     },
 
-    barWidth: function () {
-      return 'width: ' + this.get('content.progress') + '%;';
-    }.property('content.progress'),
+    barWidth: Em.computed.format('width: {0}%;', 'content.progress'),
 
     onStatus: function () {
       this.set('linkClass', Boolean(this.get('content.requestIds.length')) ? 'active-link' : 'active-text');

+ 4 - 12
ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js

@@ -57,30 +57,22 @@ App.upgradeTaskView = Em.View.extend({
   /**
    * @type {string}
    */
-  logTabId: function () {
-    return this.get('elementId') + '-log-tab'
-  }.property(''),
+  logTabId: Em.computed.format('{0}-log-tab', 'elementId'),
 
   /**
    * @type {string}
    */
-  errorTabId: function () {
-    return this.get('elementId') + '-error-tab'
-  }.property(''),
+  errorTabId:  Em.computed.format('{0}-error-tab', 'elementId'),
 
   /**
    * @type {string}
    */
-  logTabIdLink: function () {
-    return '#' + this.get('logTabId');
-  }.property(''),
+  logTabIdLink: Em.computed.format('#{0}','logTabId'),
 
   /**
    * @type {string}
    */
-  errorTabIdLInk: function () {
-    return '#' + this.get('errorTabId');
-  }.property(''),
+  errorTabIdLInk: Em.computed.format('#{0}','errorTabId'),
 
   /**
    * open error log in textarea to give ability to cope content

+ 2 - 6
ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js

@@ -100,9 +100,7 @@ App.upgradeWizardView = Em.View.extend({
    * if upgrade group is in progress it should have currently running item
    * @type {object|undefined}
    */
-  runningItem: function () {
-    return this.get('activeGroup.upgradeItems') && this.get('activeGroup.upgradeItems').findProperty('status', 'IN_PROGRESS');
-  }.property('activeGroup.upgradeItems.@each.status'),
+  runningItem: Em.computed.findBy('activeGroup.upgradeItems', 'status', 'IN_PROGRESS'),
 
   /**
    * if upgrade group is failed it should have failed item
@@ -168,9 +166,7 @@ App.upgradeWizardView = Em.View.extend({
    * if upgrade group is manual it should have manual item
    * @type {object|undefined}
    */
-  manualItem: function () {
-    return this.get('activeGroup.upgradeItems') && this.get('activeGroup.upgradeItems').findProperty('status', 'HOLDING');
-  }.property('activeGroup.upgradeItems.@each.status'),
+  manualItem: Em.computed.findBy('activeGroup.upgradeItems', 'status', 'HOLDING'),
 
   /**
    * plain manual item

+ 3 - 6
ambari-web/app/views/main/dashboard/widget.js

@@ -50,9 +50,8 @@ App.DashboardWidgetView = Em.View.extend({
    * used by re-sort
    * @type {string}
    */
-  viewID: function () {
-    return 'widget-' + this.get('id');
-  }.property('id'),
+  viewID: Em.computed.format('widget-{0}', 'id'),
+
   attributeBindings: ['viewID'],
 
   /**
@@ -118,9 +117,7 @@ App.DashboardWidgetView = Em.View.extend({
   widgetConfig: Ember.Object.extend({
     thresh1: '',
     thresh2: '',
-    hintInfo: function () {
-      return Em.I18n.t('dashboard.widgets.hintInfo.common').format(this.get('maxValue'));
-    }.property('maxValue'),
+    hintInfo: Em.computed.i18nFormat('dashboard.widgets.hintInfo.common', 'maxValue'),
     isThresh1Error: false,
     isThresh2Error: false,
     errorMessage1: "",

+ 1 - 3
ambari-web/app/views/main/dashboard/widgets.js

@@ -473,9 +473,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
    * Key-name to store data in Local Storage and Persist
    * @type {string}
    */
-  persistKey: function () {
-    return 'user-pref-' + App.router.get('loginName') + '-dashboard';
-  }.property(),
+  persistKey: Em.computed.format('user-pref-{0}-dashboard', 'App.router.loginName'),
 
   getUserPrefSuccessCallback: function (response, request, data) {
     if (response) {

+ 3 - 3
ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js

@@ -33,10 +33,10 @@ App.HBaseRegionsInTransitionView = App.TextDashboardWidgetView.extend({
 
   classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
   isGreen: Em.computed.lteProperties('data', 'thresh1'),
-  isOrange: function () {
-    return (this.get('data') <= this.get('thresh2') && this.get('data') > this.get('thresh1') );
-  }.property('data','thresh1','thresh2'),
+  isNotGreen: Em.computed.not('isGreen'),
   isRed: Em.computed.gtProperties('data', 'thresh2'),
+  isNotRed: Em.computed.not('isRed'),
+  isOrange: Em.computed.and('isNotGreen', 'isNotRed'),
   isNA: function () {
     return this.get('data') === null;
   }.property('data'),

+ 5 - 3
ambari-web/app/views/main/dashboard/widgets/hdfs_links.js

@@ -38,15 +38,17 @@ App.HDFSLinksView = App.LinkDashboardWidgetView.extend({
   },
 
   isHAEnabled: Em.computed.not('model.snameNode'),
+
   isActiveNNValid: function () {
     return this.get('model.activeNameNode') != null;
   }.property('model.activeNameNode'),
+
   isStandbyNNValid: function () {
     return this.get('model.standbyNameNode') != null;
   }.property('model.standbyNameNode'),
-  isTwoStandbyNN: function () {
-    return (this.get('model.standbyNameNode') != null && this.get('model.standbyNameNode2') != null);
-  }.property('model.standbyNameNode', 'model.standbyNameNode2'),
+
+  isTwoStandbyNN: Em.computed.and('isActiveNNValid', 'isStandbyNNValid'),
+
   twoStandbyComponent: function () {
     return App.HostComponent.find().findProperty('componentName', 'NAMENODE');
   }.property()

+ 1 - 3
ambari-web/app/views/main/dashboard/widgets/node_managers_live.js

@@ -46,9 +46,7 @@ App.NodeManagersLiveView = App.TextDashboardWidgetView.extend({
   thresh2: 70,
   maxValue: 100,
 
-  isDataAvailable: function() {
-    return !this.get('model.metricsNotAvailable') &&  App.get('router.clusterController.isComponentsStateLoaded');
-  }.property('App.router.clusterController.isComponentsStateLoaded'),
+  isDataAvailable: Em.computed.and('!model.metricsNotAvailable', 'App.router.clusterController.isComponentsStateLoaded'),
 
   nodeManagersLive: Em.computed.alias('model.nodeManagersCountActive'),
 

+ 3 - 5
ambari-web/app/views/main/dashboard/widgets/text_widget.js

@@ -26,12 +26,10 @@ App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
   classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
 
   isRed: Em.computed.lteProperties('data', 'thresh1'),
-
-  isOrange: function () {
-    return (this.get('data') <= this.get('thresh2') && this.get('data') > this.get('thresh1'));
-  }.property('data','thresh1','thresh2'),
-
+  isNotRed: Em.computed.not('isRed'),
+  isOrange: Em.computed.and('isNotGreen', 'isNotRed'),
   isGreen: Em.computed.gtProperties('data', 'thresh2'),
+  isNotGreen: Em.computed.not('isGreen'),
 
   isNA: function () {
     return this.get('data') === null;

+ 1 - 3
ambari-web/app/views/main/host/configs.js

@@ -22,9 +22,7 @@ var date = require('utils/date/date');
 App.MainHostConfigsView = Em.View.extend({
   templateName: require('templates/main/host/configs'),
 
-  content: function(){
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  content: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   isConfigAvailable: Em.computed.bool('content.hostComponents.length')
 

+ 1 - 3
ambari-web/app/views/main/host/configs_service.js

@@ -27,8 +27,6 @@ App.MainHostServiceConfigsView = Em.View.extend({
 
   isConfigsEditable: false,
 
-  content: function () {
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content')
+  content: Em.computed.alias('App.router.mainHostDetailsController.content')
 
 });

+ 1 - 3
ambari-web/app/views/main/host/configs_service_menu.js

@@ -41,9 +41,7 @@ App.MainHostServiceMenuView = Em.CollectionView.extend({
     return misc.sortByOrder(stackServices, services);
   }.property('host'),
 
-  host: function () {
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  host: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   selectedService: null,
 

+ 1 - 3
ambari-web/app/views/main/host/details.js

@@ -27,9 +27,7 @@ App.MainHostDetailsView = Em.View.extend({
    */
   isLoaded: false,
 
-  content: function(){
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  content: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   clients: Em.computed.filterBy('content.hostComponents', 'isClient', true),
 

+ 13 - 35
ambari-web/app/views/main/host/details/host_component_view.js

@@ -43,27 +43,13 @@ App.HostComponentView = Em.View.extend({
   /**
    * @type {String}
    */
-  workStatus: function () {
-    var workStatus = this.get('content.workStatus');
-    var hostComponent = this.get('hostComponent');
-    if (hostComponent) {
-      workStatus = hostComponent.get('workStatus');
-    }
-    return workStatus;
-  }.property('content.workStatus', 'hostComponent.workStatus'),
+  workStatus: Em.computed.firstNotBlank('hostComponent.workStatus', 'content.workStatus'),
 
   /**
    * Return host component text status
    * @type {String}
    */
-  componentTextStatus: function () {
-    var componentTextStatus = this.get('content.componentTextStatus');
-    var hostComponent = this.get('hostComponent');
-    if (hostComponent) {
-      componentTextStatus = hostComponent.get('componentTextStatus');
-    }
-    return componentTextStatus;
-  }.property('content.passiveState','workStatus'),
+  componentTextStatus: Em.computed.firstNotBlank('hostComponent.componentTextStatus', 'content.componentTextStatus'),
 
   /**
    * CSS-class for host component status
@@ -114,17 +100,13 @@ App.HostComponentView = Em.View.extend({
    * For Upgrade failed state
    * @type {bool}
    */
-  isUpgradeFailed: function () {
-    return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "upgrade_failed";
-  }.property("workStatus"),
+  isUpgradeFailed: Em.computed.equal('workStatus', App.HostComponentStatus.upgrade_failed),
 
   /**
    * For Install failed state
    * @type {bool}
    */
-  isInstallFailed: function () {
-    return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "install_failed";
-  }.property("workStatus"),
+  isInstallFailed: Em.computed.equal('workStatus', App.HostComponentStatus.install_failed),
 
   /**
    * For Started and Starting states
@@ -150,22 +132,20 @@ App.HostComponentView = Em.View.extend({
    */
   isInit: Em.computed.equal('workStatus', App.HostComponentStatus.init),
 
-  /**
-   * No action available while component is starting/stopping/unknown
-   * @type {String}
-   */
-  noActionAvailable: function () {
-    var workStatus = this.get('workStatus');
-    return [App.HostComponentStatus.starting, App.HostComponentStatus.stopping,
-      App.HostComponentStatus.unknown, App.HostComponentStatus.disabled].contains(workStatus) ? "hidden" : '';
-  }.property('workStatus'),
-
   /**
    * For Stopping or Starting states
    * @type {bool}
    */
   isInProgress: Em.computed.existsIn('workStatus', [App.HostComponentStatus.stopping, App.HostComponentStatus.starting]),
 
+  withoutActions: Em.computed.existsIn('workStatus', [App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.unknown, App.HostComponentStatus.disabled]),
+
+  /**
+   * No action available while component is starting/stopping/unknown
+   * @type {String}
+   */
+  noActionAvailable: Em.computed.ifThenElse('withoutActions', 'hidden', ''),
+
   /**
    * For OFF <code>passiveState</code> of host component
    * @type {bool}
@@ -229,9 +209,7 @@ App.HostComponentView = Em.View.extend({
    * Host component with some <code>workStatus</code> can't be restarted (so, disable such action in the dropdown list)
    * @type {bool}
    */
-  isRestartComponentDisabled: function() {
-    return ![App.HostComponentStatus.started].contains(this.get('workStatus'));
-  }.property('workStatus'),
+  isRestartComponentDisabled: Em.computed.notEqual('workStatus', App.HostComponentStatus.started),
 
   /**
    * Check if component configs can be refreshed

+ 1 - 3
ambari-web/app/views/main/host/metrics.js

@@ -20,7 +20,5 @@ var App = require('app');
 
 App.MainHostMetricsView = Em.View.extend({
   templateName: require('templates/main/host/metrics'),
-  content:function(){
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content')
+  content: Em.computed.alias('App.router.mainHostDetailsController.content')
 });

+ 1 - 3
ambari-web/app/views/main/host/stack_versions_view.js

@@ -27,9 +27,7 @@ App.MainHostStackVersionsView = App.TableView.extend({
   /**
    * @type {Ember.Object}
    */
-  host: function () {
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  host: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   /**
    * @type {Ember.Array}

+ 6 - 11
ambari-web/app/views/main/host/summary.js

@@ -49,9 +49,7 @@ App.MainHostSummaryView = Em.View.extend(App.TimeRangeMixin, {
   /**
    * @type {App.Host}
    */
-  content: function () {
-    return App.router.get('mainHostDetailsController.content');
-  }.property('App.router.mainHostDetailsController.content'),
+  content: Em.computed.alias('App.router.mainHostDetailsController.content'),
 
   /**
    * Host metrics panel not displayed when Metrics service (ex:Ganglia) is not in stack definition.
@@ -192,24 +190,21 @@ App.MainHostSummaryView = Em.View.extend(App.TimeRangeMixin, {
     }, this);
     return clients;
   }.property('content.hostComponents.length'),
+
+  anyClientFailedToInstall: Em.computed.someBy('clients', 'isInstallFailed', true),
+
   /**
    * Check if some clients not installed or started
    *
    * @type {bool}
    **/
-  areClientsNotInstalled: function() {
-    return this.get('clients').someProperty('isInstallFailed', true) || !!this.get('installableClientComponents.length');
-  }.property('clients.@each.workStatus', 'installableClientComponents.length'),
+  areClientsNotInstalled: Em.computed.or('anyClientFailedToInstall', 'installableClientComponents.length'),
 
   /**
    * Check if some clients have stale configs
    * @type {bool}
    */
-  areClientWithStaleConfigs: function() {
-    return !!this.get('clients').filter(function(component) {
-      return component.get('staleConfigs');
-    }).length;
-  }.property('clients.@each.staleConfigs'),
+  areClientWithStaleConfigs: Em.computed.someBy('clients', 'staleConfigs', true),
 
   /**
    * Template for addable component

+ 3 - 11
ambari-web/app/views/main/menu.js

@@ -75,23 +75,15 @@ App.MainMenuView = Em.CollectionView.extend({
       return "";
     }.property('App.router.location.lastSetURL', 'App.router.clusterController.isLoaded'),
 
-    alertsCount: function () {
-      return App.router.get('mainHostController.hostsCountMap.health-status-WITH-ALERTS');
-    }.property('App.router.mainHostController.hostsCountMap'),
+    alertsCount: Em.computed.alias('App.router.mainHostController.hostsCountMap.health-status-WITH-ALERTS'),
 
-    hasCriticalAlerts: function () {
-      return App.router.get('mainHostController.hostsCountMap.health-status-CRITICAL') > 0;
-    }.property('content.hasAlertsLabel', 'alertsCount'),
+    hasCriticalAlerts: Em.computed.gt('App.router.mainHostController.hostsCountMap.health-status-CRITICAL', 0),
 
     hasAlertsLabel: Em.computed.and('content.hasAlertsLabel', 'alertsCount'),
 
     templateName: require('templates/main/menu_item'),
 
-    dropdownMenu: function () {
-      var item = this.get('content').routing;
-      var itemsWithDropdown = ['services', 'admin', 'views'];
-      return itemsWithDropdown.contains(item);
-    }.property(''),
+    dropdownMenu: Em.computed.existsIn('content.routing', ['services', 'admin', 'views']),
     isAdminItem: Em.computed.equal('content.routing', 'admin'),
     isServicesItem: Em.computed.equal('content.routing', 'services'),
     isViewsItem: function () {

+ 2 - 6
ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js

@@ -29,13 +29,9 @@ App.FlumeAgentMetricsSectionView = Em.View.extend(App.TimeRangeMixin, {
 
   metricViewData: null,
 
-  id: function () {
-    return 'metric' + this.get('index');
-  }.property('index'),
+  id: Em.computed.format('metric{0}', 'index'),
 
-  toggleIndex: function () {
-    return '#' + this.get('id');
-  }.property('id'),
+  toggleIndex: Em.computed.format('#{0}', 'id'),
 
   header: function () {
     var metricType = Em.I18n.t('services.service.info.metrics.flume.' + this.get('metricTypeKey')).format(Em.I18n.t('common.metrics'));

+ 1 - 3
ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js

@@ -35,9 +35,7 @@ App.ChartServiceFlumeMetricGraph = App.ChartLinearTimeView.extend({
   hostName: null,
   metricItems: null,
 
-  id: function(){
-    return "service-metrics-flume-metric-graph-" + this.get('metricType') + '-' + this.get('metricName');
-  }.property('metricType', 'metricName'),
+  id: Em.computed.format('service-metrics-flume-metric-graph-{0}-{1}', 'metricType', 'metricName'),
 
   title: Em.computed.alias('metricName'),
 

+ 2 - 6
ambari-web/app/views/main/service/info/summary.js

@@ -84,9 +84,7 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, App.TimeRangeMixin
    */
   collapsedSections: null,
 
-  servicesHaveClients: function() {
-    return App.get('services.hasClient');
-  }.property('App.services.hasClient'),
+  servicesHaveClients: Em.computed.alias('App.services.hasClient'),
 
   hasManyServers: Em.computed.gt('servers.length', 1),
 
@@ -399,9 +397,7 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, App.TimeRangeMixin
    * Key-name to store time range in Persist
    * @type {string}
    */
-  persistKey: function () {
-    return 'time-range-service-' + this.get('service.serviceName');
-  }.property(),
+  persistKey: Em.computed.format('time-range-service-{0}', 'service.serviceName'),
 
   getUserPrefSuccessCallback: function (response, request, data) {
     if (response) {

+ 15 - 4
ambari-web/app/views/main/service/service.js

@@ -18,6 +18,7 @@
 
 var App = require('app');
 var uiEffects = require('utils/ui_effects');
+var numberUtils = require('utils/number_utils');
 
 App.MainDashboardServiceHealthView = Em.View.extend({
   classNameBindings: ["healthStatus", "healthStatusClass"],
@@ -141,10 +142,6 @@ App.MainDashboardServiceView = Em.View.extend(App.MainDashboardServiceViewWrappe
     }
   }),
 
-  formatUnavailable: function(value){
-    return (value || value == 0) ? value : this.t('services.service.summary.notAvailable');
-  },
-
   alertsCount: Em.computed.alias('service.alertsCount'),
 
   hasCriticalAlerts: Em.computed.alias('service.hasCriticalAlerts'),
@@ -173,3 +170,17 @@ App.MainDashboardServiceView = Em.View.extend(App.MainDashboardServiceViewWrappe
   }.property('service')
 
 });
+
+App.MainDashboardServiceView.reopenClass({
+  formattedHeap: function (i18nKey, heapUsedKey, heapMaxKey) {
+    return Em.computed(heapUsedKey, heapMaxKey, function () {
+      var memUsed = Em.get(this, heapUsedKey);
+      var memMax = Em.get(this, heapMaxKey);
+      var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
+      return Em.I18n.t(i18nKey).format(
+        numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
+        numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
+        percent.toFixed(1));
+    });
+  }
+});

+ 3 - 6
ambari-web/app/views/main/service/services/flume.js

@@ -60,12 +60,9 @@ App.MainDashboardServiceFlumeView = App.TableView.extend(App.MainDashboardServic
     return this.t("dashboard.services.flume.summary.title").format(hostCount, (hostCount > 1 ? "s" : ""), agentCount,  (agentCount > 1 ? "s" : ""));
   }.property('service.agents', 'service.hostComponents.length'),
 
-  flumeHandlerComponent: function () {
-    return Em.Object.create({
-      componentName: 'FLUME_HANDLER'
-    });
-    //return App.HostComponent.find().findProperty('componentName', 'FLUME_HANDLER');
-  }.property(),
+  flumeHandlerComponent: Em.Object.create({
+    componentName: 'FLUME_HANDLER'
+  }),
 
   agentView: Em.View.extend({
     content: null,

+ 9 - 37
ambari-web/app/views/main/service/services/hbase.js

@@ -31,25 +31,9 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
    */
   passiveMasters: Em.computed.filterBy('masters', 'haStatus', 'false'),
 
-  regionServesText: function () {
-    if (this.get('service.regionServersTotal') == 0) {
-      return '';
-    } else if (this.get('service.regionServersTotal') > 1) {
-      return Em.I18n.t('services.service.summary.viewHosts');
-    } else {
-      return Em.I18n.t('services.service.summary.viewHost');
-    }
-  }.property("service"),
+  regionServesText: Em.computed.countBasedMessage('service.regionServersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')),
 
-  phoenixServersText: function () {
-    if (this.get('service.phoenixServersTotal') == 0) {
-      return '';
-    } else if (this.get('service.phoenixServersTotal') > 1) {
-      return Em.I18n.t('services.service.summary.viewHosts');
-    } else {
-      return Em.I18n.t('services.service.summary.viewHost');
-    }
-  }.property("service"),
+  phoenixServersText: Em.computed.countBasedMessage('service.phoenixServersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')),
 
   showPhoenixInfo: Em.computed.bool('service.phoenixServersTotal'),
 
@@ -60,14 +44,7 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
 
   activeMasterTitle: Em.I18n.t('service.hbase.activeMaster'),
 
-  masterServerHeapSummary: function () {
-    var heapUsed = this.get('service').get('heapMemoryUsed');
-    var heapMax = this.get('service').get('heapMemoryMax');
-    var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
-    var heapString = numberUtils.bytesToSize(heapUsed, 1, "parseFloat");
-    var heapMaxString = numberUtils.bytesToSize(heapMax, 1, "parseFloat");
-    return this.t('dashboard.services.hbase.masterServerHeap.summary').format(heapString, heapMaxString, percent.toFixed(1));
-  }.property('service.heapMemoryUsed', 'service.heapMemoryMax'),
+  masterServerHeapSummary: App.MainDashboardServiceView.formattedHeap('dashboard.services.hbase.masterServerHeap.summary', 'service.heapMemoryUsed', 'service.heapMemoryMax'),
 
   summaryHeader: function () {
     var avgLoad = this.get('service.averageLoad');
@@ -117,16 +94,11 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
     return this.t('services.service.summary.notRunning');
   }.property("service.masterActiveTime"),
 
-  regionServerComponent: function () {
-    return Em.Object.create({
-      componentName: 'HBASE_REGIONSERVER'
-    });
-    //return this.get('service.regionServers').objectAt(0);
-  }.property(),
+  regionServerComponent: Em.Object.create({
+    componentName: 'HBASE_REGIONSERVER'
+  }),
 
-  phoenixServerComponent: function () {
-    return Em.Object.create({
-      componentName: 'PHOENIX_QUERY_SERVER'
-    });
-  }.property()
+  phoenixServerComponent: Em.Object.create({
+    componentName: 'PHOENIX_QUERY_SERVER'
+  })
 });

+ 42 - 71
ambari-web/app/views/main/service/services/hdfs.js

@@ -19,6 +19,19 @@ var App = require('app');
 var date = require('utils/date/date');
 var numberUtils = require('utils/number_utils');
 
+function diskPart(i18nKey, totalKey, usedKey) {
+  return Em.computed(totalKey, usedKey, function () {
+    var text = Em.I18n.t(i18nKey);
+    var total = this.get(totalKey);
+    var used = this.get(usedKey);
+    var percent = total > 0 ? ((used * 100) / total).toFixed(2) : 0;
+    if (percent == "NaN" || percent < 0) {
+      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
+    }
+    return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
+  });
+}
+
 App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
   templateName: require('templates/main/service/services/hdfs'),
   serviceName: 'HDFS',
@@ -81,25 +94,17 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
 
   journalNodesTotal: Em.computed.alias('service.journalNodes.length'),
 
-  dfsTotalBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsTotalBlocks'));
-  }.property('service.dfsTotalBlocks'),
-  dfsTotalFiles: function(){
-    return this.formatUnavailable(this.get('service.dfsTotalFiles'));
-  }.property('service.dfsTotalFiles'),
-  dfsCorruptBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsCorruptBlocks'));
-  }.property('service.dfsCorruptBlocks'),
-  dfsMissingBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsMissingBlocks'));
-  }.property('service.dfsMissingBlocks'),
-  dfsUnderReplicatedBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsUnderReplicatedBlocks'));
-  }.property('service.dfsUnderReplicatedBlocks'),
-
-  blockErrorsMessage: function() {
-    return Em.I18n.t('dashboard.services.hdfs.blockErrors').format(this.get('dfsCorruptBlocks'), this.get('dfsMissingBlocks'), this.get('dfsUnderReplicatedBlocks'));
-  }.property('dfsCorruptBlocks','dfsMissingBlocks','dfsUnderReplicatedBlocks'),
+  dfsTotalBlocks: Em.computed.formatUnavailable('service.dfsTotalBlocks'),
+
+  dfsTotalFiles: Em.computed.formatUnavailable('service.dfsTotalFiles'),
+
+  dfsCorruptBlocks: Em.computed.formatUnavailable('service.dfsCorruptBlocks'),
+
+  dfsMissingBlocks: Em.computed.formatUnavailable('service.dfsMissingBlocks'),
+
+  dfsUnderReplicatedBlocks: Em.computed.formatUnavailable('service.dfsUnderReplicatedBlocks'),
+
+  blockErrorsMessage: Em.computed.i18nFormat('dashboard.services.hdfs.blockErrors', 'dfsCorruptBlocks', 'dfsMissingBlocks', 'dfsUnderReplicatedBlocks'),
 
   nodeUptime: function () {
     var uptime = this.get('service').get('nameNodeStartTime');
@@ -118,62 +123,28 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
     return "http://" + (App.singleNodeInstall ? App.singleNodeAlias :  this.get('service').get('nameNode').get('publicHostName')) + ":50070";
   }.property('service.nameNode'),
 
-  nodeHeap: function () {
-    var memUsed = this.get('service').get('jvmMemoryHeapUsed');
-    var memMax = this.get('service').get('jvmMemoryHeapMax');
-    var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
-    return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
-      numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
-      numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
-      percent.toFixed(1));
-  }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
-
-  dfsUsedDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
-    var total = this.get('service.capacityTotal');
-    var dfsUsed = this.get('service.capacityUsed');
-    var percent = total > 0 ? ((dfsUsed * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(dfsUsed, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityUsed', 'service.capacityTotal'),
-  nonDfsUsedDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
+  nodeHeap: App.MainDashboardServiceView.formattedHeap('dashboard.services.hdfs.nodes.heapUsed', 'service.jvmMemoryHeapUsed', 'service,jvmMemoryHeapMax'),
+
+  dfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityUsed'),
+
+  nonDfsUsed: function () {
     var total = this.get('service.capacityTotal');
     var remaining = this.get('service.capacityRemaining');
     var dfsUsed = this.get('service.capacityUsed');
-    var nonDfsUsed = total !== null && remaining !== null && dfsUsed !== null ? total - remaining - dfsUsed : null;
-    var percent = total > 0 ? ((nonDfsUsed * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(nonDfsUsed, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityUsed', 'service.capacityRemaining', 'service.capacityTotal'),
-  remainingDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
-    var total = this.get('service.capacityTotal');
-    var remaining = this.get('service.capacityRemaining');
-    var percent = total > 0 ? ((remaining * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(remaining, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityRemaining', 'service.capacityTotal'),
-
-  dataNodeComponent: function () {
-    return Em.Object.create({
-      componentName: 'DATANODE'
-    });
-    //return this.get('service.dataNodes').objectAt(0);
-  }.property(),
+    return total !== null && remaining !== null && dfsUsed !== null ? total - remaining - dfsUsed : null;
+  }.property('service.capacityTotal', 'service.capacityRemaining', 'service.capacityUsed'),
 
-  nfsGatewayComponent: function () {
-    return Em.Object.create({
-      componentName: 'NFS_GATEWAY'
-    });
-    //return this.get('service.dataNodes').objectAt(0);
-  }.property(),
+  nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'nonDfsUsed'),
+
+  remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityRemaining'),
+
+  dataNodeComponent: Em.Object.create({
+    componentName: 'DATANODE'
+  }),
+
+  nfsGatewayComponent: Em.Object.create({
+    componentName: 'NFS_GATEWAY'
+  }),
 
   /**
    * Define if NFS_GATEWAY is present in the installed stack

+ 27 - 80
ambari-web/app/views/main/service/services/yarn.js

@@ -23,36 +23,15 @@ App.MainDashboardServiceYARNView = App.MainDashboardServiceView.extend({
   templateName: require('templates/main/service/services/yarn'),
   serviceName: 'YARN',
 
-  nodeHeap: function () {
-    var memUsed = this.get('service').get('jvmMemoryHeapUsed');
-    var memMax = this.get('service').get('jvmMemoryHeapMax');
-    var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
-    return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
-      numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
-      numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
-      percent.toFixed(1));
-  }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
-
-  summaryHeader: function () {
-    var text = this.t("dashboard.services.yarn.summary");
-    var totalCount = this.get('service.nodeManagersTotal');
-    var liveCount = this.get('service.nodeManagersStarted');
-    return text.format(liveCount, totalCount);
-  }.property('service.nodeManagersStarted', 'service.nodeManagersTotal'),
+  nodeHeap: App.MainDashboardServiceView.formattedHeap('dashboard.services.yarn.summary', 'service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
   
-  nodeManagerComponent: function () {
-    return Em.Object.create({
-      componentName: 'NODEMANAGER'
-    });
-    //return this.get('service.nodeManagerNodes').objectAt(0);
-  }.property(),
+  nodeManagerComponent: Em.Object.create({
+    componentName: 'NODEMANAGER'
+  }),
   
-  yarnClientComponent: function () {
-    return Em.Object.create({
-      componentName: 'YARN_CLIENT'
-    });
-    //return this.get('service.hostComponents').findProperty('componentName', 'YARN_CLIENT');
-  }.property(),
+  yarnClientComponent: Em.Object.create({
+    componentName: 'YARN_CLIENT'
+  }),
 
   hasManyYarnClients: Em.computed.gt('service.installedClients', 1),
 
@@ -69,58 +48,27 @@ App.MainDashboardServiceYARNView = App.MainDashboardServiceView.extend({
     return this.t('services.service.summary.notRunning');
   }.property("service.resourceManagerStartTime"),
 
-  nodeManagerText: function () {
-    if (this.get("service.nodeManagersTotal") === 0) {
-      return '';
-    } else if (this.get("service.nodeManagersTotal") > 1) {
-      return Em.I18n.t('services.service.summary.viewHosts');
-    } else {
-      return Em.I18n.t('services.service.summary.viewHost');
-    }
-  }.property("service.nodeManagersTotal"),
+  nodeManagerText: Em.computed.countBasedMessage('service.nodeManagersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')),
 
-  nodeManagersStatus: function () {
-    var nmActive = this.get('service.nodeManagersCountActive');
-    var nmLost = this.get('service.nodeManagersCountLost');
-    var nmUnhealthy = this.get('service.nodeManagersCountUnhealthy');
-    var nmRebooted = this.get('service.nodeManagersCountRebooted');
-    var nmDecom = this.get('service.nodeManagersCountDecommissioned');
-    return this.t('dashboard.services.yarn.nodeManagers.status.msg').format(
-      this.formatUnavailable(nmActive),
-      this.formatUnavailable(nmLost),
-      this.formatUnavailable(nmUnhealthy),
-      this.formatUnavailable(nmRebooted),
-      this.formatUnavailable(nmDecom)
-    );
-  }.property('service.nodeManagersCountActive', 'service.nodeManagersCountLost', 
-      'service.nodeManagersCountUnhealthy', 'service.nodeManagersCountRebooted', 'service.nodeManagersCountDecommissioned'),
+  _nmActive: Em.computed.formatUnavailable('service.nodeManagersCountActive'),
+  _nmLost: Em.computed.formatUnavailable('service.nodeManagersCountLost'),
+  _nmUnhealthy: Em.computed.formatUnavailable('service.nodeManagersCountUnhealthy'),
+  _nmRebooted: Em.computed.formatUnavailable('service.nodeManagersCountRebooted'),
+  _nmDecom: Em.computed.formatUnavailable('service.nodeManagersCountDecommissioned'),
+  nodeManagersStatus: Em.computed.i18nFormat('dashboard.services.yarn.nodeManagers.status.msg', '_nmActive', '_nmLost', '_nmUnhealthy', '_nmRebooted', '_nmDecom'),
 
-  containers: function () {
-    var allocated = this.get('service.containersAllocated');
-    var pending = this.get('service.containersPending');
-    var reserved = this.get('service.containersReserved');
-    return this.t('dashboard.services.yarn.containers.msg').format(
-      this.formatUnavailable(allocated),
-      this.formatUnavailable(pending),
-      this.formatUnavailable(reserved)
-    );
-  }.property('service.containersAllocated', 'service.containersPending', 'service.containersReserved'),
+  _allocated: Em.computed.formatUnavailable('service.containersAllocated'),
+  _pending: Em.computed.formatUnavailable('service.containersPending'),
+  _reserved: Em.computed.formatUnavailable('service.containersReserved'),
+  containers: Em.computed.i18nFormat('dashboard.services.yarn.containers.msg', '_allocated', '_pending', '_reserved'),
 
-  apps: function () {
-    var appsSubmitted = this.get('service.appsSubmitted');
-    var appsRunning = this.get('service.appsRunning');
-    var appsPending = this.get('service.appsPending');
-    var appsCompleted = this.get('service.appsCompleted');
-    var appsKilled = this.get('service.appsKilled');
-    var appsFailed = this.get('service.appsFailed');
-    return this.t('dashboard.services.yarn.apps.msg').format(
-      this.formatUnavailable(appsSubmitted),
-      this.formatUnavailable(appsRunning),
-      this.formatUnavailable(appsPending),
-      this.formatUnavailable(appsCompleted),
-      this.formatUnavailable(appsKilled),
-      this.formatUnavailable(appsFailed));
-  }.property('service.appsSubmitted', 'service.appsRunning', 'service.appsPending', 'service.appsCompleted', 'service.appsKilled', 'service.appsFailed'),
+  _appsSubmitted: Em.computed.formatUnavailable('service.appsSubmitted'),
+  _appsRunning: Em.computed.formatUnavailable('service.appsRunning'),
+  _appsPending: Em.computed.formatUnavailable('service.appsPending'),
+  _appsCompleted: Em.computed.formatUnavailable('service.appsCompleted'),
+  _appsKilled: Em.computed.formatUnavailable('service.appsKilled'),
+  _appsFailed: Em.computed.formatUnavailable('service.appsFailed'),
+  apps: Em.computed.i18nFormat('dashboard.services.yarn.apps.msg', '_appsSubmitted', '_appsRunning', '_appsPending', '_appsCompleted', '_appsKilled', '_appsFailed'),
 
   memory: function () {
     return Em.I18n.t('dashboard.services.yarn.memory.msg').format(
@@ -129,9 +77,8 @@ App.MainDashboardServiceYARNView = App.MainDashboardServiceView.extend({
         numberUtils.bytesToSize(this.get('service.availableMemory'), 1, 'parseFloat', 1024 * 1024));
   }.property('service.allocatedMemory', 'service.reservedMemory', 'service.availableMemory'),
 
-  queues: function() {
-    return Em.I18n.t('dashboard.services.yarn.queues.msg').format(this.formatUnavailable(this.get('service.queuesCount')));
-  }.property('service.queuesCount'),
+  _queuesCountFormatted: Em.computed.formatUnavailable('service.queuesCount'),
+  queues: Em.computed.i18nFormat('dashboard.services.yarn.queues.msg', '_queuesCountFormatted'),
 
   didInsertElement: function(){
     App.tooltip($("[rel='queue-tooltip']"), {html: true, placement: "right"});

+ 1 - 4
ambari-web/app/views/main/service/widgets/create/expression_view.js

@@ -202,10 +202,7 @@ App.AddNumberExpressionView = Em.TextField.extend({
 App.AddMetricExpressionView = Em.View.extend({
   templateName: require('templates/main/service/widgets/create/step2_add_metric'),
   controller: Em.computed.alias('parentView.controller'),
-  elementId: function () {
-    var expressionId = "_" + this.get('parentView').get('expression.id');
-    return 'add-metric-menu' + expressionId;
-  }.property(),
+  elementId: Em.computed.format('add-metric-menu_{0}','parentView.expression.id'),
   didInsertElement: function () {
     //prevent dropdown closing on click select
     $('html').on('click.dropdown', '.dropdown-menu li', function (e) {

+ 1 - 3
ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js

@@ -26,9 +26,7 @@ App.WizardStep3HostWarningPopupFooter = Em.View.extend({
 
   footerControllerBinding: 'App.router.wizardStep3Controller',
 
-  progressWidth: function () {
-    return 'width:' + this.get('footerController.checksUpdateProgress') + '%';
-  }.property('footerController.checksUpdateProgress'),
+  progressWidth: Em.computed.format('width:{0}%', 'footerController.checksUpdateProgress'),
 
   isUpdateInProgress: function () {
     return (this.get('footerController.checksUpdateProgress') > 0) &&

+ 1 - 3
ambari-web/app/views/wizard/step3_view.js

@@ -80,9 +80,7 @@ App.WizardStep3View = App.TableView.extend({
    */
   categoryObject: Em.Object.extend({
     hostsCount: 0,
-    label: function () {
-      return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
-    }.property('value', 'hostsCount'),
+    label: Em.computed.format('{0} ({1})', 'value', 'hostsCount'),
     isActive: false,
     itemClass: Em.computed.ifThenElse('isActive', 'active', '')
   }),

+ 13 - 19
ambari-web/app/views/wizard/step9_view.js

@@ -80,9 +80,7 @@ App.WizardStep9View = App.TableView.extend({
    */
   categoryObject: Em.Object.extend({
     hostsCount: 0,
-    label: function () {
-      return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
-    }.property('value', 'hostsCount'),
+    label: Em.computed.format('{0} ({1})', 'value', 'hostsCount'),
     isActive: false,
     itemClass: Em.computed.ifThenElse('isActive', 'active', '')
   }),
@@ -111,10 +109,7 @@ App.WizardStep9View = App.TableView.extend({
    * Css-string to overall progress-bar width-property
    * @type {string}
    */
-  barWidth: function () {
-    var controller = this.get('controller');
-    return 'width: ' + controller.get('progress') + '%;';
-  }.property('controller.progress'),
+  barWidth: Em.computed.format('width: {0}%;', 'controller.progress'),
 
   /**
    * Filter hosts info shown up on bottom of the box. Set by filter function, when 'seletedCategory' changed
@@ -287,6 +282,13 @@ App.WizardStep9View = App.TableView.extend({
 
 });
 
+function hostStatus(statuses) {
+  return Em.computed('isHostCompleted', 'obj.status', function () {
+    statuses = Em.makeArray(statuses);
+    return this.get('isHostCompleted') && statuses.contains(this.get('obj.status'));
+  });
+}
+
 App.HostStatusView = Em.View.extend({
 
   tagName: 'tr',
@@ -313,33 +315,25 @@ App.HostStatusView = Em.View.extend({
    * Css-string to progress-bar width-property
    * @type {string}
    */
-  barWidth: function () {
-    return 'width: ' + this.get('obj.progress') + '%;';
-  }.property('obj.progress'),
+  barWidth: Em.computed.format('width: {0}%;','obj.progress'),
 
   /**
    * Is current host failed
    * @type {bool}
    */
-  isFailed: function () {
-    return (this.get('isHostCompleted') && (this.get('obj.status') === 'failed' || this.get('obj.status') === 'heartbeat_lost'));
-  }.property('obj.status', 'isHostCompleted'),
+  isFailed: hostStatus(['failed', 'heartbeat_lost']),
 
   /**
    * Is current host successfully installed
    * @type {bool}
    */
-  isSuccess: function () {
-    return (this.get('isHostCompleted') && this.get('obj.status') === 'success');
-  }.property('obj.status', 'isHostCompleted'),
+  isSuccess: hostStatus('success'),
 
   /**
    * Current host has warnings
    * @type {bool}
    */
-  isWarning: function () {
-    return(this.get('isHostCompleted') && this.get('obj.status') === 'warning');
-  }.property('obj.status', 'isHostCompleted'),
+  isWarning: hostStatus('warning'),
 
   /**
    * Current host completed all its tasks

+ 5 - 5
ambari-web/test/controllers/application_test.js

@@ -56,8 +56,6 @@ describe('App.ApplicationController', function () {
     });
   });
 
-
-
   describe('#startKeepAlivePoller', function() {
     it ('Should change run poller state', function() {
       applicationController.set('isPollerRunning', false);
@@ -120,13 +118,15 @@ describe('App.ApplicationController', function () {
 
   describe('#isClusterDataLoaded', function() {
     beforeEach(function () {
-      sinon.stub(App.router, 'get').returns('cl1');
+      var stub = sinon.stub(App, 'get');
+      stub.withArgs('router.clusterController.isLoaded').returns(true);
+      stub.withArgs('router.loggedIn').returns(true);
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it ('Should return true, when data loaded', function() {
-      expect(applicationController.get('isClusterDataLoaded')).to.be.equal('cl1');
+      expect(applicationController.get('isClusterDataLoaded')).to.be.true;
     });
   });
 

+ 2 - 6
ambari-web/test/controllers/main/service_test.js

@@ -106,15 +106,11 @@ describe('App.MainServiceController', function () {
   describe('#isStartStopAllClicked', function () {
 
     beforeEach(function () {
-      sinon.stub(App.router, 'get', function () {
-        return Em.Object.create({
-          allOperationsCount: 1
-        });
-      });
+      sinon.stub(App, 'get').withArgs('router.backgroundOperationsController.allOperationsCount').returns(1);
     });
 
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
 
     it('should be based on BG ops count', function () {

+ 2 - 2
ambari-web/test/controllers/main_test.js

@@ -70,10 +70,10 @@ describe('App.MainController', function () {
 
   describe('#clusterDataLoadedPercent', function() {
     beforeEach(function () {
-      sinon.stub(App.router, 'get').returns(16);
+      sinon.stub(App, 'get').withArgs('router.clusterController.clusterDataLoadedPercent').returns(16);
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it ('Should return 16', function() {
       expect(mainController.get('clusterDataLoadedPercent')).to.be.equal(16);

+ 3 - 108
ambari-web/test/models/user_test.js

@@ -26,11 +26,7 @@ var user,
   userNameField,
   userData = {
     id: 'user'
-  },
-  objectData = Em.Object.create({
-    userName: 'name',
-    isLdap: true
-  });
+  };
 
 describe('App.User', function () {
 
@@ -61,104 +57,6 @@ describe('App.User', function () {
   });
 });
 
-describe('App.EditUserForm', function () {
-
-  beforeEach(function () {
-    form = App.EditUserForm.create();
-  });
-
-  describe('#object', function () {
-
-    before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return userData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.router.get.restore();
-    });
-
-    it('should take data from controller', function () {
-      expect(form.get('object')).to.eql(userData);
-    });
-
-  });
-
-  describe('#disableUsername', function () {
-    it('should update userName field', function () {
-      form.set('object', userData);
-      expect(form.get('field.userName.disabled')).to.equal('disabled');
-    });
-  });
-
-  describe('#disableAdminCheckbox', function () {
-
-    before(function () {
-      sinon.stub(App, 'get', function(k) {
-        switch (k) {
-          case 'router':
-            return {
-              getLoginName: Em.K
-            };
-          default:
-            return Em.get(App, k);
-        }
-      });
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return objectData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.get.restore();
-      App.router.get.restore();
-    });
-
-    it('should not disable', function () {
-      expect(form.get('field.admin.disabled')).to.be.false;
-    });
-
-    it('should disable', function () {
-      form.set('object', objectData);
-      expect(form.get('field.admin.disabled')).to.be.false;
-    });
-  });
-
-  describe('#isValid', function () {
-    it('should be true as default', function () {
-      expect(form.isValid()).to.be.true;
-    });
-    it('should be false', function () {
-      form.set('field.new_password.isRequired', true);
-      expect(form.isValid()).to.be.false;
-    });
-  });
-
-  describe('#save', function () {
-
-    before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return objectData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.router.get.restore();
-    });
-
-    it('should record form values to object', function () {
-      form.set('field.userName.value', 'name');
-      form.save();
-      expect(form.get('object.userName')).to.equal('name');
-    });
-  });
-
-});
-
 describe('App.CreateUserForm', function () {
 
   beforeEach(function () {
@@ -168,14 +66,11 @@ describe('App.CreateUserForm', function () {
   describe('#object', function () {
 
     before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserCreateController.content') return userData;
-        return Em.get(App, k);
-      });
+      sinon.stub(App, 'get').withArgs('router.mainAdminUserCreateController.content').returns(userData);
     });
 
     after(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
 
     it('should take data from controller', function () {

+ 4 - 7
ambari-web/test/views/main/dashboard/widgets_test.js

@@ -129,13 +129,10 @@ describe('App.MainDashboardWidgetsView', function () {
 
   describe('#persistKey', function () {
     beforeEach(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if ('loginName' === k) return 'tdk';
-        return Em.get(App.router, k);
-      });
+      sinon.stub(App, 'get').withArgs('router.loginName').returns('tdk');
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it('Check it', function () {
       expect(view.get('persistKey')).to.equal('user-pref-tdk-dashboard');
@@ -402,10 +399,10 @@ describe('App.MainDashboardWidgetsView', function () {
 
   describe("#persistKey", function () {
     before(function () {
-      sinon.stub(App.router, 'get').withArgs('loginName').returns('user');
+      sinon.stub(App, 'get').withArgs('router.loginName').returns('user');
     });
     after(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it("", function () {
       view.propertyDidChange('persistKey');