You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/11/26 14:05:43 UTC
[1/2] ambari git commit: AMBARI-14086. Apply created Em.computed
macros (2) (onechiporenko)
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 () {
[2/2] ambari git commit: AMBARI-14086. Apply created Em.computed
macros (2) (onechiporenko)
Posted by on...@apache.org.
AMBARI-14086. Apply created Em.computed macros (2) (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/44e59558
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/44e59558
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/44e59558
Branch: refs/heads/trunk
Commit: 44e595588d72194ac434585e61f91b8366769d39
Parents: 54fa239
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Nov 26 15:03:41 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Nov 26 15:03:41 2015 +0200
----------------------------------------------------------------------
ambari-web/app/app.js | 18 ++---
.../global/wizard_watcher_controller.js | 4 +-
.../nameNode/step3_controller.js | 4 +-
.../rangerAdmin/step1_controller.js | 4 +-
.../app/controllers/main/admin/kerberos.js | 16 ++---
.../main/admin/kerberos/step2_controller.js | 8 +--
.../main/admin/kerberos/step5_controller.js | 4 +-
.../main/admin/kerberos/step8_controller.js | 5 +-
.../add_alert_definition/step1_controller.js | 4 +-
.../main/alerts/alert_instances_controller.js | 4 +-
.../alerts/definition_configs_controller.js | 6 +-
.../alerts/manage_alert_groups_controller.js | 4 +-
.../manage_alert_notifications_controller.js | 8 +--
.../app/controllers/main/charts/heatmap.js | 12 +---
ambari-web/app/controllers/main/host/details.js | 30 +++------
ambari-web/app/controllers/main/service.js | 3 +-
.../controllers/main/service/info/summary.js | 12 +---
ambari-web/app/controllers/main/service/item.js | 32 ++-------
.../service/manage_config_groups_controller.js | 2 +-
.../service/widgets/create/step2_controller.js | 8 +--
.../service/widgets/create/step3_controller.js | 20 +++---
.../wizard/slave_component_groups_controller.js | 10 +--
.../app/controllers/wizard/step2_controller.js | 8 +--
.../app/controllers/wizard/step3_controller.js | 2 +-
.../app/controllers/wizard/step6_controller.js | 21 +++---
.../app/controllers/wizard/step8_controller.js | 4 +-
.../app/mixins/common/configs/configs_saver.js | 8 +--
.../mixins/common/configs/enhanced_configs.js | 8 +--
.../unit_convert/base_unit_convert_mixin.js | 2 +-
ambari-web/app/models/alerts/alert_config.js | 5 +-
.../app/models/alerts/alert_definition.js | 4 +-
ambari-web/app/models/alerts/alert_instance.js | 6 +-
ambari-web/app/models/cluster_states.js | 5 +-
ambari-web/app/models/configs/config_group.js | 4 +-
.../configs/objects/service_config_category.js | 13 +---
.../configs/objects/service_config_property.js | 10 +--
.../models/configs/service_config_version.js | 20 ++----
ambari-web/app/models/configs/theme/section.js | 8 +--
.../app/models/configs/theme/sub_section.js | 20 +++---
.../app/models/configs/theme/sub_section_tab.js | 10 ++-
ambari-web/app/models/configs/theme/tab.js | 5 +-
ambari-web/app/models/host.js | 4 +-
ambari-web/app/models/host_component.js | 14 +---
ambari-web/app/models/host_stack_version.js | 4 +-
ambari-web/app/models/root_service.js | 8 +--
ambari-web/app/models/service.js | 4 +-
.../app/models/stack_service_component.js | 4 +-
.../models/stack_version/repository_version.js | 8 +--
ambari-web/app/models/stack_version/version.js | 4 +-
ambari-web/app/models/widget_property.js | 4 +-
ambari-web/app/utils/ember_computed.js | 44 ++++++++++---
.../common/ajax_default_error_popup_body.js | 8 +--
.../app/views/common/chart/linear_time.js | 4 +-
ambari-web/app/views/common/chart/pie.js | 4 +-
.../views/common/configs/config_history_flow.js | 28 ++------
.../app/views/common/configs/controls_view.js | 8 +--
.../notification_configs_view.js | 4 +-
.../configs/service_configs_by_category_view.js | 4 +-
.../configs/widgets/config_widget_view.js | 8 +--
.../configs/widgets/plain_config_text_field.js | 4 +-
.../widgets/test_db_connection_widget_view.js | 6 +-
ambari-web/app/views/common/controls_view.js | 32 +++------
.../app/views/common/form/spinner_input_view.js | 4 +-
.../app/views/common/rolling_restart_view.js | 17 ++---
ambari-web/app/views/common/table_view.js | 4 +-
ambari-web/app/views/common/time_range.js | 8 +--
.../highAvailability/nameNode/step1_view.js | 4 +-
.../stack_upgrade/failed_hosts_modal_view.js | 4 +-
.../admin/stack_upgrade/upgrade_wizard_view.js | 8 +--
.../main/admin/stack_upgrade/versions_view.js | 4 +-
.../app/views/main/alert_definitions_view.js | 4 +-
.../main/alerts/definition_details_view.js | 4 +-
.../views/main/dashboard/config_history_view.js | 4 +-
.../dashboard/widgets/cluster_metrics_widget.js | 4 +-
.../main/dashboard/widgets/flume_agent_live.js | 4 +-
.../views/main/dashboard/widgets/hbase_links.js | 4 +-
.../views/main/dashboard/widgets/hdfs_links.js | 4 +-
ambari-web/app/views/main/host.js | 8 +--
.../app/views/main/host/host_alerts_view.js | 4 +-
.../app/views/main/host/stack_versions_view.js | 4 +-
ambari-web/app/views/main/host/summary.js | 4 +-
ambari-web/app/views/main/menu.js | 4 +-
.../views/main/service/reassign/step4_view.js | 14 ++--
.../views/main/service/reassign/step6_view.js | 14 ++--
.../app/views/main/service/services/hbase.js | 4 +-
.../app/views/main/service/services/storm.js | 4 +-
.../service/widgets/create/expression_view.js | 8 +--
ambari-web/app/views/wizard/step1_view.js | 4 +-
ambari-web/app/views/wizard/step9_view.js | 4 +-
.../test/controllers/wizard/step6_test.js | 4 +-
ambari-web/test/utils/ember_computed_test.js | 69 +++++++++++++++++++-
91 files changed, 309 insertions(+), 510 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index dd9570c..f2548f8 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -57,7 +57,7 @@ module.exports = Em.Application.create({
/**
* flag is true when upgrade process is waiting for user action
- * to procced, retry, perform manual steps etc.
+ * to proceed, retry, perform manual steps etc.
* @returns {boolean}
*/
upgradeHolding: function() {
@@ -76,9 +76,7 @@ module.exports = Em.Application.create({
* RU is running
* @type {boolean}
*/
- upgradeIsRunning: function() {
- return this.get('upgradeInProgress') || this.get('upgradeHolding');
- }.property('upgradeInProgress', 'upgradeHolding'),
+ upgradeIsRunning: Em.computed.or('upgradeInProgress', 'upgradeHolding'),
/**
* flag is true when upgrade process is running or aborted
@@ -177,9 +175,7 @@ module.exports = Em.Application.create({
* for now is used to disable move/HA actions
* @type {boolean}
*/
- isSingleNode: function() {
- return this.get('allHostNames.length') === 1;
- }.property('allHostNames.length'),
+ isSingleNode: Em.computed.equal('allHostNames.length', 1),
allHostNames: [],
@@ -206,9 +202,7 @@ module.exports = Em.Application.create({
return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") == -1 && stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") > -1);
}.property('currentStackVersionNumber'),
- isHadoopWindowsStack: function() {
- return this.get('currentStackName') == "HDPWIN";
- }.property('currentStackName'),
+ isHadoopWindowsStack: Em.computed.equal('currentStackName', 'HDPWIN'),
/**
* when working with enhanced configs we should rely on stack version
@@ -216,9 +210,7 @@ module.exports = Em.Application.create({
* even if flag <code>supports.enhancedConfigs<code> is true
* @type {boolean}
*/
- isClusterSupportsEnhancedConfigs: function() {
- return this.get('isHadoop22Stack') && this.get('supports.enhancedConfigs');
- }.property('isHadoop22Stack', 'supports.enhancedConfigs'),
+ isClusterSupportsEnhancedConfigs: Em.computed.and('isHadoop22Stack', 'supports.enhancedConfigs'),
/**
* If NameNode High Availability is enabled
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/global/wizard_watcher_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/wizard_watcher_controller.js b/ambari-web/app/controllers/global/wizard_watcher_controller.js
index 438e41a..8332384 100644
--- a/ambari-web/app/controllers/global/wizard_watcher_controller.js
+++ b/ambari-web/app/controllers/global/wizard_watcher_controller.js
@@ -46,9 +46,7 @@ App.WizardWatcherController = Em.Controller.extend(App.UserPref, {
* define whether Wizard is running
* @type {boolean}
*/
- isWizardRunning: function() {
- return !Em.isNone(this.get('wizardUser'));
- }.property('wizardUser'),
+ isWizardRunning: Em.computed.bool('wizardUser'),
/**
* @type {string}
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
index 63f67c1..b97f89e 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
@@ -223,9 +223,7 @@ App.HighAvailabilityWizardStep3Controller = Em.Controller.extend({
}, this);
},
- isNextDisabled: function () {
- return !this.get('isLoaded');
- }.property('isLoaded')
+ isNextDisabled: Em.computed.not('isLoaded')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step1_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step1_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step1_controller.js
index 8ffb1a4..073ea64 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step1_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step1_controller.js
@@ -35,9 +35,7 @@ App.RAHighAvailabilityWizardStep1Controller = Em.Controller.extend({
* do not show is input-field is empty
* @type {Boolean}
*/
- showloadBalancerURLError: function () {
- return this.get('content.loadBalancerURL') && !this.get('isloadBalancerURLValid');
- }.property('isloadBalancerURLValid', 'content.loadBalancerURL'),
+ showloadBalancerURLError: Em.computed.and('content.loadBalancerURL', '!isloadBalancerURLValid'),
/**
* Define either Submit is disabled or enabled
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index 86e540c..57ee8c1 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -447,9 +447,7 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
}
},
- isManualKerberos: function () {
- return this.get('kdc_type') === 'none';
- }.property('kdc_type'),
+ isManualKerberos: Em.computed.equal('kdc_type', 'none'),
checkState: function (data, opt, params) {
var res = Em.get(data, 'Services.attributes.kdc_validation_result');
@@ -465,23 +463,17 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
* Determines if some config value is changed
* @type {boolean}
*/
- isPropertiesChanged: function () {
- return this.get('stepConfigs').someProperty('isPropertiesChanged', true);
- }.property('stepConfigs.@each.isPropertiesChanged'),
+ isPropertiesChanged: Em.computed.someBy('stepConfigs', 'isPropertiesChanged', true),
/**
* Determines if the save button is disabled
*/
- isSaveButtonDisabled: function () {
- return this.get('isSubmitDisabled') || !this.get('isPropertiesChanged');
- }.property('isSubmitDisabled', 'isPropertiesChanged'),
+ isSaveButtonDisabled: Em.computed.or('isSubmitDisabled', '!isPropertiesChanged'),
/**
* Determines if the `Disbale Kerberos` and `Regenerate Keytabs` button are disabled
*/
- isKerberosButtonsDisabled: function () {
- return !this.get('isSaveButtonDisabled');
- }.property('isSaveButtonDisabled'),
+ isKerberosButtonsDisabled: Em.computed.not('isSaveButtonDisabled'),
makeConfigsEditable: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 c66a224..78922a8 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
@@ -45,9 +45,7 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend(App.KDCCred
* Should Back-button be disabled
* @type {boolean}
*/
- isBackBtnDisabled: function() {
- return this.get('testConnectionInProgress');
- }.property('testConnectionInProgress'),
+ isBackBtnDisabled: Em.computed.alias('testConnectionInProgress'),
/**
* Should Next-button be disabled
@@ -72,9 +70,7 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend(App.KDCCred
},
- isConfigsLoaded: function () {
- return this.get('wizardController.stackConfigsLoaded');
- }.property('wizardController.stackConfigsLoaded'),
+ isConfigsLoaded: Em.computed.alias('wizardController.stackConfigsLoaded'),
/**
* On load function
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js
index f2b469c..5aa4b8c 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js
@@ -116,9 +116,7 @@ App.KerberosWizardStep5Controller = App.KerberosProgressPageController.extend({
App.router.transitionTo('step5');
},
- isSubmitDisabled: function () {
- return !["COMPLETED", "FAILED"].contains(this.get('status'));
- }.property('status'),
+ isSubmitDisabled: Em.computed.notExistsIn('status', ['COMPLETED', 'FAILED']),
confirmProperties: function () {
var kdc_type = App.router.get('kerberosWizardController.content.kerberosOption'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/admin/kerberos/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step8_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step8_controller.js
index fee4835..3e659b9 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step8_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step8_controller.js
@@ -38,7 +38,6 @@ App.KerberosWizardStep8Controller = App.KerberosProgressPageController.extend({
});
},
- isSubmitDisabled: function () {
- return !["COMPLETED", "FAILED"].contains(this.get('status'));
- }.property('status')
+ isSubmitDisabled: Em.computed.notExistsIn('status', ['COMPLETED', 'FAILED'])
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/alerts/add_alert_definition/step1_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/add_alert_definition/step1_controller.js b/ambari-web/app/controllers/main/alerts/add_alert_definition/step1_controller.js
index 644fa4a..43e25c8 100644
--- a/ambari-web/app/controllers/main/alerts/add_alert_definition/step1_controller.js
+++ b/ambari-web/app/controllers/main/alerts/add_alert_definition/step1_controller.js
@@ -40,9 +40,7 @@ App.AddAlertDefinitionStep1Controller = Em.Controller.extend({
* "Next"-button is disabled if user doesn't select any alert definition type
* @type {boolean}
*/
- isSubmitDisabled: function() {
- return this.get('alertDefinitionsTypes').everyProperty('isActive', false);
- }.property('alertDefinitionsTypes.@each.isActive'),
+ isSubmitDisabled: Em.computed.everyBy('alertDefinitionsTypes', 'isActive', false),
/**
* Set selectedType if it exists in the wizard controller
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 5a72774..48c9034 100644
--- a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
+++ b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
@@ -208,9 +208,7 @@ App.MainAlertInstancesController = Em.Controller.extend({
alertsNumberBinding: 'App.router.mainAlertDefinitionsController.unhealthyAlertInstancesCount',
- header: function () {
- return Em.I18n.t('alerts.fastAccess.popup.header').format(this.get('alertsNumber'));
- }.property('alertsNumber'),
+ header: Em.computed.i18nFormat('alerts.fastAccess.popup.header', 'alertsNumber'),
classNames: ['sixty-percent-width-modal', 'alerts-popup'],
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
index a480544..36fefbf 100644
--- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
@@ -552,12 +552,12 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
return smallValid && largeValid ? Number(smallValue) > Number(largeValue) : false;
}.property('configs.@each.value'),
+ someConfigIsInvalid: Em.computed.someBy('configs', 'isValid', false),
+
/**
* Define whether all configs are valid
* @type {Boolean}
*/
- hasErrors: function () {
- return this.get('configs').someProperty('isValid', false) || this.get('hasThresholdsError');
- }.property('configs.@each.isValid', 'hasThresholdsError')
+ hasErrors: Em.computed.or('someConfigIsInvalid', 'hasThresholdsError')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
index 7c57826..7eb0945 100644
--- a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
+++ b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
@@ -76,9 +76,7 @@ App.ManageAlertGroupsController = Em.Controller.extend({
* List of all global Alert Notifications
* @type {App.AlertNotification[]}
*/
- alertGlobalNotifications: function () {
- return this.get('alertNotifications').filterProperty('global');
- }.property('alertNotifications'),
+ alertGlobalNotifications: Em.computed.filterBy('alertNotifications', 'global', true),
/**
* @type {boolean}
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 e546d57..b61b14a 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
@@ -387,9 +387,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
this.retypePasswordValidation();
},
- isEmailMethodSelected: function () {
- return this.get('controller.inputFields.method.value') === 'EMAIL';
- }.property('controller.inputFields.method.value'),
+ isEmailMethodSelected: Em.computed.equal('controller.inputFields.method.value', 'EMAIL'),
methodObserver: function () {
var currentMethod = this.get('controller.inputFields.method.value'),
@@ -605,9 +603,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
primary: Em.I18n.t('common.save'),
- disablePrimary: function () {
- return this.get('isSaving') || this.get('hasErrors');
- }.property('isSaving', 'hasErrors'),
+ disablePrimary: Em.computed.or('isSaving', 'hasErrors'),
onPrimary: function () {
this.set('isSaving', true);
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/charts/heatmap.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap.js b/ambari-web/app/controllers/main/charts/heatmap.js
index f54c1b0..2ff1341 100644
--- a/ambari-web/app/controllers/main/charts/heatmap.js
+++ b/ambari-web/app/controllers/main/charts/heatmap.js
@@ -58,13 +58,7 @@ App.MainChartsHeatmapController = Em.Controller.extend(App.WidgetSectionMixin, {
/**
* Heatmap widget currently shown on the page
*/
- activeWidget: function() {
- if (this.get('widgets') && this.get('widgets').length) {
- return this.get('widgets')[0];
- } else {
- return false;
- }
- }.property('widgets.@each'),
+ activeWidget: Em.computed.alias('widgets.firstObject'),
/**
@@ -251,9 +245,7 @@ App.MainChartsHeatmapController = Em.Controller.extend(App.WidgetSectionMixin, {
});
},
- hostToSlotMap: function () {
- return this.get('selectedMetric.hostToSlotMap');
- }.property('selectedMetric.hostToSlotMap'),
+ hostToSlotMap: Em.computed.alias('selectedMetric.hostToSlotMap'),
/**
* return class name for to be used for containing each rack.
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index b4555a3..2b7ae21 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -623,13 +623,9 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'),
header: Em.I18n.t('popup.confirmation.commonHeader'),
- addComponentMsg: function () {
- return Em.I18n.t('hosts.host.addComponent.msg').format(message);
- }.property(),
+ addComponentMsg: Em.I18n.t('hosts.host.addComponent.msg').format(message),
- manualKerberosWarning: function () {
- return isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '';
- }.property(),
+ manualKerberosWarning: isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '',
bodyClass: Em.View.extend({
templateName: require('templates/main/host/details/addComponentPopup')
@@ -1347,9 +1343,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
return App.ModalPopup.show({
primary: Em.I18n.t('hosts.host.installComponent.popup.confirm'),
header: Em.I18n.t('popup.confirmation.commonHeader'),
- installComponentMessage: function () {
- return Em.I18n.t('hosts.host.installComponent.msg').format(displayName);
- }.property(),
+ installComponentMessage: Em.I18n.t('hosts.host.installComponent.msg').format(displayName),
bodyClass: Em.View.extend({
templateName: require('templates/main/host/details/installComponentPopup')
}),
@@ -1551,9 +1545,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
showHbaseActiveWarning: function () {
return App.ModalPopup.show({
header: Em.I18n.t('common.warning'),
- message: function () {
- return Em.I18n.t('hostPopup.recommendation.beforeDecommission').format(App.format.components["HBASE_REGIONSERVER"]);
- }.property(),
+ message: Em.I18n.t('hostPopup.recommendation.beforeDecommission').format(App.format.components["HBASE_REGIONSERVER"]),
bodyClass: Ember.View.extend({
template: Em.Handlebars.compile('<div class="alert alert-warning">{{message}}</div>')
}),
@@ -2051,9 +2043,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
App.ModalPopup.show({
header: Em.I18n.t('hosts.cant.do.popup.title'),
type: type,
- showBodyEnd: function () {
- return this.get('type') === 'runningList' || this.get('type') === 'masterList';
- }.property(),
+ showBodyEnd: Em.computed.existsIn('type', ['runningList', 'masterList']),
container: container,
components: function(){
var container = this.get('container');
@@ -2068,10 +2058,8 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
}.property('type'),
componentsStr: function () {
return this.get('components').join(", ");
- }.property(),
- componentsBody: function () {
- return Em.I18n.t('hosts.cant.do.popup.' + type + '.body').format(this.get('components').length);
- }.property(),
+ }.property('components.[]'),
+ componentsBody: Em.computed.i18nFormat('hosts.cant.do.popup.' + type + '.body', 'components.length'),
componentsBodyEnd: function () {
if (this.get('showBodyEnd')) {
return Em.I18n.t('hosts.cant.do.popup.' + type + '.body.end').format(App.get('components.decommissionAllowed').map(function(c){return App.format.role(c)}).join(", "));
@@ -2094,9 +2082,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
var self = this;
return App.ModalPopup.show({
header: Em.I18n.t('hosts.delete.popup.title'),
- deletePopupBody: function () {
- return Em.I18n.t('hosts.delete.popup.body').format(self.get('content.publicHostName'));
- }.property(),
+ deletePopupBody: Em.I18n.t('hosts.delete.popup.body').format(self.get('content.publicHostName')),
lastComponent: function () {
if (container.lastComponents && container.lastComponents.length) {
this.set('isChecked', false);
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 9269780..12b1c0f 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/ambari-web/app/controllers/main/service.js
@@ -76,8 +76,7 @@ App.MainServiceController = Em.ArrayController.extend({
if (this.get('isStartStopAllClicked') == true) {
return true;
}
- var startedServiceLength = this.get('content').filterProperty('healthStatus', 'green').length;
- return (startedServiceLength === 0);
+ return !this.get('content').someProperty('healthStatus', 'green');
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 36508c1..1df9384 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -663,9 +663,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
var self = this;
return App.ModalPopup.show({
- header: function () {
- return Em.I18n.t('dashboard.widgets.browser.header');
- }.property(''),
+ header: Em.I18n.t('dashboard.widgets.browser.header'),
classNames: ['sixty-percent-width-modal', 'widgets-browser-popup'],
onPrimary: function () {
@@ -693,13 +691,9 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
this.get('controller').loadMineWidgets();
},
- isLoaded: function () {
- return !!(this.get('controller.isAllSharedWidgetsLoaded') && this.get('controller.isMineWidgetsLoaded'));
- }.property('controller.isAllSharedWidgetsLoaded', 'controller.isMineWidgetsLoaded'),
+ isLoaded: Em.computed.and('controller.isAllSharedWidgetsLoaded', 'controller.isMineWidgetsLoaded'),
- isWidgetEmptyList: function () {
- return !this.get('filteredContent.length');
- }.property('filteredContent.length'),
+ isWidgetEmptyList: Em.computed.empty('filteredContent'),
activeService: '',
activeStatus: '',
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 85f58dd..475342e 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -504,9 +504,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
var intValue = Number(this.get('inputValue'));
return this.get('inputValue')!=='DEBUG' && (isNaN(intValue) || intValue < 1 || intValue > 100);
}.property('inputValue'),
- disablePrimary : function() {
- return this.get('isInvalid');
- }.property('isInvalid'),
+ disablePrimary: Em.computed.alias('isInvalid'),
onPrimary: function () {
if (this.get('isInvalid')) {
return;
@@ -734,27 +732,15 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
self.loadHostsWithoutComponent(componentName);
return App.ModalPopup.show({
- primary: function() {
- if (this.get('anyHostsWithoutComponent')) {
- return Em.I18n.t('hosts.host.addComponent.popup.confirm')
- } else {
- return undefined;
- }
- }.property('anyHostsWithoutComponent'),
+ primary: Em.computed.ifThenElse('anyHostsWithoutComponent', Em.I18n.t('hosts.host.addComponent.popup.confirm'), undefined),
header: Em.I18n.t('popup.confirmation.commonHeader'),
- addComponentMsg: function () {
- return Em.I18n.t('hosts.host.addComponent.msg').format(componentDisplayName);
- }.property(),
+ addComponentMsg: Em.I18n.t('hosts.host.addComponent.msg').format(componentDisplayName),
- selectHostMsg: function () {
- return Em.I18n.t('services.summary.selectHostForComponent').format(this.get('componentDisplayName'))
- }.property('componentDisplayName'),
+ selectHostMsg: Em.computed.i18nFormat('services.summary.selectHostForComponent', 'componentDisplayName'),
- thereIsNoHostsMsg: function () {
- return Em.I18n.t('services.summary.allHostsAlreadyRunComponent').format(this.get('componentDisplayName'))
- }.property('componentDisplayName'),
+ thereIsNoHostsMsg: Em.computed.i18nFormat('services.summary.allHostsAlreadyRunComponent', 'componentDisplayName'),
hostsWithoutComponent: function() {
return self.get("hostsWithoutComponent-" + this.get('componentName'));
@@ -764,13 +750,9 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
selectedHost: null,
- componentName: function() {
- return componentName;
- }.property(),
+ componentName: componentName,
- componentDisplayName: function() {
- return componentDisplayName;
- }.property(),
+ componentDisplayName: componentDisplayName,
bodyClass: Em.View.extend({
templateName: require('templates/main/service/add_host_popup')
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index 41934e7..231da20 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -225,7 +225,7 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
var modifiedGroups = this.get('hostsModifiedConfigGroups');
return Em.keys(modifiedGroups).map(function (key) {
return ignoreKeys.contains(key) ? 0 : Em.get(modifiedGroups[key], 'length');
- }).reduce(Em.sum) > 0;
+ }).reduce(Em.sum, 0) > 0;
}.property('hostsModifiedConfigGroups'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
index efa26b7..079c7b0 100644
--- a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
@@ -181,9 +181,7 @@ App.WidgetWizardStep2Controller = Em.Controller.extend({
id: id,
data: [],
isInvalid: false,
- isEmpty: function () {
- return (this.get('data.length') === 0);
- }.property('data.length')
+ isEmpty: Em.computed.empty('data')
})
}));
return id;
@@ -212,9 +210,7 @@ App.WidgetWizardStep2Controller = Em.Controller.extend({
data: [],
alias: '{{' + this.get('EXPRESSION_PREFIX') + id + '}}',
isInvalid: false,
- isEmpty: function () {
- return (this.get('data.length') === 0);
- }.property('data.length')
+ isEmpty: Em.computed.empty('data')
}));
return id;
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js b/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
index 3bea2fa..dd7a93f 100644
--- a/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
@@ -70,26 +70,26 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
widgetMetrics: [],
/**
+ * @type {bool}
+ */
+ widgetNameEmpty: function () {
+ return this.get('widgetName') ? !Boolean(this.get('widgetName').trim()) : true;
+ }.property('widgetName'),
+
+ /**
* @type {boolean}
*/
- isSubmitDisabled: function () {
- var widgetNameEmpty = this.get('widgetName') ? !Boolean(this.get('widgetName').trim()) : true;
- return widgetNameEmpty || this.get('isNameInvalid') || this.get('isDescriptionInvalid');
- }.property('widgetName', 'isNameInvalid', 'isDescriptionInvalid'),
+ isSubmitDisabled: Em.computed.or('widgetNameEmpty', 'isNameInvalid', 'isDescriptionInvalid'),
/**
* @type {boolean}
*/
- isNameInvalid: function () {
- return this.get('widgetName') ? this.get('widgetName').length >= 129 : false;
- }.property('widgetName'),
+ isNameInvalid: Em.computed.gte('widgetName.length', 129),
/**
* @type {boolean}
*/
- isDescriptionInvalid: function () {
- return this.get('widgetDescription') ? this.get('widgetDescription').length >= 2049 : false;
- }.property('widgetDescription'),
+ isDescriptionInvalid: Em.computed.gte('widgetDescription.length', 2049),
/**
* restore widget data set on 2nd step
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/slave_component_groups_controller.js b/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
index 019d32b..3cf42d6 100644
--- a/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
+++ b/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
@@ -127,9 +127,7 @@ App.SlaveComponentGroupsController = Em.ArrayController.extend({
}.property('service'),
- selectedComponentDisplayName: function() {
- return App.format.role(this.get('selectedComponentName'));
- }.property('selectedComponentName'),
+ selectedComponentDisplayName: Em.computed.formatRole('selectedComponentName'),
selectedSlaveComponent: function () {
var selectedComponentName = this.get('selectedComponentName') ? this.get('selectedComponentName').displayName : null;
@@ -145,11 +143,7 @@ App.SlaveComponentGroupsController = Em.ArrayController.extend({
return configs;
}.property('selectedComponentName', 'stepConfigs.@each.configCategories', 'stepConfigs.@each.configCategories.@each.slaveConfigs'),
- hosts: function () {
- if (this.get('selectedSlaveComponent')) {
- return this.get('selectedSlaveComponent').get('hosts');
- }
- }.property('selectedSlaveComponent'),
+ hosts: Em.computed.alias('selectedSlaveComponent.hosts'),
groups: function () {
var hosts = this.get('hosts');
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/wizard/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step2_controller.js b/ambari-web/app/controllers/wizard/step2_controller.js
index 3a298a4..1fd5dd9 100644
--- a/ambari-web/app/controllers/wizard/step2_controller.js
+++ b/ambari-web/app/controllers/wizard/step2_controller.js
@@ -124,7 +124,7 @@ App.WizardStep2Controller = Em.Controller.extend({
* @type {string|null}
*/
sshKeyError: function () {
- if (this.get('hasSubmitted') && this.get('manualInstall') === false && this.get('useSSH') && Em.isEmpty(this.get('sshKey').trim())) {
+ if (this.get('hasSubmitted') && this.get('manualInstall') === false && this.get('useSSH') && Em.isBlank(this.get('sshKey'))) {
return Em.I18n.t('installer.step2.sshKey.error.required');
}
return null;
@@ -135,7 +135,7 @@ App.WizardStep2Controller = Em.Controller.extend({
* @type {string|null}
*/
sshUserError: function () {
- if (this.get('manualInstall') === false && this.get('useSSH') && Em.isEmpty(this.get('sshUser').trim())) {
+ if (this.get('manualInstall') === false && this.get('useSSH') && Em.isBlank(this.get('sshUser'))) {
return Em.I18n.t('installer.step2.sshUser.required');
}
return null;
@@ -146,7 +146,7 @@ App.WizardStep2Controller = Em.Controller.extend({
* @type {string|null}
*/
sshPortError: function () {
- if (this.get('manualInstall') === false && this.get('useSSH') && Em.isEmpty(this.get('sshPort').trim() )) {
+ if (this.get('manualInstall') === false && this.get('useSSH') && Em.isBlank(this.get('sshPort'))) {
return Em.I18n.t('installer.step2.sshPort.required');
}
return null;
@@ -157,7 +157,7 @@ App.WizardStep2Controller = Em.Controller.extend({
* @type {string|null}
*/
agentUserError: function () {
- if (App.get('supports.customizeAgentUserAccount') && this.get('manualInstall') === false && Em.isEmpty(this.get('agentUser').trim())) {
+ if (App.get('supports.customizeAgentUserAccount') && this.get('manualInstall') === false && Em.isBlank(this.get('agentUser'))) {
return Em.I18n.t('installer.step2.sshUser.required');
}
return null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 18edd9b..76b3ee6 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -105,7 +105,7 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
* @type {bool}
*/
isRetryDisabled: function() {
- return (this.get('isBackDisabled')) ? this.get('isBackDisabled') : !this.get('bootHosts').filterProperty('bootStatus', 'FAILED').length;
+ return this.get('isBackDisabled') ? this.get('isBackDisabled') : !this.get('bootHosts').filterProperty('bootStatus', 'FAILED').length;
}.property('bootHosts.@each.bootStatus', 'isBackDisabled'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index b0896b5..04930f4 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -121,10 +121,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
/**
* true if validation has any general (which is not related with concrete host) error message
*/
- anyGeneralErrors: function() {
- var messages = this.get('generalErrorMessages');
- return this.get('errorMessage') || (messages && messages.length > 0);
- }.property('generalErrorMessages', 'generalErrorMessages.@each', 'errorMessage'),
+ anyGeneralErrors: Em.computed.or('errorMessage','generalErrorMessages.length'),
/**
* true if validation has any general (which is not related with concrete host) warning message
@@ -136,19 +133,23 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
*/
anyGeneralIssues: Em.computed.or('anyGeneralErrors', 'anyGeneralWarnings'),
+ anyHostErrors: function () {
+ return this.get('hosts').some(function(h) { return h.errorMessages.length > 0; });
+ }.property('hosts.@each.errorMessages'),
+
/**
* true if validation has any error message (general or host specific)
*/
- anyErrors: function() {
- return this.get('anyGeneralErrors') || this.get('hosts').some(function(h) { return h.errorMessages.length > 0; });
- }.property('anyGeneralErrors', 'hosts.@each.errorMessages'),
+ anyErrors: Em.computed.or('anyGeneralErrors', 'anyHostErrors'),
+
+ anyHostWarnings: function () {
+ return this.get('hosts').some(function(h) { return h.warnMessages.length > 0; });
+ }.property('hosts.@each.warnMessages'),
/**
* true if validation has any warning message (general or host specific)
*/
- anyWarnings: function() {
- return this.get('anyGeneralWarnings') || this.get('hosts').some(function(h) { return h.warnMessages.length > 0; });
- }.property('anyGeneralWarnings', 'hosts.@each.warnMessages'),
+ anyWarnings: Em.computed.or('anyGeneralWarnings', 'anyHostWarnings'),
openSlavesAndClientsIssues: function () {
App.ModalPopup.show({
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 e57f856..fa0adaa 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -136,9 +136,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* List of installed services
* @type {Object[]}
*/
- installedServices: function () {
- return this.get('content.services').filterProperty('isInstalled');
- }.property('content.services').cacheable(),
+ installedServices: Em.computed.filterBy('content.services', 'isInstalled', true),
/**
* Current cluster name
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index b2a96f4..4101601 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -794,13 +794,9 @@ App.ConfigsSaverMixin = Em.Mixin.create({
}.property('siteProperties'),
- runningHostsMessage: function () {
- return Em.I18n.t('services.service.config.stopService.runningHostComponents').format(this.get('runningComponentCount'), this.get('runningHosts.length'));
- }.property('runningComponentCount', 'runningHosts.length'),
+ runningHostsMessage: Em.computed.i18nFormat('services.service.config.stopService.runningHostComponents', 'runningComponentCount', 'runningHosts.length'),
- unknownHostsMessage: function () {
- return Em.I18n.t('services.service.config.stopService.unknownHostComponents').format(this.get('unknownComponentCount'), this.get('unknownHosts.length'));
- }.property('unknownComponentCount', 'unknownHosts.length'),
+ unknownHostsMessage: Em.computed.i18nFormat('services.service.config.stopService.unknownHostComponents', 'unknownComponentCount', 'unknownHosts.length'),
templateName: require('templates/main/service/info/configs_save_popup')
})
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 2e2a926..96916d0 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -49,9 +49,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
* rely on controller
* @type {boolean}
*/
- isControllerSupportsEnhancedConfigs: function() {
- return ['wizardStep7Controller','mainServiceInfoConfigsController'].contains(this.get('name'));
- }.property('name'),
+ isControllerSupportsEnhancedConfigs: Em.computed.existsIn('name', ['wizardStep7Controller','mainServiceInfoConfigsController']),
/**
* defines if initialValue of config can be used on current controller
@@ -117,9 +115,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
* defines if change dependent group message should be shown
* @type {boolean}
*/
- showSelectGroupsPopup: function() {
- return !this.get('selectedConfigGroup.isDefault') && this.get('selectedService.dependentServiceNames.length');
- }.property('selectedConfigGroup.isDefault'),
+ showSelectGroupsPopup: Em.computed.and('!selectedConfigGroup.isDefault', 'selectedService.dependentServiceNames.length'),
/**
* set default values for dependentGroups
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js b/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js
index a073fbd..1825908 100644
--- a/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js
+++ b/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js
@@ -146,7 +146,7 @@ App.BaseUnitConvertMixin = Em.Mixin.create({
else {
return value.map(function(item) {
return self._convertToSingleValue(item.value, item.type, toUnit[0]);
- }).reduce(Em.sum);
+ }).reduce(Em.sum, 0);
}
}
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 3e3325f..3b38abb 100644
--- a/ambari-web/app/models/alerts/alert_config.js
+++ b/ambari-web/app/models/alerts/alert_config.js
@@ -104,10 +104,7 @@ App.AlertConfigProperty = Ember.Object.extend({
* if false - label is shown after input
* @type {Boolean}
*/
- isPreLabeled: function () {
- var afterLabeledTypes = ['radioButton'];
- return !afterLabeledTypes.contains(this.get('displayType'));
- }.property('displayType'),
+ isPreLabeled: Em.computed.notExistsIn('displayType', ['radioButton']),
/**
* value converted to appropriate format for sending to server
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 adf7323..9033169 100644
--- a/ambari-web/app/models/alerts/alert_definition.js
+++ b/ambari-web/app/models/alerts/alert_definition.js
@@ -132,9 +132,7 @@ App.AlertDefinition = DS.Model.extend({
* Formatted displayName for <code>componentName</code>
* @type {String}
*/
- componentNameFormatted: function () {
- return App.format.role(this.get('componentName'));
- }.property('componentName'),
+ componentNameFormatted: Em.computed.formatRole('componentName'),
/**
* Status generates from child-alerts
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/alerts/alert_instance.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_instance.js b/ambari-web/app/models/alerts/alert_instance.js
index f80b859..20f4560 100644
--- a/ambari-web/app/models/alerts/alert_instance.js
+++ b/ambari-web/app/models/alerts/alert_instance.js
@@ -131,11 +131,7 @@ App.AlertInstance = DS.Model.extend({
* Formatted lastChecked and lastTriggered timestamp
* @returns {string}
*/
- statusChangedAndLastCheckedFormatted: function () {
- var lastCheckedFormatted = this.get('lastCheckedFormatted');
- var lastTriggeredFormatted = this.get('lastTriggeredFormatted');
- return Em.I18n.t('models.alert_definition.triggered.checked').format(lastTriggeredFormatted, lastCheckedFormatted);
- }.property('lastCheckedFormatted', 'lastTriggeredFormatted'),
+ statusChangedAndLastCheckedFormatted: Em.computed.i18nFormat('models.alert_definition.triggered.checked', 'lastTriggeredFormatted', 'lastCheckedFormatted'),
/**
* List of css-classes for alert instance status
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/cluster_states.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster_states.js b/ambari-web/app/models/cluster_states.js
index bdf60e6..8641f1f 100644
--- a/ambari-web/app/models/cluster_states.js
+++ b/ambari-web/app/models/cluster_states.js
@@ -83,10 +83,7 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
* Is cluster installed
* @type {bool}
*/
- isInstalled: function () {
- var notInstalledStates = ['CLUSTER_NOT_CREATED_1', 'CLUSTER_DEPLOY_PREP_2', 'CLUSTER_INSTALLING_3', 'SERVICE_STARTING_3'];
- return !notInstalledStates.contains(this.get('clusterState'));
- }.property('clusterState'),
+ isInstalled: Em.computed.notExistsIn('clusterState', ['CLUSTER_NOT_CREATED_1', 'CLUSTER_DEPLOY_PREP_2', 'CLUSTER_INSTALLING_3', 'SERVICE_STARTING_3']),
/**
* General info about cluster
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 c204774..840d54f 100644
--- a/ambari-web/app/models/configs/config_group.js
+++ b/ambari-web/app/models/configs/config_group.js
@@ -138,9 +138,7 @@ App.ServiceConfigGroup = DS.Model.extend({
return availableHosts;
}.property('isDefault', 'parentConfigGroup', 'childConfigGroups', 'parentConfigGroup.hosts.@each', 'clusterHosts'),
- isAddHostsDisabled: function () {
- return (this.get('isDefault') || this.get('availableHosts.length') === 0);
- }.property('availableHosts.length'),
+ isAddHostsDisabled: Em.computed.or('isDefault', '!availableHosts.length'),
/**
* @type {Array}
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/configs/objects/service_config_category.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config_category.js b/ambari-web/app/models/configs/objects/service_config_category.js
index bac0be8..c351d97 100644
--- a/ambari-web/app/models/configs/objects/service_config_category.js
+++ b/ambari-web/app/models/configs/objects/service_config_category.js
@@ -56,17 +56,10 @@ App.ServiceConfigCategory = Ember.Object.extend({
}.property('name'),
- isForMasterComponent: function () {
- var masterServices = [ 'NameNode', 'SNameNode', 'JobTracker', 'HBase Master', 'Oozie Master',
- 'Hive Metastore', 'WebHCat Server', 'ZooKeeper Server', 'Ganglia' ];
+ isForMasterComponent: Em.computed.existsIn('name', ['NameNode', 'SNameNode', 'JobTracker', 'HBase Master', 'Oozie Master',
+ 'Hive Metastore', 'WebHCat Server', 'ZooKeeper Server', 'Ganglia']),
- return (masterServices.contains(this.get('name')));
- }.property('name'),
-
- isForSlaveComponent: function () {
- var slaveComponents = ['DataNode', 'TaskTracker', 'RegionServer'];
- return (slaveComponents.contains(this.get('name')));
- }.property('name'),
+ isForSlaveComponent: Em.computed.existsIn('name', ['DataNode', 'TaskTracker', 'RegionServer']),
slaveErrorCount: function () {
var length = 0;
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 812ebb2..5e23735 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -124,10 +124,8 @@ App.ServiceConfigProperty = Em.Object.extend({
isRequired: true, // by default a config property is required
isReconfigurable: true, // by default a config property is reconfigurable
isEditable: true, // by default a config property is editable
- isNotEditable: Ember.computed.not('isEditable'),
- hideFinalIcon: function () {
- return (!this.get('isFinal')) && this.get('isNotEditable');
- }.property('isFinal', 'isNotEditable'),
+ isNotEditable: Em.computed.not('isEditable'),
+ hideFinalIcon: Em.computed.and('!isFinal', 'isNotEditable'),
isVisible: true,
isMock: false, // mock config created created only to displaying
isRequiredByAgent: true, // Setting it to true implies property will be stored in configuration
@@ -276,9 +274,7 @@ App.ServiceConfigProperty = Em.Object.extend({
/**
* Don't show "Undo" for hosts on Installer Step7
*/
- cantBeUndone: function() {
- return ["componentHost", "componentHosts", "radio button"].contains(this.get('displayType'));
- }.property('displayType'),
+ cantBeUndone: Em.computed.existsIn('displayType', ["componentHost", "componentHosts", "radio button"]),
isValid: Em.computed.equal('errorMessage', ''),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/configs/service_config_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/service_config_version.js b/ambari-web/app/models/configs/service_config_version.js
index ed7e9b3..36cd572 100644
--- a/ambari-web/app/models/configs/service_config_version.js
+++ b/ambari-web/app/models/configs/service_config_version.js
@@ -23,9 +23,7 @@ var dateUtil = require('utils/date/date');
App.ServiceConfigVersion = DS.Model.extend({
serviceName: DS.attr('string'),
- displayName: function() {
- return App.format.role(this.get('serviceName'));
- }.property('serviceName'),
+ displayName: Em.computed.formatRole('serviceName'),
groupName: DS.attr('string'),
groupId: DS.attr('number'),
version: DS.attr('number'),
@@ -40,13 +38,9 @@ App.ServiceConfigVersion = DS.Model.extend({
isDisplayed: DS.attr('boolean'),
stackVersion: DS.attr('string'),
isCompatible: DS.attr('boolean'),
- canBeMadeCurrent: function () {
- return this.get('isCompatible') && !this.get('isCurrent');
- }.property('isCurrent', 'isCompatible'),
+ canBeMadeCurrent: Em.computed.and('isCompatible', '!isCurrent'),
isDefault: Em.computed.equal('groupName', 'default'),
- currentTooltip: function () {
- return Em.I18n.t('dashboard.configHistory.table.current.tooltip').format(this.get('displayName'), this.get('configGroupName'));
- }.property('displayName', 'configGroupName'),
+ currentTooltip: Em.computed.i18nFormat('dashboard.configHistory.table.current.tooltip', 'displayName', 'configGroupName'),
configGroupName: function () {
return this.get('isDefault') ? Em.I18n.t('common.default') : this.get('groupName');
}.property('groupName','isDefault'),
@@ -65,12 +59,8 @@ App.ServiceConfigVersion = DS.Model.extend({
moreNotesExists: function () {
return (typeof this.get('notes') === 'string') ? this.get('notes').length > 80 : false;
}.property('notes'),
- versionText: function () {
- return Em.I18n.t('dashboard.configHistory.table.version.versionText').format(this.get('version'));
- }.property('version'),
- makeCurrentButtonText: function() {
- return Em.I18n.t('dashboard.configHistory.info-bar.revert.versionButton').format(this.get('versionText'));
- }.property('versionText'),
+ versionText: Em.computed.i18nFormat('dashboard.configHistory.table.version.versionText', 'version'),
+ makeCurrentButtonText: Em.computed.i18nFormat('dashboard.configHistory.info-bar.revert.versionButton', 'versionText'),
createdDate: function () {
return dateUtil.dateFormat(this.get('createTime'));
}.property('createTime'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/configs/theme/section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/theme/section.js b/ambari-web/app/models/configs/theme/section.js
index 4df0e2e..449dd6c 100644
--- a/ambari-web/app/models/configs/theme/section.js
+++ b/ambari-web/app/models/configs/theme/section.js
@@ -78,11 +78,11 @@ App.Section = DS.Model.extend({
*/
errorsCount: function () {
var errors = this.get('subSections').filterProperty('isSectionVisible').mapProperty('errorsCount');
- return errors.length ? errors.reduce(Em.sum) : 0;
+ return errors.length ? errors.reduce(Em.sum, 0) : 0;
}.property('subSections.@each.errorsCount', 'subSections.@each.isSectionVisible'),
/**
- * @type {boolean}/
+ * @type {boolean}
*/
isFirstRow: Em.computed.equal('rowIndex', 0),
@@ -123,9 +123,7 @@ App.Section = DS.Model.extend({
* Determines if section is filtered out (all it's subsections should be hidden)
* @type {boolean}
*/
- isHiddenByFilter: function () {
- return !this.get('subSections').someProperty('isSectionVisible', true);
- }.property('subSections.@each.isHiddenByFilter')
+ isHiddenByFilter: Em.computed.everyBy('subSections', 'isSectionVisible', false)
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/configs/theme/sub_section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/theme/sub_section.js b/ambari-web/app/models/configs/theme/sub_section.js
index f813b4e..c89500d 100644
--- a/ambari-web/app/models/configs/theme/sub_section.js
+++ b/ambari-web/app/models/configs/theme/sub_section.js
@@ -100,7 +100,7 @@ App.SubSection = DS.Model.extend({
*/
errorsCount: function () {
var visibleTabs = this.get('subSectionTabs').filterProperty('isVisible');
- var subSectionTabsErrors = visibleTabs.length ? visibleTabs.mapProperty('errorsCount').reduce(function(p, c) { return p + c; }) : 0;
+ var subSectionTabsErrors = visibleTabs.length ? visibleTabs.mapProperty('errorsCount').reduce(Em.sum, 0) : 0;
return subSectionTabsErrors + this.get('configs').filter(function(config) {
return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false));
}).length;
@@ -109,9 +109,7 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- addLeftVerticalSplitter: function() {
- return !this.get('isFirstColumn') && this.get('leftVerticalSplitter');
- }.property('isFirstColumn', 'leftVerticalSplitter'),
+ addLeftVerticalSplitter: Em.computed.and('!isFirstColumn', 'leftVerticalSplitter'),
/**
* @type {boolean}
@@ -121,9 +119,7 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- showTopSplitter: function() {
- return !this.get('isFirstRow') && !this.get('border');
- }.property('isFirstRow', 'border'),
+ showTopSplitter: Em.computed.and('!isFirstRow', '!border'),
/**
* @type {boolean}
@@ -181,12 +177,16 @@ App.SubSection = DS.Model.extend({
}.property('configs.@each.isHiddenByFilter'),
/**
+ * @type {boolean}
+ */
+ someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true),
+
+ /**
* Determines if subsection is visible
* @type {boolean}
*/
- isSectionVisible: function () {
- return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('configs').someProperty('isVisible', true);
- }.property('isHiddenByFilter', 'configs.@each.isVisible', 'isHiddenByConfig')
+ isSectionVisible: Em.computed.and('!isHiddenByFilter', '!isHiddenByConfig', 'someConfigIsVisible')
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/configs/theme/sub_section_tab.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/theme/sub_section_tab.js b/ambari-web/app/models/configs/theme/sub_section_tab.js
index f78f39e..7550f23 100644
--- a/ambari-web/app/models/configs/theme/sub_section_tab.js
+++ b/ambari-web/app/models/configs/theme/sub_section_tab.js
@@ -83,12 +83,16 @@ App.SubSectionTab = DS.Model.extend({
}.property('configs.@each.isHiddenByFilter'),
/**
+ * @type {boolean}
+ */
+ someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true),
+
+ /**
* Determines if subsection is visible
* @type {boolean}
*/
- isVisible: function () {
- return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('configs').someProperty('isVisible', true);
- }.property('isHiddenByFilter', 'isHiddenByConfig', 'configs.@each.isVisible')
+ isVisible: Em.computed.and('!isHiddenByFilter', '!isHiddenByConfig', 'someConfigIsVisible')
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 54ae579..cf98e86 100644
--- a/ambari-web/app/models/configs/theme/tab.js
+++ b/ambari-web/app/models/configs/theme/tab.js
@@ -39,10 +39,7 @@ App.Tab = DS.Model.extend({
* Number of the errors in all sections in the current tab
* @type {number}
*/
- errorsCount: function () {
- var errors = this.get('sections').mapProperty('errorsCount');
- return errors.length ? errors.reduce(Em.sum) : 0;
- }.property('sections.@each.errorsCount'),
+ errorsCount: Em.computed.sumBy('sections', 'errorsCount'),
/**
* Class name used for tab switching
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index c9be63d..487806a 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -137,9 +137,7 @@ App.Host = DS.Model.extend({
* Percent value of used disk space
* @returns {Number}
*/
- diskUsage: function() {
- return (this.get('diskUsed')) / this.get('diskTotal') * 100;
- }.property('diskUsed', 'diskTotal'),
+ diskUsage: Em.computed.percents('diskUsed', 'diskTotal', 2),
/**
* Format diskUsage to float with 2 digits
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js
index 203eff2..da87071 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -49,17 +49,13 @@ App.HostComponent = DS.Model.extend({
* Based on <code>workStatus</code>
* @returns {bool}
*/
- isRunning: function () {
- return (this.get('workStatus') == 'STARTED' || this.get('workStatus') == 'STARTING');
- }.property('workStatus'),
+ isRunning: Em.computed.existsIn('workStatus', ['STARTED', 'STARTING']),
/**
* Formatted <code>componentName</code>
* @returns {String}
*/
- displayName: function () {
- return App.format.role(this.get('componentName'));
- }.property('componentName'),
+ displayName: Em.computed.formatRole('componentName'),
/**
* Determine if component is master
@@ -109,11 +105,7 @@ App.HostComponent = DS.Model.extend({
*/
isActive: Em.computed.equal('passiveState', 'OFF'),
- passiveTooltip: function () {
- if (!this.get('isActive')) {
- return Em.I18n.t('hosts.component.passive.mode');
- }
- }.property('isActive'),
+ passiveTooltip: Em.computed.ifThenElse('isActive', '', Em.I18n.t('hosts.component.passive.mode')),
statusClass: function () {
return this.get('isActive') ? this.get('workStatus') : 'icon-medkit';
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/host_stack_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_stack_version.js b/ambari-web/app/models/host_stack_version.js
index 8962552..b0c000e 100644
--- a/ambari-web/app/models/host_stack_version.js
+++ b/ambari-web/app/models/host_stack_version.js
@@ -57,9 +57,7 @@ App.HostStackVersion = DS.Model.extend({
/**
* @type {boolean}
*/
- installEnabled: function () {
- return ['OUT_OF_SYNC', 'INSTALL_FAILED'].contains(this.get('status'));
- }.property('status'),
+ installEnabled: Em.computed.existsIn('status', ['OUT_OF_SYNC', 'INSTALL_FAILED']),
installDisabled: Em.computed.not('installEnabled')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/root_service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/root_service.js b/ambari-web/app/models/root_service.js
index af42a1f..b5d703b 100644
--- a/ambari-web/app/models/root_service.js
+++ b/ambari-web/app/models/root_service.js
@@ -25,9 +25,7 @@ var App = require('app');
*/
App.RootService = DS.Model.extend({
serviceName: DS.attr('string'),
- displayName: function() {
- return App.format.role(this.get('serviceName'));
- }.property('serviceName'),
+ displayName: Em.computed.formatRole('serviceName'),
components: DS.hasMany('App.RootServiceComponents')
});
@@ -35,9 +33,7 @@ App.RootService.FIXTURES = [];
App.RootServiceComponents = DS.Model.extend({
componentName: DS.attr('string'),
- displayName: function() {
- return App.format.role(this.get('componentName'));
- }.property('componentName'),
+ displayName: Em.computed.formatRole('componentName'),
componentVersion: DS.attr('string'),
serverClock: DS.attr('number'),
serviceName: DS.attr('string'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index ddec4f9..27647a0 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -22,9 +22,7 @@ require('utils/config');
App.Service = DS.Model.extend({
serviceName: DS.attr('string'),
- displayName: function() {
- return App.format.role(this.get('serviceName'));
- }.property('serviceName'),
+ displayName: Em.computed.formatRole('serviceName'),
passiveState: DS.attr('string'),
workStatus: DS.attr('string'),
rand: DS.attr('string'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/stack_service_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_service_component.js b/ambari-web/app/models/stack_service_component.js
index 1321d11..bb18cc4 100644
--- a/ambari-web/app/models/stack_service_component.js
+++ b/ambari-web/app/models/stack_service_component.js
@@ -127,9 +127,7 @@ App.StackServiceComponent = DS.Model.extend({
*
* @property {Boolean} isMasterAddableInstallerWizard
**/
- isMasterAddableInstallerWizard: function() {
- return this.get('isMaster') && this.get('isMultipleAllowed') && !this.get('isMasterAddableOnlyOnHA') && !this.get('isNotAddableOnlyInInstall');
- }.property('componentName'),
+ isMasterAddableInstallerWizard: Em.computed.and('isMaster', 'isMultipleAllowed', '!isMasterAddableOnlyOnHA', '!isNotAddableOnlyInInstall'),
/**
* Master components with cardinality more than 1 (n+ or n-n) that could not be added in wizards
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 9dc1bc6..566c4f2 100644
--- a/ambari-web/app/models/stack_version/repository_version.js
+++ b/ambari-web/app/models/stack_version/repository_version.js
@@ -26,9 +26,7 @@ App.RepositoryVersion = DS.Model.extend({
stackVersionNumber: DS.attr('string'),
operatingSystems: DS.hasMany('App.OS'),
stackVersion: DS.belongsTo('App.StackVersion'),
- stack: function () {
- return this.get('stackVersionType') + " " + this.get('stackVersionNumber');
- }.property('stackVersionType', 'stackVersionNumber'),
+ stack: Em.computed.concat(' ', 'stackVersionType', 'stackVersionNumber'),
/**
* status used until corresponding stack version get created
@@ -39,9 +37,7 @@ App.RepositoryVersion = DS.Model.extend({
/**
* @type {string}
*/
- status: function () {
- return this.get('stackVersion.state') || this.get('defaultStatus');
- }.property('stackVersion.state', 'defaultStatus'),
+ status: Em.computed.firstNotBlank('stackVersion.state', 'defaultStatus'),
/**
* @type {Array}
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/stack_version/version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/version.js b/ambari-web/app/models/stack_version/version.js
index 9b1167d..3f2fe37 100644
--- a/ambari-web/app/models/stack_version/version.js
+++ b/ambari-web/app/models/stack_version/version.js
@@ -22,9 +22,7 @@ App.StackVersion = DS.Model.extend({
clusterName: DS.attr('string'),
stack: DS.attr('string'),
version: DS.attr('string'),
- name: function() {
- return this.get('stack') + " " + this.get('version');
- }.property('stack', 'version'),
+ name: Em.computed.concat(' ', 'stack', 'version'),
state: DS.attr('string'),
repositoryVersion: DS.belongsTo('App.RepositoryVersion'),
notInstalledHosts: DS.attr('array'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/models/widget_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/widget_property.js b/ambari-web/app/models/widget_property.js
index 5d1563f..0b7e414 100644
--- a/ambari-web/app/models/widget_property.js
+++ b/ambari-web/app/models/widget_property.js
@@ -220,8 +220,6 @@ App.WidgetPropertyTypes = [
return validator.isValidFloat(value) && value > this.get('MIN_VALUE') && value <= this.get('MAX_VALUE');
},
- isValid: function () {
- return this.get('isSmallValueValid') && this.get('isBigValueValid') ;
- }.property( 'isSmallValueValid', 'isBigValueValid')
+ isValid: Em.computed.and('isSmallValueValid', 'isBigValueValid')
}
];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/utils/ember_computed.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_computed.js b/ambari-web/app/utils/ember_computed.js
index 4ae8c5b..c996f32 100644
--- a/ambari-web/app/utils/ember_computed.js
+++ b/ambari-web/app/utils/ember_computed.js
@@ -270,7 +270,7 @@ computed.sumProperties = generateComputedWithProperties(function (properties) {
var sum = 0;
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
- sum += properties[key];
+ sum += Number(properties[key]);
}
}
return sum;
@@ -399,6 +399,9 @@ computed.ltProperties = function (dependentKey1, dependentKey2) {
computed.match = function (dependentKey, regexp) {
return computed(dependentKey, function () {
var value = get(this, dependentKey);
+ if (!regexp) {
+ return false;
+ }
return regexp.test(value);
});
};
@@ -414,7 +417,11 @@ computed.match = function (dependentKey, regexp) {
*/
computed.someBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- return get(this, collectionKey).someProperty(propertyName, neededValue);
+ var collection = get(this, collectionKey);
+ if (!collection) {
+ return false;
+ }
+ return collection.someProperty(propertyName, neededValue);
});
};
@@ -429,7 +436,11 @@ computed.someBy = function (collectionKey, propertyName, neededValue) {
*/
computed.everyBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- return get(this, collectionKey).everyProperty(propertyName, neededValue);
+ var collection = get(this, collectionKey);
+ if (!collection) {
+ return false;
+ }
+ return collection.everyProperty(propertyName, neededValue);
});
};
@@ -443,7 +454,11 @@ computed.everyBy = function (collectionKey, propertyName, neededValue) {
*/
computed.mapBy = function (collectionKey, propertyName) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- return get(this, collectionKey).mapProperty(propertyName);
+ var collection = get(this, collectionKey);
+ if (!collection) {
+ return [];
+ }
+ return collection.mapProperty(propertyName);
});
};
@@ -458,7 +473,11 @@ computed.mapBy = function (collectionKey, propertyName) {
*/
computed.filterBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- return get(this, collectionKey).filterProperty(propertyName, neededValue);
+ var collection = get(this, collectionKey);
+ if (!collection) {
+ return [];
+ }
+ return collection.filterProperty(propertyName, neededValue);
});
};
@@ -473,7 +492,11 @@ computed.filterBy = function (collectionKey, propertyName, neededValue) {
*/
computed.findBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- return get(this, collectionKey).findProperty(propertyName, neededValue);
+ var collection = get(this, collectionKey);
+ if (!collection) {
+ return null;
+ }
+ return collection.findProperty(propertyName, neededValue);
});
};
@@ -537,8 +560,8 @@ computed.percents = function (dependentKey1, dependentKey2, accuracy) {
accuracy = 0;
}
return computed(dependentKey1, dependentKey2, function () {
- var v1 = get(this, dependentKey1);
- var v2 = get(this, dependentKey2);
+ var v1 = Number(get(this, dependentKey1));
+ var v2 = Number(get(this, dependentKey2));
var result = v1 / v2 * 100;
if (0 === accuracy) {
return Math.round(result);
@@ -577,7 +600,7 @@ computed.sumBy = function (collectionKey, propertyName) {
}
var sum = 0;
collection.forEach(function (item) {
- sum += get(item, propertyName);
+ sum += Number(get(item, propertyName));
});
return sum;
});
@@ -594,6 +617,9 @@ computed.sumBy = function (collectionKey, propertyName) {
*/
computed.i18nFormat = generateComputedWithKey(function (key, dependentValues) {
var str = Em.I18n.t(key);
+ if (!str) {
+ return '';
+ }
return str.format.apply(str, dependentValues);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/ajax_default_error_popup_body.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/ajax_default_error_popup_body.js b/ambari-web/app/views/common/ajax_default_error_popup_body.js
index 60bff17..35fb68b 100644
--- a/ambari-web/app/views/common/ajax_default_error_popup_body.js
+++ b/ambari-web/app/views/common/ajax_default_error_popup_body.js
@@ -51,9 +51,7 @@ App.AjaxDefaultErrorPopupBodyView = Em.View.extend({
* Status code string
* @type {string}
*/
- statusCode: function () {
- return Em.I18n.t('utils.ajax.defaultErrorPopupBody.statusCode').format(this.get('status'));
- }.property('status'),
+ statusCode: Em.computed.i18nFormat('utils.ajax.defaultErrorPopupBody.statusCode', 'status'),
/**
* Indicates if error message should be displayed
@@ -65,8 +63,6 @@ App.AjaxDefaultErrorPopupBodyView = Em.View.extend({
* HTTP response error description
* @type {string}
*/
- api: function () {
- return Em.I18n.t('utils.ajax.defaultErrorPopupBody.message').format(this.get('type'), this.get('url'));
- }.property('type', 'url')
+ api: Em.computed.i18nFormat('utils.ajax.defaultErrorPopupBody.message', 'type', 'url')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 efea946..4b12bdd 100644
--- a/ambari-web/app/views/common/chart/linear_time.js
+++ b/ambari-web/app/views/common/chart/linear_time.js
@@ -171,9 +171,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
return '#' + this.get('id') + '-container';
}.property('id'),
- _popupSelector: function () {
- return this.get('_containerSelector') + this.get('popupSuffix');
- }.property('_containerSelector', 'popupSuffix'),
+ _popupSelector: Em.computed.concat('', '_containerSelector', 'popupSuffix'),
didInsertElement: function () {
var self = this;
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 0bc09f3..f52e4c9 100644
--- a/ambari-web/app/views/common/chart/pie.js
+++ b/ambari-web/app/views/common/chart/pie.js
@@ -34,9 +34,7 @@ App.ChartPieView = Em.View.extend({
return Math.min(this.get('w'), this.get('h')) / 2 - this.get('strokeWidth');
}.property('w', 'h'),
- outerR:function () {
- return this.get('r'); // - 10;
- }.property('r'),
+ outerR: Em.computed.alias('r'),
innerR:function () {
return 0; // this.get('r') - 20;
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/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 89f0c03..bbc7438 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -69,15 +69,11 @@ App.ConfigHistoryFlowView = Em.View.extend({
return !Em.isNone(this.get('compareServiceVersion'));
}.property('compareServiceVersion'),
- isSaveDisabled: function () {
- return (this.get('controller.isSubmitDisabled') || !this.get('controller.versionLoaded') || !this.get('controller.isPropertiesChanged')) ;
- }.property('controller.isSubmitDisabled', 'controller.versionLoaded', 'controller.isPropertiesChanged'),
+ isSaveDisabled: Em.computed.or('controller.isSubmitDisabled', '!controller.versionLoaded', '!controller.isPropertiesChanged'),
serviceName: Em.computed.alias('controller.selectedService.serviceName'),
- displayedServiceVersion: function () {
- return this.get('serviceVersions').findProperty('isDisplayed');
- }.property('serviceVersions.@each.isDisplayed'),
+ displayedServiceVersion: Em.computed.findBy('serviceVersions', 'isDisplayed', true),
/**
* identify whether to show link that open whole content of notes
*/
@@ -128,16 +124,12 @@ App.ConfigHistoryFlowView = Em.View.extend({
/**
* enable actions to manipulate version only after it's loaded
*/
- versionActionsDisabled: function () {
- return !this.get('controller.versionLoaded') || this.get('dropDownList.length') === 0;
- }.property('controller.versionLoaded', 'dropDownList.length'),
+ versionActionsDisabled: Em.computed.or('!controller.versionLoaded', '!dropDownList.length'),
/**
* enable discard to manipulate version only after it's loaded and any property is changed
*/
- isDiscardDisabled: function () {
- return !this.get('controller.versionLoaded') || !this.get('controller.isPropertiesChanged');
- }.property('controller.versionLoaded','controller.isPropertiesChanged'),
+ isDiscardDisabled: Em.computed.or('!controller.versionLoaded', '!controller.isPropertiesChanged'),
/**
* list of service versions
* by default 6 is number of items in short list
@@ -526,17 +518,9 @@ App.ConfigsServiceVersionBoxView = Em.View.extend({
actionTypesBinding: 'parentView.actionTypes',
- disabledActionAttr: function() {
- if (this.get('serviceVersion')) {
- return this.get('serviceVersion').get('disabledActionAttr');
- }
- }.property('serviceVersion.disabledActionAttr'),
+ disabledActionAttr: Em.computed.alias('serviceVersion.disabledActionAttr'),
- disabledActionMessages: function() {
- if (this.get('serviceVersion')) {
- return this.get('serviceVersion').get('disabledActionMessages');
- }
- }.property('serviceVersion.disabledActionMessages'),
+ disabledActionMessages: Em.computed.alias('serviceVersion.disabledActionMessages'),
templateName: require('templates/common/configs/service_version_box'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/configs/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/controls_view.js b/ambari-web/app/views/common/configs/controls_view.js
index 8096f64..6232a27 100644
--- a/ambari-web/app/views/common/configs/controls_view.js
+++ b/ambari-web/app/views/common/configs/controls_view.js
@@ -29,9 +29,7 @@ App.ControlsView = Ember.View.extend({
return App.isAccessible('ADMIN') && this.get('serviceConfigProperty.isEditable') && this.get('serviceConfigProperty.isRequiredByAgent') && !this.get('serviceConfigProperty.isComparison');
}.property('serviceConfigProperty.isEditable', 'serviceConfigProperty.isRequiredByAgent', 'serviceConfigProperty.isComparison'),
- showSwitchToGroup: function() {
- return !this.get('serviceConfigProperty.isEditable') && this.get('serviceConfigProperty.group');
- }.property('showActions', 'serviceConfigProperty.group'),
+ showSwitchToGroup: Em.computed.and('!serviceConfigProperty.isEditable', 'serviceConfigProperty.group'),
showIsFinal: Em.computed.alias('serviceConfigProperty.supportsFinal'),
@@ -39,9 +37,7 @@ App.ControlsView = Ember.View.extend({
showOverride: Em.computed.and('showActions', 'serviceConfigProperty.isPropertyOverridable'),
- showUndo: function() {
- return this.get('showActions') && !this.get('serviceConfigProperty.cantBeUndone') && this.get('serviceConfigProperty.isNotDefaultValue');
- }.property('showActions', 'serviceConfigProperty.cantBeUndone', 'serviceConfigProperty.isNotDefaultValue'),
+ showUndo: Em.computed.and('showActions', '!serviceConfigProperty.cantBeUndone', 'serviceConfigProperty.isNotDefaultValue'),
showSetRecommended: Em.computed.and('showActions', 'serviceConfigProperty.recommendedValueExists')
http://git-wip-us.apache.org/repos/asf/ambari/blob/44e59558/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js b/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
index 9b8bb5f..9e34bd3 100644
--- a/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
+++ b/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
@@ -51,9 +51,7 @@ App.NotificationsConfigsView = App.ServiceConfigsByCategoryView.extend({
* Config with flag for user auth in the notification
* @type {App.ServiceConfigProperty}
*/
- useAuthConfig: function () {
- return this.get('categoryConfigs').findProperty('name', 'smtp_use_auth');
- }.property(),
+ useAuthConfig: Em.computed.findBy('categoryConfigs', 'name', 'smtp_use_auth'),
/**
* Empty categoryConfigsAll means that user isn't at Installer, so manage notification view shouldn't be processed