Repository: ambari Updated Branches: refs/heads/trunk 54fa239e2 -> 44e595588
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 83180ce..5ca94af 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 @@ -80,9 +80,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri * Without this property, all serviceConfigs Objects will show up even if some was collapsed before. * @type {boolean} */ - isCategoryBodyVisible: function () { - return this.get('category.isCollapsed') ? "display: none;" : "display: block;" - }.property('serviceConfigs.length'), + isCategoryBodyVisible: Em.computed.ifThenElse('category.isCollapsed', 'display: none;', 'display: block;'), /** * Should we show config group or not http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/configs/widgets/config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js index ec492af..9858b75 100644 --- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js @@ -102,9 +102,7 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo /** * @type {boolean} */ - showPencil: function () { - return this.get('supportSwitchToTextBox') && !this.get('disabled'); - }.property('supportSwitchToTextBox', 'disabled'), + showPencil: Em.computed.and('supportSwitchToTextBox', '!disabled'), /** * Alias to <code>config.isOriginalSCP</code> @@ -232,9 +230,7 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo * Config name to display. * @type {String} */ - configLabel: function() { - return this.get('config.stackConfigProperty.displayName') || this.get('config.displayName') || this.get('config.name'); - }.property('config.name', 'config.displayName'), + configLabel: Em.computed.firstNotBlank('config.stackConfigProperty.displayName', 'config.displayName', 'config.name'), /** http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/configs/widgets/plain_config_text_field.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/plain_config_text_field.js b/ambari-web/app/views/common/configs/widgets/plain_config_text_field.js index a6388e8..25b9994 100644 --- a/ambari-web/app/views/common/configs/widgets/plain_config_text_field.js +++ b/ambari-web/app/views/common/configs/widgets/plain_config_text_field.js @@ -32,9 +32,7 @@ App.PlainConfigTextField = Ember.View.extend(App.SupportsDependentConfigs, App.W disabled: Em.computed.not('config.isEditable'), - configLabel: function() { - return this.get('config.stackConfigProperty.displayName') || this.get('config.displayName') || this.get('config.name'); - }.property('config.name', 'config.displayName'), + configLabel: Em.computed.firstNotBlank('config.stackConfigProperty.displayName', 'config.displayName', 'config.name'), /** * @type {string|boolean} http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js b/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js index b5073cf..87d0359 100644 --- a/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js @@ -62,10 +62,10 @@ App.TestDbConnectionWidgetView = App.ConfigWidgetView.extend({ /** @property {String} user_passwd: password for the user name to be used for performing db connection**/ user_passwd: null, + + someRequiredPropertyIsInvalid: Em.computed.someBy('requiredProperties', 'isValid', false), /** @property {boolean} isBtnDisabled - disable button on failed validation or active request **/ - isBtnDisabled: function () { - return !this.get('requiredProperties').everyProperty('isValid') || this.get('isConnecting'); - }.property('requiredProperties.@each.isValid', 'isConnecting'), + isBtnDisabled: Em.computed.or('someRequiredPropertyIsInvalid', 'isConnecting'), /** @property {object} requiredProperties - properties that necessary for database connection **/ requiredProperties: [], http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js index 9362dfe..cef2eb2 100644 --- a/ambari-web/app/views/common/controls_view.js +++ b/ambari-web/app/views/common/controls_view.js @@ -66,9 +66,7 @@ App.ServiceConfigPopoverSupport = Ember.Mixin.create({ this.$().popover('destroy'); }, - readOnly: function () { - return !this.get('serviceConfig.isEditable'); - }.property('serviceConfig.isEditable') + readOnly: Em.computed.not('serviceConfig.isEditable') }); App.SupportsDependentConfigs = Ember.Mixin.create({ @@ -251,14 +249,10 @@ App.ServiceConfigPasswordField = Ember.TextField.extend(App.ServiceConfigPopover } }, valueBinding: 'parentView.serviceConfig.retypedPassword', - readOnly: function () { - return !this.get('parentView.serviceConfig.isEditable'); - }.property('parentView.serviceConfig.isEditable') + readOnly: Em.computed.not('parentView.serviceConfig.isEditable') }), - readOnly: function () { - return !this.get('serviceConfig.isEditable'); - }.property('serviceConfig.isEditable') + readOnly: Em.computed.not('serviceConfig.isEditable') }); @@ -384,9 +378,7 @@ App.ServiceConfigCheckbox = Ember.Checkbox.extend(App.ServiceConfigPopoverSuppor } }, - disabled: function () { - return !this.get('serviceConfig.isEditable'); - }.property('serviceConfig.isEditable'), + disabled: Em.computed.not('serviceConfig.isEditable'), //Set editDone false for all current category config text field parameter focusIn: function (event) { @@ -484,9 +476,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId, * in this case some properties can have different behaviour * @type {boolean} */ - inMSSQLWithIA: function() { - return this.get('serviceConfig.value') === 'Existing MSSQL Server database with integrated authentication'; - }.property('serviceConfig.value'), + inMSSQLWithIA: Em.computed.equal('serviceConfig.value', 'Existing MSSQL Server database with integrated authentication'), /** * Radio button has very uncomfortable values for managing it's state @@ -894,13 +884,9 @@ App.ServiceConfigMultipleHostsDisplay = Ember.Mixin.create(App.ServiceConfigHost } }.property('value'), - hasOneHost: function () { - return !Em.isArray(this.get('value')) || this.get('value').length === 1; - }.property('value'), + hasOneHost: Em.computed.equal('value.length', 1), - hasMultipleHosts: function () { - return Em.isArray(this.get('value')) && this.get('value').length > 1; - }.property('value'), + hasMultipleHosts: Em.computed.gt('value.length', 1), otherLength: function () { var len = this.get('value').length; @@ -1023,9 +1009,7 @@ App.CheckDBConnectionView = Ember.View.extend({ return '{0}_existing_{1}_host'.format(this.get('parentView.service.serviceName').toLowerCase(), this.get('databaseName').toLowerCase()); }.property('databaseName'), /** @property {boolean} isBtnDisabled - disable button on failed validation or active request **/ - isBtnDisabled: function() { - return !this.get('isValidationPassed') || this.get('isConnecting'); - }.property('isValidationPassed', 'isConnecting'), + isBtnDisabled: Em.computed.or('!isValidationPassed', 'isConnecting'), /** @property {object} requiredProperties - properties that necessary for database connection **/ requiredProperties: function() { var propertiesMap = { http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/form/spinner_input_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/form/spinner_input_view.js b/ambari-web/app/views/common/form/spinner_input_view.js index d7620a0..f8997ee 100644 --- a/ambari-web/app/views/common/form/spinner_input_view.js +++ b/ambari-web/app/views/common/form/spinner_input_view.js @@ -94,9 +94,7 @@ App.SpinnerInputView = Em.View.extend({ * Input should be disabled, if whole widget is disabled or if its unit is less than step_increment value * @type {boolean} */ - computedDisabled: function () { - return !this.get('content.enabled') || this.get('disabled'); - }.property('disabled', 'content.enabled'), + computedDisabled: Em.computed.or('!content.enabled', 'disabled'), incrementValue: function () { this.setValue(true); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/rolling_restart_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/rolling_restart_view.js b/ambari-web/app/views/common/rolling_restart_view.js index 16477ea..5410e0b 100644 --- a/ambari-web/app/views/common/rolling_restart_view.js +++ b/ambari-web/app/views/common/rolling_restart_view.js @@ -160,9 +160,7 @@ App.RollingRestartView = Em.View.extend({ * Formatted <code>hostComponentName</code> * @type {String} */ - hostComponentDisplayName : function() { - return App.format.role(this.get('hostComponentName')); - }.property('hostComponentName'), + hostComponentDisplayName: Em.computed.formatRole('hostComponentName'), /** * List of all host components @@ -209,9 +207,7 @@ App.RollingRestartView = Em.View.extend({ /** * @type {String} */ - restartMessage : function() { - return Em.I18n.t('rollingrestart.dialog.msg.restart').format(this.get('hostComponentDisplayName')) - }.property('hostComponentDisplayName'), + restartMessage: Em.computed.i18nFormat('rollingrestart.dialog.msg.restart', 'hostComponentDisplayName'), /** * @type {String} @@ -231,14 +227,11 @@ App.RollingRestartView = Em.View.extend({ /** * @type {String} */ - batchSizeMessage : function() { - return Em.I18n.t('rollingrestart.dialog.msg.componentsAtATime').format(this.get('hostComponentDisplayName')); - }.property('hostComponentDisplayName'), + batchSizeMessage: Em.computed.i18nFormat('rollingrestart.dialog.msg.componentsAtATime', 'hostComponentDisplayName'), /** * @type {String} */ - staleConfigsOnlyMessage : function() { - return Em.I18n.t('rollingrestart.dialog.msg.staleConfigsOnly').format(this.get('hostComponentDisplayName')); - }.property('hostComponentDisplayName') + staleConfigsOnlyMessage: Em.computed.i18nFormat('rollingrestart.dialog.msg.staleConfigsOnly', 'hostComponentDisplayName') + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/table_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js index cf0d761..823cb40 100644 --- a/ambari-web/app/views/common/table_view.js +++ b/ambari-web/app/views/common/table_view.js @@ -172,9 +172,7 @@ App.TableView = Em.View.extend(App.UserPref, { * Return pagination information displayed on the page * @type {String} */ - paginationInfo: function () { - return this.t('tableView.filters.paginationInfo').format(this.get('startIndex'), this.get('endIndex'), this.get('filteredCount')); - }.property('filteredCount', 'endIndex'), + paginationInfo: Em.computed.i18nFormat('tableView.filters.paginationInfo', 'startIndex', 'endIndex', 'filteredCount'), paginationLeft: Ember.View.extend({ tagName: 'a', http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/time_range.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/time_range.js b/ambari-web/app/views/common/time_range.js index 20777f6..0a18bd4 100644 --- a/ambari-web/app/views/common/time_range.js +++ b/ambari-web/app/views/common/time_range.js @@ -59,12 +59,8 @@ App.TimeRangeWidget = Em.View.extend({ presetView:Em.View.extend({ tagName:'li', classNameBindings:['disabled'], - disabled:function () { - return this.get('isActive') ? "disabled" : false; - }.property('isActive'), - isActive:function () { - return this.get('preset.value') == this.get('widget.chosenPreset.value'); - }.property('widget.chosenPreset'), + disabled: Em.computed.ifThenElse('isActive', 'disabled', false), + isActive: Em.computed.equalProperties('preset.value', 'widget.chosenPreset.value'), template:Em.Handlebars.compile('<a {{action activate view.preset target="view.widget" href="true" }}>{{unbound view.preset.label}}</a>') }), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/admin/highAvailability/nameNode/step1_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/nameNode/step1_view.js b/ambari-web/app/views/main/admin/highAvailability/nameNode/step1_view.js index b16dca7..000fb7c 100644 --- a/ambari-web/app/views/main/admin/highAvailability/nameNode/step1_view.js +++ b/ambari-web/app/views/main/admin/highAvailability/nameNode/step1_view.js @@ -27,8 +27,6 @@ App.HighAvailabilityWizardStep1View = Em.View.extend({ App.popover($("div.controls input[type=text]"), {'placement': 'right', 'trigger': 'hover', 'title': this.t('admin.highAvailability.wizard.step1.nameserviceid.tooltip.title'), 'content': this.t('admin.highAvailability.wizard.step1.nameserviceid.tooltip.content')}); }, - showInputError: function () { - return !this.get('controller.isNameServiceIdValid') && this.get('controller.content.nameServiceId').length != 0 ; - }.property('controller.isNameServiceIdValid', 'controller.content.nameServiceId') + showInputError: Em.computed.and('!controller.isNameServiceIdValid', 'controller.content.nameServiceId.length') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/admin/stack_upgrade/failed_hosts_modal_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/failed_hosts_modal_view.js b/ambari-web/app/views/main/admin/stack_upgrade/failed_hosts_modal_view.js index 2dbcb75..d577e11 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/failed_hosts_modal_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/failed_hosts_modal_view.js @@ -32,9 +32,7 @@ App.FailedHostsPopupBodyView = Em.View.extend({ /** * @type {string} */ - subHeader: function () { - return Em.I18n.t('admin.stackUpgrade.failedHosts.subHeader').format(this.get('parentView.content.hosts.length')); - }.property('parentView.content.hosts.length'), + subHeader: Em.computed.i18nFormat('admin.stackUpgrade.failedHosts.subHeader', 'parentView.content.hosts.length'), didInsertElement: function () { App.tooltip(this.$("[rel='UsageTooltip']")); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 22ab044..c9627d0 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 @@ -68,9 +68,7 @@ App.upgradeWizardView = Em.View.extend({ * when downgrade already started * @type {boolean} */ - isDowngradeAvailable: function () { - return !this.get('controller.isDowngrade') && this.get('controller.downgradeAllowed'); - }.property('controller.isDowngrade', 'controller.downgradeAllowed'), + isDowngradeAvailable: Em.computed.and('!controller.isDowngrade', 'controller.downgradeAllowed'), /** * progress value is rounded to floor @@ -164,9 +162,7 @@ App.upgradeWizardView = Em.View.extend({ /** * @type {boolean} */ - isManualProceedDisabled: function () { - return !this.get('isManualDone') || this.get('controller.requestInProgress'); - }.property('isManualDone'), + isManualProceedDisabled: Em.computed.or('!isManualDone', 'controller.requestInProgress'), /** * if upgrade group is manual it should have manual item http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js index c0b9b57..1a97354 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js @@ -115,9 +115,7 @@ App.MainAdminStackVersionsView = Em.View.extend({ /** * @type {object} */ - selectedCategory: function () { - return this.get('categories').findProperty('isSelected'); - }.property('categories.@each.isSelected'), + selectedCategory: Em.computed.findBy('categories', 'isSelected', true), /** * @type {Em.Array} http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/alert_definitions_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alert_definitions_view.js b/ambari-web/app/views/main/alert_definitions_view.js index 328ecbf..d94226e 100644 --- a/ambari-web/app/views/main/alert_definitions_view.js +++ b/ambari-web/app/views/main/alert_definitions_view.js @@ -458,9 +458,7 @@ App.MainAlertDefinitionsView = App.TableView.extend({ * Filtered number of all content number information displayed on the page footer bar * @returns {String} */ - filteredContentInfo: function () { - return this.t('alerts.filters.filteredAlertsInfo').format(this.get('filteredCount'), this.get('totalCount')); - }.property('filteredCount', 'totalCount'), + filteredContentInfo: Em.computed.i18nFormat('alerts.filters.filteredAlertsInfo', 'filteredCount', 'totalCount'), /** * Determines how display "back"-link - as link or text http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/alerts/definition_details_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts/definition_details_view.js b/ambari-web/app/views/main/alerts/definition_details_view.js index 6b5e065..89a5531 100644 --- a/ambari-web/app/views/main/alerts/definition_details_view.js +++ b/ambari-web/app/views/main/alerts/definition_details_view.js @@ -191,8 +191,6 @@ App.AlertInstanceServiceHostView = Em.View.extend({ /** * Define whether show separator between service and hosts labels */ - showSeparator: function () { - return this.get('instance.serviceDisplayName') && this.get('instance.hostName'); - }.property('instance.serviceDisplayName', 'instance.hostName') + showSeparator: Em.computed.and('instance.serviceDisplayName', 'instance.hostName') }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/dashboard/config_history_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/config_history_view.js b/ambari-web/app/views/main/dashboard/config_history_view.js index ad28831..a0737c4 100644 --- a/ambari-web/app/views/main/dashboard/config_history_view.js +++ b/ambari-web/app/views/main/dashboard/config_history_view.js @@ -36,9 +36,7 @@ App.MainConfigHistoryView = App.TableView.extend(App.TableServerViewMixin, { * return filtered number of all content number information displayed on the page footer bar * @returns {String} */ - filteredContentInfo: function () { - return this.t('tableView.filters.filteredConfigVersionInfo').format(this.get('filteredCount'), this.get('totalCount')); - }.property('filteredCount', 'totalCount'), + filteredContentInfo: Em.computed.i18nFormat('tableView.filters.filteredConfigVersionInfo', 'filteredCount', 'totalCount'), willInsertElement: function () { var http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js b/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js index 9704ae2..500f9e8 100644 --- a/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js +++ b/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js @@ -22,9 +22,7 @@ App.ClusterMetricsDashboardWidgetView = App.DashboardWidgetView.extend(App.Expor templateName: require('templates/main/dashboard/widgets/cluster_metrics'), - exportTargetView: function () { - return this.get('childViews.lastObject'); - }.property(), + exportTargetView: Em.computed.alias('childViews.lastObject'), didInsertElement: function () { var self = this; http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/dashboard/widgets/flume_agent_live.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/flume_agent_live.js b/ambari-web/app/views/main/dashboard/widgets/flume_agent_live.js index df4f62d..2d73e20 100644 --- a/ambari-web/app/views/main/dashboard/widgets/flume_agent_live.js +++ b/ambari-web/app/views/main/dashboard/widgets/flume_agent_live.js @@ -60,9 +60,7 @@ App.FlumeAgentUpView = App.TextDashboardWidgetView.extend({ } }.property('model.hostComponents.length', 'flumeAgentsLive'), - content: function () { - return this.get('flumeAgentsLive').length + "/" + this.get('flumeAgentComponents').length; - }.property('flumeAgentComponents.length', 'flumeAgentsLive'), + content: Em.computed.concat('/', 'flumeAgentsLive.length', 'flumeAgentComponents.length'), statusObserver: function() { Em.run.once(this, 'filterStatusOnce'); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/dashboard/widgets/hbase_links.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/hbase_links.js b/ambari-web/app/views/main/dashboard/widgets/hbase_links.js index 53ad59c..01536e6 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hbase_links.js +++ b/ambari-web/app/views/main/dashboard/widgets/hbase_links.js @@ -43,9 +43,7 @@ App.HBaseLinksView = App.LinkDashboardWidgetView.extend({ */ activeMaster: Em.computed.findBy('masters', 'haStatus', 'true'), - activeMasterTitle: function(){ - return this.t('service.hbase.activeMaster'); - }.property('activeMaster'), + activeMasterTitle: Em.I18n.t('service.hbase.activeMaster'), hbaseMasterWebUrl: function () { if (this.get('activeMaster.host') && this.get('activeMaster.host').get('publicHostName')) { http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 ec555a7..2c5b4eb 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js +++ b/ambari-web/app/views/main/dashboard/widgets/hdfs_links.js @@ -37,9 +37,7 @@ App.HDFSLinksView = App.LinkDashboardWidgetView.extend({ this.calc(); }, - isHAEnabled: function() { - return !this.get('model.snameNode'); - }.property('model.snameNode'), + isHAEnabled: Em.computed.not('model.snameNode'), isActiveNNValid: function () { return this.get('model.activeNameNode') != null; }.property('model.activeNameNode'), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/host.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js index f8e98f6..00d0ced 100644 --- a/ambari-web/app/views/main/host.js +++ b/ambari-web/app/views/main/host.js @@ -70,9 +70,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, { * return filtered number of all content number information displayed on the page footer bar * @returns {String} */ - filteredContentInfo: function () { - return this.t('hosts.filters.filteredHostsInfo').format(this.get('filteredCount'), this.get('totalCount')); - }.property('filteredCount', 'totalCount'), + filteredContentInfo: Em.computed.i18nFormat('hosts.filters.filteredHostsInfo', 'filteredCount', 'totalCount'), /** * request latest data filtered by new parameters @@ -106,9 +104,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, { * Return pagination information displayed on the page * @type {String} */ - paginationInfo: function () { - return this.t('tableView.filters.paginationInfo').format(this.get('startIndex'), this.get('endIndex'), this.get('filteredCount')); - }.property('startIndex', 'endIndex', 'filteredCount'), + paginationInfo: Em.computed.i18nFormat('tableView.filters.paginationInfo', 'startIndex', 'endIndex', 'filteredCount'), paginationLeftClass: function () { if (this.get("startIndex") > 1 && this.get('filteringComplete')) { http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/host/host_alerts_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/host_alerts_view.js b/ambari-web/app/views/main/host/host_alerts_view.js index 731212f..6ae2ddd 100644 --- a/ambari-web/app/views/main/host/host_alerts_view.js +++ b/ambari-web/app/views/main/host/host_alerts_view.js @@ -200,9 +200,7 @@ App.MainHostAlertsView = App.TableView.extend({ * Filtered number of all content number information displayed on the page footer bar * @returns {String} */ - filteredContentInfo: function () { - return this.t('alerts.filters.filteredAlertsInfo').format(this.get('filteredCount'), this.get('totalCount')); - }.property('filteredCount', 'totalCount'), + filteredContentInfo: Em.computed.i18nFormat('alerts.filters.filteredAlertsInfo', 'filteredCount', 'totalCount'), /** * Determines how display "back"-link - as link or text http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 94dd2f9..84fd35c 100644 --- a/ambari-web/app/views/main/host/stack_versions_view.js +++ b/ambari-web/app/views/main/host/stack_versions_view.js @@ -40,9 +40,7 @@ App.MainHostStackVersionsView = App.TableView.extend({ * return filtered number of all content number information displayed on the page footer bar * @returns {string} */ - filteredContentInfo: function () { - return this.t('hosts.host.stackVersions.table.filteredInfo').format(this.get('filteredCount'), this.get('totalCount')); - }.property('filteredCount', 'totalCount'), + filteredContentInfo: Em.computed.i18nFormat('hosts.host.stackVersions.table.filteredInfo', 'filteredCount', 'totalCount'), /** * @type {Ember.View} http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 a8d1bed..93d7a1c 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -236,9 +236,7 @@ App.MainHostSummaryView = Em.View.extend(App.TimeRangeMixin, { * Disable "Add" button if components can't be added to the current host * @type {bool} */ - addComponentDisabled: function() { - return (!this.get('isAddComponent')) || (this.get('addableComponents.length') == 0); - }.property('isAddComponent', 'addableComponents.length'), + addComponentDisabled: Em.computed.or('!isAddComponent', '!addableComponents.length'), /** * List of client's that may be installed to the current host http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 d01aa67..36f5c11 100644 --- a/ambari-web/app/views/main/menu.js +++ b/ambari-web/app/views/main/menu.js @@ -83,9 +83,7 @@ App.MainMenuView = Em.CollectionView.extend({ return App.router.get('mainHostController.hostsCountMap.health-status-CRITICAL') > 0; }.property('content.hasAlertsLabel', 'alertsCount'), - hasAlertsLabel: function () { - return this.get('content.hasAlertsLabel') && this.get('alertsCount') > 0; - }.property('content.hasAlertsLabel', 'alertsCount'), + hasAlertsLabel: Em.computed.and('content.hasAlertsLabel', 'alertsCount'), templateName: require('templates/main/menu_item'), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/service/reassign/step4_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/reassign/step4_view.js b/ambari-web/app/views/main/service/reassign/step4_view.js index bd5950a..91123bb 100644 --- a/ambari-web/app/views/main/service/reassign/step4_view.js +++ b/ambari-web/app/views/main/service/reassign/step4_view.js @@ -23,19 +23,17 @@ App.ReassignMasterWizardStep4View = App.HighAvailabilityProgressPageView.extend( headerTitle: Em.I18n.t('services.reassign.step4.header'), - noticeInProgress: function () { - return Em.I18n.t('services.reassign.step4.status.info').format(App.format.role(this.get('controller.content.reassign.component_name'))) - }.property('controller.content.reassign.component_name'), + formattedComponentName: Em.computed.formatRole('controller.content.reassign.component_name'), - noticeFailed: function () { - return Em.I18n.t('services.reassign.step4.status.failed').format(App.format.role(this.get('controller.content.reassign.component_name')),this.get('controller.content.reassignHosts.source'),this.get('controller.content.reassignHosts.target')); - }.property('controller.content.reassign.component_name','controller.content.reassignHosts.source','controller.content.reassignHosts.target'), + noticeInProgress: Em.computed.i18nFormat('services.reassign.step4.status.info', 'formattedComponentName'), + + noticeFailed: Em.computed.i18nFormat('services.reassign.step4.status.failed', 'formattedComponentName', 'controller.content.reassignHosts.source', 'controller.content.reassignHosts.target'), noticeCompleted: function () { if (this.get('controller.content.hasManualSteps')) { - return Em.I18n.t('services.reassign.step4.status.success.withManualSteps').format(App.format.role(this.get('controller.content.reassign.component_name'))); + return Em.I18n.t('services.reassign.step4.status.success.withManualSteps').format(this.get('formattedComponentName')); } else { - return Em.I18n.t('services.reassign.step4.status.success').format(App.format.role(this.get('controller.content.reassign.component_name')),this.get('controller.content.reassignHosts.source'),this.get('controller.content.reassignHosts.target')); + return Em.I18n.t('services.reassign.step4.status.success').format(this.get('formattedComponentName'),this.get('controller.content.reassignHosts.source'),this.get('controller.content.reassignHosts.target')); } }.property('controller.content.reassign.component_name','controller.content.reassignHosts.source','controller.content.reassignHosts.target'), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/service/reassign/step6_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/reassign/step6_view.js b/ambari-web/app/views/main/service/reassign/step6_view.js index 9c718e9..9ebc235 100644 --- a/ambari-web/app/views/main/service/reassign/step6_view.js +++ b/ambari-web/app/views/main/service/reassign/step6_view.js @@ -23,17 +23,13 @@ App.ReassignMasterWizardStep6View = App.HighAvailabilityProgressPageView.extend( headerTitle: Em.I18n.t('services.reassign.step6.header'), - noticeInProgress: function () { - return Em.I18n.t('services.reassign.step6.status.info').format(App.format.role(this.get('controller.content.reassign.component_name'))) - }.property('controller.content.reassign.component_name'), + formattedComponentName: Em.computed.formatRole('controller.content.reassign.component_name'), - noticeFailed: function () { - return Em.I18n.t('services.reassign.step6.status.failed').format(App.format.role(this.get('controller.content.reassign.component_name')),this.get('controller.content.reassignHosts.source'),this.get('controller.content.reassignHosts.target')) - }.property('controller.content.reassign.component_name','controller.content.reassignHosts.source','controller.content.reassignHosts.target'), + noticeInProgress: Em.computed.i18nFormat('services.reassign.step6.status.info', 'formattedComponentName'), - noticeCompleted: function () { - return Em.I18n.t('services.reassign.step6.status.success').format(App.format.role(this.get('controller.content.reassign.component_name')),this.get('controller.content.reassignHosts.source'),this.get('controller.content.reassignHosts.target')) - }.property('controller.content.reassign.component_name','controller.content.reassignHosts.source','controller.content.reassignHosts.target'), + noticeFailed: Em.computed.i18nFormat('services.reassign.step6.status.failed', 'formattedComponentName', 'controller.content.reassignHosts.source', 'controller.content.reassignHosts.target'), + + noticeCompleted: Em.computed.i18nFormat('services.reassign.step6.status.success', 'formattedComponentName', 'controller.content.reassignHosts.source', 'controller.content.reassignHosts.target'), submitButtonText: Em.I18n.t('common.complete'), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 de0818d..72a29d2 100644 --- a/ambari-web/app/views/main/service/services/hbase.js +++ b/ambari-web/app/views/main/service/services/hbase.js @@ -58,9 +58,7 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({ */ activeMaster: Em.computed.findBy('masters', 'haStatus', 'true'), - activeMasterTitle: function(){ - return this.t('service.hbase.activeMaster'); - }.property('activeMaster'), + activeMasterTitle: Em.I18n.t('service.hbase.activeMaster'), masterServerHeapSummary: function () { var heapUsed = this.get('service').get('heapMemoryUsed'); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/service/services/storm.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/storm.js b/ambari-web/app/views/main/service/services/storm.js index 237fdca..c236193 100644 --- a/ambari-web/app/views/main/service/services/storm.js +++ b/ambari-web/app/views/main/service/services/storm.js @@ -31,9 +31,7 @@ App.MainDashboardServiceStormView = App.MainDashboardServiceView.extend({ return Em.Object.create({componentName: 'SUPERVISOR'}); }.property(), - freeSlotsPercentage: function() { - return Math.round(this.get('service.freeSlots')/this.get('service.totalSlots')*100); - }.property('service.freeSlots', 'service.totalSlots'), + freeSlotsPercentage: Em.computed.percents('service.freeSlots', 'service.totalSlots'), superVisorsLive: Em.computed.alias('service.superVisorsStarted'), http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/main/service/widgets/create/expression_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/widgets/create/expression_view.js b/ambari-web/app/views/main/service/widgets/create/expression_view.js index 30c5451..e6dd2ad 100644 --- a/ambari-web/app/views/main/service/widgets/create/expression_view.js +++ b/ambari-web/app/views/main/service/widgets/create/expression_view.js @@ -201,9 +201,7 @@ App.AddNumberExpressionView = Em.TextField.extend({ */ App.AddMetricExpressionView = Em.View.extend({ templateName: require('templates/main/service/widgets/create/step2_add_metric'), - controller: function () { - return this.get('parentView.controller'); - }.property('parentView.controller'), + controller: Em.computed.alias('parentView.controller'), elementId: function () { var expressionId = "_" + this.get('parentView').get('expression.id'); return 'add-metric-menu' + expressionId; @@ -366,9 +364,7 @@ App.AddMetricExpressionView = Em.View.extend({ id: componentId + expressionId, aggregatorId: componentId + expressionId + '_aggregator', serviceName: serviceName, - showAggregateSelect: function () { - return this.get('level') === 'COMPONENT'; - }.property('level'), + showAggregateSelect: Em.computed.equal('level', 'COMPONENT'), selectedMetric: null, selectedAggregation: Em.I18n.t('dashboard.widgets.wizard.step2.aggregateFunction.scanOps'), isAddEnabled: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/wizard/step1_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/step1_view.js b/ambari-web/app/views/wizard/step1_view.js index ff9dd68..452e676 100644 --- a/ambari-web/app/views/wizard/step1_view.js +++ b/ambari-web/app/views/wizard/step1_view.js @@ -83,9 +83,7 @@ App.WizardStep1View = Em.View.extend({ * Enable error count badge * @type {bool} */ - showErrorsWarningCount: function () { - return this.get('isSubmitDisabled') && !!this.get('totalErrorCnt'); - }.property('isSubmitDisabled', 'totalErrorCnt'), + showErrorsWarningCount: Em.computed.and('isSubmitDisabled', 'totalErrorCnt'), /** * Verify if some invalid repo-urls exist http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/wizard/step9_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/step9_view.js b/ambari-web/app/views/wizard/step9_view.js index 620f26b..3a11f33 100644 --- a/ambari-web/app/views/wizard/step9_view.js +++ b/ambari-web/app/views/wizard/step9_view.js @@ -126,9 +126,7 @@ App.WizardStep9View = App.TableView.extend({ * Message for overall progress * @type {string} */ - progressMessage: function () { - return Em.I18n.t('installer.step9.overallProgress').format(this.get('controller.progress')); - }.property('controller.progress'), + progressMessage: Em.computed.i18nFormat('installer.step9.overallProgress', 'controller.progress'), /** * Run <code>countCategoryHosts</code>, <code>filter</code> only once http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/test/controllers/wizard/step6_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js index 2de57fd..b2524e4 100644 --- a/ambari-web/test/controllers/wizard/step6_test.js +++ b/ambari-web/test/controllers/wizard/step6_test.js @@ -216,7 +216,7 @@ describe('App.WizardStep6Controller', function () { }); it('should return errorMessage', function () { controller.set('errorMessage', "error 404"); - expect(controller.get('anyGeneralErrors')).to.equal("error 404"); + expect(controller.get('anyGeneralErrors')).to.be.true }); it('true if generalErrorMessages is non empty array and errorMessage is undefined', function () { controller.set('generalErrorMessages', ["error1", "error2"]); @@ -228,7 +228,7 @@ describe('App.WizardStep6Controller', function () { }); it('undefined if generalErrorMessages is undefined and errorMessage is undefined', function () { controller.set('generalErrorMessages', undefined); - expect(controller.get('anyGeneralErrors')).to.equal(undefined); + expect(controller.get('anyGeneralErrors')).to.equal(false); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/test/utils/ember_computed_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/ember_computed_test.js b/ambari-web/test/utils/ember_computed_test.js index 659139c..380982c 100644 --- a/ambari-web/test/utils/ember_computed_test.js +++ b/ambari-web/test/utils/ember_computed_test.js @@ -202,11 +202,26 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop4')).to.equal(6); }); - it('should be updated if some dependent vlaue is changed', function () { + it('should be updated if some dependent value is changed', function () { this.obj.set('prop1', 4); expect(this.obj.get('prop4')).to.equal(9); }); + it('should be updated if some dependent value is string', function () { + this.obj.set('prop1', '4'); + expect(this.obj.get('prop4')).to.equal(9); + }); + + it('should be updated if some dependent value is string (2)', function () { + this.obj.set('prop1', '4.5'); + expect(this.obj.get('prop4')).to.equal(9.5); + }); + + it('should be updated if some dependent value is null', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop4')).to.equal(5); + }); + }); describe('#gte', function () { @@ -456,6 +471,11 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop2')).to.be.false; }); + it('`false` for null/undefined collection', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop2')).to.be.false; + }); + }); describe('#everyBy', function () { @@ -476,6 +496,11 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop2')).to.be.false; }); + it('`false` for null/undefined collection', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop2')).to.be.false; + }); + }); describe('#mapBy', function () { @@ -496,6 +521,11 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop2')).to.eql([1, 2, 3, 4]); }); + it('`[]` for null/undefined collection', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop2')).to.eql([]); + }); + }); describe('#filterBy', function () { @@ -516,6 +546,11 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop2')).to.eql([{a: 2}, {a: 2}, {a: 2}]); }); + it('`[]` for null/undefined collection', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop2')).to.eql([]); + }); + }); describe('#findBy', function () { @@ -536,6 +571,11 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop2')).to.eql({b: 1, a: 2}); }); + it('`null` for null/undefined collection', function () { + this.obj.set('prop1', null); + expect(this.obj.get('prop2')).to.be.null; + }); + }); describe('#alias', function() { @@ -611,6 +651,26 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop4')).to.equal(28.57); }); + it('should calculate percents (3)', function () { + this.obj.set('prop2', '35'); + expect(this.obj.get('prop3')).to.equal(29); + expect(this.obj.get('prop4')).to.equal(28.57); + }); + + it('should calculate percents (4)', function () { + this.obj.set('prop1', 10.6); + this.obj.set('prop2', 100); + expect(this.obj.get('prop3')).to.equal(11); + expect(this.obj.get('prop4')).to.equal(10.60); + }); + + it('should calculate percents (5)', function () { + this.obj.set('prop1', '10.6'); + this.obj.set('prop2', 100); + expect(this.obj.get('prop3')).to.equal(11); + expect(this.obj.get('prop4')).to.equal(10.60); + }); + }); describe('#formatRole', function () { @@ -685,7 +745,8 @@ describe('Ember.computed macros', function () { prop1: 'abc', prop2: 'cba', prop3: 'aaa', - prop4: Em.computed.i18nFormat('key1', 'prop1', 'prop2', 'prop3') + prop4: Em.computed.i18nFormat('key1', 'prop1', 'prop2', 'prop3'), + prop5: Em.computed.i18nFormat('not_existing_key', 'prop1', 'prop2', 'prop3') }); }); @@ -706,6 +767,10 @@ describe('Ember.computed macros', function () { expect(this.obj.get('prop4')).to.equal('aaa cba aaa'); }); + it('empty string for not existing i18-key', function () { + expect(this.obj.get('prop5')).to.equal(''); + }); + }); describe('#concat', function () {