Repository: ambari Updated Branches: refs/heads/branch-2.0.0 116d577a5 -> f35e06fe2
Revert "AMBARI-10299. Unable to save SNMPv1 and SNMPv2c notifications (alexantonenko)" This reverts commit 116d577a504e7848b2ef11c72862dd5e8b8a9a2b. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/205911d3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/205911d3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/205911d3 Branch: refs/heads/branch-2.0.0 Commit: 205911d34e2de957606f0ca1fa0b5348c0cc8d08 Parents: 116d577 Author: Jayush Luniya <[email protected]> Authored: Thu Apr 9 07:47:24 2015 -0700 Committer: Jayush Luniya <[email protected]> Committed: Thu Apr 9 07:47:24 2015 -0700 ---------------------------------------------------------------------- .../manage_alert_notifications_controller.js | 59 ++---- ambari-web/app/messages.js | 5 - .../main/alerts/create_alert_notification.hbs | 48 ++--- ...anage_alert_notifications_controller_test.js | 184 +------------------ 4 files changed, 25 insertions(+), 271 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/205911d3/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 d415036..995f2ae 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 @@ -126,26 +126,11 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ value: '', defaultValue: '' }, - OIDSubject: { - label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.OIDSubject'), - value: '', - defaultValue: '' - }, - OIDBody: { - label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.OIDBody'), - value: '', - defaultValue: '' - }, community: { label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.community'), value: '', defaultValue: '' }, - host: { - label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.host'), - value: '', - defaultValue: '' - }, port: { label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.port'), value: '', @@ -222,8 +207,6 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ 'ambari.dispatch.recipients', 'ambari.dispatch.snmp.community', 'ambari.dispatch.snmp.oids.trap', - 'ambari.dispatch.snmp.oids.subject', - 'ambari.dispatch.snmp.oids.body', 'ambari.dispatch.snmp.port', 'ambari.dispatch.snmp.version', 'mail.smtp.auth', @@ -315,11 +298,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ inputFields.set('emailFrom.value', selectedAlertNotification.get('properties')['mail.smtp.from']); inputFields.set('version.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.version']); inputFields.set('OIDs.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.oids.trap']); - inputFields.set('OIDSubject.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.oids.subject']); - inputFields.set('OIDBody.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.oids.body']); inputFields.set('community.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.community']); - inputFields.set('host.value', selectedAlertNotification.get('properties')['ambari.dispatch.recipients'] ? - selectedAlertNotification.get('properties')['ambari.dispatch.recipients'].join(', ') : ''); inputFields.set('port.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.port']); inputFields.set('severityFilter.value', selectedAlertNotification.get('alertStates')); inputFields.set('global.value', selectedAlertNotification.get('global')); @@ -363,7 +342,6 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ this.emailToValidation(); this.emailFromValidation(); this.smtpPortValidation(); - this.hostsValidation(); this.portValidation(); this.retypePasswordValidation(); }, @@ -406,12 +384,17 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ }.observes('controller.inputFields.name.value'), emailToValidation: function () { - var emailToError = false; - if (this.get('isEmailMethodSelected')) { - var inputValues = this.get('controller.inputFields.email.value').trim().split(','); - emailToError = inputValues.some(function(emailTo) { - return emailTo && !validator.isValidEmail(emailTo.trim()); - }) + var inputValue = this.get('controller.inputFields.email.value').trim(), + emailsTo = inputValue.split(','), + emailToError = false, + i = emailsTo.length, + emailTo; + while (i--) { + emailTo = emailsTo[i]; + if (emailTo && !validator.isValidEmail(emailTo.trim())) { + emailToError = true; + break; + } } this.set('emailToError', emailToError); this.set('controller.inputFields.email.errorMsg', emailToError ? Em.I18n.t('alerts.notifications.error.email') : null); @@ -439,19 +422,6 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ } }.observes('controller.inputFields.SMTPPort.value'), - hostsValidation: function() { - var inputValue = this.get('controller.inputFields.host.value').trim(), - hostError = false;; - if (!this.get('isEmailMethodSelected')) { - var array = inputValue.split(','); - hostError = array.some(function(hostname) { - return hostname && !validator.isHostname(hostname.trim()); - }); - hostError = hostError || inputValue===''; - } - this.set('hostError', hostError); - this.set('controller.inputFields.host.errorMsg', hostError ? Em.I18n.t('alerts.notifications.error.host') : null); - }.observes('controller.inputFields.host.value'), portValidation: function () { var value = this.get('controller.inputFields.port.value'); if (value && (!validator.isValidInt(value) || value < 0)) { @@ -477,9 +447,9 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ setParentErrors: function () { var hasErrors = this.get('nameError') || this.get('emailToError') || this.get('emailFromError') || - this.get('smtpPortError') || this.get('hostError') || this.get('portError') || this.get('passwordError'); + this.get('smtpPortError') || this.get('portError') || this.get('passwordError'); this.set('parentView.hasErrors', hasErrors); - }.observes('nameError', 'emailToError', 'emailFromError', 'smtpPortError', 'hostError', 'portError', 'passwordError'), + }.observes('nameError', 'emailToError', 'emailFromError', 'smtpPortError', 'portError', 'passwordError'), groupsSelectView: Em.Select.extend({ @@ -616,10 +586,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ } else { properties['ambari.dispatch.snmp.version'] = inputFields.get('version.value'); properties['ambari.dispatch.snmp.oids.trap'] = inputFields.get('OIDs.value'); - properties['ambari.dispatch.snmp.oids.subject'] = inputFields.get('OIDSubject.value'); - properties['ambari.dispatch.snmp.oids.body'] = inputFields.get('OIDBody.value'); properties['ambari.dispatch.snmp.community'] = inputFields.get('community.value'); - properties['ambari.dispatch.recipients'] = inputFields.get('host.value').replace(/\s/g, '').split(','); properties['ambari.dispatch.snmp.port'] = inputFields.get('port.value'); } inputFields.get('customProperties').forEach(function (customProperty) { http://git-wip-us.apache.org/repos/asf/ambari/blob/205911d3/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 67c0bcd..97adb7a 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -890,8 +890,6 @@ Em.I18n.translations = { 'alerts.notifications.error.email': 'Must be a valid email address', 'alerts.notifications.error.integer': 'Must be an integer', - 'alerts.notifications.error.host': 'Hosts must be a valid Fully Qualified Domain Name (FQDN)', - 'alerts.notifications.error.retypePassword': 'Password confirmation must match password', 'alerts.notifications.addCustomPropertyPopup.header': 'Add Property', @@ -1923,10 +1921,7 @@ Em.I18n.translations = { 'alerts.actions.manage_alert_notifications_popup.emailFrom':'Email From', 'alerts.actions.manage_alert_notifications_popup.version':'Version', 'alerts.actions.manage_alert_notifications_popup.OIDs':'OIDs', - 'alerts.actions.manage_alert_notifications_popup.OIDSubject':'OID Subject', - 'alerts.actions.manage_alert_notifications_popup.OIDBody':'OID Body', 'alerts.actions.manage_alert_notifications_popup.community':'Community', - 'alerts.actions.manage_alert_notifications_popup.host':'Hosts', 'alerts.actions.manage_alert_notifications_popup.port':'Port', 'alerts.actions.manage_alert_notifications_popup.global':'Global', 'alerts.actions.manage_alert_notifications_popup.noDescription':'<i>No description</i>', http://git-wip-us.apache.org/repos/asf/ambari/blob/205911d3/ambari-web/app/templates/main/alerts/create_alert_notification.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs index e38d216..00ba20e 100644 --- a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs +++ b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs @@ -194,25 +194,11 @@ </div> <div class="control-group"> - <label class="control-label">{{controller.inputFields.OIDs.label}}</label> + <label class="control-label">{{controller.inputFields.OIDs.label}}</label> - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} - </div> - </div> - <div class="control-group"> - <label class="control-label">{{controller.inputFields.OIDSubject.label}}</label> - - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.OIDSubject.value" class="input-xlarge"}} - </div> - </div> - <div class="control-group"> - <label class="control-label">{{controller.inputFields.OIDBody.label}}</label> - - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.OIDBody.value" class="input-xlarge"}} - </div> + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} + </div> </div> <div class="control-group"> @@ -223,28 +209,16 @@ </div> </div> - <div {{bindAttr class=":control-group controller.inputFields.host.errorMsg:error"}}> - <label class="control-label">{{controller.inputFields.host.label}}</label> - - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.host.value" class="input-xlarge"}} - </div> - - <div class="controls error-msg"> - {{controller.inputFields.host.errorMsg}} - </div> - </div> - <div {{bindAttr class=":control-group controller.inputFields.port.errorMsg:error"}}> - <label class="control-label">{{controller.inputFields.port.label}}</label> + <label class="control-label">{{controller.inputFields.port.label}}</label> - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.port.value" class="input-xlarge"}} - </div> + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.port.value" class="input-xlarge"}} + </div> - <div class="controls error-msg"> - {{controller.inputFields.port.errorMsg}} - </div> + <div class="controls error-msg"> + {{controller.inputFields.port.errorMsg}} + </div> </div> {{/if}} {{! alert-notification email end }} http://git-wip-us.apache.org/repos/asf/ambari/blob/205911d3/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 4d3f68d..b6cbc39 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 @@ -169,7 +169,7 @@ describe('App.ManageAlertNotificationsController', function () { describe('#fillEditCreateInputs()', function () { - it("should map properties from selectedAlertNotification to inputFields (ambari.dispatch.recipients ignored) - EMAIL", function () { + it("should map properties from selectedAlertNotification to inputFields (ambari.dispatch.recipients ignored)", function () { controller.set('selectedAlertNotification', Em.Object.create({ name: 'test_name', @@ -249,18 +249,9 @@ describe('App.ManageAlertNotificationsController', function () { OIDs: { value: '' }, - OIDSubject: { - value: '' - }, - OIDBody: { - value: '' - }, community: { value: '' }, - host: { - value: '' - }, port: { value: '' }, @@ -324,12 +315,7 @@ describe('App.ManageAlertNotificationsController', function () { }, version: {}, OIDs: {}, - OIDSubject: {}, - OIDBody: {}, community: {}, - host: { - value: '[email protected], [email protected]' - }, port: {}, customProperties: [ {name: 'customName', value: 'customValue', defaultValue: 'customValue'} @@ -338,174 +324,6 @@ describe('App.ManageAlertNotificationsController', function () { }); - it("should map properties from selectedAlertNotification to inputFields (ambari.dispatch.recipients ignored) - SNMP", function () { - - controller.set('selectedAlertNotification', Em.Object.create({ - name: 'test_SNMP_name', - global: true, - description: 'test_description', - groups: ['test1', 'test2'], - type: '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.oids.trap': '1', - 'ambari.dispatch.snmp.oids.subject': 'OID Subject', - 'ambari.dispatch.snmp.oids.body': 'OID Body', - 'ambari.dispatch.snmp.community': 'snmp', - '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: '' - }, - OIDSubject: { - value: '' - }, - OIDBody: { - 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: 'test_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: { - value: '1' - }, - OIDSubject: { - value: 'OID Subject' - }, - OIDBody: { - value:'OID Body' - }, - community: { - value: 'snmp' - }, - host: { - value: 'c6401.ambari.apache.org, c6402.ambari.apache.org' - }, - port: { - value: 161 - }, - customProperties: [ - {name: 'customName', value: 'customValue', defaultValue: 'customValue'} - ] - })); - - }) }); describe("#showCreateEditPopup()", function () {
