Переглянути джерело

AMBARI-9329 Versions: handle other version filtering states. (atkach)

Andrii Tkach 10 роки тому
батько
коміт
03456c57d2

+ 3 - 3
ambari-web/app/assets/data/stack_versions/stack_version_all.json

@@ -28,7 +28,7 @@
           "RepositoryVersions": {
             "display_name": "HDP-2.2",
             "id": 1,
-            "repository_version": "2.2",
+            "repository_version": "2.2.0.2",
             "stack_name": "HDP",
             "stack_version": "2.2",
             "upgrade_pack": ""
@@ -312,7 +312,7 @@
         "id": 6,
         "repository_version": 6,
         "stack": "HDP",
-        "state": "INSTALLED",
+        "state": "UPGRADING",
         "version": "2.2",
         "host_states": {
           "CURRENT": [],
@@ -380,7 +380,7 @@
         "id": 7,
         "repository_version": 7,
         "stack": "HDP",
-        "state": "INSTALLED",
+        "state": "OUT_OF_SYNC",
         "version": "2.2",
         "host_states": {
           "CURRENT": [],

+ 3 - 1
ambari-web/app/messages.js

@@ -1310,6 +1310,8 @@ Em.I18n.translations = {
   'admin.stackVersions.filter.upgradeReady': "Upgrade Ready ({0})",
   'admin.stackVersions.filter.installed': "Installed ({0})",
   'admin.stackVersions.filter.current': "Current ({0})",
+  'admin.stackVersions.filter.upgrading': "Upgrade In Process ({0})",
+  'admin.stackVersions.filter.upgraded': "Ready to Finalize ({0})",
 
   'admin.stackVersions.editRepositories.info': 'Provide Base URLs for the Operating Systems you are configuring. Uncheck all other Operating Systems.',
   'admin.stackVersions.editRepositories.validation.warning': 'Some of the repositories failed validation. Make changes to the base url or skip validation if you are sure that urls are correct',
@@ -1990,7 +1992,7 @@ Em.I18n.translations = {
   'hosts.host.stackVersions.status.install_failed': 'Install Failed',
   'hosts.host.stackVersions.status.installing': 'Installing',
   'hosts.host.stackVersions.status.current': 'Current',
-  'hosts.host.stackVersions.status.out_of_sync': 'Out of sync',
+  'hosts.host.stackVersions.status.out_of_sync': 'Out of Sync',
   'hosts.host.stackVersions.status.upgrading': 'Upgrading',
   'hosts.host.stackVersions.status.upgrade_failed': 'Upgrade Failed',
   'hosts.host.stackVersions.install.confirmation': 'You are about to install version <b>{0}</b> on this host.',

+ 9 - 0
ambari-web/app/styles/stack_versions.less

@@ -135,6 +135,7 @@
     box-shadow: 0 8px 6px -6px black;
   }
   .version-box {
+    position: relative;
     background: none repeat scroll 0 0 #fff;
     border: 1px solid #d2d9dd;
     height: 168px;
@@ -143,6 +144,14 @@
     a.not-active:hover {
       text-decoration: none;
     }
+    .out-of-sync-badge {
+      background-color: transparent;
+      font-size: 30px;
+      top: -8px;
+      position: absolute;
+      left: -8px;
+      color: orange;
+    }
     .state {
       margin: 15px 0;
       line-height: 30px;

+ 7 - 3
ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs

@@ -16,6 +16,10 @@
 * limitations under the License.
 }}
 
+{{#if view.isOutOfSync}}
+  <i class="icon-exclamation-sign out-of-sync-badge"></i>
+{{/if}}
+
 <p class="version">
   <span>{{view.content.displayName}}</span>
   <a class="pull-right not-active link-tooltip" {{action editRepositories target="view"}}>
@@ -47,19 +51,19 @@
   <div class="hosts-bar">{{t common.hosts}}</div>
   <div class="row-fluid host-link">
     <div class="span4 align-center">
-      <div><a href="#" {{bindAttr class="view.content.noInitHosts:emply-hosts-tooltip:hosts-tooltip :not-active"}}
+      <div><a href="#" {{bindAttr class="view.content.noInitHosts:empty-hosts-tooltip:hosts-tooltip :not-active"}}
         {{action showHosts view.versionStateMap.not_installed view.content.repositoryVersion view.content.notInstalledHosts target="view"}}>
         {{view.content.notInstalledHosts.length}}</a></div>
       <div>{{t admin.stackVersions.version.notInstalled}}</div>
     </div>
     <div class="span4 align-center">
-      <div><a href="#" {{bindAttr class="view.content.noInstalledHosts:emply-hosts-tooltip:hosts-tooltip :not-active"}}
+      <div><a href="#" {{bindAttr class="view.content.noInstalledHosts:empty-hosts-tooltip:hosts-tooltip :not-active"}}
         {{action showHosts view.versionStateMap.installed view.content.repositoryVersion view.content.installedHosts target="view"}}>
         {{view.content.installedHosts.length}}</a></div>
       <div>{{t common.installed}}</div>
     </div>
     <div class="span4 align-center">
-      <div><a href="#" {{bindAttr class="view.content.noCurrentHosts:emply-hosts-tooltip:hosts-tooltip :not-active"}}
+      <div><a href="#" {{bindAttr class="view.content.noCurrentHosts:empty-hosts-tooltip:hosts-tooltip :not-active"}}
         {{action showHosts view.versionStateMap.current view.content.repositoryVersion view.content.currentHosts target="view"}}>
         {{view.content.currentHosts.length}}</a></div>
       <div>{{t common.current}}</div>

+ 12 - 1
ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js

@@ -41,11 +41,21 @@ App.UpgradeVersionBoxView = Em.View.extend({
     return (installRequest) ? installRequest.get('progress') : 0;
   }.property('App.router.backgroundOperationsController.services.@each.progress'),
 
+  /**
+   * @type {string}
+   */
   versionClass: function () {
     return this.get('content.status') == 'CURRENT'
       ? 'current-version-box' : '';
   }.property('content.status'),
 
+  /**
+   * @type {boolean}
+   */
+  isOutOfSync: function () {
+    return this.get('content.status') == 'OUT_OF_SYNC';
+  }.property('content.status'),
+
   /**
    * map containing version (id, label)
    * this is used as param for <code>showHosts<code> method
@@ -128,7 +138,8 @@ App.UpgradeVersionBoxView = Em.View.extend({
   didInsertElement: function () {
     App.tooltip($('.link-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.linkTooltip')});
     App.tooltip($('.hosts-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.hostsTooltip')});
-    App.tooltip($('.emply-hosts-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip')});
+    App.tooltip($('.empty-hosts-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip')});
+    App.tooltip($('.out-of-sync-badge'), {title: Em.I18n.t('hosts.host.stackVersions.status.out_of_sync')});
   },
 
   /**

+ 39 - 10
ambari-web/app/views/main/admin/stack_upgrade/versions_view.js

@@ -31,27 +31,49 @@ App.MainAdminStackVersionsView = Em.View.extend({
   updateTimer: null,
 
   /**
+   * Not Installed = the version is not installed or out of sync
+   * Upgrade Ready = the version is installed and ready for upgrade
+   * Current = the version currently being used
+   * Upgrade in Process = UPGRADING
+   * Ready to Finalize = UPGRADED
+   * Installed = All the versions that are installed BUT cannot be upgraded to (meaning: they are lower than the current)
    * @type {Array}
    */
   categories: [
     Em.Object.create({
       labelKey: 'admin.stackVersions.filter.all',
+      value: '',
       isSelected: true
     }),
     Em.Object.create({
       labelKey: 'admin.stackVersions.filter.notInstalled',
-      isSelected: false,
-      statuses: ["INIT", "INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"]
+      value: 'NOT_INSTALLED',
+      isSelected: false
     }),
     Em.Object.create({
       labelKey: 'admin.stackVersions.filter.upgradeReady',
-      isSelected: false,
-      statuses: ["INSTALLED"]
+      value: 'UPGRADE_READY',
+      isSelected: false
     }),
     Em.Object.create({
       labelKey: 'admin.stackVersions.filter.current',
-      isSelected: false,
-      statuses: ["CURRENT"]
+      value: 'CURRENT',
+      isSelected: false
+    }),
+    Em.Object.create({
+      labelKey: 'admin.stackVersions.filter.installed',
+      value: 'INSTALLED',
+      isSelected: false
+    }),
+    Em.Object.create({
+      labelKey: 'admin.stackVersions.filter.upgrading',
+      value: 'UPGRADING',
+      isSelected: false
+    }),
+    Em.Object.create({
+      labelKey: 'admin.stackVersions.filter.upgraded',
+      value: 'UPGRADED',
+      isSelected: false
     })
   ],
 
@@ -115,12 +137,19 @@ App.MainAdminStackVersionsView = Em.View.extend({
    */
   filterBy: function (versions, filter) {
     var currentVersion = this.get('controller.currentVersion');
-    if (filter && filter.get('statuses')) {
+    if (filter && filter.get('value')) {
       return versions.filter(function (version) {
-        if (version.get('status') === 'INSTALLED' && filter.get('statuses').contains("INSTALLED")) {
-          return stringUtils.compareVersions(version.get('repositoryVersion'), Em.get(currentVersion, 'repository_version')) === 1;
+        var status = version.get('status');
+        if (status === 'INSTALLED' && ['UPGRADE_READY', 'INSTALLED'].contains(filter.get('value'))) {
+          if (filter.get('value') === 'UPGRADE_READY') {
+            return stringUtils.compareVersions(version.get('repositoryVersion'), Em.get(currentVersion, 'repository_version')) === 1;
+          } else if (filter.get('value') === 'INSTALLED') {
+            return stringUtils.compareVersions(version.get('repositoryVersion'), Em.get(currentVersion, 'repository_version')) < 1;
+          }
+        } else if (filter.get('value') === 'NOT_INSTALLED') {
+          return ['INIT', 'INSTALL_FAILED', 'INSTALLING', 'OUT_OF_SYNC'].contains(status);
         } else {
-          return filter.get('statuses').contains(version.get('status'));
+          return status === filter.get('value');
         }
       }, this);
     }

+ 42 - 10
ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js

@@ -55,16 +55,18 @@ describe('App.mainAdminStackVersionsView', function () {
         status: "UPGRADING"
       }),
       Em.Object.create({
-        status: "UPGRADE_FAILED"
+        status: "UPGRADED"
       }),
       Em.Object.create({
         status: "CURRENT"
       })
     ];
 
-    var tets = [
+    var testCases = [
       {
-        filter:  Em.Object.create({}),
+        filter:  Em.Object.create({
+          value: ''
+        }),
         filteredVersions: [
           Em.Object.create({
             status: "INIT"
@@ -90,7 +92,7 @@ describe('App.mainAdminStackVersionsView', function () {
             status: "UPGRADING"
           }),
           Em.Object.create({
-            status: "UPGRADE_FAILED"
+            status: "UPGRADED"
           }),
           Em.Object.create({
             status: "CURRENT"
@@ -99,7 +101,7 @@ describe('App.mainAdminStackVersionsView', function () {
       },
       {
         filter:  Em.Object.create({
-          statuses: ["INIT", "INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"]
+          value: 'NOT_INSTALLED'
         }),
         filteredVersions: [
           Em.Object.create({
@@ -118,7 +120,18 @@ describe('App.mainAdminStackVersionsView', function () {
       },
       {
         filter:  Em.Object.create({
-          statuses: ["INSTALLED"]
+          value: 'INSTALLED'
+        }),
+        filteredVersions: [
+          Em.Object.create({
+            status: "INSTALLED",
+            repositoryVersion: "2.2.0.1"
+          })
+        ]
+      },
+      {
+        filter:  Em.Object.create({
+          value: 'UPGRADE_READY'
         }),
         filteredVersions: [
           Em.Object.create({
@@ -129,21 +142,40 @@ describe('App.mainAdminStackVersionsView', function () {
       },
       {
         filter:  Em.Object.create({
-          statuses: ["CURRENT"]
+          value: 'CURRENT'
         }),
         filteredVersions: [
           Em.Object.create({
             status: "CURRENT"
           })
         ]
+      },
+      {
+        filter:  Em.Object.create({
+          value: 'UPGRADING'
+        }),
+        filteredVersions: [
+          Em.Object.create({
+            status: "UPGRADING"
+          })
+        ]
+      },
+      {
+        filter:  Em.Object.create({
+          value: 'UPGRADED'
+        }),
+        filteredVersions: [
+          Em.Object.create({
+            status: "UPGRADED"
+          })
+        ]
       }
     ].forEach(function(t) {
-        var msg = t.filter.get('statuses') ? t.filter.get('statuses').toString() : "All";
+        var msg = t.filter.get('value') ? t.filter.get('value') : "All";
         it("filter By " + msg, function () {
+          view.set('controller.currentVersion', {repository_version: '2.2.1.1'});
           expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
         });
       });
-
   });
-
 });