Author: yusaku
Date: Sat Jan 26 05:30:31 2013
New Revision: 1438855
URL: http://svn.apache.org/viewvc?rev=1438855&view=rev
Log:
AMBARI-1172. Alert status change does not change time for the alerts. (srimanth
via yusaku)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1438855&r1=1438854&r2=1438855&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Jan 26 05:30:31 2013
@@ -151,6 +151,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1172. Alert status change does not change time for the alerts.
+ (srimanth via yusaku)
+
AMBARI-1264. Service graphs refresh with spinners. (yusaku)
AMBARI-1257. Separator missing in between Oozie and ZooKeeper. (yusaku)
Modified: incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js?rev=1438855&r1=1438854&r2=1438855&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js (original)
+++ incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js Sat Jan 26
05:30:31 2013
@@ -48,8 +48,22 @@ App.alertsMapper = App.QuickDataMapper.c
this.update(alerts);
} else {
var result = [];
- alerts.forEach(function (item) {
- result.push(this.parseIt(item, this.config));
+ alerts.forEach(function(item){
+ var applyConfig = jQuery.extend({}, this.config);
+ if (item.current_state && item.last_hard_state && item.current_state
!= item.last_hard_state) {
+ switch (item.current_state) {
+ case "0":
+ applyConfig['date'] = 'last_time_ok';
+ break;
+ case "1":
+ applyConfig['date'] = 'last_time_warning';
+ break;
+ case "2":
+ applyConfig['date'] = 'last_time_critical';
+ break;
+ }
+ }
+ result.push(this.parseIt(item, applyConfig));
}, this);
App.store.loadMany(this.get('model'), result);
}
@@ -65,11 +79,42 @@ App.alertsMapper = App.QuickDataMapper.c
alerts.forEach(function(item){
var existAlert = titleToAlertMap[item.service_type +
item.service_description + item.plugin_output];
if (existAlert == null) {
- newRecords.push(this.parseIt(item, this.config));
+ var applyConfig = jQuery.extend({}, this.config);
+ if (item.current_state && item.last_hard_state && item.current_state
!= item.last_hard_state) {
+ switch (item.current_state) {
+ case "0":
+ applyConfig['date'] = 'last_time_ok';
+ break;
+ case "1":
+ applyConfig['date'] = 'last_time_warning';
+ break;
+ case "2":
+ applyConfig['date'] = 'last_time_critical';
+ break;
+ }
+ }
+ newRecords.push(this.parseIt(item, applyConfig));
} else {
// update record
existAlert.set('serviceType', item.service_type);
- existAlert.set('date',
DS.attr.transforms.date.from(item.last_hard_state_change));
+ if (item.current_state && item.last_hard_state && item.current_state
!= item.last_hard_state) {
+ switch (item.current_state) {
+ case "0":
+ existAlert.set('date',
DS.attr.transforms.date.from(item.last_time_ok));
+ break;
+ case "1":
+ existAlert.set('date',
DS.attr.transforms.date.from(item.last_time_warning));
+ break;
+ case "2":
+ existAlert.set('date',
DS.attr.transforms.date.from(item.last_time_critical));
+ break;
+ default:
+ existAlert.set('date',
DS.attr.transforms.date.from(item.last_hard_state_change));
+ break;
+ }
+ }else{
+ existAlert.set('date',
DS.attr.transforms.date.from(item.last_hard_state_change));
+ }
existAlert.set('status', item.current_state);
existAlert.set('message', item.plugin_output);
existAlert.set('lastHardStateChange', item.last_hard_state_change);