You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/11/10 13:01:52 UTC

ambari git commit: AMBARI-8245 Host Details: Add Stack versions tab to host details page. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/trunk b5a3d2ab3 -> 3266c7da8


AMBARI-8245 Host Details: Add Stack versions tab to host details page. (atkach)


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

Branch: refs/heads/trunk
Commit: 3266c7da8ac3ff70173c9c10908220260d8a937f
Parents: b5a3d2a
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Mon Nov 10 14:01:35 2014 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Mon Nov 10 14:01:35 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 ambari-web/app/messages.js                      |  13 ++
 ambari-web/app/models.js                        |   1 +
 ambari-web/app/models/host_stack_version.js     |  69 +++++++++++
 ambari-web/app/routes/main.js                   |   6 +-
 ambari-web/app/styles/application.less          |   6 +
 .../templates/main/dashboard/config_history.hbs |  11 --
 .../app/templates/main/host/stack_versions.hbs  |  71 +++++++++++
 ambari-web/app/views.js                         |   1 +
 ambari-web/app/views/common/table_view.js       |   9 +-
 ambari-web/app/views/main/host/menu.js          |  16 ++-
 .../app/views/main/host/stack_versions_view.js  | 124 +++++++++++++++++++
 .../test/models/host_stack_version_test.js      |  98 +++++++++++++++
 13 files changed, 406 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index dea7d1f..2752a0c 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -208,6 +208,7 @@ var files = ['test/init_model_test',
   'test/models/service_test',
   'test/models/stack_service_test',
   'test/models/user_test',
+  'test/models/host_stack_version_test',
   //contains test with fake timers that affect Date
   'test/utils/lazy_loading_test'
 ];

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 3b8bbcd..f01f9c2 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -177,6 +177,7 @@ Em.I18n.translations = {
   'common.errorPopup.header': 'An error has been encountered',
   'common.use': 'Use',
   'common.stacks': 'Stacks',
+  'common.stack': 'Stack',
   'common.reset': 'Reset',
   'common.path': 'Path',
   'common.package': 'Package',
@@ -226,6 +227,10 @@ Em.I18n.translations = {
   'common.custom': 'Custom',
   'common.continueAnyway': 'Continue Anyway',
   'common.property.undefined': "Undefined",
+  'common.summary': "Summary",
+  'common.configs': "Configs",
+  'common.unknown': "Unknown",
+  'common.install': "Install",
 
   'passiveState.turnOn':'Turn On Maintenance Mode',
   'passiveState.turnOff':'Turn Off Maintenance Mode',
@@ -1704,6 +1709,14 @@ Em.I18n.translations = {
 
   'hosts.host.serviceNotAvailable': 'Service not available on this host',
 
+  'hosts.host.menu.stackVersions': 'Versions',
+  'hosts.host.stackVersions.table.noVersions': 'No versions',
+  'hosts.host.stackVersions.table.filteredInfo': '{0} of {1} versions showing',
+  'hosts.host.stackVersions.status.init': 'Uninstalled',
+  'hosts.host.stackVersions.status.installed': 'Installed',
+  'hosts.host.stackVersions.status.install_failed': 'Install Failed',
+  'hosts.host.stackVersions.status.installing': 'Installing',
+
   'hosts.host.metrics.dataUnavailable':'Data Unavailable',
   'hosts.host.metrics.cpu':'CPU Usage',
   'hosts.host.metrics.cpu.displayNames.cpu_wio':'CPU I/O Idle',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/models.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js
index 5aa3bd6..df19e28 100644
--- a/ambari-web/app/models.js
+++ b/ambari-web/app/models.js
@@ -62,3 +62,4 @@ require('classes/run_class');
 require('classes/job_class');
 require('models/config_group');
 require('models/service_config_version');
+require('models/host_stack_version');

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/models/host_stack_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_stack_version.js b/ambari-web/app/models/host_stack_version.js
new file mode 100644
index 0000000..c170c53
--- /dev/null
+++ b/ambari-web/app/models/host_stack_version.js
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.HostStackVersion = DS.Model.extend({
+  stack: DS.attr('string'),
+  version: DS.attr('string'),
+  /**
+   * property can have next values:
+   *  - INSTALLED
+   *  - INSTALLING
+   *  - INSTALL_FAILED
+   *  - INIT
+   */
+  status: DS.attr('string'),
+  isCurrent: DS.attr('boolean'),
+  displayStatus: function() {
+    return this.get('status') ?
+      Em.I18n.t('hosts.host.stackVersions.status.' + this.get('status').toLowerCase()) :
+      Em.I18n.t('common.unknown');
+  }.property('status'),
+  installEnabled: function () {
+    return (this.get('status') === 'INIT' || this.get('status') === 'INSTALL_FAILED');
+  }.property('status'),
+  installDisabled: Ember.computed.not('installEnabled')
+});
+
+App.HostStackVersion.FIXTURES = [
+  {
+    stack: 'HDP-2.2',
+    version: 'HDP-2.2.2',
+    status: 'INIT',
+    isCurrent: false
+  },
+  {
+    stack: 'HDP-2.2',
+    version: 'HDP-2.2.1',
+    status: 'INSTALLED',
+    isCurrent: true
+  },
+  {
+    stack: 'HDP-2.2',
+    version: 'HDP-2.2.3',
+    status: 'INSTALLING',
+    isCurrent: false
+  },
+  {
+    stack: 'HDP-2.3',
+    version: 'HDP-2.3.0',
+    status: 'INSTALL_FAILED',
+    isCurrent: false
+  }
+];

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index c2ab3d4..76c46a5 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -282,10 +282,10 @@ module.exports = Em.Route.extend({
         }
       }),
 
-      audit: Em.Route.extend({
-        route: '/audit',
+      stackVersions: Em.Route.extend({
+        route: '/stackVersions',
         connectOutlets: function (router, context) {
-          router.get('mainHostDetailsController').connectOutlet('mainHostAudit');
+          router.get('mainHostDetailsController').connectOutlet('mainHostStackVersions');
         }
       }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 70c7271..df43c1a 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3957,6 +3957,12 @@ table.graphs {
       }
     }
   }
+  .host-tab-content {
+    margin-top: 20px;
+    .table thead {
+      background: none repeat scroll 0 0 #F8F8F8;
+    }
+  }
 }
 
 .services-menu {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/templates/main/dashboard/config_history.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/config_history.hbs b/ambari-web/app/templates/main/dashboard/config_history.hbs
index 9f7ee86..b27158c 100644
--- a/ambari-web/app/templates/main/dashboard/config_history.hbs
+++ b/ambari-web/app/templates/main/dashboard/config_history.hbs
@@ -90,17 +90,6 @@
       <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
               href="#">{{t tableView.filters.clearAllFilters}}</a></label>
     </div>
-    <div class="selected-hosts-info span4">
-      {{#if view.showSelectedFilter}}
-        <div>
-          <a {{action filterSelected target="view"}} href="#">
-            {{view.selectedHosts.length}}
-            {{pluralize view.selectedHostsCount singular="t:hosts.filters.selectedHostInfo" plural="t:hosts.filters.selectedHostsInfo"}}
-          </a>
-        </div>
-          - <a {{action clearSelection target="view"}} href="#">{{t hosts.filters.clearSelection}}</a>
-      {{/if}}
-    </div>
     <div class="items-on-page">
       <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.displayLength"}}</label>
     </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/templates/main/host/stack_versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/stack_versions.hbs b/ambari-web/app/templates/main/host/stack_versions.hbs
new file mode 100644
index 0000000..276bb40
--- /dev/null
+++ b/ambari-web/app/templates/main/host/stack_versions.hbs
@@ -0,0 +1,71 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+<table class="table advanced-header-table table-bordered table-striped">
+  <thead>
+  {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
+    {{view view.parentView.stackSort classNames="first"}}
+    {{view view.parentView.versionSort}}
+    {{view view.parentView.statusSort}}
+    <th></th>
+  {{/view}}
+  <tr class="filter-row">
+    <th class="first">{{view view.stackFilterView}}</th>
+    <th>{{view view.versionFilterView}}</th>
+    <th>{{view view.statusFilterView}}</th>
+    <th> </th>
+  </tr>
+  </thead>
+  <tbody>
+  {{#if view.pageContent}}
+    {{#each view.pageContent}}
+      <tr>
+        <td class="first">{{this.stack}}</td>
+        <td>{{this.version}}</td>
+        <td>
+          {{this.displayStatus}}
+          {{#if this.isCurrent}}
+            <span class="label label-success">{{t common.current}}</span>
+          {{/if}}
+        </td>
+        <td><button class="btn" {{bindAttr disabled="this.installDisabled"}}><i class="icon-off"></i>&nbsp;{{t common.install}}</button></td>
+      </tr>
+    {{/each}}
+  {{else}}
+    <tr>
+      <td colspan="4" class="first">
+        {{t hosts.host.stackVersions.table.noVersions}}
+      </td>
+    </tr>
+  {{/if}}
+  </tbody>
+</table>
+
+<div class="page-bar">
+  <div class="filtered-info span4">
+    <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
+      href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+  </div>
+  <div class="items-on-page">
+    <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.parentView.displayLength"}}</label>
+  </div>
+  <div class="info">{{view.paginationInfo}}</div>
+  <div class="paging_two_button">
+    {{view view.paginationLeft}}
+    {{view view.paginationRight}}
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index bfc3708..842596b 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -61,6 +61,7 @@ require('views/main/host/alerts');
 require('views/main/host/configs_service');
 require('views/main/host/configs_service_menu');
 require('views/main/host/metrics');
+require('views/main/host/stack_versions_view');
 require('views/main/host/add_view');
 require('views/main/host/metrics/cpu');
 require('views/main/host/metrics/disk');

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js
index 1efe044..bbf346a 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -55,13 +55,20 @@ App.TableView = Em.View.extend(App.UserPref, {
   defaultDisplayLength: "10",
 
   /**
-   * number of hosts in table after applying filters
+   * number of items in table after applying filters
    */
   filteredCount: function () {
     return this.get('filteredContent.length');
   }.property('filteredContent.length'),
 
   /**
+   * total number of items in table before applying filters
+   */
+  totalCount: function () {
+    return this.get('content.length');
+  }.property('content.length'),
+
+  /**
    * Do filtering, using saved in the local storage filter conditions
    */
   willInsertElement:function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/views/main/host/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/menu.js b/ambari-web/app/views/main/host/menu.js
index 6e87a1a..c8b2461 100644
--- a/ambari-web/app/views/main/host/menu.js
+++ b/ambari-web/app/views/main/host/menu.js
@@ -24,15 +24,21 @@ App.MainHostMenuView = Em.CollectionView.extend({
   content: function () {
     var array = [
       {
-        label: 'Summary',
+        label: Em.I18n.t('common.summary'),
         routing: 'summary'
+      },
+      {
+        label: Em.I18n.t('common.configs'),
+        routing: 'configs'
       }
       /* { label:'Audit', routing:'audit'} */
     ];
-    array.push({
-      label: 'Configs',
-      routing: 'configs'
-    });
+    if (App.supports.stackUpgrade) {
+      array.push({
+        label: Em.I18n.t('hosts.host.menu.stackVersions'),
+        routing: 'stackVersions'
+      });
+    }
     if (App.get('supports.alerts')) {
       array.push({
         label: 'Alerts',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/app/views/main/host/stack_versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/stack_versions_view.js b/ambari-web/app/views/main/host/stack_versions_view.js
new file mode 100644
index 0000000..cf6a06c
--- /dev/null
+++ b/ambari-web/app/views/main/host/stack_versions_view.js
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var filters = require('views/common/filter_view');
+var sort = require('views/common/sort_view');
+
+App.MainHostStackVersionsView = App.TableView.extend({
+  templateName: require('templates/main/host/stack_versions'),
+  classNames: ['host-tab-content'],
+
+  host: function () {
+    return App.router.get('mainHostDetailsController.content');
+  }.property('App.router.mainHostDetailsController.content'),
+
+  content: function () {
+    return App.HostStackVersion.find();
+  }.property(),
+
+  /**
+   * return filtered number of all content number information displayed on the page footer bar
+   * @returns {String}
+   */
+  filteredContentInfo: function () {
+    return this.t('hosts.host.stackVersions.table.filteredInfo').format(this.get('filteredCount'), this.get('totalCount'));
+  }.property('filteredCount', 'totalCount'),
+
+  sortView: sort.wrapperView,
+  stackSort: sort.fieldView.extend({
+    column: 1,
+    name: 'stack',
+    displayName: Em.I18n.t('common.stack'),
+    type: 'version'
+  }),
+  versionSort: sort.fieldView.extend({
+    column: 2,
+    name: 'version',
+    displayName: Em.I18n.t('common.version'),
+    type: 'version'
+  }),
+  statusSort: sort.fieldView.extend({
+    column: 3,
+    name: 'status',
+    displayName: Em.I18n.t('common.status')
+  }),
+
+  /**
+   * Filter view for stack column
+   * Based on <code>filters</code> library
+   */
+  stackFilterView: filters.createSelectView({
+    column: 1,
+    fieldType: 'filter-input-width',
+    content: function () {
+      return ['All'].concat(this.get('parentView.content').mapProperty('stack').uniq());
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function () {
+      this.get('parentView').updateFilter(this.get('column'), this.get('actualValue'), 'select');
+    },
+    emptyValue: 'All'
+  }),
+
+  /**
+   * Filter view for version column
+   * Based on <code>filters</code> library
+   */
+  versionFilterView: filters.createSelectView({
+    column: 2,
+    fieldType: 'filter-input-width',
+    content: function () {
+      return ['All'].concat(this.get('parentView.content').mapProperty('version'));
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function () {
+      this.get('parentView').updateFilter(this.get('column'), this.get('actualValue'), 'select');
+    },
+    emptyValue: 'All'
+  }),
+
+  /**
+   * Filter view for status column
+   * Based on <code>filters</code> library
+   */
+  statusFilterView: filters.createSelectView({
+    column: 3,
+    fieldType: 'filter-input-width',
+    content: function () {
+      return [
+        'All',
+        'Installed',
+        'Installing',
+        'Install Failed',
+        'Uninstalled'
+      ];
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function () {
+      this.get('parentView').updateFilter(this.get('column'), this.get('actualValue'), 'select');
+    },
+    emptyValue: 'All'
+  }),
+
+  colPropAssoc: function () {
+    var associations = [];
+    associations[1] = 'stack';
+    associations[2] = 'version';
+    associations[3] = 'status';
+    return associations;
+  }.property()
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/3266c7da/ambari-web/test/models/host_stack_version_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_stack_version_test.js b/ambari-web/test/models/host_stack_version_test.js
new file mode 100644
index 0000000..957ac49
--- /dev/null
+++ b/ambari-web/test/models/host_stack_version_test.js
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+require('models/host_stack_version');
+
+describe('App.HostStackVersion', function () {
+
+  describe("#displayStatus", function () {
+    var testCases = [
+      {
+        status: 'INIT',
+        result: Em.I18n.t('hosts.host.stackVersions.status.init')
+      },
+      {
+        status: 'INSTALLED',
+        result: Em.I18n.t('hosts.host.stackVersions.status.installed')
+      },
+      {
+        status: 'INSTALLING',
+        result: Em.I18n.t('hosts.host.stackVersions.status.installing')
+      },
+      {
+        status: 'INSTALL_FAILED',
+        result: Em.I18n.t('hosts.host.stackVersions.status.install_failed')
+      },
+      {
+        status: '',
+        result: Em.I18n.t('common.unknown')
+      }
+    ];
+    afterEach(function () {
+      App.HostStackVersion.find().clear();
+    });
+    testCases.forEach(function (test) {
+      it('status is ' + test.status, function () {
+        App.store.load(App.HostStackVersion, {
+          id: 1,
+          status: test.status
+        });
+        expect(App.HostStackVersion.find().objectAt(0).get('displayStatus')).to.equal(test.result);
+      });
+    }, this);
+  });
+
+  describe("#installEnabled", function () {
+    var testCases = [
+      {
+        status: 'INIT',
+        result: true
+      },
+      {
+        status: 'INSTALLED',
+        result: false
+      },
+      {
+        status: 'INSTALLING',
+        result: false
+      },
+      {
+        status: 'INSTALL_FAILED',
+        result: true
+      },
+      {
+        status: '',
+        result: false
+      }
+    ];
+    afterEach(function () {
+      App.HostStackVersion.find().clear();
+    });
+    testCases.forEach(function (test) {
+      it('status is ' + test.status, function () {
+        App.store.load(App.HostStackVersion, {
+          id: 1,
+          status: test.status
+        });
+        expect(App.HostStackVersion.find().objectAt(0).get('installEnabled')).to.equal(test.result);
+      });
+    }, this);
+  });
+});