|
@@ -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);
|
|
|
}
|
|
|
|
|
|
});
|