ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [27/50] [abbrv] ambari git commit: AMBARI-21715. Upgrade History Is too Verbose (alexantonenko)
Date Tue, 05 Sep 2017 09:41:22 GMT
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/84ab2eb4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/84ab2eb4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/84ab2eb4

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 84ab2eb406159609ea10c7279d7f268163ecf527
Parents: 3fd4004
Author: Alex Antonenko <aantonenko@hortonworks.com>
Authored: Thu Aug 31 19:04:39 2017 +0300
Committer: Alex Antonenko <aantonenko@hortonworks.com>
Committed: Thu Aug 31 19:04:39 2017 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  |  14 +-
 ambari-web/app/messages.js                      |   2 +
 ambari-web/app/styles/stack_versions.less       |  37 ++++++
 .../admin/stack_upgrade/upgrade_history.hbs     |  49 +++++--
 .../admin/stack_upgrade/upgrade_options.hbs     |  44 +++----
 .../admin/stack_upgrade/upgrade_history_view.js |  53 +++++---
 .../stack_upgrade/upgrade_history_view_test.js  | 129 ++++++++++---------
 7 files changed, 216 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/84ab2eb4/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 5c96251..7a3ec20 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -1100,7 +1100,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
         }.property().volatile(),
         isInUpgradeWizard: isInUpgradeWizard,
         showPreUpgradeChecks: App.get('supports.preUpgradeCheck') && !isInUpgradeWizard,
-        versionText: preUpgradeShow ? Em.I18n.t('admin.stackVersions.version.preUpgrade.bodyMsg.version').format(version.get('displayName'))
: isInUpgradeWizard ? '' : Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.version').format(version.get('displayName')),
+        versionText: self.getVersionText( preUpgradeShow, isInUpgradeWizard, version ),
         selectMethod: function (event) {
           if (isInUpgradeWizard || !event.context.get('allowed') || event.context.get('isPrecheckFailed'))
return;
           var selectedMethod = event.context;
@@ -1221,6 +1221,18 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     });
   },
 
