You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/12/05 18:03:05 UTC
ambari git commit: AMBARI-8562. Alerts UI: Alert Notifications dialog
has multiple issues. (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 0fb990959 -> 3c8e7ba78
AMBARI-8562. Alerts UI: Alert Notifications dialog has multiple issues. (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3c8e7ba7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3c8e7ba7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3c8e7ba7
Branch: refs/heads/trunk
Commit: 3c8e7ba780bd61332d61aff14b363c438ea18d9f
Parents: 0fb9909
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Fri Dec 5 19:00:16 2014 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Dec 5 19:00:16 2014 +0200
----------------------------------------------------------------------
.../manage_alert_notifications_controller.js | 149 ++++++++++++++-----
ambari-web/app/messages.js | 5 +
ambari-web/app/styles/alerts.less | 4 +
.../main/alerts/create_alert_notification.hbs | 45 +++---
.../main/alerts/definition_details.hbs | 3 +
.../alerts/manage_alert_notifications_popup.hbs | 62 ++++----
.../templates/main/alerts/severity_filter.hbs | 30 ----
ambari-web/app/views.js | 1 -
ambari-web/app/views/common/modal_popup.js | 7 +-
.../alerts/manage_alert_notifications_view.js | 8 +
.../views/main/alerts/severity_filter_view.js | 52 -------
...anage_alert_notifications_controller_test.js | 36 +++--
12 files changed, 224 insertions(+), 178 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/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 a5c13cf..a45e04a 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
@@ -48,8 +48,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
},
groups: {
label: Em.I18n.t('common.groups'),
- value: '',
- defaultValue: ''
+ value: [],
+ defaultValue: []
},
global: {
label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.global'),
@@ -69,8 +69,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
},
severityFilter: {
label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.severityFilter'),
- value: [true, true, true, true],
- defaultValue: [true, true, true, true]
+ value: [],
+ defaultValue: []
},
description: {
label: Em.I18n.t('common.description'),
@@ -88,6 +88,13 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
methods: ['EMAIL', 'SNMP'],
/**
+ * List of available value for Severity Filter
+ * used in Severity Filter combobox
+ * @type {Array}
+ */
+ severities: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'],
+
+ /**
* List of all Alert Notifications
* @type {App.AlertNotification[]}
*/
@@ -96,6 +103,14 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
}.property('isLoaded'),
/**
+ * List of all Alert Groups
+ * @type {App.AlertGroup[]}
+ */
+ allAlertGroups: function () {
+ return this.get('isLoaded') ? App.AlertGroup.find().toArray() : [];
+ }.property('isLoaded'),
+
+ /**
* Selected Alert Notification
* @type {App.AlertNotification}
*/
@@ -177,14 +192,10 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
var inputFields = this.get('inputFields');
var selectedAlertNotification = this.get('selectedAlertNotification');
inputFields.set('name.value', (addCopyToName ? 'Copy of ' : '') + selectedAlertNotification.get('name'));
+ inputFields.set('groups.value', selectedAlertNotification.get('groups').toArray());
inputFields.set('email.value', selectedAlertNotification.get('properties')['ambari.dispatch.recipients'] ?
selectedAlertNotification.get('properties')['ambari.dispatch.recipients'].join(', ') : '');
- inputFields.set('severityFilter.value', [
- selectedAlertNotification.get('alertStates').contains('OK'),
- selectedAlertNotification.get('alertStates').contains('WARNING'),
- selectedAlertNotification.get('alertStates').contains('CRITICAL'),
- selectedAlertNotification.get('alertStates').contains('UNKNOWN')
- ]);
+ inputFields.set('severityFilter.value', selectedAlertNotification.get('alertStates'));
inputFields.set('global.value', selectedAlertNotification.get('global'));
// not allow to edit global field
inputFields.set('global.disabled', true);
@@ -216,13 +227,66 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
bodyClass: Em.View.extend({
controller: this,
templateName: require('templates/main/alerts/create_alert_notification'),
+
+ didInsertElement: function () {
+ this.nameValidation();
+ },
+
isEmailMethodSelected: function () {
return this.get('controller.inputFields.method.value') === 'EMAIL';
- }.property('controller.inputFields.method.value')
+ }.property('controller.inputFields.method.value'),
+
+ nameValidation: function () {
+ this.set('parentView.hasErrors', !this.get('controller.inputFields.name.value').trim());
+ }.observes('controller.inputFields.name.value'),
+
+ groupsSelectView: Em.Select.extend({
+ init: function () {
+ this._super();
+ this.set('parentView.groupSelect', this);
+ }
+ }),
+
+ groupSelect: null,
+
+ selectAllGroups: function () {
+ this.set('groupSelect.selection', this.get('groupSelect.content').slice());
+ },
+
+ clearAllGroups: function () {
+ this.set('groupSelect.selection', []);
+ },
+
+ severitySelectView: Em.Select.extend({
+ init: function () {
+ this._super();
+ this.set('parentView.severitySelect', this);
+ }
+ }),
+
+ severitySelect: null,
+
+ selectAllSeverity: function () {
+ this.set('severitySelect.selection', this.get('severitySelect.content').slice());
+ },
+
+ clearAllSeverity: function () {
+ this.set('severitySelect.selection', []);
+ }
}),
+
+ isSaving: false,
+
+ hasErrors: false,
+
primary: Em.I18n.t('common.save'),
+
+ disablePrimary: function () {
+ return this.get('isSaving') || this.get('hasErrors');
+ }.property('isSaving', 'hasErrors'),
+
onPrimary: function () {
- this.set('disablePrimary', true);
+ this.set('isSaving', true);
var apiObject = self.formatNotificationAPIObject();
if (isEdit) {
self.updateAlertNotification(apiObject);
@@ -242,20 +306,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
*/
formatNotificationAPIObject: function () {
var inputFields = this.get('inputFields');
- var alertStates = [];
var properties = {};
- if (inputFields.get('severityFilter.value')[0]) {
- alertStates.push('OK');
- }
- if (inputFields.get('severityFilter.value')[1]) {
- alertStates.push('WARNING');
- }
- if (inputFields.get('severityFilter.value')[2]) {
- alertStates.push('CRITICAL');
- }
- if (inputFields.get('severityFilter.value')[3]) {
- alertStates.push('UNKNOWN');
- }
+ var clusterId = App.Cluster.find().objectAt(0).get('id');
if (inputFields.get('method.value') === 'EMAIL') {
properties['ambari.dispatch.recipients'] = inputFields.get('email.value').replace(/\s/g, '').split(',');
}
@@ -267,8 +319,16 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
name: inputFields.get('name.value'),
description: inputFields.get('description.value'),
global: inputFields.get('global.value'),
+ groups: inputFields.get('groups.value').map(function (group) {
+ return {
+ name: group.get('name'),
+ id: group.get('id'),
+ default: group.get('default'),
+ cluster_id: clusterId
+ };
+ }),
notification_type: inputFields.get('method.value'),
- alert_states: alertStates,
+ alert_states: inputFields.get('severityFilter.value'),
properties: properties
}
};
@@ -287,7 +347,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
data: {
data: apiObject
},
- success: 'createAlertNotificationSuccessCallback'
+ success: 'createAlertNotificationSuccessCallback',
+ error: 'saveErrorCallback'
});
},
@@ -317,7 +378,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
data: apiObject,
id: this.get('selectedAlertNotification.id')
},
- success: 'updateAlertNotificationSuccessCallback'
+ success: 'updateAlertNotificationSuccessCallback',
+ error: 'saveErrorCallback'
});
},
@@ -334,6 +396,14 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
},
/**
+ * Error callback for <code>createAlertNotification</code> and <code>updateAlertNotification</code>
+ * @method saveErrorCallback
+ */
+ saveErrorCallback: function () {
+ this.set('createEditPopup.isSaving', false);
+ },
+
+ /**
* Delete Notification button handler
* @return {App.ModalPopup}
* @method deleteAlertNotification
@@ -341,15 +411,16 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
deleteAlertNotification: function () {
var self = this;
return App.showConfirmationPopup(function () {
- App.ajax.send({
- name: 'alerts.delete_alert_notification',
- sender: self,
- data: {
- id: self.get('selectedAlertNotification.id')
- },
- success: 'deleteAlertNotificationSuccessCallback'
- });
- });
+ App.ajax.send({
+ name: 'alerts.delete_alert_notification',
+ sender: self,
+ data: {
+ id: self.get('selectedAlertNotification.id')
+ },
+ success: 'deleteAlertNotificationSuccessCallback'
+ });
+ }, Em.I18n.t('alerts.actions.manage_alert_notifications_popup.confirmDeleteBody').format(this.get('selectedAlertNotification.name')),
+ null, Em.I18n.t('alerts.actions.manage_alert_notifications_popup.confirmDeleteHeader'), Em.I18n.t('common.delete'));
},
/**
@@ -411,7 +482,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
var flag = validator.isValidConfigKey(name);
if (flag) {
if (this.get('controller.inputFields.customProperties').mapProperty('name').contains(name) ||
- this.get('controller.ignoredCustomProperties').contains(name)) {
+ this.get('controller.ignoredCustomProperties').contains(name)) {
this.set('errorMessage', Em.I18n.t('alerts.notifications.addCustomPropertyPopup.error.propertyExists'));
flag = false;
}
@@ -426,6 +497,8 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
templateName: require('templates/main/alerts/add_custom_config_to_alert_notification_popup')
}),
+ disablePrimary: true,
+
onPrimary: function () {
self.addCustomProperty();
self.set('newCustomProperty', {name: '', value: ''}); // cleanup
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 87bc8ec..04eaa6b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -241,6 +241,7 @@ Em.I18n.translations = {
'common.alertDefinition': "Alert Definition",
'common.prerequisites': 'Prerequisites',
'common.finalize': "Finalize",
+ 'common.severity': "Severity",
'passiveState.turnOn':'Turn On Maintenance Mode',
'passiveState.turnOff':'Turn Off Maintenance Mode',
@@ -1864,6 +1865,10 @@ Em.I18n.translations = {
'alerts.actions.manage_alert_notifications_popup.email':'Email',
'alerts.actions.manage_alert_notifications_popup.global':'Global',
'alerts.actions.manage_alert_notifications_popup.severityFilter':'Severity Filter',
+ 'alerts.actions.manage_alert_notifications_popup.clearAll':'Clear All',
+ 'alerts.actions.manage_alert_notifications_popup.selectAll':'Select All',
+ 'alerts.actions.manage_alert_notifications_popup.confirmDeleteHeader':'Confirm Delete',
+ 'alerts.actions.manage_alert_notifications_popup.confirmDeleteBody':'Are you sure you want to delete {0} group?',
'hosts.host.add':'Add New Hosts',
'hosts.table.noHosts':'No hosts to display',
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/styles/alerts.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/alerts.less b/ambari-web/app/styles/alerts.less
index 23998ac..b909b49 100644
--- a/ambari-web/app/styles/alerts.less
+++ b/ambari-web/app/styles/alerts.less
@@ -365,6 +365,10 @@
margin-bottom: 20px
}
+.notification-description {
+ white-space: pre;
+}
+
#create-edit-alert-notification {
.form-horizontal {
.controls {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/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 9ef86eb..4b8a3b8 100644
--- a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
+++ b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
@@ -32,7 +32,13 @@
<label class="control-label" for="inputGroups">{{controller.inputFields.groups.label}}</label>
<div class="controls">
- {{view Em.TextField valueBinding="controller.inputFields.groups.value" id="inputGroups" class="input-xlarge" disabledBinding="controller.inputFields.global.value"}}
+ {{view view.groupsSelectView multiple="true" id="inputGroups" class="input-large"
+ selectionBinding="controller.inputFields.groups.value"
+ contentBinding="controller.allAlertGroups"
+ optionLabelPath="content.name"
+ }}
+ <a href="#" {{action selectAllGroups target="view"}}>{{t alerts.actions.manage_alert_notifications_popup.selectAll}}</a> |
+ <a href="#" {{action clearAllGroups target="view"}}>{{t alerts.actions.manage_alert_notifications_popup.clearAll}}</a>
</div>
</div>
@@ -45,39 +51,44 @@
</div>
<div class="control-group">
- <label class="control-label" for="inputMethod">{{controller.inputFields.method.label}}</label>
+ <label class="control-label">{{controller.inputFields.severityFilter.label}}</label>
<div class="controls">
- {{view Em.Select contentBinding="controller.methods" selectionBinding="controller.inputFields.method.value" id="inputMethod" class="input-xlarge"}}
+ {{view view.severitySelectView multiple="true" id="inputSeverity" class="input-large"
+ selectionBinding="controller.inputFields.severityFilter.value"
+ contentBinding="controller.severities"
+ }}
+ <a href="#" {{action selectAllSeverity target="view"}}>{{t alerts.actions.manage_alert_notifications_popup.selectAll}}</a> |
+ <a href="#" {{action clearAllSeverity target="view"}}>{{t alerts.actions.manage_alert_notifications_popup.clearAll}}</a>
</div>
</div>
- {{#if view.isEmailMethodSelected}}
- <div class="control-group">
- <label class="control-label" for="inputEmail">{{controller.inputFields.email.label}}</label>
-
- <div class="controls">
- {{view Em.TextField valueBinding="controller.inputFields.email.value" id="inputEmail" class="input-xlarge"}}
- </div>
- </div>
- {{/if}}
-
<div class="control-group">
- <label class="control-label">{{controller.inputFields.severityFilter.label}}</label>
+ <label class="control-label" for="inputDescription">{{controller.inputFields.description.label}}</label>
<div class="controls">
- {{view App.AlertSeverityFilterView selectionBinding="controller.inputFields.severityFilter.value"}}
+ {{view Em.TextArea valueBinding="controller.inputFields.description.value" id="inputDescription" rows="4" class="input-xlarge"}}
</div>
</div>
<div class="control-group">
- <label class="control-label" for="inputDescription">{{controller.inputFields.description.label}}</label>
+ <label class="control-label" for="inputMethod">{{controller.inputFields.method.label}}</label>
<div class="controls">
- {{view Em.TextArea valueBinding="controller.inputFields.description.value" id="inputDescription" rows="4" class="input-xlarge"}}
+ {{view Em.Select contentBinding="controller.methods" selectionBinding="controller.inputFields.method.value" id="inputMethod" class="input-xlarge"}}
</div>
</div>
+ {{#if view.isEmailMethodSelected}}
+ <div class="control-group">
+ <label class="control-label" for="inputEmail">{{controller.inputFields.email.label}}</label>
+
+ <div class="controls">
+ {{view Em.TextField valueBinding="controller.inputFields.email.value" id="inputEmail" class="input-xlarge"}}
+ </div>
+ </div>
+ {{/if}}
+
{{#each customProperty in controller.inputFields.customProperties}}
<div class="control-group">
<label class="control-label" for="inputGroups">{{customProperty.name}}</label>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/templates/main/alerts/definition_details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/definition_details.hbs b/ambari-web/app/templates/main/alerts/definition_details.hbs
index 4e4e5c8..1bbb5a8 100644
--- a/ambari-web/app/templates/main/alerts/definition_details.hbs
+++ b/ambari-web/app/templates/main/alerts/definition_details.hbs
@@ -149,6 +149,9 @@
</div>
</div>
</div>
+ {{! Right column end }}
+
+ {{! List of alerts }}
<div class="definition-details-block">
<span>
<strong>{{t alerts.definition.details.instances}}</strong>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
index 94f7ed8..749b86b 100644
--- a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
+++ b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
@@ -17,17 +17,17 @@
}}
<div class="alert alert-info margin-bottom-5">{{t alerts.actions.manageNotifications.info}}</div>
{{#if controller.isLoaded}}
- <div class="row-fluid manage-configuration-group-content" id="manage-alert-notification-content">
+ <div class="row-fluid manage-configuration-group-content" id="manage-alert-notification-content">
<div class="span12">
<div class="row-fluid">
<div class="span4 notification-list">
<span> </span>
{{view Em.Select
- contentBinding="alertNotifications"
- optionLabelPath="content.name"
- multiple="multiple"
- class="group-select"
- selectionBinding="view.selectedAlertNotification"
+ contentBinding="alertNotifications"
+ optionLabelPath="content.name"
+ multiple="multiple"
+ class="group-select"
+ selectionBinding="view.selectedAlertNotification"
}}
<div class="btn-toolbar pull-right">
<button rel="button-info" class="btn"
@@ -62,33 +62,37 @@
<div class="row-fluid">
<div class="span12 pull-right">
{{#if selectedAlertNotification}}
- <div class="row-fluid">
- <div class="span3">{{t common.name}}</div>
- <div class="span9">{{selectedAlertNotification.name}}</div>
- </div>
- <div class="row-fluid">
- <div class="span3">{{t common.groups}}</div>
- <div class="span9">{{view.selectedAlertNotificationGroups}}</div>
- </div>
- <div class="row-fluid global-info">
- <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.global}}</div>
- <div class="span9">{{view Em.Checkbox checkedBinding="selectedAlertNotification.global" disabled="disabled" class="global-checkbox"}}</div>
- </div>
- <div class="row-fluid">
- <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.method}}</div>
- <div class="span9">{{selectedAlertNotification.type}}</div>
- </div>
- {{#if view.showEmailDetails}}
<div class="row-fluid">
- <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.email}}</div>
- <div class="span9">{{selectedAlertNotification.properties.email}}</div>
+ <div class="span3">{{t common.name}}</div>
+ <div class="span9">{{selectedAlertNotification.name}}</div>
</div>
- {{/if}}
- {{#if view.showSNMPDetails}}
- {{/if}}
+ <div class="row-fluid">
+ <div class="span3">{{t common.groups}}</div>
+ <div class="span9">{{view.selectedAlertNotificationGroups}}</div>
+ </div>
+ <div class="row-fluid">
+ <div class="span3">{{t common.severity}}</div>
+ <div class="span9">{{view.severities}}</div>
+ </div>
+ <div class="row-fluid global-info">
+ <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.global}}</div>
+ <div class="span9">{{view Em.Checkbox checkedBinding="selectedAlertNotification.global" disabled="disabled" class="global-checkbox"}}</div>
+ </div>
+ <div class="row-fluid">
+ <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.method}}</div>
+ <div class="span9">{{selectedAlertNotification.type}}</div>
+ </div>
+ {{#if view.showEmailDetails}}
+ <div class="row-fluid">
+ <div class="span3">{{t alerts.actions.manage_alert_notifications_popup.email}}</div>
+ <div class="span9">{{view.email}}</div>
+ </div>
+ {{/if}}
+ {{#if view.showSNMPDetails}}
+ {{/if}}
<div class="row-fluid">
<div class="span3">{{t common.description}}</div>
- <div class="span9">{{selectedAlertNotification.description}}</div>
+ <div class="span9 notification-description">{{selectedAlertNotification.description}}</div>
</div>
{{/if}}
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/templates/main/alerts/severity_filter.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/severity_filter.hbs b/ambari-web/app/templates/main/alerts/severity_filter.hbs
deleted file mode 100644
index cfb7dae..0000000
--- a/ambari-web/app/templates/main/alerts/severity_filter.hbs
+++ /dev/null
@@ -1,30 +0,0 @@
-{{!
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-}}
-
-<label class="checkbox inline">
- {{view Em.Checkbox checkedBinding="view.okChecked"}} OK
-</label>
-<label class="checkbox inline">
- {{view Em.Checkbox checkedBinding="view.warningChecked"}} WARNING
-</label>
-<label class="checkbox inline">
- {{view Em.Checkbox checkedBinding="view.criticalChecked"}} CRITICAL
-</label>
-<label class="checkbox inline">
- {{view Em.Checkbox checkedBinding="view.unknownChecked"}} UNKNOWN
-</label>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index e5770d7..1f0eacd 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -53,7 +53,6 @@ require('views/main/alerts/add_alert_definition/step3_view');
require('views/main/alerts');
require('views/main/alerts/manage_alert_groups_view');
require('views/main/alerts/manage_alert_notifications_view');
-require('views/main/alerts/severity_filter_view');
require('views/main/charts');
require('views/main/views/details');
require('views/main/host');
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index b5d74d1..155da55 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -132,15 +132,18 @@ App.showReloadPopup = function () {
* @param {Function} primary - "OK" button click handler
* @param {String} body - additional text constant. Will be placed in the popup-body
* @param {Function} secondary
+ * @param {String} header
+ * @param {String} primaryText
* @return {*}
*/
-App.showConfirmationPopup = function (primary, body, secondary) {
+App.showConfirmationPopup = function (primary, body, secondary, header, primaryText) {
if (!primary) {
return false;
}
return App.ModalPopup.show({
encodeBody: false,
- header: Em.I18n.t('popup.confirmation.commonHeader'),
+ primary: primaryText || Em.I18n.t('ok'),
+ header: header || Em.I18n.t('popup.confirmation.commonHeader'),
body: body || Em.I18n.t('question.sure'),
onPrimary: function () {
this.hide();
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
index 56e8556..51dee4a 100644
--- a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
+++ b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
@@ -53,6 +53,14 @@ App.ManageAlertNotificationsView = Em.View.extend({
return this.get('controller.selectedAlertNotification.type') === 'SNMP';
}.property('controller.selectedAlertNotification.type'),
+ email: function () {
+ return this.get('controller.selectedAlertNotification.properties')['ambari.dispatch.recipients'];
+ }.property('controller.selectedAlertNotification'),
+
+ severities: function () {
+ return this.get('controller.selectedAlertNotification.alertStates').join(', ');
+ }.property('controller.selectedAlertNotification'),
+
/**
* Enable/disable "edit"/"remove"/"duplicate" buttons basing on <code>controller.selectedAlertNotification</code>
* @method buttonObserver
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/ambari-web/app/views/main/alerts/severity_filter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/severity_filter_view.js b/ambari-web/app/views/main/alerts/severity_filter_view.js
deleted file mode 100644
index af4544c..0000000
--- a/ambari-web/app/views/main/alerts/severity_filter_view.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-App.AlertSeverityFilterView = Em.View.extend({
-
- templateName: require('templates/main/alerts/severity_filter'),
-
- /**
- * Array of Boolean values binded to checkboxes
- * @type {Array}
- */
- selection: [],
-
- didInsertElement: function () {
- this.set('okChecked', this.get('selection')[0]);
- this.set('warningChecked', this.get('selection')[1]);
- this.set('criticalChecked', this.get('selection')[2]);
- this.set('unknownChecked', this.get('selection')[3]);
- this.addObserver('okChecked', this, 'onChange');
- this.addObserver('warningChecked', this, 'onChange');
- this.addObserver('criticalChecked', this, 'onChange');
- this.addObserver('unknownChecked', this, 'onChange');
- },
-
- okChecked: true,
-
- warningChecked: true,
-
- criticalChecked: true,
-
- unknownChecked: true,
-
- onChange: function () {
- this.set('selection', [this.get('okChecked'), this.get('warningChecked'), this.get('criticalChecked'), this.get('unknownChecked')]);
- }
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3c8e7ba7/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 e11c5a8..07bae31 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
@@ -24,7 +24,7 @@ describe('App.ManageAlertNotificationsController', function () {
beforeEach(function () {
controller = App.ManageAlertNotificationsController.create({});
- sinon.spy(App.ajax, 'send');
+ sinon.stub(App.ajax, 'send');
});
afterEach(function () {
@@ -103,7 +103,7 @@ describe('App.ManageAlertNotificationsController', function () {
describe('#addAlertNotification()', function () {
beforeEach(function () {
- sinon.spy(controller, 'showCreateEditPopup');
+ sinon.stub(controller, 'showCreateEditPopup');
});
afterEach(function () {
@@ -127,7 +127,7 @@ describe('App.ManageAlertNotificationsController', function () {
},
severityFilter: {
value: [],
- defaultValue: [true, true, true, true]
+ defaultValue: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
},
global: {
value: false
@@ -173,6 +173,7 @@ describe('App.ManageAlertNotificationsController', function () {
name: 'test_name',
global: true,
description: 'test_description',
+ groups: ['test1', 'test2'],
type: 'EMAIL',
alertStates: ['OK', 'UNKNOWN'],
properties: {
@@ -189,7 +190,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: ''
},
groups: {
- value: ''
+ value: []
},
global: {
value: false
@@ -219,7 +220,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: 'test_name'
},
groups: {
- value: ''
+ value: ['test1', 'test2']
},
global: {
value: true,
@@ -232,7 +233,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: 'test1@test.test, test2@test.test'
},
severityFilter: {
- value: [true, false, false, true]
+ value: ['OK', 'UNKNOWN']
},
description: {
value: 'test_description'
@@ -272,6 +273,22 @@ describe('App.ManageAlertNotificationsController', function () {
describe("#formatNotificationAPIObject()", function () {
+ beforeEach(function(){
+ sinon.stub(App.Cluster, 'find', function () {
+ return {
+ objectAt: function () {
+ return Em.Object.create({
+ id: 1
+ })
+ }
+ }
+ });
+ });
+
+ afterEach(function() {
+ App.Cluster.find.restore();
+ });
+
it("should create object with properties from inputFields values", function () {
controller.set('inputFields', Em.Object.create({
@@ -279,7 +296,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: 'test_name'
},
groups: {
- value: ''
+ value: []
},
global: {
value: false
@@ -291,7 +308,7 @@ describe('App.ManageAlertNotificationsController', function () {
value: 'test1@test.test, test2@test.test,test3@test.test , test4@test.test'
},
severityFilter: {
- value: [true, false, true, false]
+ value: ['OK', 'CRITICAL']
},
description: {
value: 'test_description'
@@ -307,8 +324,9 @@ describe('App.ManageAlertNotificationsController', function () {
expect(result).to.eql({
AlertTarget: {
name: 'test_name',
- global: false,
description: 'test_description',
+ global: false,
+ groups: [],
notification_type: 'EMAIL',
alert_states: ['OK', 'CRITICAL'],
properties: {