You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/12/04 05:31:48 UTC

ambari git commit: AMBARI-8538. Alerts UI: Implement binding to AlertGroups in Manage Alert Notifications dialog

Repository: ambari
Updated Branches:
  refs/heads/trunk 7b77f4dc6 -> 3a8e1c5e1


AMBARI-8538. Alerts UI: Implement binding to AlertGroups in Manage Alert Notifications dialog


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3a8e1c5e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3a8e1c5e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3a8e1c5e

Branch: refs/heads/trunk
Commit: 3a8e1c5e121d5bf532271c7b123e98338f274010
Parents: 7b77f4d
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Wed Dec 3 20:30:45 2014 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Wed Dec 3 20:30:52 2014 -0800

----------------------------------------------------------------------
 ambari-web/app/mappers/alert_groups_mapper.js           | 12 +++++++++++-
 ambari-web/app/mappers/alert_notification_mapper.js     |  8 +++++++-
 ambari-web/app/models/alert_notification.js             |  1 +
 .../main/alerts/manage_alert_notifications_view.js      |  3 +--
 4 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3a8e1c5e/ambari-web/app/mappers/alert_groups_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_groups_mapper.js b/ambari-web/app/mappers/alert_groups_mapper.js
index e5eebef..ff44e21 100644
--- a/ambari-web/app/mappers/alert_groups_mapper.js
+++ b/ambari-web/app/mappers/alert_groups_mapper.js
@@ -67,7 +67,8 @@ App.alertGroupsMapper = App.QuickDataMapper.create({
          * </code>
          * @type {object}
          */
-        alertDefinitionsGroupsMap = {};
+        alertDefinitionsGroupsMap = {},
+        alertNotificationsGroupsMap = {};
 
       json.items.forEach(function(item) {
         var group = self.parseIt(item, self.get('config'));
@@ -87,6 +88,14 @@ App.alertGroupsMapper = App.QuickDataMapper.create({
             alertDefinitionsGroupsMap[definition.id].push(group.id);
           });
         }
+        if (item.AlertGroup.targets) {
+          item.AlertGroup.targets.forEach(function(target) {
+            if (Em.isNone(alertNotificationsGroupsMap[target.id])) {
+              alertNotificationsGroupsMap[target.id] = [];
+            }
+            alertNotificationsGroupsMap[target.id].push(group.id);
+          });
+        }
         alertGroups.push(group);
       }, this);
 
@@ -95,6 +104,7 @@ App.alertGroupsMapper = App.QuickDataMapper.create({
       });
 
       App.cache['previousAlertGroupsMap'] = alertDefinitionsGroupsMap;
+      App.cache['alertNotificationsGroupsMap'] = alertNotificationsGroupsMap;
       App.store.loadMany(this.get('model'), alertGroups);
       App.store.commit();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a8e1c5e/ambari-web/app/mappers/alert_notification_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_notification_mapper.js b/ambari-web/app/mappers/alert_notification_mapper.js
index ba59477..bd1a42a 100644
--- a/ambari-web/app/mappers/alert_notification_mapper.js
+++ b/ambari-web/app/mappers/alert_notification_mapper.js
@@ -31,9 +31,15 @@ App.alertNotificationMapper = App.QuickDataMapper.create({
       var result = [];
       var notificationsProperties = {};
       var notificationsAlertStates = {};
+      var groupsMap = App.cache['alertNotificationsGroupsMap'];
 
       json.items.forEach(function (item) {
-        result.push(this.parseIt(item, this.config));
+        var notification = this.parseIt(item, this.config);
+        var groups = groupsMap && groupsMap[notification.id];
+        if (groups) {
+          notification.groups = groups;
+        }
+        result.push(notification);
         notificationsProperties[item.AlertTarget.id] = item.AlertTarget.properties;
         notificationsAlertStates[item.AlertTarget.id] = item.AlertTarget.alert_states;
       }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a8e1c5e/ambari-web/app/models/alert_notification.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alert_notification.js b/ambari-web/app/models/alert_notification.js
index 2ad89f3..40e2089 100644
--- a/ambari-web/app/models/alert_notification.js
+++ b/ambari-web/app/models/alert_notification.js
@@ -23,6 +23,7 @@ App.AlertNotification = DS.Model.extend({
   name: DS.attr('string'),
   type: DS.attr('string'),
   description: DS.attr('string'),
+  groups: DS.hasMany('App.AlertGroup'),
 
   properties: {},
   alertStates: []

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a8e1c5e/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 f5fe600..5835be6 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
@@ -28,8 +28,7 @@ App.ManageAlertNotificationsView = Em.View.extend({
   selectedAlertNotification: null,
 
   selectedAlertNotificationGroups: function () {
-    //TODO: Implement binding to AlertGroups
-    return ['Group1', 'Group2'].join(', ');
+    return this.get('controller.selectedAlertNotification.groups').toArray().mapProperty('name').join(', ');
   }.property('controller.selectedAlertNotification'),
 
   isEditButtonDisabled: true,