You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2016/12/28 18:05:55 UTC
ambari git commit: AMBARI-19252. Incorrect Method types displayed in
the description of created Alert notification. (Vivek Subramanian via yusaku)
Repository: ambari
Updated Branches:
refs/heads/trunk d1109a5ec -> 69e973c41
AMBARI-19252. Incorrect Method types displayed in the description of created Alert notification. (Vivek Subramanian via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/69e973c4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/69e973c4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/69e973c4
Branch: refs/heads/trunk
Commit: 69e973c41cb35541ee165372212947c0d8357d6f
Parents: d1109a5
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Wed Dec 28 10:05:24 2016 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Wed Dec 28 10:05:24 2016 -0800
----------------------------------------------------------------------
.../manage_alert_notifications_controller.js | 34 ++--
.../alerts/manage_alert_notifications_popup.hbs | 2 +-
.../alerts/manage_alert_notifications_view.js | 4 +
...anage_alert_notifications_controller_test.js | 154 ++++++++++++++++++-
4 files changed, 181 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/69e973c4/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 466d2e1..8501678 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
@@ -402,6 +402,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
fillEditCreateInputs: function (addCopyToName) {
var inputFields = this.get('inputFields');
var selectedAlertNotification = this.get('selectedAlertNotification');
+ var methodValue = this.getNotificationTypeText(selectedAlertNotification.get('type'));
inputFields.set('name.value', (addCopyToName ? 'Copy of ' : '') + selectedAlertNotification.get('name'));
inputFields.set('groups.value', selectedAlertNotification.get('groups').toArray());
inputFields.set('email.value', selectedAlertNotification.get('properties')['ambari.dispatch.recipients'] ?
@@ -426,7 +427,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
// not allow to edit global field
inputFields.set('global.disabled', true);
inputFields.set('description.value', selectedAlertNotification.get('description'));
- inputFields.set('method.value', selectedAlertNotification.get('type'));
+ inputFields.set('method.value', methodValue);
inputFields.get('customProperties').clear();
var properties = selectedAlertNotification.get('properties');
var ignoredCustomProperties = this.get('ignoredCustomProperties');
@@ -778,21 +779,12 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
inputFields.get('customProperties').forEach(function (customProperty) {
properties[customProperty.name] = customProperty.value;
});
- var getNotificationType = function() {
- var methodValue = inputFields.get('method.value');
- if(methodValue == "Custom SNMP") {
- methodValue = "SNMP";
- } else if(methodValue == "SNMP") {
- methodValue = "AMBARI_SNMP"
- }
- return methodValue;
- };
var apiObject = {
AlertTarget: {
name: inputFields.get('name.value'),
description: inputFields.get('description.value'),
global: inputFields.get('allGroups.value') === 'all',
- notification_type: getNotificationType(),
+ notification_type: this.getNotificationType(inputFields.get('method.value')),
alert_states: inputFields.get('severityFilter.value'),
properties: properties
}
@@ -803,6 +795,26 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
return apiObject;
},
+ getNotificationType: function(text) {
+ var notificationType = text;
+ if(notificationType == "Custom SNMP") {
+ notificationType = "SNMP";
+ } else if(notificationType == "SNMP") {
+ notificationType = "AMBARI_SNMP";
+ }
+ return notificationType;
+ },
+
+ getNotificationTypeText: function(notificationType) {
+ var notificationTypeText = notificationType;
+ if(notificationType == "SNMP") {
+ notificationTypeText = "Custom SNMP";
+ } else if(notificationType == "AMBARI_SNMP") {
+ notificationTypeText = "SNMP";
+ }
+ return notificationTypeText;
+ },
+
/**
* Send request to server to create Alert Notification
* @param {object} apiObject (@see formatNotificationAPIObject)
http://git-wip-us.apache.org/repos/asf/ambari/blob/69e973c4/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
index 5599e09..9b5442d 100644
--- a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
+++ b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
@@ -101,7 +101,7 @@
</div>
<div class="row notification-method">
<div class="col-md-3 input-label">{{t alerts.actions.manage_alert_notifications_popup.method}}</div>
- <div class="col-md-9 input-value">{{selectedAlertNotification.type}}</div>
+ <div class="col-md-9 input-value">{{view.selectedAlertNotificationTypeText}}</div>
</div>
{{#if view.showEmailDetails}}
<div class="row notification-email">
http://git-wip-us.apache.org/repos/asf/ambari/blob/69e973c4/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
index 9d01791..5d81281 100644
--- a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
+++ b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
@@ -87,6 +87,10 @@ App.ManageAlertNotificationsView = Em.View.extend({
return this.get('controller.selectedAlertNotification.alertStates').join(', ');
}.property('controller.selectedAlertNotification.alertStates'),
+ selectedAlertNotificationTypeText: function() {
+ return this.get('controller').getNotificationTypeText(this.get('controller.selectedAlertNotification.type'))
+ }.property('controller.selectedAlertNotification', 'controller.isLoaded'),
+
editAlertNotification: function () {
if(!this.get('isEditButtonDisabled')) {
this.get('controller').editAlertNotification();
http://git-wip-us.apache.org/repos/asf/ambari/blob/69e973c4/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index a0a4ce4..d63dcb8 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -514,7 +514,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: 'all'
},
method: {
- value: 'SNMP'
+ value: 'Custom SNMP'
},
email: {
value: 'c6401.ambari.apache.org, c6402.ambari.apache.org'
@@ -557,6 +557,158 @@ describe('App.ManageAlertNotificationsController', function () {
]
}));
+ });
+
+ it("should map properties from selectedAlertNotification to inputFields (ambari.dispatch.recipients ignored) - AMBARI_SNMP", function () {
+
+ controller.set('selectedAlertNotification', Em.Object.create({
+ name: 'AMBARI_SNMP_name',
+ global: true,
+ description: 'test_description',
+ groups: ['test1', 'test2'],
+ type: 'AMBARI_SNMP',
+ alertStates: ['OK', 'UNKNOWN'],
+ properties: {
+ 'ambari.dispatch.recipients': [
+ 'c6401.ambari.apache.org',
+ 'c6402.ambari.apache.org'
+ ],
+ 'customName': 'customValue',
+ 'ambari.dispatch.snmp.version': 'SNMPv1',
+ 'ambari.dispatch.snmp.community': 'public',
+ 'ambari.dispatch.snmp.port': 161
+
+ }
+ }));
+
+ controller.set('inputFields', Em.Object.create({
+ name: {
+ value: ''
+ },
+ groups: {
+ value: []
+ },
+ global: {
+ value: false
+ },
+ allGroups: {
+ value: false
+ },
+ method: {
+ value: ''
+ },
+ email: {
+ value: ''
+ },
+ severityFilter: {
+ value: []
+ },
+ description: {
+ value: ''
+ },
+ SMTPServer: {
+ value: ''
+ },
+ SMTPPort: {
+ value: ''
+ },
+ SMTPUseAuthentication: {
+ value: ''
+ },
+ SMTPUsername: {
+ value: ''
+ },
+ SMTPPassword: {
+ value: ''
+ },
+ retypeSMTPPassword: {
+ value: ''
+ },
+ SMTPSTARTTLS: {
+ value: ''
+ },
+ emailFrom: {
+ value: ''
+ },
+ version: {
+ value: ''
+ },
+ OIDs: {
+ value: ''
+ },
+ community: {
+ value: ''
+ },
+ host: {
+ value: ''
+ },
+ port: {
+ value: ''
+ },
+ customProperties: [
+ {name: 'customName', value: 'customValue1', defaultValue: 'customValue1'},
+ {name: 'customName2', value: 'customValue1', defaultValue: 'customValue1'}
+ ]
+ }));
+
+ controller.fillEditCreateInputs();
+
+ expect(JSON.stringify(controller.get('inputFields'))).to.equal(JSON.stringify({
+ name: {
+ value: 'AMBARI_SNMP_name'
+ },
+ groups: {
+ value: ['test1', 'test2']
+ },
+ global: {
+ value: true,
+ disabled: true
+ },
+ allGroups: {
+ value: 'all'
+ },
+ method: {
+ value: 'SNMP'
+ },
+ email: {
+ value: 'c6401.ambari.apache.org, c6402.ambari.apache.org'
+ },
+ severityFilter: {
+ value: ['OK', 'UNKNOWN']
+ },
+ description: {
+ value: 'test_description'
+ },
+ SMTPServer: {},
+ SMTPPort: {},
+ SMTPUseAuthentication: {
+ value: true
+ },
+ SMTPUsername: {},
+ SMTPPassword: {},
+ retypeSMTPPassword: {},
+ SMTPSTARTTLS: {
+ value: true
+ },
+ emailFrom: {},
+ version: {
+ value:'SNMPv1'
+ },
+ OIDs: {},
+ community: {
+ value: 'public'
+ },
+ host: {
+ value: 'c6401.ambari.apache.org, c6402.ambari.apache.org'
+ },
+ port: {
+ value: 161
+ },
+ customProperties: [
+ {name: 'customName', value: 'customValue', defaultValue: 'customValue'}
+ ]
+ }));
+
})
});