ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-14035. $.timeago for alert instance and alert definitions should use not converted with timezone timestamps (onechiporenko)
Date Tue, 24 Nov 2015 11:13:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9f7e87e3e -> ed6f3ab01


AMBARI-14035. $.timeago for alert instance and alert definitions should use not converted
with timezone timestamps (onechiporenko)


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

Branch: refs/heads/trunk
Commit: ed6f3ab01aa67384dac728454c86a45df318a287
Parents: 9f7e87e
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Tue Nov 24 13:07:27 2015 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Tue Nov 24 13:13:42 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/mappers/alert_definition_summary_mapper.js | 3 ++-
 ambari-web/app/mappers/alert_definitions_mapper.js        | 1 +
 ambari-web/app/mappers/alert_instances_mapper.js          | 1 +
 ambari-web/app/models/alerts/alert_definition.js          | 9 +++++----
 ambari-web/app/models/alerts/alert_instance.js            | 5 +++--
 ambari-web/test/models/alerts/alert_definition_test.js    | 4 ++--
 6 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/app/mappers/alert_definition_summary_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_definition_summary_mapper.js b/ambari-web/app/mappers/alert_definition_summary_mapper.js
index b6aa135..3977518 100644
--- a/ambari-web/app/mappers/alert_definition_summary_mapper.js
+++ b/ambari-web/app/mappers/alert_definition_summary_mapper.js
@@ -48,7 +48,8 @@ App.alertDefinitionSummaryMapper = App.QuickDataMapper.create({
         });
         summaryMap[alertDefinitionSummary.definition_id] = {
           summary: summary,
-          lastTriggered: App.dateTimeWithTimeZone(parseInt(timestamp))
+          lastTriggered: App.dateTimeWithTimeZone(parseInt(timestamp)),
+          lastTriggeredRaw: timestamp
         };
       }
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/app/mappers/alert_definitions_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_definitions_mapper.js b/ambari-web/app/mappers/alert_definitions_mapper.js
index 7dad450..58d8c0b 100644
--- a/ambari-web/app/mappers/alert_definitions_mapper.js
+++ b/ambari-web/app/mappers/alert_definitions_mapper.js
@@ -122,6 +122,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
           // new values will be parsed in the another mapper, so for now just use old values
           alertDefinition.summary = oldAlertDefinition.get('summary');
           alertDefinition.last_triggered = oldAlertDefinition.get('lastTriggered');
+          alertDefinition.last_triggered_raw = oldAlertDefinition.get('lastTriggeredRaw');
         }
 
         alertDefinitionsToDelete = alertDefinitionsToDelete.without(alertDefinition.id);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/app/mappers/alert_instances_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_instances_mapper.js b/ambari-web/app/mappers/alert_instances_mapper.js
