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-19643. Not completed Upgrade History items show End Time as "Not started" (onechiporenko)
Date Fri, 20 Jan 2017 12:02:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 495146c57 -> 5e6265857


AMBARI-19643. Not completed Upgrade History items show End Time as "Not started" (onechiporenko)


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

Branch: refs/heads/branch-2.5
Commit: 5e6265857168e0cf493239448000dfa006c426d1
Parents: 495146c
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Jan 20 12:13:21 2017 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Jan 20 14:02:22 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/utils/date/date.js               | 29 ++++++++++++--------
 .../admin/stack_upgrade/upgrade_history_view.js |  2 +-
 ambari-web/test/utils/date/date_test.js         | 17 ++++++++++++
 .../stack_upgrade/upgrade_history_view_test.js  |  4 +++
 4 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5e626585/ambari-web/app/utils/date/date.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/date/date.js b/ambari-web/app/utils/date/date.js
index 877b421..d461d21 100644
--- a/ambari-web/app/utils/date/date.js
+++ b/ambari-web/app/utils/date/date.js
@@ -82,26 +82,33 @@ module.exports = {
     return date;
   },
 
+  startTime: function (startTimestamp) {
+    return this._time(startTimestamp, 'Not started');
+  },
+
+  endTime: function (endTimestamp) {
+    return this._time(endTimestamp, 'Not finished');
+  },
+
   /**
-   * Convert starTimestamp to 'DAY_OF_THE_WEEK, MONTH DAY, YEAR HOURS:MINUTES', except for
the case: year equals 1969
+   * Convert timestamp to 'DAY_OF_THE_WEEK, MONTH DAY, YEAR HOURS:MINUTES', except for the
case: year equals 1969
    *
-   * @param {string} startTimestamp
-   * @return {string} startTimeSummary
-   * @method startTime
+   * @param {string} timestamp
+   * @param {string} msg
+   * @return {string} TimeSummary
    */
-  startTime: function (startTimestamp) {
-    if (!validator.isValidInt(startTimestamp)) {
+  _time: function (timestamp, msg) {
+    if (!validator.isValidInt(timestamp)) {
       return '';
     }
-    var startDate = new Date(startTimestamp);
+    var startDate = new Date(timestamp);
     var months = this.dateMonths;
     var days = this.dateDays;
-    // generate start time
-    if (startDate.getFullYear() == 1969 || startTimestamp < 1) {
-      return 'Not started';
+    if (startDate.getFullYear() === 1969 || timestamp < 1) {
+      return msg;
     }
     var startTimeSummary = '';
-    if (new Date(startTimestamp).setHours(0, 0, 0, 0) == new Date().setHours(0, 0, 0, 0))
{ //today
+    if (new Date(timestamp).setHours(0, 0, 0, 0) === new Date().setHours(0, 0, 0, 0)) { //today
       startTimeSummary = 'Today ' + this.dateFormatZeroFirst(startDate.getHours()) + ':'
+ this.dateFormatZeroFirst(startDate.getMinutes());
     } else {
       startTimeSummary = days[startDate.getDay()] + ' ' + months[startDate.getMonth()] +
' ' +

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e626585/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
index 5954673..3dfb4c1 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
@@ -134,7 +134,7 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
         directionLabel: direction,
         upgradeTypeLabel: method ? method.get('displayName') : method,
         startTimeLabel: date.startTime(App.dateTimeWithTimeZone(item.get('startTime'))),
-        endTimeLabel: date.startTime(App.dateTimeWithTimeZone(item.get('endTime'))),
+        endTimeLabel: date.endTime(App.dateTimeWithTimeZone(item.get('endTime'))),
         duration: date.durationSummary(item.get('startTime'), item.get('endTime'))
       });
       processedContent.push(item);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e626585/ambari-web/test/utils/date/date_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/date/date_test.js b/ambari-web/test/utils/date/date_test.js
index c82a02e..5289fdd 100644
--- a/ambari-web/test/utils/date/date_test.js
+++ b/ambari-web/test/utils/date/date_test.js
@@ -68,6 +68,23 @@ describe('date', function () {
     });
   });
 
+  describe('#endTime()', function() {
+    var today = new Date();
+    var testDate = new Date(1349752195000);
+    var tests = [
+      { t: 1349752195000, e: testDate.toDateString() + ' {0}:{1}'.format(date.dateFormatZeroFirst(testDate.getHours()),
date.dateFormatZeroFirst(testDate.getMinutes())) },
+      { t: -10000000, e: 'Not finished' },
+      { t: today.getTime(), e: 'Today {0}:{1}'.format(date.dateFormatZeroFirst(today.getHours()),
date.dateFormatZeroFirst(today.getMinutes())) },
+      { t: today, e: ''}
+    ];
+    tests.forEach(function(test) {
+      var testMessage = 'should convert {0} to {1}'.format(test.t, test.e);
+      it(testMessage, function() {
+        expect(date.endTime(test.t)).to.be.eql(test.e);
+      });
+    });
+  });
+
   describe('#timingFormat', function() {
     var tests = Em.A([
       {i: '30', e:'30 ms'},

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e626585/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
index d13ccd5..2e4838c 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
@@ -232,6 +232,10 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
     });
 
 
+    it('End Time for upgrade in progress is `Not finished`', function () {
+      processedContent = view.processForDisplay([Em.Object.create({endTime: -1})]);
+      expect(processedContent[0].get('endTimeLabel')).to.be.equal('Not finished');
+    });
   });
 
 });


Mime
View raw message