Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 0aba12139 -> 272e1ce18


AMBARI-21715. Upgrade History Is too Verbose (alexantonenko)


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 272e1ce18f66e4ed9b2546b77ad5c50a2bf8d743
Parents: 0aba121
Author: Alex Antonenko <hiv...@gmail.com>
Authored: Mon Aug 14 14:22:07 2017 +0300
Committer: Alex Antonenko <hiv...@gmail.com>
Committed: Mon Aug 14 14:22:07 2017 +0300

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |   2 +
 ambari-web/app/styles/stack_versions.less       |  31 +++++
 .../admin/stack_upgrade/upgrade_history.hbs     |  49 +++++--
 .../admin/stack_upgrade/upgrade_history_view.js |  57 +++++---
 .../stack_upgrade/upgrade_history_view_test.js  | 129 ++++++++++---------
 5 files changed, 177 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/272e1ce1/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a0dcf8c..64b5ae4 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -346,6 +346,8 @@ Em.I18n.translations = {
   'common.rolling': 'Rolling',
   'common.express': 'Express',
   'common.hostOrdered': 'Host Ordered',
+  'common.repository': 'Repository',
+  'common.repositoryType': 'Repository Type',
   'common.rolling.downgrade': 'Rolling Downgrade',
   'common.express.downgrade': 'Express Downgrade',
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/272e1ce1/ambari-web/app/styles/stack_versions.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/stack_versions.less 
b/ambari-web/app/styles/stack_versions.less
index 06ad16c..07d6f83 100644
--- a/ambari-web/app/styles/stack_versions.less
+++ b/ambari-web/app/styles/stack_versions.less
@@ -807,3 +807,34 @@
     border-bottom: 1px solid #eee;
   }
 }