index 45a4760..349d94d 100644
--- a/ambari-web/app/mappers/alert_instances_mapper.js
+++ b/ambari-web/app/mappers/alert_instances_mapper.js
@@ -35,6 +35,7 @@ App.alertInstanceMapper = App.QuickDataMapper.create({
     host_name: 'Alert.host_name',
     scope: 'Alert.scope',
     original_timestamp: 'Alert.original_timestamp',
+    original_raw_timestamp: 'Alert.original_timestamp',
     latest_timestamp: 'Alert.latest_timestamp',
     maintenance_state: 'Alert.maintenance_state',
     instance: 'Alert.instance',

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/app/models/alerts/alert_definition.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_definition.js b/ambari-web/app/models/alerts/alert_definition.js
index ec5797e..40e601d 100644
--- a/ambari-web/app/models/alerts/alert_definition.js
+++ b/ambari-web/app/models/alerts/alert_definition.js
@@ -41,6 +41,7 @@ App.AlertDefinition = DS.Model.extend({
   groups: DS.hasMany('App.AlertGroup'),
   reporting: DS.hasMany('App.AlertReportDefinition'),
   lastTriggered: DS.attr('number'),
+  lastTriggeredRaw: DS.attr('number'),
 
   //relates only to SCRIPT-type alert definition
   location: DS.attr('string'),
@@ -102,9 +103,9 @@ App.AlertDefinition = DS.Model.extend({
    * @type {string}
    */
   lastTriggeredAgoFormatted: function () {
-    var lastTriggered = this.get('lastTriggered');
+    var lastTriggered = this.get('lastTriggeredRaw');
     return lastTriggered ? $.timeago(new Date(lastTriggered)) : '';
-  }.property('lastTriggered'),
+  }.property('lastTriggeredRaw'),
 
   lastTriggeredVerboseDisplay: function () {
     var lastTriggered = this.get('lastTriggered');
@@ -116,7 +117,7 @@ App.AlertDefinition = DS.Model.extend({
    * @type {string}
    */
   lastTriggeredForFormatted: function () {
-    var lastTriggered = this.get('lastTriggered');
+    var lastTriggered = this.get('lastTriggeredRaw');
     var previousSuffixAgo = $.timeago.settings.strings.suffixAgo;
     var previousPrefixAgo = $.timeago.settings.strings.prefixAgo;
     $.timeago.settings.strings.suffixAgo = null;
@@ -125,7 +126,7 @@ App.AlertDefinition = DS.Model.extend({
     $.timeago.settings.strings.suffixAgo = previousSuffixAgo;
     $.timeago.settings.strings.prefixAgo = previousPrefixAgo;
     return triggeredFor;
-  }.property('lastTriggered'),
+  }.property('lastTriggeredRaw'),
 
   /**
    * Formatted displayName for <code>componentName</code>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/app/models/alerts/alert_instance.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_instance.js b/ambari-web/app/models/alerts/alert_instance.js
index bec2148..f80b859 100644
--- a/ambari-web/app/models/alerts/alert_instance.js
+++ b/ambari-web/app/models/alerts/alert_instance.js
@@ -31,6 +31,7 @@ App.AlertInstance = DS.Model.extend({
   hostName: DS.attr('string'),
   scope: DS.attr('string'),
   originalTimestamp: DS.attr('number'),
+  originalRawTimestamp: DS.attr('number'),
   latestTimestamp: DS.attr('number'),
   maintenanceState: DS.attr('string'),
   instance: DS.attr('string'),
@@ -89,7 +90,7 @@ App.AlertInstance = DS.Model.extend({
    * @type {string}
    */
   lastTriggeredAgoFormatted: function () {
-    var lastTriggered = this.get('originalTimestamp');
+    var lastTriggered = this.get('originalRawTimestamp');
     return lastTriggered ? $.timeago(new Date(lastTriggered)) : '';
   }.property('originalTimestamp'),
 
@@ -106,7 +107,7 @@ App.AlertInstance = DS.Model.extend({
    * @type {string}
    */
   lastTriggeredForFormatted: function () {
-    var lastTriggered = this.get('originalTimestamp');
+    var lastTriggered = this.get('originalRawTimestamp');
     var previousSuffixAgo = $.timeago.settings.strings.suffixAgo;
     var previousPrefixAgo = $.timeago.settings.strings.prefixAgo;
     $.timeago.settings.strings.suffixAgo = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed6f3ab0/ambari-web/test/models/alerts/alert_definition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_definition_test.js b/ambari-web/test/models/alerts/alert_definition_test.js
index 1aeea49..c32dde4 100644
--- a/ambari-web/test/models/alerts/alert_definition_test.js
+++ b/ambari-web/test/models/alerts/alert_definition_test.js
@@ -162,12 +162,12 @@ describe('App.AlertDefinition', function () {
   describe('#lastTriggeredAgoFormatted', function () {
 
     it('should be empty', function () {
-      model.set('lastTriggered', 0);
+      model.set('lastTriggeredRaw', 0);
       expect(model.get('lastTriggeredAgoFormatted')).to.equal('');
     });
 
     it('should not be empty', function () {
-      model.set('lastTriggered', new Date().getTime() - 61000);
+      model.set('lastTriggeredRaw', new Date().getTime() - 61000);
       expect(model.get('lastTriggeredAgoFormatted')).to.equal('about a minute ago');
     });
 


Mime
View raw message