You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2014/12/13 02:28:05 UTC
ambari git commit: AMBARI-8697. Alerts UI: thresholds
validation.(xiwang)
Repository: ambari
Updated Branches:
refs/heads/trunk 12d13e8b0 -> bf499456c
AMBARI-8697. Alerts UI: thresholds validation.(xiwang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bf499456
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bf499456
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bf499456
Branch: refs/heads/trunk
Commit: bf499456c17a5cabaa1fb7d8610f6fa8f08bf854
Parents: 12d13e8
Author: Xi Wang <xi...@apache.org>
Authored: Fri Dec 12 17:18:16 2014 -0800
Committer: Xi Wang <xi...@apache.org>
Committed: Fri Dec 12 17:18:26 2014 -0800
----------------------------------------------------------------------
.../alerts/definition_configs_controller.js | 20 +++++++++---
ambari-web/app/messages.js | 1 +
ambari-web/app/models/alert_config.js | 32 +++++++++++++++++---
ambari-web/app/styles/alerts.less | 12 ++++++++
.../app/templates/main/alerts/configs.hbs | 5 +++
.../main/alerts/definition_configs_view.js | 4 ++-
6 files changed, 65 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/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 c63baa0..199e0cd 100644
--- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
@@ -171,13 +171,13 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
value: isWizard ? '' : this.getThresholdsProperty('ok', 'value')
}),
App.AlertConfigProperties.Thresholds.WarningThreshold.create({
- valueMetric: 'sec',
+ valueMetric: 'Sec',
text: isWizard ? '' : this.getThresholdsProperty('warning', 'text'),
value: isWizard ? '' : this.getThresholdsProperty('warning', 'value')
}),
App.AlertConfigProperties.Thresholds.CriticalThreshold.create({
- valueMetric: 'sec',
+ valueMetric: 'Sec',
text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
value: isWizard ? '' : this.getThresholdsProperty('critical', 'value')
})
@@ -498,11 +498,23 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
},
/**
+ * Define whether critical threshold >= critical threshold
+ * @type {Boolean}
+ */
+ hasThresholdsError: function () {
+ var smallValue = Em.get(this.get('configs').findProperty('name', 'warning_threshold'), 'value');
+ var smallValid = Em.get(this.get('configs').findProperty('name', 'warning_threshold'), 'isValid');
+ var largeValue = Em.get(this.get('configs').findProperty('name', 'critical_threshold'), 'value');
+ var largeValid = Em.get(this.get('configs').findProperty('name', 'critical_threshold'), 'isValid');
+ return smallValid && largeValid ? !(smallValue <= largeValue) : false;
+ }.property('configs.@each.value'),
+
+ /**
* Define whether all configs are valid
* @type {Boolean}
*/
hasErrors: function () {
- return this.get('configs').someProperty('isValid', false);
- }.property('configs.@each.isValid')
+ return this.get('configs').someProperty('isValid', false) || this.get('hasThresholdsError');
+ }.property('configs.@each.isValid', 'hasThresholdsError')
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 44018cd..5da9d96 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -903,6 +903,7 @@ Em.I18n.translations = {
'alerts.definition.details.24-hour': '24-Hour',
'alerts.definition.details.notification': 'Notification',
'alerts.definition.details.noAlerts': 'No alert instances to show',
+ 'alerts.definition.details.configs.thresholdsErrorMsg': 'Critical threshold should be larger than warning threshold',
'alerts.notifications.addCustomPropertyPopup.header': 'Add Property',
'alerts.notifications.addCustomPropertyPopup.error.propertyExists': 'Custom Property with current name already exists',
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/ambari-web/app/models/alert_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alert_config.js b/ambari-web/app/models/alert_config.js
index a3b8a46..d6e10c7 100644
--- a/ambari-web/app/models/alert_config.js
+++ b/ambari-web/app/models/alert_config.js
@@ -348,7 +348,7 @@ App.AlertConfigProperties = {
var valueMetric = this.get('valueMetric');
var displayValue = this.get('displayValue');
var newDisplayValue = value;
- if ('%' == valueMetric) {
+ if (value && '%' == valueMetric && !isNaN(value)) {
newDisplayValue = (Number(value) * 100) + '';
}
if (newDisplayValue != displayValue) {
@@ -361,7 +361,7 @@ App.AlertConfigProperties = {
var valueMetric = this.get('valueMetric');
var displayValue = this.get('displayValue');
var newValue = displayValue;
- if ('%' == valueMetric) {
+ if (displayValue && '%' == valueMetric && !isNaN(displayValue)) {
newValue = (Number(displayValue) / 100) + '';
}
if (newValue != value) {
@@ -461,7 +461,19 @@ App.AlertConfigProperties.Thresholds = {
ret.push('source.reporting.warning.text');
}
return ret;
- }.property('showInputForValue', 'showInputForText')
+ }.property('showInputForValue', 'showInputForText'),
+ isValid: function () {
+ var value = this.get('value');
+ if (!value) return false;
+ value = ('' + value).trim();
+ if (this.get('showInputForValue') && this.get('valueMetric') == '%') {
+ return !isNaN(value) && value > 0 && value <= 1.0;
+ } else if (this.get('showInputForValue')) {
+ return !isNaN(value) && value > 0;
+ } else {
+ return true;
+ }
+ }.property('value', 'showInputForValue')
}),
CriticalThreshold: App.AlertConfigProperties.Threshold.extend({
@@ -476,7 +488,19 @@ App.AlertConfigProperties.Thresholds = {
ret.push('source.reporting.critical.text');
}
return ret;
- }.property('showInputForValue', 'showInputForText')
+ }.property('showInputForValue', 'showInputForText'),
+ isValid: function () {
+ var value = this.get('value');
+ if (!value) return false;
+ value = ('' + value).trim();
+ if (this.get('showInputForValue') && this.get('valueMetric') == '%') {
+ return !isNaN(value) && value > 0 && value <= 1.0;
+ } else if (this.get('showInputForValue')) {
+ return !isNaN(value) && value > 0;
+ } else {
+ return true;
+ }
+ }.property('value', 'showInputForValue')
})
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/ambari-web/app/styles/alerts.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/alerts.less b/ambari-web/app/styles/alerts.less
index e017b6e..87ea103 100644
--- a/ambari-web/app/styles/alerts.less
+++ b/ambari-web/app/styles/alerts.less
@@ -327,6 +327,18 @@
height: 26px;
}
}
+
+ .control-group.error{
+ .alert-text-input input{
+ color: #555555;
+ border-color: #ccc;
+ }
+ }
+ .error-message {
+ color: #b94a48;
+ }
+
+
}
#host-alerts-table {
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/ambari-web/app/templates/main/alerts/configs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/configs.hbs b/ambari-web/app/templates/main/alerts/configs.hbs
index b7e2b7f..cbac133 100644
--- a/ambari-web/app/templates/main/alerts/configs.hbs
+++ b/ambari-web/app/templates/main/alerts/configs.hbs
@@ -34,4 +34,9 @@
{{/if}}
</div>
{{/each}}
+ {{#if controller.hasThresholdsError}}
+ <div class="error-message controls">
+ {{view.errorMessage}}
+ </div>
+ {{/if}}
</form>
http://git-wip-us.apache.org/repos/asf/ambari/blob/bf499456/ambari-web/app/views/main/alerts/definition_configs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/definition_configs_view.js b/ambari-web/app/views/main/alerts/definition_configs_view.js
index b063207..16f283d 100644
--- a/ambari-web/app/views/main/alerts/definition_configs_view.js
+++ b/ambari-web/app/views/main/alerts/definition_configs_view.js
@@ -44,7 +44,9 @@ App.AlertDefinitionConfigsView = Em.View.extend({
this.set('controller.content', this.get('content'));
this.get('controller').renderConfigs();
this._super();
- }
+ },
+
+ errorMessage: Em.I18n.t('alerts.definition.details.configs.thresholdsErrorMsg')
});