Repository: ambari Updated Branches: refs/heads/trunk bf3d2857f -> bbb346667
AMBARI-8904. Alerts UI: Create Notification (step 8) request issue (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bbb34666 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bbb34666 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bbb34666 Branch: refs/heads/trunk Commit: bbb346667a80af773f8b9d2b10c6d53d01d024d2 Parents: bf3d285 Author: Oleg Nechiporenko <[email protected]> Authored: Wed Dec 24 13:51:42 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Wed Dec 24 13:51:42 2014 +0200 ---------------------------------------------------------------------- .../app/controllers/wizard/step8_controller.js | 81 ++++++++++---------- .../test/controllers/wizard/step8_test.js | 22 +++--- 2 files changed, 54 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb34666/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 1ce55ca..a0f3e6d 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -1820,52 +1820,55 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz /** * Create one Alert Notification (if user select this on step7) - * Only for Install Wizard and stack >= 2! + * Only for Install Wizard and stack * @method createNotification */ createNotification: function () { if (this.get('content.controllerName') !== 'installerController') return; var miscConfigs = this.get('configs').filterProperty('serviceName', 'MISC'), createNotification = miscConfigs.findProperty('name', 'create_notification').value; - if (createNotification === 'yes') { - var properties = {}, - names = [ - 'ambari.dispatch.recipients', - 'mail.smtp.host', - 'mail.smtp.port', - 'mail.smtp.from', - 'mail.smtp.starttls.enable', - 'mail.smtp.startssl.enable' - ]; - if (miscConfigs.findProperty('name', 'smtp_use_auth').value == 'true') { // yes, it's not converted to boolean - names.pushObjects(['ambari.dispatch.credential.username', 'ambari.dispatch.credential.password']); - } - var customConfigNames = miscConfigs.filterProperty('displayType', 'advanced').filterProperty('filename', '').mapProperty('name'); - if (customConfigNames) { - names.pushObjects(customConfigNames); - } - names.forEach(function (name) { - properties[name] = miscConfigs.findProperty('name', name).value; - }); + if (createNotification !== 'yes') return; + var predefinedNotificationConfigNames = require('data/site_properties').configProperties.filterProperty('filename', 'alert_notification').mapProperty('name'), + configsForNotification = this.get('configs').filterProperty('filename', 'alert_notification'); + var properties = {}, + names = [ + 'ambari.dispatch.recipients', + 'mail.smtp.host', + 'mail.smtp.port', + 'mail.smtp.from', + 'mail.smtp.starttls.enable', + 'mail.smtp.startssl.enable' + ]; + if (miscConfigs.findProperty('name', 'smtp_use_auth').value == 'true') { // yes, it's not converted to boolean + names.pushObjects(['ambari.dispatch.credential.username', 'ambari.dispatch.credential.password']); + } - properties['ambari.dispatch.recipients'] = properties['ambari.dispatch.recipients'].replace(/\s/g, '').split(','); + names.forEach(function (name) { + properties[name] = miscConfigs.findProperty('name', name).value; + }); - var apiObject = { - AlertTarget: { - name: 'Initial Notification', - description: 'Notification created during cluster installing', - global: true, - notification_type: 'EMAIL', - alert_states: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'], - properties: properties - } - }; - this.addRequestToAjaxQueue({ - name: 'alerts.create_alert_notification', - data: { - data: apiObject - } - }); - } + properties['ambari.dispatch.recipients'] = properties['ambari.dispatch.recipients'].replace(/\s/g, '').split(','); + + configsForNotification.forEach(function (config) { + if (predefinedNotificationConfigNames.contains(config.name)) return; + properties[config.name] = config.value; + }); + + var apiObject = { + AlertTarget: { + name: 'Initial Notification', + description: 'Notification created during cluster installing', + global: true, + notification_type: 'EMAIL', + alert_states: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'], + properties: properties + } + }; + this.addRequestToAjaxQueue({ + name: 'alerts.create_alert_notification', + data: { + data: apiObject + } + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb34666/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 386f884..63772e7 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -1409,16 +1409,17 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.clearStep(); installerStep8Controller.set('content', {controllerName: 'installerController'}); installerStep8Controller.set('configs', [ - {name: 'create_notification', value: 'yes', serviceName: 'MISC'}, - {name: 'ambari.dispatch.recipients', value: '[email protected]', serviceName: 'MISC'}, - {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC'}, - {name: 'mail.smtp.port', value: '25', serviceName: 'MISC'}, - {name: 'mail.smtp.from', value: '[email protected]', serviceName: 'MISC'}, - {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC'}, - {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC'}, - {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC'}, - {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC'}, - {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC'} + {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'ambari.dispatch.recipients', value: '[email protected]', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'mail.smtp.from', value: '[email protected]', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'}, + {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'} ]); installerStep8Controller.get('ajaxRequestsQueue').clear(); }); @@ -1448,6 +1449,7 @@ describe('App.WizardStep8Controller', function () { expect(data.properties['mail.smtp.startssl.enable']).to.equal(false); expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr'); expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd'); + expect(data.properties['some_p']).to.equal('some_v'); });
