Repository: ambari Updated Branches: refs/heads/trunk af19b7d0f -> 780cd6095
AMBARI-15603 Exposure of Global Alert Repeat Tolerance Value in Web Client (zhewang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/780cd609 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/780cd609 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/780cd609 Branch: refs/heads/trunk Commit: 780cd60957219aea422fd454bf26ad26f0faa6e2 Parents: af19b7d Author: Zhe (Joe) Wang <[email protected]> Authored: Mon Apr 4 15:22:20 2016 -0700 Committer: Zhe (Joe) Wang <[email protected]> Committed: Mon Apr 4 15:23:08 2016 -0700 ---------------------------------------------------------------------- .../alert_definitions_actions_controller.js | 97 ++++++++++++++++++++ ambari-web/app/messages.js | 9 ++ ambari-web/app/styles/application.less | 3 - .../common/modal_popups/prompt_popup.hbs | 4 + 4 files changed, 110 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/780cd609/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js index dc9f78c..1712b6f 100644 --- a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js +++ b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js @@ -16,6 +16,8 @@ * limitations under the License. */ +var validator = require('utils/validator'); + App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ name: 'mainAlertDefinitionActionsController', @@ -42,6 +44,12 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ icon: 'icon-envelope-alt', action: 'manageNotifications', showDivider: false + }, + { + title: Em.I18n.t('alerts.actions.manageSettings'), + icon: 'icon-cogs', + action: 'manageSettings', + showDivider: false } ], @@ -201,6 +209,95 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ autoHeight: false }); + }, + + /** + * "Manage Alert Settings" handler + * @method manageSettings + * @return {App.ModalPopup} + */ + manageSettings: function () { + var controller = this; + var loadingPopup = App.ModalPopup.show({ + header: Em.I18n.t('jobs.loadingTasks'), + primary: false, + secondary: false, + bodyClass: Em.View.extend({ + template: Em.Handlebars.compile('{{view App.SpinnerView}}') + }) + }); + this.loadClusterConfig().done(function (data) { + var tag = [ + { + siteName: 'cluster-env', + tagName: data.Clusters.desired_configs['cluster-env'].tag, + newTagName: null + } + ]; + App.router.get('configurationController').getConfigsByTags(tag).done(function (config) { + var configProperties = config[0].properties; + + loadingPopup.hide(); + return App.ModalPopup.show({ + classNames: ['fourty-percent-width-modal'], + header: Em.I18n.t('alerts.actions.manageSettings'), + primary: Em.I18n.t('common.save'), + secondary: Em.I18n.t('common.cancel'), + inputValue: configProperties.alerts_repeat_tolerance || '1', + errorMessage: Em.I18n.t('alerts.actions.editRepeatTolerance.error'), + isInvalid: function () { + var intValue = Number(this.get('inputValue')); + return this.get('inputValue') !== 'DEBUG' && (!validator.isValidInt(intValue) || intValue < 1); + }.property('inputValue'), + disablePrimary: Em.computed.alias('isInvalid'), + onPrimary: function () { + if (this.get('isInvalid')) { + return; + } + configProperties.alerts_repeat_tolerance = this.get('inputValue'); + App.ajax.send({ + name: 'admin.save_configs', + sender: controller, + data: { + siteName: 'cluster-env', + properties: configProperties + }, + error: 'manageSettingsErrorCallback' + }); + this.hide(); + }, + bodyClass: Ember.View.extend({ + templateName: require('templates/common/modal_popups/prompt_popup'), + text: Em.I18n.t('alerts.actions.editRepeatTolerance.text'), + title: Em.I18n.t('alerts.actions.editRepeatTolerance.title'), + description: Em.I18n.t('alerts.actions.editRepeatTolerance.description'), + label: Em.I18n.t('alerts.actions.editRepeatTolerance.label') + }) + }); + }); + }); + }, + + loadClusterConfig: function () { + return App.ajax.send({ + name: 'config.tags.site', + sender: this, + data: { + site: 'cluster-env' + } + }); + }, + + manageSettingsErrorCallback: function(data) { + var error = Em.I18n.t('alerts.actions.manageSettings.error'); + if(data && data.responseText){ + try { + var json = $.parseJSON(data.responseText); + error += json.message; + } catch (err) { + } + } + App.showAlertPopup(Em.I18n.t('alerts.actions.manageSettings.error'), error); } }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/780cd609/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 1b2a02f..1653eeb 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -999,6 +999,15 @@ Em.I18n.translations = { 'alerts.actions.manageGroups': 'Manage Alert Groups', 'alerts.actions.manageNotifications': 'Manage Notifications', 'alerts.actions.manageNotifications.info': 'You can manage notification methods and recipients.', + 'alerts.actions.editRepeatTolerance.text': 'Manage global setting for alerts', + 'alerts.actions.editRepeatTolerance.title': 'Alert Check Retries', + 'alerts.actions.editRepeatTolerance.description': 'Set the amount of alert check retries to perform before dispatching a notification.' + + 'If during an alert check a state change occurs, Ambari will retry this number of times before dispatching a notification. Increase this number if your environment experiences temporal issues.', + 'alerts.actions.editRepeatTolerance.label': 'Retries:', + 'alerts.actions.editRepeatTolerance.error':'Input should be a positive integer.', + 'alerts.actions.manageSettings': 'Manage Alert Settings', + 'alerts.actions.manageGlobalRepeatTolerance.tooltip': 'This value will be overriden, if specific repeat tolerance value is set for individual alert.', + 'alerts.actions.manageSettings.error':'Error during remote command: ', 'alerts.groups.successPopup.header': 'Alert Groups processing results', 'alerts.groups.successPopup.body.created': 'New Alert Groups', http://git-wip-us.apache.org/repos/asf/ambari/blob/780cd609/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index a6b79ce..683ba24 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -5772,9 +5772,6 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox { form { margin-top: 20px; } - .prompt-input { - width: 520px; - } } #views { http://git-wip-us.apache.org/repos/asf/ambari/blob/780cd609/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs b/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs index 078cc65..e1e03fb 100644 --- a/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs +++ b/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs @@ -19,7 +19,11 @@ <form> <div {{bindAttr class=":control-group view.parentView.isInvalid:error"}}> <label class="control-label">{{view.text}}</label> + <br> + <h4>{{view.title}}</h4> + <p>{{view.description}}</p> <div class="controls"> + <strong>{{view.label}} </strong> {{view Em.TextField class="prompt-input" valueBinding="view.parentView.inputValue"}} </div> {{#if view.parentView.isInvalid}}
