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

2017-01-20 Thread onechiporenko
Repository: ambari
Updated Branches:
  refs/heads/trunk 6e8c2263f -> 7131068df


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/7131068d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7131068d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7131068d

Branch: refs/heads/trunk
Commit: 7131068df0cef726b9044e7b4ffe4977d86c6d88
Parents: 6e8c226
Author: Oleg Nechiporenko 
Authored: Fri Jan 20 12:13:21 2017 +0200
Committer: Oleg Nechiporenko 
Committed: Fri Jan 20 14:02:48 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/7131068d/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/7131068d/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 e259e3f..c4a428e 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/7131068d/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 = [
+ 

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

2017-01-20 Thread onechiporenko
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 
Authored: Fri Jan 20 12:13:21 2017 +0200
Committer: Oleg Nechiporenko 
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 te