You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/11/18 17:51:45 UTC
[49/50] [abbrv] ambari git commit: AMBARI-13950. Apply created
Em.computed macros to ambari-web models/mixins (onechiporenko)
AMBARI-13950. Apply created Em.computed macros to ambari-web models/mixins (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/779b4f9d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/779b4f9d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/779b4f9d
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 779b4f9d51fe3a0e523e5577477209e05f84b52d
Parents: 177a91f
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Nov 18 18:38:44 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Nov 18 18:38:44 2015 +0200
----------------------------------------------------------------------
.../mixins/common/table_server_view_mixin.js | 16 ++-----
.../app/mixins/common/widgets/widget_mixin.js | 4 +-
.../details/host_components/decommissionable.js | 4 +-
.../main/service/configs/config_overridable.js | 8 +---
.../mixins/wizard/assign_master_components.js | 4 +-
.../wizard/wizardProgressPageController.js | 4 +-
.../app/mixins/wizard/wizardProgressPageView.js | 8 +---
ambari-web/app/models/alerts/alert_config.js | 4 +-
.../app/models/alerts/alert_definition.js | 35 ++++++--------
ambari-web/app/models/alerts/alert_group.js | 5 +-
ambari-web/app/models/alerts/alert_instance.js | 4 +-
ambari-web/app/models/authentication.js | 13 ++----
ambari-web/app/models/cluster.js | 4 +-
.../app/models/configs/config_property.js | 20 ++------
.../configs/objects/service_config_category.js | 4 +-
.../configs/objects/service_config_property.js | 4 +-
.../models/configs/service_config_version.js | 4 +-
.../app/models/configs/stack_config_property.js | 4 +-
ambari-web/app/models/configs/theme/section.js | 10 ++--
.../app/models/configs/theme/sub_section.js | 22 +++------
ambari-web/app/models/configs/theme/tab.js | 4 +-
ambari-web/app/models/form.js | 12 ++---
ambari-web/app/models/host.js | 12 ++---
ambari-web/app/models/host_component.js | 4 +-
ambari-web/app/models/host_stack_version.js | 15 ++----
ambari-web/app/models/repository.js | 13 ++----
ambari-web/app/models/service.js | 13 ++----
ambari-web/app/models/service/yarn.js | 4 +-
ambari-web/app/models/stack_service.js | 43 ++++-------------
.../app/models/stack_service_component.js | 49 +++++---------------
.../models/stack_version/repository_version.js | 12 ++---
ambari-web/app/models/stack_version/version.js | 16 ++-----
ambari-web/app/models/upgrade_entity.js | 8 +---
ambari-web/app/models/user.js | 8 +---
.../test/models/alerts/alert_definition_test.js | 34 ++++++++++++++
35 files changed, 142 insertions(+), 286 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/common/table_server_view_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_view_mixin.js b/ambari-web/app/mixins/common/table_server_view_mixin.js
index b1dabb2..674042f 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -32,29 +32,21 @@ App.TableServerViewMixin = Em.Mixin.create({
/**
* count of filtered items
*/
- filteredCount: function () {
- return this.get('controller.filteredCount');
- }.property('controller.filteredCount'),
+ filteredCount: Em.computed.alias('controller.filteredCount'),
/**
* total count of items
*/
- totalCount: function () {
- return this.get('controller.totalCount');
- }.property('controller.totalCount'),
+ totalCount: Em.computed.alias('controller.totalCount'),
/**
* data requested from server
*/
- content: function () {
- return this.get('controller.content');
- }.property('controller.content'),
+ content: Em.computed.alias('controller.content'),
/**
* content already filtered on server-side
*/
- filteredContent: function () {
- return this.get('content');
- }.property('content'),
+ filteredContent: Em.computed.alias('content'),
/**
* sort and slice recieved content by pagination parameters
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/common/widgets/widget_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index c2c7f47..8c920f7 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -81,9 +81,7 @@ App.WidgetMixin = Ember.Mixin.create({
* color of content calculated by thresholds
* @type {string}
*/
- contentColor: function () {
- return this.get('value') ? 'green' : 'grey';
- }.property('value'),
+ contentColor: Em.computed.ifThenElse('value', 'green', 'grey'),
beforeRender: function () {
this.get('metrics').clear();
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
index b99cea7..9febc51 100644
--- a/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
+++ b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
@@ -309,9 +309,7 @@ App.Decommissionable = Em.Mixin.create({
templateName: require('templates/main/host/decommission'),
- text: function () {
- return this.get('parentView.isComponentDecommissionAvailable') ? Em.I18n.t('common.decommission') : Em.I18n.t('common.recommission');
- }.property('parentView.isComponentDecommissionAvailable'),
+ text: Em.computed.ifThenElse('parentView.isComponentDecommissionAvailable', Em.I18n.t('common.decommission'), Em.I18n.t('common.recommission')),
didInsertElement: function () {
this._super();
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index 4de6d0c..fdfa356 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -112,12 +112,8 @@ App.ConfigOverridable = Em.Mixin.create({
warningMessage: ' ',
isWarning: false,
optionSelectConfigGroup: true,
- optionCreateConfigGroup: function () {
- return !this.get('optionSelectConfigGroup');
- }.property('optionSelectConfigGroup'),
- hasExistedGroups: function () {
- return !!this.get('availableConfigGroups').length;
- }.property('availableConfigGroups'),
+ optionCreateConfigGroup: Em.computed.not('optionSelectConfigGroup'),
+ hasExistedGroups: Em.computed.bool('availableConfigGroups.length'),
availableConfigGroups: availableConfigGroups,
selectedConfigGroup: selectedConfigGroup,
newConfigGroupName: '',
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/wizard/assign_master_components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js
index 4d091c3..c22a2db 100644
--- a/ambari-web/app/mixins/wizard/assign_master_components.js
+++ b/ambari-web/app/mixins/wizard/assign_master_components.js
@@ -131,9 +131,7 @@ App.AssignMasterComponents = Em.Mixin.create({
* Check if <code>installerWizard</code> used
* @type {bool}
*/
- isInstallerWizard: function () {
- return this.get('content.controllerName') === 'installerController';
- }.property('content.controllerName'),
+ isInstallerWizard: Em.computed.equal('content.controllerName', 'installerController'),
/**
* Master components which could be assigned to multiple hosts
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/wizard/wizardProgressPageController.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/wizardProgressPageController.js b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
index f2af630..d9c5747 100644
--- a/ambari-web/app/mixins/wizard/wizardProgressPageController.js
+++ b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
@@ -43,9 +43,7 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create(App.InstallComponent, {
completedStatuses: ['COMPLETED', 'FAILED', 'TIMEDOUT', 'ABORTED'],
currentPageRequestId: null,
isSingleRequestPage: false,
- isCommandLevelRetry: function () {
- return !this.get('isSingleRequestPage');
- }.property('isSingleRequestPage'),
+ isCommandLevelRetry: Em.computed.not('isSingleRequestPage'),
showRetry: false,
/**
* Show whether tasks data was loaded
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/mixins/wizard/wizardProgressPageView.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/wizardProgressPageView.js b/ambari-web/app/mixins/wizard/wizardProgressPageView.js
index bc278b9..e3a321c 100644
--- a/ambari-web/app/mixins/wizard/wizardProgressPageView.js
+++ b/ambari-web/app/mixins/wizard/wizardProgressPageView.js
@@ -43,9 +43,7 @@ App.wizardProgressPageViewMixin = Em.Mixin.create({
noticeCompleted: Em.I18n.t('wizard.progressPage.notice.completed'),
- noticeFailed: function() {
- return (this.get('controller.isSingleRequestPage') ? Em.I18n.t('wizard.singleRequest.progressPage.notice.failed') : Em.I18n.t('wizard.progressPage.notice.failed'))
- }.property('controller.isSingleRequestPage'),
+ noticeFailed: Em.computed.ifThenElse('controller.isSingleRequestPage', Em.I18n.t('wizard.singleRequest.progressPage.notice.failed'), Em.I18n.t('wizard.progressPage.notice.failed')),
/**
* @noticeInProgress: Following computed property needs to be overridden to show the label text while the commands
@@ -119,9 +117,7 @@ App.wizardProgressPageViewMixin = Em.Mixin.create({
}
}.observes('content.status', 'content.hosts.length','content.requestIds'),
- showProgressBar: function () {
- return this.get('content.status') === "IN_PROGRESS";
- }.property('content.status')
+ showProgressBar: Em.computed.equal('content.status', 'IN_PROGRESS')
})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 07a9453..3e3325f 100644
--- a/ambari-web/app/models/alerts/alert_config.js
+++ b/ambari-web/app/models/alerts/alert_config.js
@@ -115,9 +115,7 @@ App.AlertConfigProperty = Ember.Object.extend({
* should be defined in child class
* @type {*}
*/
- apiFormattedValue: function () {
- return this.get('value');
- }.property('value'),
+ apiFormattedValue: Em.computed.alias('value'),
/**
* define if property was changed by user
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 e33324b..ec5797e 100644
--- a/ambari-web/app/models/alerts/alert_definition.js
+++ b/ambari-web/app/models/alerts/alert_definition.js
@@ -19,6 +19,13 @@
var App = require('app');
var dateUtils = require('utils/date/date');
+function computedOnSummaryState(state) {
+ return Em.computed('summary.' + state, 'summary.' + state + '.count', 'summary.' + state + '.maintenanceCount', function () {
+ var summary = Em.get(this, 'summary');
+ return !!summary[state] && !!(summary[state].count || summary[state].maintenanceCount);
+ });
+}
+
App.AlertDefinition = DS.Model.extend({
name: DS.attr('string'),
@@ -207,44 +214,28 @@ App.AlertDefinition = DS.Model.extend({
}.property('summary'),
/**
- * if this definition is in state: CRIT
+ * if this definition is in state: CRITICAL
* @type {boolean}
*/
- isCritical: function () {
- var summary = this.get('summary');
- var state = 'CRITICAL';
- return !!summary[state] && !!(summary[state].count || summary[state].maintenanceCount);
- }.property('summary'),
+ isCritical: computedOnSummaryState('CRITICAL'),
/**
* if this definition is in state: WARNING
* @type {boolean}
*/
- isWarning: function () {
- var summary = this.get('summary');
- var state = 'WARNING';
- return !!summary[state] && !!(summary[state].count || summary[state].maintenanceCount);
- }.property('summary'),
+ isWarning: computedOnSummaryState('WARNING'),
/**
* if this definition is in state: OK
* @type {boolean}
*/
- isOK: function () {
- var summary = this.get('summary');
- var state = 'OK';
- return !!summary[state] && !!(summary[state].count || summary[state].maintenanceCount);
- }.property('summary'),
+ isOK: computedOnSummaryState('OK'),
/**
- * if this definition is in state: OK
+ * if this definition is in state: UNKNOWN
* @type {boolean}
*/
- isUnknown: function () {
- var summary = this.get('summary');
- var state = 'UNKNOWN';
- return !!summary[state] && !!(summary[state].count || summary[state].maintenanceCount);
- }.property('summary'),
+ isUnknown: computedOnSummaryState('UNKNOWN'),
/**
* For alerts we will have processes which are not typical
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/alerts/alert_group.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_group.js b/ambari-web/app/models/alerts/alert_group.js
index e914ed5..d8d297b 100644
--- a/ambari-web/app/models/alerts/alert_group.js
+++ b/ambari-web/app/models/alerts/alert_group.js
@@ -70,9 +70,8 @@ App.AlertGroup = DS.Model.extend({
return this.get('displayName') + ' (' + this.get('definitions.length') + ')';
}.property('displayName', 'definitions.length'),
- isAddDefinitionsDisabled: function () {
- return this.get('default');
- }.property('default')
+ isAddDefinitionsDisabled: Em.computed.alias('default')
+
});
App.AlertGroup.FIXTURES = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 60a2723..bec2148 100644
--- a/ambari-web/app/models/alerts/alert_instance.js
+++ b/ambari-web/app/models/alerts/alert_instance.js
@@ -149,9 +149,7 @@ App.AlertInstance = DS.Model.extend({
* Used in some logic in templates to distinguish definitions with Ambari serviceName
* @returns {boolean}
*/
- isAmbariServiceName: function () {
- return this.get('serviceName') === 'AMBARI';
- }.property('serviceName'),
+ isAmbariServiceName: Em.computed.equal('serviceName', 'AMBARI'),
shortState: {
'CRITICAL': 'CRIT',
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/authentication.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/authentication.js b/ambari-web/app/models/authentication.js
index 47ea775..436c184 100644
--- a/ambari-web/app/models/authentication.js
+++ b/ambari-web/app/models/authentication.js
@@ -97,11 +97,8 @@ App.AuthenticationForm = App.Form.extend({
this.set('testResult', parseInt(Math.random() * 2));
return true;
},
- testConfigurationMessage:function () {
- return this.get('testResult') ? Em.I18n.t('admin.authentication.form.test.success') : Em.I18n.t('admin.authentication.form.test.fail');
- }.property('testResult'),
- testConfigurationClass:function () {
- return this.get('testResult') ? "text-success" : "text-error";
- }.property('testConfigurationMessage')
-})
-;
\ No newline at end of file
+ testConfigurationMessage: Em.computed.ifThenElse('testResult', Em.I18n.t('admin.authentication.form.test.success'), Em.I18n.t('admin.authentication.form.test.fail')),
+
+ testConfigurationClass: Em.computed.ifThenElse('testResult', 'text-success', 'text-error')
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/cluster.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster.js b/ambari-web/app/models/cluster.js
index 18ad1ce..a571a28 100644
--- a/ambari-web/app/models/cluster.js
+++ b/ambari-web/app/models/cluster.js
@@ -33,9 +33,7 @@ App.Cluster = DS.Model.extend({
*/
desiredConfigs: null,
- isKerberosEnabled: function() {
- return this.get('securityType') === 'KERBEROS';
- }.property('securityType'),
+ isKerberosEnabled: Em.computed.equal('securityType', 'KERBEROS'),
isCredentialStorePersistent: function() {
return this.get('credentialStoreProperties')[credentialUtils.STORE_TYPES.PERSISTENT_PATH] === "true";
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/configs/config_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/config_property.js b/ambari-web/app/models/configs/config_property.js
index 31ba3f6..bede126 100644
--- a/ambari-web/app/models/configs/config_property.js
+++ b/ambari-web/app/models/configs/config_property.js
@@ -179,26 +179,20 @@ App.ConfigProperty = DS.Model.extend({
* defines if property has errors
* @type {boolean}
*/
- hasErrors: function() {
- return this.get('errorMessage') !== '';
- }.property('errorMessage'),
+ hasErrors: Em.computed.notEqual('errorMessage', ''),
/**
* defines if property has warnings
* @type {boolean}
*/
- hasWarnings: function() {
- return this.get('warnMessage') !== '';
- }.property('warnMessage'),
+ hasWarnings: Em.computed.notEqual('warnMessage', ''),
/**
* defines if property belongs to default config group
* if true it's config group is default
* @type {boolean}
*/
- isOriginalSCP: function() {
- return this.get('configVersion.isDefault');
- }.property('configVersion.isDefault'),
+ isOriginalSCP: Em.computed.alias('configVersion.isDefault'),
/**
* defines if property is added by user
@@ -213,17 +207,13 @@ App.ConfigProperty = DS.Model.extend({
* with which we make comparison
* @property {boolean}
*/
- isForCompare: function() {
- return this.get('configVersion.isForCompare');
- }.property('configVersion.isForCompare'),
+ isForCompare: Em.computed.alias('configVersion.isForCompare'),
/**
* if this property can be final
* @property {boolean}
*/
- supportsFinal: function () {
- return this.get('stackConfigProperty.supportsFinal') || this.get('isUserProperty');
- }.property('stackConfigProperty.supportsFinal', 'isUserProperty'),
+ supportsFinal: Em.computed.or('stackConfigProperty.supportsFinal', 'isUserProperty'),
/**
* Indicates when value is not the default value.
* Returns false when there is no default value.
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 d54241e..bac0be8 100644
--- a/ambari-web/app/models/configs/objects/service_config_category.js
+++ b/ambari-web/app/models/configs/objects/service_config_category.js
@@ -78,9 +78,7 @@ App.ServiceConfigCategory = Ember.Object.extend({
return length;
}.property('slaveConfigs.groups.@each.errorCount'),
- errorCount: function () {
- return this.get('slaveErrorCount') + this.get('nonSlaveErrorCount');
- }.property('slaveErrorCount', 'nonSlaveErrorCount'),
+ errorCount: Em.computed.sumProperties('slaveErrorCount', 'nonSlaveErrorCount'),
isAdvanced : function(){
var name = this.get('name');
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 c078a9e..9bfb9cf 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -280,9 +280,7 @@ App.ServiceConfigProperty = Em.Object.extend({
return ["componentHost", "componentHosts", "radio button"].contains(this.get('displayType'));
}.property('displayType'),
- isValid: function () {
- return this.get('errorMessage') === '';
- }.property('errorMessage'),
+ isValid: Em.computed.equal('errorMessage', ''),
viewClass: function () {
switch (this.get('displayType')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 6020fe6..02aeb92 100644
--- a/ambari-web/app/models/configs/service_config_version.js
+++ b/ambari-web/app/models/configs/service_config_version.js
@@ -42,9 +42,7 @@ App.ServiceConfigVersion = DS.Model.extend({
canBeMadeCurrent: function () {
return this.get('isCompatible') && !this.get('isCurrent');
}.property('isCurrent', 'isCompatible'),
- isDefault: function() {
- return this.get('groupName') === 'default';
- }.property('groupName'),
+ 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'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/configs/stack_config_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/stack_config_property.js b/ambari-web/app/models/configs/stack_config_property.js
index 8451fcf..1083b3f 100644
--- a/ambari-web/app/models/configs/stack_config_property.js
+++ b/ambari-web/app/models/configs/stack_config_property.js
@@ -47,9 +47,7 @@ App.StackConfigProperty = DS.Model.extend({
* same as fileName
* @property {string}
*/
- filename: function() {
- return this.get('fileName');
- }.property('fileName'),
+ filename: Em.computed.alias('fileName'),
/**
* description of config property meaning
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 c04665e..4df0e2e 100644
--- a/ambari-web/app/models/configs/theme/section.js
+++ b/ambari-web/app/models/configs/theme/section.js
@@ -82,11 +82,9 @@ App.Section = DS.Model.extend({
}.property('subSections.@each.errorsCount', 'subSections.@each.isSectionVisible'),
/**
- * @type {boolean}
+ * @type {boolean}/
*/
- isFirstRow: function () {
- return this.get('rowIndex') == 0;
- }.property('rowIndex'),
+ isFirstRow: Em.computed.equal('rowIndex', 0),
/**
* @type {boolean}
@@ -105,9 +103,7 @@ App.Section = DS.Model.extend({
/**
* @type {boolean}
*/
- isFirstColumn: function () {
- return this.get('columnIndex') == 0;
- }.property('columnIndex'),
+ isFirstColumn: Em.computed.equal('columnIndex', 0),
/**
* @type {boolean}
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 eea3802..f813b4e 100644
--- a/ambari-web/app/models/configs/theme/sub_section.js
+++ b/ambari-web/app/models/configs/theme/sub_section.js
@@ -88,13 +88,11 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- hasTabs: function() {
- return this.get('subSectionTabs.length');
- }.property('subSectionTabs.length'),
+ hasTabs: Em.computed.bool('subSectionTabs.length'),
- showTabs: function() {
- return this.get('hasTabs') && this.get('subSectionTabs').someProperty('isVisible');
- }.property('hasTabs','subSectionTabs.@each.isVisible'),
+ someSubSectionTabIsVisible: Em.computed.someBy('subSectionTabs', 'isVisible', true),
+
+ showTabs: Em.computed.and('hasTabs', 'someSubSectionTabIsVisible'),
/**
* Number of the errors in all configs
@@ -118,9 +116,7 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- addRightVerticalSplitter: function() {
- return !this.get('isLastColumn');
- }.property('isLastColumn'),
+ addRightVerticalSplitter: Em.computed.not('isLastColumn'),
/**
* @type {boolean}
@@ -132,9 +128,7 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- isFirstRow: function () {
- return this.get('rowIndex') == 0;
- }.property('rowIndex'),
+ isFirstRow: Em.computed.equal('rowIndex', 0),
/**
* @type {boolean}
@@ -153,9 +147,7 @@ App.SubSection = DS.Model.extend({
/**
* @type {boolean}
*/
- isFirstColumn: function () {
- return this.get('columnIndex') == 0;
- }.property('columnIndex'),
+ isFirstColumn: Em.computed.equal('columnIndex', 0),
/**
* @type {boolean}
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 cb7aeae..54ae579 100644
--- a/ambari-web/app/models/configs/theme/tab.js
+++ b/ambari-web/app/models/configs/theme/tab.js
@@ -59,9 +59,7 @@ App.Tab = DS.Model.extend({
* for now used when tab is disabled
* @type {String}
*/
- tooltipMsg: function() {
- return this.get('isHiddenByFilter') ? Em.I18n.t('services.service.config.nothing.to.display') : '';
- }.property('isHiddenByFilter'),
+ tooltipMsg: Em.computed.ifThenElse('isHiddenByFilter', Em.I18n.t('services.service.config.nothing.to.display') , ''),
/**
* Determines if tab is filtered out (all it's sections should be hidden)
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/form.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/form.js b/ambari-web/app/models/form.js
index c45c6cb..09a620a 100644
--- a/ambari-web/app/models/form.js
+++ b/ambari-web/app/models/form.js
@@ -92,9 +92,7 @@ App.Form = Em.View.extend({
}, this);
},
- visibleFields:function () {
- return this.get('fields').filterProperty('isHiddenField', false);
- }.property('fields'),
+ visibleFields:Em.computed.filterBy('fields', 'isHiddenField', false),
resultText:function () {
var text = "";
@@ -126,9 +124,7 @@ App.FormField = Em.Object.extend({ // try to realize this as view
unit:'',
value:'',
- isValid:function () {
- return this.get('errorMessage') === '';
- }.property('errorMessage'),
+ isValid:Em.computed.equal('errorMessage', ''),
viewClass:function () {
var options = {};
@@ -178,7 +174,5 @@ App.FormField = Em.Object.extend({ // try to realize this as view
}
},
- isHiddenField:function () {
- return this.get('displayType') == 'hidden';
- }.property('type')
+ isHiddenField: Em.computed.equal('displayType', 'hidden')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index c268d44..1c6da8d 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -90,25 +90,19 @@ App.Host = DS.Model.extend({
/**
* @type {number}
*/
- componentsInPassiveStateCount: function() {
- return this.get('componentsInPassiveState').length;
- }.property('componentsInPassiveState.length'),
+ componentsInPassiveStateCount: Em.computed.alias('componentsInPassiveState.length'),
/**
* Get count of host components with stale configs
* @returns {Number}
*/
- componentsWithStaleConfigsCount: function() {
- return this.get('componentsWithStaleConfigs.length');
- }.property('componentsWithStaleConfigs.length'),
+ componentsWithStaleConfigsCount: Em.computed.alias('componentsWithStaleConfigs.length'),
/**
* Count of mounted on host disks
* @returns {Number}
*/
- disksMounted: function() {
- return this.get('diskInfo.length');
- }.property('diskInfo.length'),
+ disksMounted: Em.computed.alias('diskInfo.length'),
coresFormatted: function() {
return this.get('cpu') + ' (' + this.get('cpuPhysical') + ')';
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 1ef23db..203eff2 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -107,9 +107,7 @@ App.HostComponent = DS.Model.extend({
* User friendly host component status
* @returns {String}
*/
- isActive: function () {
- return (this.get('passiveState') == 'OFF');
- }.property('passiveState'),
+ isActive: Em.computed.equal('passiveState', 'OFF'),
passiveTooltip: function () {
if (!this.get('isActive')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 2d49a76..8962552 100644
--- a/ambari-web/app/models/host_stack_version.js
+++ b/ambari-web/app/models/host_stack_version.js
@@ -36,23 +36,17 @@ App.HostStackVersion = DS.Model.extend({
/**
* @type {boolean}
*/
- isCurrent: function () {
- return this.get('status') === 'CURRENT'
- }.property('status'),
+ isCurrent: Em.computed.equal('status', 'CURRENT'),
/**
* @type {boolean}
*/
- isInstalling: function () {
- return this.get('status') === 'INSTALLING';
- }.property('status'),
+ isInstalling: Em.computed.equal('status', 'INSTALLING'),
/**
* @type {boolean}
*/
- isOutOfSync: function () {
- return this.get('status') === 'OUT_OF_SYNC';
- }.property('status'),
+ isOutOfSync: Em.computed.equal('status', 'OUT_OF_SYNC'),
/**
* @type {string}
*/
@@ -66,7 +60,8 @@ App.HostStackVersion = DS.Model.extend({
installEnabled: function () {
return ['OUT_OF_SYNC', 'INSTALL_FAILED'].contains(this.get('status'));
}.property('status'),
- installDisabled: Ember.computed.not('installEnabled')
+
+ installDisabled: Em.computed.not('installEnabled')
});
App.HostStackVersion.FIXTURES = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/repository.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/repository.js b/ambari-web/app/models/repository.js
index 66c22bf..8ad20ce 100644
--- a/ambari-web/app/models/repository.js
+++ b/ambari-web/app/models/repository.js
@@ -36,9 +36,7 @@ App.Repository = DS.Model.extend({
errorContent: DS.attr('string', {defaultValue: ''}),
errorTitle: DS.attr('string', {defaultValue: ''}),
- isSelected: function() {
- return this.get('operatingSystem.isSelected');
- }.property('id','operatingSystem.isSelected'),
+ isSelected: Em.computed.alias('operatingSystem.isSelected'),
invalidFormatError: function() {
return !validator.isValidBaseUrl(this.get('baseUrl'));
@@ -48,13 +46,10 @@ App.Repository = DS.Model.extend({
return this.get('validation') == App.Repository.validation['INVALID'];
}.property('validation'),
- undo: function() {
- return this.get('baseUrl') != this.get('latestBaseUrl');
- }.property('baseUrl','latestBaseUrl'),
+ undo: Em.computed.notEqualProperties('baseUrl', 'latestBaseUrl'),
+
+ clearAll: Em.computed.alias('baseUrl')
- clearAll: function() {
- return this.get('baseUrl')
- }.property('baseUrl')
});
App.Repository.validation = {
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index 250f810..ddec4f9 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -45,9 +45,7 @@ App.Service = DS.Model.extend({
/**
* @type {bool}
*/
- isInPassive: function() {
- return this.get('passiveState') === "ON";
- }.property('passiveState'),
+ isInPassive: Em.computed.equal('passiveState', 'ON'),
serviceComponents: function() {
var clientComponents = this.get('clientComponents').mapProperty('componentName');
@@ -77,12 +75,9 @@ App.Service = DS.Model.extend({
return 'yellow';
}
}.property('workStatus'),
- isStopped: function () {
- return this.get('workStatus') === 'INSTALLED';
- }.property('workStatus'),
- isStarted: function () {
- return this.get('workStatus') === 'STARTED';
- }.property('workStatus'),
+ isStopped: Em.computed.equal('workStatus', 'INSTALLED'),
+
+ isStarted: Em.computed.equal('workStatus', 'STARTED'),
/**
* Service Tagging by their type.
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/service/yarn.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service/yarn.js b/ambari-web/app/models/service/yarn.js
index c8967e6..ef44f19 100644
--- a/ambari-web/app/models/service/yarn.js
+++ b/ambari-web/app/models/service/yarn.js
@@ -67,9 +67,7 @@ App.YARNService = App.Service.extend({
allQueueNames: [],
childQueueNames: [],
- maxMemory: function() {
- return this.get('allocatedMemory') + this.get('availableMemory');
- }.property('allocatedMemory','availableMemory'),
+ maxMemory: Em.computed.sumProperties('allocatedMemory', 'availableMemory'),
/**
* Provides a flat array of queue names.
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/stack_service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_service.js b/ambari-web/app/models/stack_service.js
index 1926b9c..bdcf303 100644
--- a/ambari-web/app/models/stack_service.js
+++ b/ambari-web/app/models/stack_service.js
@@ -62,9 +62,7 @@ App.StackService = DS.Model.extend({
// Primary DFS. used if there is more than one DFS in a stack.
// Only one service in the stack should be tagged as primary DFS.
- isPrimaryDFS: function () {
- return this.get('serviceName') === 'HDFS';
- }.property('serviceName'),
+ isPrimaryDFS: Em.computed.equal('serviceName', 'HDFS'),
configTypesRendered: function () {
var configTypes = this.get('configTypes');
@@ -105,22 +103,13 @@ App.StackService = DS.Model.extend({
}.property('serviceName'),
// Is the service required for monitoring of other hadoop ecosystem services
- isMonitoringService: function () {
- var services = ['GANGLIA'];
- return services.contains(this.get('serviceName'));
- }.property('serviceName'),
+ isMonitoringService: Em.computed.existsIn('serviceName', ['GANGLIA']),
// Is the service required for reporting host metrics
- isHostMetricsService: function () {
- var services = ['GANGLIA', 'AMBARI_METRICS'];
- return services.contains(this.get('serviceName'));
- }.property('serviceName'),
+ isHostMetricsService: Em.computed.existsIn('serviceName', ['GANGLIA', 'AMBARI_METRICS']),
// Is the service required for reporting hadoop service metrics
- isServiceMetricsService: function () {
- var services = ['GANGLIA'];
- return services.contains(this.get('serviceName'));
- }.property('serviceName'),
+ isServiceMetricsService: Em.computed.existsIn('serviceName', ['GANGLIA']),
coSelectedServices: function () {
var coSelectedServices = App.StackService.coSelected[this.get('serviceName')];
@@ -131,30 +120,18 @@ App.StackService = DS.Model.extend({
}
}.property('serviceName'),
- hasClient: function () {
- var serviceComponents = this.get('serviceComponents');
- return serviceComponents.someProperty('isClient');
- }.property('serviceName'),
+ hasClient: Em.computed.someBy('serviceComponents', 'isClient', true),
- hasMaster: function () {
- var serviceComponents = this.get('serviceComponents');
- return serviceComponents.someProperty('isMaster');
- }.property('serviceName'),
+ hasMaster: Em.computed.someBy('serviceComponents', 'isMaster', true),
- hasSlave: function () {
- var serviceComponents = this.get('serviceComponents');
- return serviceComponents.someProperty('isSlave');
- }.property('serviceName'),
+ hasSlave: Em.computed.someBy('serviceComponents', 'isSlave', true),
hasNonMastersWithCustomAssignment: function () {
var serviceComponents = this.get('serviceComponents');
return serviceComponents.rejectProperty('isMaster').rejectProperty('cardinality', 'ALL').length > 0;
}.property('serviceName'),
- isClientOnlyService: function () {
- var serviceComponents = this.get('serviceComponents');
- return serviceComponents.everyProperty('isClient');
- }.property('serviceName'),
+ isClientOnlyService: Em.computed.everyBy('serviceComponents', 'isClient', true),
isNoConfigTypes: function () {
var configTypes = this.get('configTypes');
@@ -165,9 +142,7 @@ App.StackService = DS.Model.extend({
return App.StackService.reviewPageHandlers[this.get('serviceName')];
}.property('serviceName'),
- hasHeatmapSection: function() {
- return ['HDFS', 'YARN', 'HBASE'].contains(this.get('serviceName'));
- }.property('serviceName'),
+ hasHeatmapSection: Em.computed.existsIn('serviceName', ['HDFS', 'YARN', 'HBASE']),
/**
* configCategories are fetched from App.StackService.configCategories.
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 b51ed1f..1321d11 100644
--- a/ambari-web/app/models/stack_service_component.js
+++ b/ambari-web/app/models/stack_service_component.js
@@ -56,29 +56,19 @@ App.StackServiceComponent = DS.Model.extend({
}.property('cardinality'),
/** @property {Boolean} isRequired - component required to install **/
- isRequired: function() {
- return this.get('minToInstall') > 0;
- }.property('cardinality'),
+ isRequired: Em.computed.gt('minToInstall', 0),
/** @property {Boolean} isMultipleAllowed - component can be assigned for more than one host **/
- isMultipleAllowed: function() {
- return this.get('maxToInstall') > 1;
- }.property('cardinality'),
+ isMultipleAllowed: Em.computed.gt('maxToInstall', 1),
/** @property {Boolean} isSlave **/
- isSlave: function() {
- return this.get('componentCategory') === 'SLAVE';
- }.property('componentCategory'),
+ isSlave: Em.computed.equal('componentCategory', 'SLAVE'),
/** @property {Boolean} isRestartable - component supports restart action **/
- isRestartable: function() {
- return !this.get('isClient');
- }.property('isClient'),
+ isRestartable: Em.computed.not('isClient'),
/** @property {Boolean} isReassignable - component supports reassign action **/
- isReassignable: function() {
- return ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER', 'APP_TIMELINE_SERVER', 'OOZIE_SERVER', 'WEBHCAT_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE', 'MYSQL_SERVER', 'METRICS_COLLECTOR'].contains(this.get('componentName'));
- }.property('componentName'),
+ isReassignable: Em.computed.existsIn('componentName', ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER', 'APP_TIMELINE_SERVER', 'OOZIE_SERVER', 'WEBHCAT_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE', 'MYSQL_SERVER', 'METRICS_COLLECTOR']),
/** @property {Boolean} isRollinRestartAllowed - component supports rolling restart action **/
isRollinRestartAllowed: function() {
@@ -86,14 +76,10 @@ App.StackServiceComponent = DS.Model.extend({
}.property('componentName'),
/** @property {Boolean} isDecommissionAllowed - component supports decommission action **/
- isDecommissionAllowed: function() {
- return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"].contains(this.get('componentName'));
- }.property('componentName'),
+ isDecommissionAllowed: Em.computed.existsIn('componentName', ['DATANODE', 'TASKTRACKER', 'NODEMANAGER', 'HBASE_REGIONSERVER']),
/** @property {Boolean} isRefreshConfigsAllowed - component supports refresh configs action **/
- isRefreshConfigsAllowed: function() {
- return ["FLUME_HANDLER"].contains(this.get('componentName'));
- }.property('componentName'),
+ isRefreshConfigsAllowed: Em.computed.existsIn('componentName', ['FLUME_HANDLER']),
/** @property {Boolean} isAddableToHost - component can be added on host details page **/
isAddableToHost: function() {
@@ -150,20 +136,13 @@ App.StackServiceComponent = DS.Model.extend({
* New instances of these components are added in appropriate HA wizards
* @property {Boolean} isMasterAddableOnlyOnHA
*/
- isMasterAddableOnlyOnHA: function () {
- return ['NAMENODE', 'RESOURCEMANAGER', 'RANGER_ADMIN'].contains(this.get('componentName'));
- }.property('componentName'),
+ isMasterAddableOnlyOnHA: Em.computed.existsIn('componentName', ['NAMENODE', 'RESOURCEMANAGER', 'RANGER_ADMIN']),
/** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
- isHAComponentOnly: function() {
- var HAComponentNames = ['ZKFC','JOURNALNODE'];
- return HAComponentNames.contains(this.get('componentName'));
- }.property('componentName'),
+ isHAComponentOnly: Em.computed.existsIn('componentName', ['ZKFC','JOURNALNODE']),
/** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
- isRequiredOnAllHosts: function() {
- return this.get('minToInstall') == Infinity;
- }.property('stackService','isSlave'),
+ isRequiredOnAllHosts: Em.computed.equal('minToInstall', Infinity),
/** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
defaultNoOfMasterHosts: function() {
@@ -185,9 +164,7 @@ App.StackServiceComponent = DS.Model.extend({
}.property('componentName'),
/** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
- isOtherComponentCoHosted: function() {
- return !!this.get('coHostedComponents').length;
- }.property('coHostedComponents'),
+ isOtherComponentCoHosted: Em.computed.bool('coHostedComponents.length'),
/** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
isCoHostedComponent: function() {
@@ -196,9 +173,7 @@ App.StackServiceComponent = DS.Model.extend({
}.property('componentName'),
/** @property {Boolean} isNotAddableOnlyInInstall - is this component addable, except Install and Add Service Wizards **/
- isNotAddableOnlyInInstall: function() {
- return ['HIVE_METASTORE', 'HIVE_SERVER', 'RANGER_KMS_SERVER', 'OOZIE_SERVER'].contains(this.get('componentName'));
- }.property('componentName')
+ isNotAddableOnlyInInstall: Em.computed.existsIn('componentName', ['HIVE_METASTORE', 'HIVE_SERVER', 'RANGER_KMS_SERVER', 'OOZIE_SERVER'])
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 01806cb..9dc1bc6 100644
--- a/ambari-web/app/models/stack_version/repository_version.js
+++ b/ambari-web/app/models/stack_version/repository_version.js
@@ -88,23 +88,17 @@ App.RepositoryVersion = DS.Model.extend({
/**
* @type {string}
*/
- noInitHostsTooltip: function () {
- return (this.get('noInitHosts')) ? Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip') : Em.I18n.t('admin.stackVersions.version.hostsTooltip');
- }.property('noInitHosts'),
+ noInitHostsTooltip: Em.computed.ifThenElse('noInitHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
/**
* @type {string}
*/
- noCurrentHostsTooltip: function () {
- return (this.get('noCurrentHosts')) ? Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip') : Em.I18n.t('admin.stackVersions.version.hostsTooltip');
- }.property('noCurrentHosts'),
+ noCurrentHostsTooltip: Em.computed.ifThenElse('noCurrentHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
/**
* @type {string}
*/
- noInstalledHostsTooltip: function () {
- return (this.get('noInstalledHosts')) ? Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip') : Em.I18n.t('admin.stackVersions.version.hostsTooltip');
- }.property('noInstalledHosts'),
+ noInstalledHostsTooltip: Em.computed.ifThenElse('noInstalledHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
/**
* @type {boolean}
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/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 7fd4134..9b1167d 100644
--- a/ambari-web/app/models/stack_version/version.js
+++ b/ambari-web/app/models/stack_version/version.js
@@ -37,21 +37,13 @@ App.StackVersion = DS.Model.extend({
upgradeFailedHosts: DS.attr('array'),
currentHosts: DS.attr('array'),
- noInstalledHosts: function() {
- return this.get('installedHosts.length') == 0;
- }.property('installedHosts.length'),
+ noInstalledHosts: Em.computed.empty('installedHosts'),
- noCurrentHosts: function() {
- return this.get('currentHosts.length') == 0;
- }.property('currentHosts.length'),
+ noCurrentHosts: Em.computed.empty('currentHosts'),
- noInitHosts: function() {
- return this.get('notInstalledHosts.length') == 0;
- }.property('notInstalledHosts.length'),
+ noInitHosts: Em.computed.empty('notInstalledHosts'),
- isCurrent: function() {
- return this.get('state') === 'CURRENT';
- }.property('state')
+ isCurrent: Em.computed.equal('state', 'CURRENT')
});
App.StackVersion.FIXTURES = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/upgrade_entity.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/upgrade_entity.js b/ambari-web/app/models/upgrade_entity.js
index ab9806a..953f1eb 100644
--- a/ambari-web/app/models/upgrade_entity.js
+++ b/ambari-web/app/models/upgrade_entity.js
@@ -42,9 +42,7 @@ App.upgradeEntity = Em.Object.extend({
/**
* @type {boolean}
*/
- isVisible: function () {
- return this.get('status') !== 'PENDING';
- }.property('status'),
+ isVisible: Em.computed.notEqual('status', 'PENDING'),
/**
* status of tasks/items/groups which should be grayed out and disabled
@@ -55,9 +53,7 @@ App.upgradeEntity = Em.Object.extend({
/**
* @type {boolean}
*/
- isRunning: function () {
- return ['IN_PROGRESS'].contains(this.get('status'));
- }.property('status'),
+ isRunning: Em.computed.existsIn('status', ['IN_PROGRESS']),
/**
* @type {number}
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/app/models/user.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/user.js b/ambari-web/app/models/user.js
index 1b8359a..776de50 100644
--- a/ambari-web/app/models/user.js
+++ b/ambari-web/app/models/user.js
@@ -21,9 +21,7 @@ var validator = require('utils/validator');
App.User = DS.Model.extend({
userName:DS.attr('string'),
- id:function(){
- return this.get('userName');
- }.property('userName'),
+ id: Em.computed.alias('userName'),
userType: DS.attr('string'),
auditItems:DS.hasMany('App.ServiceAudit'),
admin: DS.attr('boolean'),
@@ -42,9 +40,7 @@ App.User = DS.Model.extend({
/**
* @type {Boolean}
*/
- isLdap: function() {
- return this.get('userType') === 'LDAP';
- }.property('userType')
+ isLdap: Em.computed.equal('userType', 'LDAP')
});
App.EditUserForm = App.Form.extend({
http://git-wip-us.apache.org/repos/asf/ambari/blob/779b4f9d/ambari-web/test/models/alerts/alert_definition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_definition_test.js b/ambari-web/test/models/alerts/alert_definition_test.js
index 0e8cc79..1aeea49 100644
--- a/ambari-web/test/models/alerts/alert_definition_test.js
+++ b/ambari-web/test/models/alerts/alert_definition_test.js
@@ -125,6 +125,40 @@ describe('App.AlertDefinition', function () {
});
+ describe('#isOK', function () {
+
+ Em.A([
+ {summary: {CRITICAL: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {WARNING: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {OK: {count: 1, maintenanceCount: 0}}, e: true},
+ {summary: {UNKNOWN: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {}, e: false}
+ ]).forEach(function (test, i) {
+ it('test ' + (i + 1), function () {
+ model.set('summary', test.summary);
+ expect(model.get('isOK')).to.equal(test.e);
+ });
+ });
+
+ });
+
+ describe('#isUnknown', function () {
+
+ Em.A([
+ {summary: {CRITICAL: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {WARNING: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {OK: {count: 1, maintenanceCount: 0}}, e: false},
+ {summary: {UNKNOWN: {count: 1, maintenanceCount: 0}}, e: true},
+ {summary: {}, e: false}
+ ]).forEach(function (test, i) {
+ it('test ' + (i + 1), function () {
+ model.set('summary', test.summary);
+ expect(model.get('isUnknown')).to.equal(test.e);
+ });
+ });
+
+ });
+
describe('#lastTriggeredAgoFormatted', function () {
it('should be empty', function () {