You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/02/06 01:54:19 UTC

svn commit: r1442819 - in /incubator/ambari/trunk: ./ ambari-web/app/controllers/main/ ambari-web/app/models/ ambari-web/app/styles/ ambari-web/app/templates/main/ ambari-web/app/templates/main/host/ ambari-web/app/views/main/

Author: yusaku
Date: Wed Feb  6 00:54:18 2013
New Revision: 1442819

URL: http://svn.apache.org/viewvc?rev=1442819&view=rev
Log:
AMBARI-1349. Expose host-specific Nagios alerts in Ambari Web. (yusaku)

Added:
    incubator/ambari/trunk/ambari-web/app/templates/main/host/alerts_popup.hbs
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/main/host.js
    incubator/ambari/trunk/ambari-web/app/models/host.js
    incubator/ambari/trunk/ambari-web/app/styles/application.less
    incubator/ambari/trunk/ambari-web/app/templates/main/host.hbs
    incubator/ambari/trunk/ambari-web/app/templates/main/host/details.hbs
    incubator/ambari/trunk/ambari-web/app/views/main/menu.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed Feb  6 00:54:18 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1349. Expose host-specific Nagios alerts in Ambari Web. (yusaku)
+
  AMBARI-1294. Add isEmpty() query operator support. (jspeidel)
 
  AMBARI-1280. Support explicit predicate grouping in API queries. (jspeidel)

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/host.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host.js?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/host.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/host.js Wed Feb  6 00:54:18 2013
@@ -25,6 +25,10 @@ App.MainHostController = Em.ArrayControl
   content: App.Host.find(),
   comeWithFilter: false,
 
+  hostsWithAlerts: function () {
+    return App.Alert.find().mapProperty('hostName').uniq();
+  }.property('App.router.clusterController.alerts.length'),
+
   /**
    * Components which will be shown in component filter
    */
@@ -101,6 +105,38 @@ App.MainHostController = Em.ArrayControl
     });
   },
 
+  showAlertsPopup: function (event) {
+    var host = event.context;
+    App.ModalPopup.show({
+      header: this.t('services.alerts.headingOfList'),
+      bodyClass: Ember.View.extend({
+        hostAlerts: function () {
+          var allAlerts = App.router.get('clusterController.alerts');
+          if (host) {
+            return allAlerts.filterProperty('hostName', host.get('hostName'));
+          }
+          return 0;
+        }.property('App.router.clusterController.alerts'),
+
+        closePopup: function () {
+          this.get('parentView').hide();
+        },
+
+        templateName: require('templates/main/host/alerts_popup')
+      }),
+      primary: 'Close',
+      onPrimary: function() {
+        this.hide();
+      },
+      secondary : null,
+      didInsertElement: function () {
+        this.$().find('.modal-footer').addClass('align-center');
+        this.$().children('.modal').css({'margin-top': '-350px'});
+      }
+    });
+    event.stopPropagation();
+  },
+
   /**
    * remove selected hosts
    */

Modified: incubator/ambari/trunk/ambari-web/app/models/host.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/host.js?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/host.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/host.js Wed Feb  6 00:54:18 2013
@@ -52,8 +52,12 @@ App.Host = DS.Model.extend({
   loadFive:DS.attr('number'),
   loadFifteen:DS.attr('number'),
 
+  alertsCount: function () {
+    return App.Alert.find().filterProperty('hostName', this.get('hostName')).length;
+  }.property('App.router.clusterController.alerts.length'),
+
   publicHostNameFormatted: function() {
-    return this.get('publicHostName').substr(0, 25) + ' ...';
+    return this.get('publicHostName').substr(0, 20) + ' ...';
   }.property('publicHostName'),
   /**
    * API return diskTotal and diskFree. Need to save their different

Modified: incubator/ambari/trunk/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/styles/application.less?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/trunk/ambari-web/app/styles/application.less Wed Feb  6 00:54:18 2013
@@ -1704,6 +1704,7 @@ a:focus {
 
 /*Dashboard*/
 .alerts-count {
+  cursor: pointer;
   margin-left: 5px;
 }
 

Modified: incubator/ambari/trunk/ambari-web/app/templates/main/host.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/host.hbs?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/host.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/host.hbs Wed Feb  6 00:54:18 2013
@@ -63,6 +63,9 @@
       </td>
       <td class="name">
         <a title="{{unbound host.publicHostName}}" href="#" {{action "showDetails" host}}>{{unbound host.publicHostNameFormatted}}</a>
+        {{#if host.alertsCount}}
+          <span class="label label-important alerts-count" {{action "showAlertsPopup" host target="controller"}}>{{host.alertsCount}}</span>
+        {{/if}}
       </td>
       <td>{{host.ip}}</td>
       <td>{{host.cpu}}</td>

Added: incubator/ambari/trunk/ambari-web/app/templates/main/host/alerts_popup.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/host/alerts_popup.hbs?rev=1442819&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/host/alerts_popup.hbs (added)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/host/alerts_popup.hbs Wed Feb  6 00:54:18 2013
@@ -0,0 +1,25 @@
+{{!
+* 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.
+}}
+
+{{#if view.hostAlerts.length}}
+<ul id='summary-alerts-list' class="alerts">
+  {{#each view.hostAlerts}}
+  {{view App.AlertItemView contentBinding="this"}}
+  {{/each}}
+</ul>
+{{/if}}

Modified: incubator/ambari/trunk/ambari-web/app/templates/main/host/details.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/host/details.hbs?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/host/details.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/host/details.hbs Wed Feb  6 00:54:18 2013
@@ -18,6 +18,11 @@
 
 <div id="host-details">
   <span {{bindAttr class="view.content.healthClass"}} {{bindAttr title="view.content.healthToolTip" }}></span><span class='host-title'>{{unbound view.content.publicHostName}}</span>
+  {{#if view.content.alertsCount}}
+    <span class="label label-important alerts-count" {{action "showAlertsPopup" content target="App.router.mainHostController"}}>{{view.content.alertsCount}}</span>
+  {{else}}
+    <span class="label label-important alerts-count">No alerts</span>
+  {{/if}}
   <div><a href="javascript:void(null)" data-toggle="modal" {{action backToHostsList}}><i class="icon-arrow-left"></i>&nbsp;Back to Hosts</a></div>
 <!--   {{#if App.isAdmin}} -->
 <!--   <div class="host-maintenance"> -->

Modified: incubator/ambari/trunk/ambari-web/app/views/main/menu.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/menu.js?rev=1442819&r1=1442818&r2=1442819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/menu.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/menu.js Wed Feb  6 00:54:18 2013
@@ -67,18 +67,10 @@ App.MainMenuView = Em.CollectionView.ext
     active:'',
 
     alertsCount:function () {
-      if (this.get('content').routing == 'dashboard') {
-        return App.router.get('mainDashboardController.alertsCount');
+      if (this.get('content').routing == 'hosts') {
+        return App.router.get('mainHostController.hostsWithAlerts').length;
       }
-    }.property(),
-
-//    hostDetailsOperationsCount:function () {
-//      if (this.get('content').routing == 'hosts') {
-//        if (App.router.currentState.parentState.name == 'hostDetails') {
-//          return App.router.get('mainHostDetailsController.hostOperationsCount');
-//        }
-//      }
-//    }.property('App.router.currentState.parentState.name', 'App.router.mainHostDetailsController.hostOperationsCount'),
+    }.property('App.router.mainHostController.hostsWithAlerts.length'),
 
     templateName: require('templates/main/menu_item')
   })