+  getVersionText: function (preUpgradeShow, isInUpgradeWizard, version) {
+    if ( preUpgradeShow ){
+      return Em.I18n.t('admin.stackVersions.version.preUpgrade.bodyMsg.version').format(version.get('displayName'));
+    }
+    else{
+      if ( isInUpgradeWizard ){
+        return '';
+      }
+      return Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.version').format(version.get('displayName'));
+    }
+  },
+
   /**
    * open upgrade options from upgrade wizard
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/84ab2eb4/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index caaca95..a2b9960 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -351,6 +351,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/84ab2eb4/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 8bd5835..5914348 100644
--- a/ambari-web/app/styles/stack_versions.less
+++ b/ambari-web/app/styles/stack_versions.less
@@ -751,3 +751,40 @@
     }
   }
 }
+
+#upgrade-summary-table {
+  .wide-column {
+    width: 14%;
+  }
+  .accordion-group {
+    border-right: none;
+    padding-left:20px;
+  }
+  .accordion-heading {
+    background-color: transparent;
+  }
+  .accordion-toggle {
+    padding: 5px;
+    display: inline-block;
+    float: left;
+    line-height: 10px;
+    margin-left: -20px;
+    cursor: pointer;
+  }
+  .accordion-body {
+    min-width: 350px;
+    .accordion-inner{
+      padding-top:10px;
+      .label{
+        padding: 5px 15px;
+        &.available{
+          background-color: #468847;
+        }
+      }
+    }
+    .service-name {
+      text-align: left;
+      min-width: 70px;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84ab2eb4/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 85fa4c0..1287a82 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
@@ -51,33 +51,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 service-version-info">
+                          <div class="col-xs-4 service-name">
+                            {{service.displayName}}
+                          </div>
+                          <div class="col-xs-3">
+                            <span class="label available">
+                              {{service.fromVersion}}
+                            </span>
+                          </div>
+                          <div class="col-xs-2">
+                            <i class="icon-arrow-right"></i>
+                          </div>
+                          <div class="col-xs-3">
+                            <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/84ab2eb4/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
index ad1703c..0e4e105 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
@@ -62,24 +62,24 @@
                 {{/unless}}
             {{/each}}
         </div>
-
-        <div class="text tolerance-text">{{t admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.tolerance}}
-          <i class="glyphicon glyphicon-question-sign failure-tolerance-tooltip" data-toggle="tooltip"></i>
-
-          <div>
+        {{#if view.upgradeShow}}
+          <div class="text tolerance-text">{{t admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.tolerance}}
+            <i class="glyphicon glyphicon-question-sign failure-tolerance-tooltip" data-toggle="tooltip"></i>
+            <div>
               {{view App.CheckboxView
-              labelClassNames="tolerance-option"
-              labelTranslate="admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option2"
-              checkedBinding="view.parentView.skipSCFailures"}}
-          </div>
-          <div>
+                labelClassNames="tolerance-option"
+                labelTranslate="admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option2"
+                checkedBinding="view.parentView.skipSCFailures"}}
+            </div>
+            <div>
               {{view App.CheckboxView
-              labelClassNames="tolerance-option"
-              labelTranslate="admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option1"
-              checkedBinding="view.parentView.skipComponentFailures"
+                labelClassNames="tolerance-option"
+                labelTranslate="admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option1"
+                checkedBinding="view.parentView.skipComponentFailures"
               }}
+            </div>
           </div>
-        </div>
+        {{/if}}
         <div class="alert alert-warning">{{t admin.stackVersions.version.upgrade.alertsWarning}}</div>
       </div>
     {{/if}}
@@ -90,14 +90,12 @@
       {{t admin.stackVersions.version.upgrade.upgradeOptions.loading}}
     </div>
   </div>
-  {{#if view.upgradeShow}}
       <div class="text tolerance-text">{{t admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.tolerance}}
-          <i class="icon-question-sign failure-tolerance-tooltip" data-toggle="tooltip"></i>
-          <label class="tolerance-option">{{view Ember.Checkbox checkedBinding="view.parentView.skipSCFailures"}}
-              {{t admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option2}}</label>
-          <label class="tolerance-option">{{view Ember.Checkbox checkedBinding="view.parentView.skipComponentFailures"}}
-              {{t admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option1}}</label>
-      </div>
-      <div class="alert alert-warning">{{t admin.stackVersions.version.upgrade.alertsWarning}}</div>
+        <i class="icon-question-sign failure-tolerance-tooltip" data-toggle="tooltip"></i>
+        <label class="tolerance-option">{{view Ember.Checkbox checkedBinding="view.parentView.skipSCFailures"}}
+            {{t admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option2}}</label>
+        <label class="tolerance-option">{{view Ember.Checkbox checkedBinding="view.parentView.skipComponentFailures"}}
+           {{t admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option1}}</label>
+    </div>
+    <div class="alert alert-warning">{{t admin.stackVersions.version.upgrade.alertsWarning}}</div>
   {{/if}}
-{{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84ab2eb4/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 39e0d6b..252e7b0 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
@@ -125,23 +125,39 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
 
   processForDisplay: function (content) {
     var upgradeMethods = this.get('upgradeMethods');
-    return arrayUtils.flatten(content.map(item => {
-      const versions = item.get('versions');
-      const method = upgradeMethods.findProperty('type', item.get('upgradeType'));
-      return Object.keys(versions).map(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
-        };
-      });
-    }));
+    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 {
+        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 +207,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 () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/84ab2eb4/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 de60c74..0de24f9 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();
@@ -169,61 +171,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;
@@ -231,14 +178,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: {}}
@@ -247,16 +198,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'
       })
     ];
 
@@ -265,6 +224,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
       });
@@ -273,11 +240,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) {
 
@@ -295,9 +264,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'
+        }
+      ]);
+    });
+  });
+
 });


Mime
View raw message