|
@@ -230,7 +230,7 @@ App.MainAlertDefinitionDetailsController = Em.Controller.extend({
|
|
|
});
|
|
|
|
|
|
return App.showConfirmationFeedBackPopup(function (query) {
|
|
|
- self.toggleDefinitionState(alertDefinition, "enabled");
|
|
|
+ self.toggleDefinitionState(alertDefinition);
|
|
|
}, bodyMessage);
|
|
|
},
|
|
|
|
|
@@ -241,101 +241,99 @@ App.MainAlertDefinitionDetailsController = Em.Controller.extend({
|
|
|
* @returns {$.ajax}
|
|
|
* @method toggleDefinitionState
|
|
|
*/
|
|
|
- toggleDefinitionState: function (alertDefinition, property) {
|
|
|
- var newState = !alertDefinition.get(property);
|
|
|
- alertDefinition.set(property, newState);
|
|
|
- var data = {};
|
|
|
- data['AlertDefinition/' + property] = newState;
|
|
|
+ toggleDefinitionState: function (alertDefinition) {
|
|
|
+ var newState = !alertDefinition.get('enabled');
|
|
|
+ alertDefinition.set('enabled', newState);
|
|
|
return App.ajax.send({
|
|
|
name: 'alerts.update_alert_definition',
|
|
|
sender: this,
|
|
|
data: {
|
|
|
id: alertDefinition.get('id'),
|
|
|
- data: data
|
|
|
+ data: {
|
|
|
+ "AlertDefinition/enabled": newState
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * "Disable / Enable Repeat Tolerance" button handler
|
|
|
- * @method toggleRepeatTolerance
|
|
|
- */
|
|
|
- toggleRepeatTolerance: function () {
|
|
|
+ globalAlertsRepeatTolerance: function () {
|
|
|
+ return App.router.get('clusterController.clusterEnv.properties.alerts_repeat_tolerance') || "1";
|
|
|
+ }.property('App.router.clusterController.clusterEnv'),
|
|
|
+
|
|
|
+ enableRepeatTolerance: function (enable) {
|
|
|
var alertDefinition = this.get('content');
|
|
|
- var self = this;
|
|
|
- var bodyMessage = Em.Object.create({
|
|
|
- confirmMsg: alertDefinition.get('repeat_tolerance_enabled') ? Em.I18n.t('alerts.table.repeatTolerance.enabled.confirm.msg') : Em.I18n.t('alerts.table.repeatTolerance.disabled.confirm.msg').format(alertDefinition.get('repeat_tolerance') || 1),
|
|
|
- confirmButton: Em.I18n.t('common.confirm')
|
|
|
+ alertDefinition.set('repeat_tolerance_enabled', enable);
|
|
|
+ return App.ajax.send({
|
|
|
+ name: 'alerts.update_alert_definition',
|
|
|
+ sender: this,
|
|
|
+ data: {
|
|
|
+ id: alertDefinition.get('id'),
|
|
|
+ data: {
|
|
|
+ "AlertDefinition/repeat_tolerance_enabled": enable
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- return App.showConfirmationFeedBackPopup(function (query) {
|
|
|
- self.toggleDefinitionState(alertDefinition, "repeat_tolerance_enabled");
|
|
|
- }, bodyMessage);
|
|
|
},
|
|
|
|
|
|
editRepeatTolerance: function () {
|
|
|
var self = this;
|
|
|
var alertDefinition = this.get('content');
|
|
|
|
|
|
- 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}}')
|
|
|
- })
|
|
|
- });
|
|
|
+ var alertsRepeatTolerance = App.router.get('clusterController.clusterEnv.properties.alerts_repeat_tolerance') || "1";
|
|
|
|
|
|
- App.router.get('mainAlertDefinitionActionsController').loadClusterConfig().done(function (data) {
|
|
|
- var tag = [
|
|
|
- {
|
|
|
- siteName: 'cluster-env',
|
|
|
- tagName: data.Clusters.desired_configs['cluster-env'].tag,
|
|
|
- newTagName: null
|
|
|
+ return App.ModalPopup.show({
|
|
|
+ classNames: ['fourty-percent-width-modal'],
|
|
|
+ header: Em.I18n.t('alerts.actions.editRepeatTolerance.header'),
|
|
|
+ primary: Em.I18n.t('common.save'),
|
|
|
+ secondary: Em.I18n.t('common.cancel'),
|
|
|
+ inputValue: self.get('content.repeat_tolerance_enabled') ? (self.get('content.repeat_tolerance') || 1) : alertsRepeatTolerance,
|
|
|
+ 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 || intValue > 99);
|
|
|
+ }.property('inputValue'),
|
|
|
+ isChanged: function () {
|
|
|
+ var intValue = Number(this.get('inputValue'));
|
|
|
+ var isValueChanged = intValue != alertsRepeatTolerance;
|
|
|
+ return isValueChanged;
|
|
|
+ }.property('inputValue'),
|
|
|
+ doRestoreDefaultValue: function () {
|
|
|
+ this.set('inputValue', alertsRepeatTolerance);
|
|
|
+ this.$('[data-toggle=tooltip]').tooltip('destroy');
|
|
|
+ },
|
|
|
+ disablePrimary: Em.computed.alias('isInvalid'),
|
|
|
+ onPrimary: function () {
|
|
|
+ if (this.get('isInvalid')) {
|
|
|
+ return;
|
|
|
}
|
|
|
- ];
|
|
|
- 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.editRepeatTolerance.header'),
|
|
|
- primary: Em.I18n.t('common.save'),
|
|
|
- secondary: Em.I18n.t('common.cancel'),
|
|
|
- inputValue: self.get('content.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;
|
|
|
+ var input = this.get('inputValue');
|
|
|
+ self.set('content.repeat_tolerance', input);
|
|
|
+ if (input == alertsRepeatTolerance) {
|
|
|
+ self.enableRepeatTolerance(false);
|
|
|
+ } else {
|
|
|
+ self.enableRepeatTolerance(true);
|
|
|
+ }
|
|
|
+ App.ajax.send({
|
|
|
+ name: 'alerts.update_alert_definition',
|
|
|
+ sender: self,
|
|
|
+ data: {
|
|
|
+ id: alertDefinition.get('id'),
|
|
|
+ data: {
|
|
|
+ "AlertDefinition/repeat_tolerance": input
|
|
|
}
|
|
|
- self.set('content.repeat_tolerance', this.get('inputValue'));
|
|
|
- App.ajax.send({
|
|
|
- name: 'alerts.update_alert_definition',
|
|
|
- sender: self,
|
|
|
- data: {
|
|
|
- id: alertDefinition.get('id'),
|
|
|
- data: {
|
|
|
- "AlertDefinition/repeat_tolerance": this.get('inputValue')
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- this.hide();
|
|
|
- },
|
|
|
- bodyClass: Ember.View.extend({
|
|
|
- templateName: require('templates/common/modal_popups/prompt_popup'),
|
|
|
- text: Em.I18n.t('alerts.actions.editRepeatTolerance.body').format(configProperties.alerts_repeat_tolerance || "1"),
|
|
|
- title: Em.I18n.t('alerts.actions.editRepeatTolerance.title'),
|
|
|
- description: Em.I18n.t('alerts.actions.editRepeatTolerance.description'),
|
|
|
- label: Em.I18n.t('alerts.actions.editRepeatTolerance.label')
|
|
|
- })
|
|
|
+ }
|
|
|
});
|
|
|
- });
|
|
|
+ this.hide();
|
|
|
+ },
|
|
|
+ didInsertElement: function () {
|
|
|
+ App.tooltip(this.$('[data-toggle=tooltip]'));
|
|
|
+ },
|
|
|
+ bodyClass: Ember.View.extend({
|
|
|
+ templateName: require('templates/common/modal_popups/prompt_popup'),
|
|
|
+ title: Em.I18n.t('alerts.actions.editRepeatTolerance.title'),
|
|
|
+ description: Em.I18n.t('alerts.actions.editRepeatTolerance.description'),
|
|
|
+ label: Em.I18n.t('alerts.actions.editRepeatTolerance.label')
|
|
|
+ })
|
|
|
});
|
|
|
},
|
|
|
|