+
+#upgrade-summary-table {
+  .wide-column {
+    width: 14%;
+  }
+  .accordion-group {
+    border-right: none;
+  }
+  .accordion-inner {
+    border-top: none;
+    padding-left: 0;
+    padding-top: 20px;
+  }
+  .accordion-heading {
+    background-color: transparent;
+  }
+  .accordion-toggle {
+    padding: 5px;
+    display: inline-block;
+    float: left;
+    line-height: 10px;
+    margin-left: -20px;
+  }
+  .accordion-body {
+    min-width: 350px;
+    .service-name {
+      text-align: left;
+      min-width: 70px;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/272e1ce1/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs 
b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
index d70a991..6b226cc 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
@@ -46,33 +46,62 @@
       <tr>
         <th>{{t common.direction}}</th>
         <th>{{t common.type}}</th>
-        <th>{{t common.service}}</th>
-        <th>{{t common.version}}</th>
+        <th class="wide-column">{{t common.repository}}</th>
+        <th class="wide-column">{{t common.repositoryType}}</th>
         <th>{{t common.start.time}}</th>
         <th>{{t common.duration}}</th>
         <th>{{t common.end.time}}</th>
         <th>{{t common.status}}</th>
       </tr>
       </thead>
-      <tbody>
+      <tbody class="accordion" id="versionsAccordion">
         {{#if view.pageContent}}
           {{#each item in view.pageContent}}
             <tr>
-              <td class='name'>
-                <span class="trim_hostname">
-                  <a href="#" class="black" {{action 
"showUpgradeHistoryRecord" item.stackUpgradeHistoryItem target="view"}}>
+              <td class="name accordion-group">
+                <span class="trim_hostname accordion-heading">
+                  <i class="icon-caret-right accordion-toggle"
+                     data-toggle="collapse"
+                     data-parent="#versionsAccordion"
+                     {{bindAttr href="item.idHref"}}></i>
+                  <a href="#" class="black"
+                     {{action "showUpgradeHistoryRecord" 
item.stackUpgradeHistoryItem target="view"}}>
                     {{unbound item.directionLabel}}
                   </a>
                 </span>
+                <div class="accordion-body collapse" {{bindAttr id="item.id"}}>
+                  <div class="accordion-inner">
+                      {{#each service in item.services}}
+                        <div class="row-fluid service-version-info">
+                          <div class="span1 service-name">
+                            {{service.displayName}}
+                          </div>
+                          <div class="span1">
+                            <span class="label available">
+                              {{service.fromVersion}}
+                            </span>
+                          </div>
+                          <div class="span1">
+                            <i class="icon-arrow-right"></i>
+                          </div>
+                          <div class="span1">
+                            <span class="label available">
+                              {{service.toVersion}}
+                            </span>
+                          </div>
+                        </div>
+                      {{/each}}
+                  </div>
+                </div>
               </td>
               <td>
                 <span>{{item.upgradeTypeLabel}}</span>
               </td>
-              <td>
-                <span>{{item.serviceName}}</span>
+              <td class="wide-column">
+                <span>{{item.repositoryName}}</span>
               </td>
-              <td>
-                <span>{{item.version}}</span>
+              <td class="wide-column">
+                <span>{{item.repositoryType}}</span>
               </td>
               <td>
                 <span>{{item.startTimeLabel}}</span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/272e1ce1/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 c1ad3cf..674783e 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
@@ -97,9 +97,7 @@ App.MainAdminStackUpgradeHistoryView = 
App.TableView.extend(App.TableServerViewM
    */
   selectedCategory: Em.computed.findBy('categories', 'isSelected', true),
 
-  filteredCount: function () {
-    return this.get('filteredContent').map(function(item) {return 
Object.keys(item.get('versions') || {}).length}).reduce(Em.sum, 0);
-  }.property('filteredContent'),
+  filteredCount: Em.computed.alias('filteredContent.length'),
 
   /**
    * displaying content filtered by upgrade type and upgrade status.
@@ -125,23 +123,39 @@ App.MainAdminStackUpgradeHistoryView = 
App.TableView.extend(App.TableServerViewM
 
   processForDisplay: function (content) {
     var upgradeMethods = this.get('upgradeMethods');
-    return arrayUtils.flatten(content.map(function(item) {
+    var repoVersions = App.RepositoryVersion.find();
+    return content.map(function(item) {
       var versions = item.get('versions');
+      var repoVersion = repoVersions.findProperty('repositoryVersion', 
item.get('associatedVersion'));
       var method = upgradeMethods.findProperty('type', 
item.get('upgradeType'));
-      return Object.keys(versions).map(function(serviceName) {
-        return {
-          version: versions[serviceName].to_repository_version,
-          serviceName: App.format.role(serviceName),
-          directionLabel: item.get('direction') === 'UPGRADE' ? 
Em.I18n.t('common.upgrade') : Em.I18n.t('common.downgrade'),
-          upgradeTypeLabel: method ? method.get('displayName') : method,
-          startTimeLabel: 
date.startTime(App.dateTimeWithTimeZone(item.get('startTime'))),
-          endTimeLabel: 
date.endTime(App.dateTimeWithTimeZone(item.get('endTime'))),
-          duration: date.durationSummary(item.get('startTime'), 
item.get('endTime')),
-          displayStatus: item.get('displayStatus'),
-          stackUpgradeHistoryItem: item
-        };
-      });
-    }));
+      return {
+        idHref: '#' + item.get('upgradeId'),
+        id: item.get('upgradeId'),
+        repositoryName: repoVersion.get('displayName'),
+        repositoryType: repoVersion.get('type').toLowerCase().capitalize(),
+        directionLabel: item.get('direction') === 'UPGRADE' ? 
Em.I18n.t('common.upgrade') : Em.I18n.t('common.downgrade'),
+        upgradeTypeLabel: method ? method.get('displayName') : method,
+        startTimeLabel: 
date.startTime(App.dateTimeWithTimeZone(item.get('startTime'))),
+        endTimeLabel: 
date.endTime(App.dateTimeWithTimeZone(item.get('endTime'))),
+        duration: date.durationSummary(item.get('startTime'), 
item.get('endTime')),
+        displayStatus: item.get('displayStatus'),
+        stackUpgradeHistoryItem: item,
+        services: this.getRepoServicesForDisplay(versions)
+      };
+    }, this);
+  },
+
+  getRepoServicesForDisplay: function(versions) {
+    return Object.keys(versions).map(function(serviceName) {
+      var fromVersion = 
App.RepositoryVersion.find(versions[serviceName].from_repository_id);
+      var toVersion = 
App.RepositoryVersion.find(versions[serviceName].to_repository_id);
+      return {
+        name: serviceName,
+        displayName: fromVersion.get('stackServices').findProperty('name', 
serviceName).get('displayName'),
+        fromVersion: fromVersion.get('stackServices').findProperty('name', 
serviceName).get('latestVersion'),
+        toVersion: toVersion.get('stackServices').findProperty('name', 
serviceName).get('latestVersion')
+      }
+    });
   },
 
   paginationLeftClass: function () {
@@ -191,6 +205,9 @@ App.MainAdminStackUpgradeHistoryView = 
App.TableView.extend(App.TableServerViewM
 
   didInsertElement: function () {
     this.observesCategories();
+    this.$(".accordion").on("show hide", function (e) {
+      
$(e.target).siblings(".accordion-heading").find("i.accordion-toggle").toggleClass('icon-caret-right
 icon-caret-down');
+    });
   },
 
   observesCategories: function () {
@@ -316,7 +333,7 @@ App.MainAdminStackUpgradeHistoryView = 
App.TableView.extend(App.TableServerViewM
         var scrollable = this.$().find('#modal .scrollable-block');
         scrollable.css('max-height', Number(block.css('max-height').slice(0, 
-2)) - block.height());
         block.css('max-height', 'none');
-      },
+      }
     });
-  },
+  }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/272e1ce1/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 9780470..8a89321 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
@@ -94,9 +94,11 @@ describe('App.MainAdminStackUpgradeHistoryView', function () 
{
   describe("#didInsertElement()", function() {
     beforeEach(function () {
       sinon.stub(view, 'observesCategories', Em.K);
+      sinon.stub(view, '$').returns({on: Em.K});
     });
     afterEach(function () {
       view.observesCategories.restore();
+      view.$.restore();
     });
     it("observesCategories is called once", function() {
       view.didInsertElement();
@@ -170,61 +172,6 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
     });
   });
 
-  describe('#filteredCount', function () {
-
-    [
-      {
-        filteredContent: [
-          Em.Object.create({
-            versions: {s1: {}}
-          })
-        ],
-        m: '1 version',
-        e: 1
-      },
-      {
-        filteredContent: [
-          Em.Object.create({
-            versions: {s1: {}, s2: {}}
-          })
-        ],
-        m: '2 versions',
-        e: 2
-      },
-      {
-        filteredContent: [
-          Em.Object.create({
-            versions: {s1: {}, s2: {}}
-          }),
-          Em.Object.create({
-            versions: {s1: {}, s2: {}, s3: {}}
-          })
-        ],
-        m: '5 versions',
-        e: 5
-      }
-    ].forEach(function (test) {
-      describe(test.m, function () {
-        beforeEach(function () {
-          sinon.stub(view, 'get', function (key) {
-            if (key === 'filteredContent') {
-              return test.filteredContent;
-            }
-            return Em.get(this, key);
-          });
-        });
-        afterEach(function () {
-          view.get.restore();
-        });
-        it('should map versions', function () {
-          view.set('filteredContent', test.filteredContent);
-          expect(view.get('filteredCount')).to.be.equal(test.e);
-        });
-      });
-    });
-
-  });
-
   describe('#processForDisplay', function () {
 
     var timestamp = 1484698121448;
@@ -232,14 +179,18 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
     var content = [
       Em.Object.create({
         direction: 'UPGRADE',
+        upgradeId: 1,
         upgradeType: 'ROLLING',
+        associatedVersion: '1.1',
         startTime: timestamp,
         endTime: timestamp + 3600 * 1000,
         versions: {s1: {}}
       }),
       Em.Object.create({
         direction: 'DOWNGRADE',
+        upgradeId: 2,
         upgradeType: 'HOST_ORDERED',
+        associatedVersion: '1.1',
         startTime: timestamp,
         endTime: timestamp + 3600 * 1000 * 2,
         versions: {s1: {}}
@@ -248,16 +199,24 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
 
     var expected = [
       Em.Object.create({
+        idHref: '#1',
+        id: 1,
+        repositoryName: 'hdp-1.1',
+        repositoryType: 'Type1',
+        services: [],
         directionLabel: Em.I18n.t('common.upgrade'),
         upgradeTypeLabel: Em.I18n.t('common.rolling'),
-        duration: '1.00 hours',
-        serviceName: 'S1'
+        duration: '1.00 hours'
       }),
       Em.Object.create({
+        idHref: '#2',
+        id: 1,
+        repositoryName: 'hdp-1.1',
+        repositoryType: 'Type1',
+        services: [],
         directionLabel: Em.I18n.t('common.downgrade'),
         upgradeTypeLabel: Em.I18n.t('common.hostOrdered'),
-        duration: '2.00 hours',
-        serviceName: 'S1'
+        duration: '2.00 hours'
       })
     ];
 
@@ -266,6 +225,14 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
     var processedContent;
 
     beforeEach(function () {
+      sinon.stub(view, 'getRepoServicesForDisplay').returns([]);
+      sinon.stub(App.RepositoryVersion, 'find').returns([
+        Em.Object.create({
+          repositoryVersion: '1.1',
+          displayName: 'hdp-1.1',
+          type: 'TYPE1'
+        })
+      ]);
       sinon.stub(App, 'dateTimeWithTimeZone', function (ts) {
         return ts - 3600 * 1000 * 2
       });
@@ -274,11 +241,13 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
 
     afterEach(function () {
       App.dateTimeWithTimeZone.restore();
+      view.getRepoServicesForDisplay.restore();
+      App.RepositoryVersion.find.restore();
     });
 
     it('2 items mapped', function () {
       expect(processedContent.length).to.be.equal(2);
-    })
+    });
 
     expected.forEach(function (item, index) {
 
@@ -296,9 +265,47 @@ describe('App.MainAdminStackUpgradeHistoryView', function 
() {
 
 
     it('End Time for upgrade in progress is `Not finished`', function () {
-      processedContent = view.processForDisplay([Em.Object.create({endTime: 
-1, versions: {s1:{}}})]);
+      processedContent = view.processForDisplay([Em.Object.create({
+        endTime: -1,
+        versions: {s1: {}},
+        associatedVersion: '1.1'
+      })]);
       expect(processedContent[0].endTimeLabel).to.be.equal('Not finished');
     });
   });
 
+  describe('#getRepoServicesForDisplay', function() {
+    beforeEach(function() {
+      sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({
+        stackServices: [
+          Em.Object.create({
+            name: 'S1',
+            displayName: 's1',
+            latestVersion: '1.1'
+          })
+        ]
+      }));
+    });
+    afterEach(function() {
+      App.RepositoryVersion.find.restore();
+    });
+
+    it('should return services with versions', function() {
+      var versions = {
+        S1: {
+          from_repository_id: 1,
+          to_repository_id: 2
+        }
+      };
+      expect(view.getRepoServicesForDisplay(versions)).to.be.eql([
+        {
+          name: 'S1',
+          displayName: 's1',
+          fromVersion: '1.1',
+          toVersion: '1.1'
+        }
+      ]);
+    });
+  });
+
 });

Reply via email to