AMBARI-14176. Apply App.* supported macros (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/35b28f01 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/35b28f01 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/35b28f01 Branch: refs/heads/trunk Commit: 35b28f01e923ed521e4c633d58afd37651b6f99a Parents: 4d13432 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Thu Dec 3 12:42:40 2015 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Thu Dec 3 12:43:55 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/application.js | 8 +- .../controllers/global/cluster_controller.js | 4 +- .../app/controllers/global/update_controller.js | 8 +- ambari-web/app/controllers/main.js | 8 +- .../main/admin/kerberos/step2_controller.js | 4 +- .../main/alerts/alert_instances_controller.js | 4 +- .../alerts/definition_details_controller.js | 8 +- .../manage_alert_notifications_controller.js | 9 +- .../main/host/host_alerts_controller.js | 4 +- ambari-web/app/controllers/main/service.js | 8 +- .../controllers/main/service/info/configs.js | 4 +- .../controllers/main/service/info/summary.js | 11 +- .../app/controllers/wizard/step8_controller.js | 4 +- .../mixins/common/configs/enhanced_configs.js | 4 +- .../common/kdc_credentials_controller_mixin.js | 4 +- .../main/service/configs/config_overridable.js | 8 +- .../mixins/wizard/assign_master_components.js | 4 +- .../app/mixins/wizard/wizardProgressPageView.js | 4 +- ambari-web/app/models/alerts/alert_config.js | 8 +- .../app/models/alerts/alert_definition.js | 10 +- ambari-web/app/models/alerts/alert_group.js | 4 +- ambari-web/app/models/configs/config_group.js | 4 +- .../configs/objects/service_config_property.js | 4 +- ambari-web/app/models/configs/theme/tab.js | 4 +- ambari-web/app/models/host.js | 4 +- .../models/stack_version/repository_version.js | 4 +- ambari-web/app/models/user.js | 72 +----------- ambari-web/app/utils/hosts.js | 8 +- ambari-web/app/utils/polling.js | 12 +- .../common/assign_master_components_view.js | 8 +- ambari-web/app/views/common/chart/linear.js | 4 +- .../app/views/common/chart/linear_time.js | 8 +- ambari-web/app/views/common/chart/pie.js | 4 +- .../views/common/configs/config_history_flow.js | 4 +- .../configs/service_configs_by_category_view.js | 4 +- .../common/form/manage_credentials_form_view.js | 4 +- .../modal_popups/confirmation_feedback_popup.js | 20 +--- .../common/modal_popups/invalid_KDC_popup.js | 4 +- .../manage_kdc_credentials_popup.js | 10 +- .../app/views/common/progress_bar_view.js | 4 +- .../views/common/widget/gauge_widget_view.js | 4 +- .../admin/highAvailability/progress_view.js | 4 +- .../admin/stack_upgrade/upgrade_task_view.js | 16 +-- .../admin/stack_upgrade/upgrade_wizard_view.js | 8 +- ambari-web/app/views/main/dashboard/widget.js | 9 +- ambari-web/app/views/main/dashboard/widgets.js | 4 +- .../widgets/hbase_regions_in_transition.js | 6 +- .../views/main/dashboard/widgets/hdfs_links.js | 8 +- .../dashboard/widgets/node_managers_live.js | 4 +- .../views/main/dashboard/widgets/text_widget.js | 8 +- ambari-web/app/views/main/host/configs.js | 4 +- .../app/views/main/host/configs_service.js | 4 +- .../app/views/main/host/configs_service_menu.js | 4 +- ambari-web/app/views/main/host/details.js | 4 +- .../main/host/details/host_component_view.js | 48 +++----- ambari-web/app/views/main/host/metrics.js | 4 +- .../app/views/main/host/stack_versions_view.js | 4 +- ambari-web/app/views/main/host/summary.js | 17 +-- ambari-web/app/views/main/menu.js | 14 +-- .../flume/flume_agent_metrics_section.js | 8 +- .../info/metrics/flume/flume_metric_graph.js | 4 +- .../app/views/main/service/info/summary.js | 8 +- ambari-web/app/views/main/service/service.js | 19 +++- .../app/views/main/service/services/flume.js | 9 +- .../app/views/main/service/services/hbase.js | 46 ++------ .../app/views/main/service/services/hdfs.js | 113 +++++++------------ .../app/views/main/service/services/yarn.js | 107 +++++------------- .../service/widgets/create/expression_view.js | 5 +- .../wizard/step3/hostWarningPopupFooter_view.js | 4 +- ambari-web/app/views/wizard/step3_view.js | 4 +- ambari-web/app/views/wizard/step9_view.js | 32 +++--- ambari-web/test/controllers/application_test.js | 10 +- .../test/controllers/main/service_test.js | 8 +- ambari-web/test/controllers/main_test.js | 4 +- ambari-web/test/models/user_test.js | 111 +----------------- .../test/views/main/dashboard/widgets_test.js | 11 +- 76 files changed, 256 insertions(+), 737 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/application.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/application.js b/ambari-web/app/controllers/application.js index 0f30a62..12d33eb 100644 --- a/ambari-web/app/controllers/application.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/global/cluster_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js index 7488bd7..2201730 100644 --- a/ambari-web/app/controllers/global/cluster_controller.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/global/update_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js index 899c0ab..21e4e94 100644 --- a/ambari-web/app/controllers/global/update_controller.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main.js b/ambari-web/app/controllers/main.js index 41944ae..530fd99 100644 --- a/ambari-web/app/controllers/main.js +++ b/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 */ http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js index 78922a8..9963523 100644 --- a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js +++ b/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: [], http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/alerts/alert_instances_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js index 48c9034..5913070 100644 --- a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/alerts/definition_details_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/definition_details_controller.js b/ambari-web/app/controllers/main/alerts/definition_details_controller.js index 415b9ec..4730bf4 100644 --- a/ambari-web/app/controllers/main/alerts/definition_details_controller.js +++ b/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); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js index b61b14a..38e4e75 100644 --- a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js +++ b/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'], http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/host/host_alerts_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/host_alerts_controller.js b/ambari-web/app/controllers/main/host/host_alerts_controller.js index a864b28..841961c 100644 --- a/ambari-web/app/controllers/main/host/host_alerts_controller.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js index 12b1c0f..93bf8a1 100644 --- a/ambari-web/app/controllers/main/service.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 8b97b0d..5079ac5 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/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) http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/main/service/info/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/summary.js b/ambari-web/app/controllers/main/service/info/summary.js index 1df9384..0e6cc88 100644 --- a/ambari-web/app/controllers/main/service/info/summary.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/controllers/wizard/step8_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js index bbe40bd..62ba32a 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/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') http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/mixins/common/configs/enhanced_configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js index 7b16b55..ba51233 100644 --- a/ambari-web/app/mixins/common/configs/enhanced_configs.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js b/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js index a634ef9..367b873 100644 --- a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/mixins/main/service/configs/config_overridable.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js index 25d3c62..f0a7f56 100644 --- a/ambari-web/app/mixins/main/service/configs/config_overridable.js +++ b/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); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/mixins/wizard/assign_master_components.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js index c22a2db..5545e92 100644 --- a/ambari-web/app/mixins/wizard/assign_master_components.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/mixins/wizard/wizardProgressPageView.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/wizardProgressPageView.js b/ambari-web/app/mixins/wizard/wizardProgressPageView.js index e3a321c..8197086 100644 --- a/ambari-web/app/mixins/wizard/wizardProgressPageView.js +++ b/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'; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/alerts/alert_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/alerts/alert_config.js b/ambari-web/app/models/alerts/alert_config.js index 3b38abb..0143a38 100644 --- a/ambari-web/app/models/alerts/alert_config.js +++ b/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') }) }; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/alerts/alert_definition.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/alerts/alert_definition.js b/ambari-web/app/models/alerts/alert_definition.js index 9033169..4e81f7a 100644 --- a/ambari-web/app/models/alerts/alert_definition.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/alerts/alert_group.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/alerts/alert_group.js b/ambari-web/app/models/alerts/alert_group.js index d8d297b..489e617 100644 --- a/ambari-web/app/models/alerts/alert_group.js +++ b/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') http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/configs/config_group.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/config_group.js b/ambari-web/app/models/configs/config_group.js index 840d54f..1bbcd3f 100644 --- a/ambari-web/app/models/configs/config_group.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/configs/objects/service_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js index fc723c7..ac6597c 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/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: '', http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/configs/theme/tab.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/tab.js b/ambari-web/app/models/configs/theme/tab.js index cf98e86..3b3c6d2 100644 --- a/ambari-web/app/models/configs/theme/tab.js +++ b/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. http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/host.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js index 487806a..4c6e9fb 100644 --- a/ambari-web/app/models/host.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/stack_version/repository_version.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/stack_version/repository_version.js b/ambari-web/app/models/stack_version/repository_version.js index 566c4f2..ada7f24 100644 --- a/ambari-web/app/models/stack_version/repository_version.js +++ b/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} http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/models/user.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/user.js b/ambari-web/app/models/user.js index 776de50..2cdbdbc 100644 --- a/ambari-web/app/models/user.js +++ b/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') }, http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/utils/hosts.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/hosts.js b/ambari-web/app/utils/hosts.js index 90b746c..2467e1a 100644 --- a/ambari-web/app/utils/hosts.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/utils/polling.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js index 6db61ad..b83ca23 100644 --- a/ambari-web/app/utils/polling.js +++ b/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'))) { http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/assign_master_components_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/assign_master_components_view.js b/ambari-web/app/views/common/assign_master_components_view.js index 7e97128..e37d864 100644 --- a/ambari-web/app/views/common/assign_master_components_view.js +++ b/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'], http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/chart/linear.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/chart/linear.js b/ambari-web/app/views/common/chart/linear.js index d85cce3..27b5cc5 100644 --- a/ambari-web/app/views/common/chart/linear.js +++ b/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; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/chart/linear_time.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js index 4b12bdd..74a3f92 100644 --- a/ambari-web/app/views/common/chart/linear_time.js +++ b/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; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/chart/pie.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/chart/pie.js b/ambari-web/app/views/common/chart/pie.js index f52e4c9..0280f87 100644 --- a/ambari-web/app/views/common/chart/pie.js +++ b/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 () { http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/configs/config_history_flow.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js index bbc7438..3355431 100644 --- a/ambari-web/app/views/common/configs/config_history_flow.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/configs/service_configs_by_category_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js index 5ca94af..fdd0bfc 100644 --- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js +++ b/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, http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/form/manage_credentials_form_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/form/manage_credentials_form_view.js b/ambari-web/app/views/common/form/manage_credentials_form_view.js index 237b94d..7e46431 100644 --- a/ambari-web/app/views/common/form/manage_credentials_form_view.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js b/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js index f445222..e554930 100644 --- a/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js +++ b/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(); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js b/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js index 2d1a34a..675e01e 100644 --- a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js b/ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js index 2839a7d..67c09d0 100644 --- a/ambari-web/app/views/common/modal_popups/manage_kdc_credentials_popup.js +++ b/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; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/progress_bar_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/progress_bar_view.js b/ambari-web/app/views/common/progress_bar_view.js index 403435a..9f15f3d 100644 --- a/ambari-web/app/views/common/progress_bar_view.js +++ b/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} http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/common/widget/gauge_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/widget/gauge_widget_view.js b/ambari-web/app/views/common/widget/gauge_widget_view.js index 4a9ab25..a0bdaea 100644 --- a/ambari-web/app/views/common/widget/gauge_widget_view.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/admin/highAvailability/progress_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/progress_view.js b/ambari-web/app/views/main/admin/highAvailability/progress_view.js index 9d8b7cb..abe6685 100644 --- a/ambari-web/app/views/main/admin/highAvailability/progress_view.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js index 2e4e45c..05f7e6f 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js index c9627d0..2f2b4dd 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widget.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widget.js b/ambari-web/app/views/main/dashboard/widget.js index 4ab8ec5..9c62675 100644 --- a/ambari-web/app/views/main/dashboard/widget.js +++ b/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: "", http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widgets.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js index e8e0565..7996cc9 100644 --- a/ambari-web/app/views/main/dashboard/widgets.js +++ b/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) { http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js b/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js index ec91ab6..3c22a5c 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js b/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js index 2c5b4eb..e339e6b 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js +++ b/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() http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widgets/node_managers_live.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/node_managers_live.js b/ambari-web/app/views/main/dashboard/widgets/node_managers_live.js index 0817f27..e555c1d 100644 --- a/ambari-web/app/views/main/dashboard/widgets/node_managers_live.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/dashboard/widgets/text_widget.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/text_widget.js b/ambari-web/app/views/main/dashboard/widgets/text_widget.js index dc5f484..4389cb3 100644 --- a/ambari-web/app/views/main/dashboard/widgets/text_widget.js +++ b/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; http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/configs.js b/ambari-web/app/views/main/host/configs.js index c9779a9..a87626f 100644 --- a/ambari-web/app/views/main/host/configs.js +++ b/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') http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/configs_service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/configs_service.js b/ambari-web/app/views/main/host/configs_service.js index 3026f25..eb3fc56 100644 --- a/ambari-web/app/views/main/host/configs_service.js +++ b/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') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/configs_service_menu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/configs_service_menu.js b/ambari-web/app/views/main/host/configs_service_menu.js index 3e2ca3c..01fa7d0 100644 --- a/ambari-web/app/views/main/host/configs_service_menu.js +++ b/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, http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/details.js b/ambari-web/app/views/main/host/details.js index 53e4f94..143f091 100644 --- a/ambari-web/app/views/main/host/details.js +++ b/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), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/details/host_component_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js index 8c03888..7247134 100644 --- a/ambari-web/app/views/main/host/details/host_component_view.js +++ b/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 @@ -151,21 +133,19 @@ 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/metrics.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/metrics.js b/ambari-web/app/views/main/host/metrics.js index 3fb0a14..4596d92 100644 --- a/ambari-web/app/views/main/host/metrics.js +++ b/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') }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/host/stack_versions_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/stack_versions_view.js b/ambari-web/app/views/main/host/stack_versions_view.js index 84fd35c..83a724c 100644 --- a/ambari-web/app/views/main/host/stack_versions_view.js +++ b/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} http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/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 93d7a1c..1969a1d 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/menu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/menu.js b/ambari-web/app/views/main/menu.js index 36f5c11..5585eaf 100644 --- a/ambari-web/app/views/main/menu.js +++ b/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 () { http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js index 43e4422..a652b5f 100644 --- a/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js +++ b/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')); http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js index 0d9b382..bb028f5 100644 --- a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js +++ b/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'), http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/info/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js index 4cda6a2..6431c91 100644 --- a/ambari-web/app/views/main/service/info/summary.js +++ b/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) { http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/service.js b/ambari-web/app/views/main/service/service.js index 520fd75..28e7272 100644 --- a/ambari-web/app/views/main/service/service.js +++ b/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)); + }); + } +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/services/flume.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/flume.js b/ambari-web/app/views/main/service/services/flume.js index 9a150bd..3f8c4cc 100644 --- a/ambari-web/app/views/main/service/services/flume.js +++ b/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, http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/services/hbase.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/hbase.js b/ambari-web/app/views/main/service/services/hbase.js index 72a29d2..ec48650 100644 --- a/ambari-web/app/views/main/service/services/hbase.js +++ b/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' + }) });