You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/04/30 18:05:33 UTC
ambari git commit: AMBARI-10869. Unusable formatting of components
names on Hosts page (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk b3ef40c69 -> 4102d919a
AMBARI-10869. Unusable formatting of components names on Hosts page (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4102d919
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4102d919
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4102d919
Branch: refs/heads/trunk
Commit: 4102d919a18d24442910daba0c1de2016f035fae
Parents: b3ef40c
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Apr 30 19:02:43 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Apr 30 19:02:43 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
ambari-web/app/controllers/main/host.js | 4 -
ambari-web/app/styles/common.less | 17 ++
.../modal_popups/hosts_table_list_popup.hbs | 37 ++++
ambari-web/app/templates/main/host.hbs | 18 +-
ambari-web/app/views.js | 1 +
.../modal_popups/hosts_table_list_popup.js | 42 +++++
ambari-web/app/views/main/host.js | 71 +++-----
.../modal_popups/hosts_table_list_popup_test.js | 62 +++++++
ambari-web/test/views/main/host_test.js | 173 ++++++-------------
10 files changed, 244 insertions(+), 182 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/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 8fc4b9c..8fd5e0e 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -181,6 +181,7 @@ var files = ['test/init_model_test',
'test/views/common/custom_date_popup_test',
'test/views/common/progress_bar_view_test',
'test/views/common/widget/graph_widget_view_test',
+ 'test/views/common/modal_popups/hosts_table_list_popup_test',
'test/views/main/admin_test',
'test/views/main/dashboard_test',
'test/views/main/menu_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index aef3205..02ca468 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -44,10 +44,6 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
startIndex: 1,
- expandedComponentsSections: [],
-
- expandedVersionsSections: [],
-
/**
* Components which will be shown in component filter
* @returns {Array}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/styles/common.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/common.less b/ambari-web/app/styles/common.less
index 67a966f..1b49e5e 100644
--- a/ambari-web/app/styles/common.less
+++ b/ambari-web/app/styles/common.less
@@ -312,4 +312,21 @@
.spinner {
display: none;
}
+}
+
+.host-elements {
+ border: 1px solid #ddd;
+ height: 120px;
+ overflow: auto;
+ padding: 5px;
+ ul {
+ margin-bottom: 0;
+ }
+ table {
+ width: 100%;
+ td {
+ width: 50%;
+ padding: 0;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/templates/common/modal_popups/hosts_table_list_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popups/hosts_table_list_popup.hbs b/ambari-web/app/templates/common/modal_popups/hosts_table_list_popup.hbs
new file mode 100644
index 0000000..0115fe5
--- /dev/null
+++ b/ambari-web/app/templates/common/modal_popups/hosts_table_list_popup.hbs
@@ -0,0 +1,37 @@
+{{!
+* 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.
+}}
+
+{{view.hostName}}
+<div class="host-elements">
+ {{#if view.isObjectsList}}
+ <table>
+ {{#each view.items}}
+ <tr>
+ <td>{{name}}</td>
+ <td>{{status}}</td>
+ </tr>
+ {{/each}}
+ </table>
+ {{else}}
+ <ul class="unstyled">
+ {{#each item in view.items}}
+ <li>{{item}}</li>
+ {{/each}}
+ </ul>
+ {{/if}}
+</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/templates/main/host.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host.hbs b/ambari-web/app/templates/main/host.hbs
index de7b454..1445964 100644
--- a/ambari-web/app/templates/main/host.hbs
+++ b/ambari-web/app/templates/main/host.hbs
@@ -138,22 +138,14 @@
<td class="load-avg">{{host.loadAvg}}</td>
<td {{bindAttr class="App.supports.stackUpgrade::hidden App.stackVersionsAvailable::hidden view.hasSingleVersion:not-active-link :host-table-versions"}}>
- <a href="#" class="expander black" {{action toggleVersions target="view"}}>
- {{#unless view.hasSingleVersion}}
- <span {{bindAttr class="view.isVersionsCollapsed:icon-caret-right:icon-caret-down"}}></span>
- {{/unless}}
+ <a href="#" class="black" {{action displayVersions target="view"}}>
{{view.currentVersion}}
</a>
- <div {{bindAttr class="view.isVersionsCollapsed:noDisplay:display :stack-versions :collapsed-list"}}>
- {{{view.versionLabels}}}
- </div>
</td>
- <td class="host-table-components">
- <a href="#" class="expander" {{action toggleComponents target="view"}}> <span {{bindAttr class="view.isComponentsCollapsed:icon-caret-right:icon-caret-down"}}></span>
- {{view.content.hostComponents.length}} {{pluralize view.content.hostComponents.length singular="t:common.component" plural="t:common.components"}}</a>
- <div {{bindAttr class="view.isComponentsCollapsed:noDisplay:display :host-components :collapsed-list"}}>
- {{{view.labels}}}
- </div>
+ <td {{bindAttr class="view.hasNoComponents:not-active-link :host-table-components"}}>
+ <a href="#" class="black" {{action displayComponents target="view"}}>
+ {{view.content.hostComponents.length}} {{pluralize view.content.hostComponents.length singular="t:common.component" plural="t:common.components"}}
+ </a>
</td>
{{/view}}
{{/each}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 87862b4..6b3a834 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -29,6 +29,7 @@ require('views/common/modal_popup');
require('views/common/modal_popups/alert_popup');
require('views/common/modal_popups/confirmation_feedback_popup');
require('views/common/modal_popups/confirmation_popup');
+require('views/common/modal_popups/hosts_table_list_popup');
require('views/common/modal_popups/prompt_popup');
require('views/common/modal_popups/cluster_check_popup');
require('views/common/modal_popups/invalid_KDC_popup');
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/views/common/modal_popups/hosts_table_list_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/hosts_table_list_popup.js b/ambari-web/app/views/common/modal_popups/hosts_table_list_popup.js
new file mode 100644
index 0000000..148d7e4
--- /dev/null
+++ b/ambari-web/app/views/common/modal_popups/hosts_table_list_popup.js
@@ -0,0 +1,42 @@
+/**
+ * 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');
+
+/**
+ * Show popup with list of stack versions/components installed on host
+ * @param header
+ * @param hostName
+ * @param items
+ * @returns {App.ModalPopup}
+ */
+App.showHostsTableListPopup = function (header, hostName, items) {
+ var isObjectsList = items.map(function (item) {
+ return typeof item;
+ }).contains('object');
+ return App.ModalPopup.show({
+ header: header,
+ secondary: null,
+ bodyClass: Em.View.extend({
+ templateName: require('templates/common/modal_popups/hosts_table_list_popup'),
+ hostName: hostName,
+ items: items,
+ isObjectsList: isObjectsList
+ })
+ });
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js
index d3de708..4145608 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -210,20 +210,13 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
},
updateHostsPagination: function () {
- this.clearExpandedSections();
this.updatePagination();
},
willDestroyElement: function () {
- this.clearExpandedSections();
$('.tooltip').remove();
},
- clearExpandedSections: function () {
- this.get('controller.expandedComponentsSections').clear();
- this.get('controller.expandedVersionsSections').clear();
- },
-
onInitialLoad: function () {
if (this.get('tableFilteringComplete')) {
this.refresh();
@@ -555,30 +548,26 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
content:null,
tagName: 'tr',
didInsertElement: function(){
- var hostName = this.get('content.hostName');
App.tooltip(this.$("[rel='HealthTooltip'], [rel='UsageTooltip'], [rel='ComponentsTooltip']"));
- this.set('isComponentsCollapsed', !this.get('controller.expandedComponentsSections').contains(hostName));
- this.set('isVersionsCollapsed', !this.get('controller.expandedVersionsSections').contains(hostName));
- },
-
- toggleList: function (flagName, arrayName) {
- var arrayPropertyName = 'controller.' + arrayName;
- var hostNameArray = this.get(arrayPropertyName);
- var hostName = this.get('content.hostName');
- this.toggleProperty(flagName);
- if (this.get(flagName)) {
- this.set(arrayPropertyName, hostNameArray.without(hostName));
- } else {
- hostNameArray.push(hostName);
- }
},
- toggleComponents: function () {
- this.toggleList('isComponentsCollapsed', 'expandedComponentsSections');
+ displayComponents: function () {
+ var header = Em.I18n.t('common.components'),
+ hostName = this.get('content.hostName'),
+ items = this.get('content.hostComponents').getEach('displayName');
+ App.showHostsTableListPopup(header, hostName, items);
},
- toggleVersions: function () {
- this.toggleList('isVersionsCollapsed', 'expandedVersionsSections');
+ displayVersions: function () {
+ var header = Em.I18n.t('common.versions'),
+ hostName = this.get('content.hostName'),
+ items = this.get('content.stackVersions').filterProperty('isVisible').map(function (stackVersion) {
+ return {
+ name: stackVersion.get('displayName'),
+ status: App.format.role(stackVersion.get('status'))
+ };
+ });
+ App.showHostsTableListPopup(header, hostName, items);
},
/**
@@ -611,14 +600,6 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
}.property('content.hostComponents.@each.passiveState'),
/**
- * String with list of host components <code>displayName</code>
- * @returns {String}
- */
- labels: function() {
- return this.get('content.hostComponents').getEach('displayName').join("<br />");
- }.property('content.hostComponents.length'),
-
- /**
* true if host has only one repoversion
* in this case expander in version column is hidden
* @returns {Boolean}
@@ -628,6 +609,16 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
}.property('content.stackVersions.length'),
/**
+ * true if host has no components
+ * @returns {Boolean}
+ */
+ hasNoComponents: function() {
+ return !this.get('content.hostComponents.length');
+ }.property('content.hostComponents.length'),
+
+ /**
+
+ /**
* this version is always shown others hidden unless expander is open
* host may have no stack versions
* @returns {String}
@@ -638,18 +629,6 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
}.property('content.stackVersions'),
/**
- * String with list of host components <code>displayName</code>
- * @returns {String}
- */
- versionLabels: function () {
- return this.get('content.stackVersions').filter(function(sv) {
- return sv.get('isVisible') === true && sv.get('isCurrent') === false;
- }).map(function (version) {
- return version.get('displayName');
- }).join("<br />");
- }.property('content.stackVersions.length'),
-
- /**
* CSS value for disk usage bar
* @returns {String}
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js b/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
new file mode 100644
index 0000000..f80f016
--- /dev/null
+++ b/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
@@ -0,0 +1,62 @@
+/**
+ * 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('views/common/modal_popups/hosts_table_list_popup');
+
+describe('App.showHostsTableListPopup', function () {
+
+ var cases = [
+ {
+ header: 'h0',
+ hostName: 'hn0',
+ items: ['i0', 'i1'],
+ isObjectsList: false,
+ title: 'strings list'
+ },
+ {
+ header: 'h1',
+ hostName: 'hn1',
+ items: [
+ {
+ name: 'n0',
+ status: 's0'
+ },
+ {
+ name: 'n1',
+ status: 's1'
+ }
+ ],
+ isObjectsList: true,
+ title: 'objects list'
+ }
+ ];
+
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ var popup = App.showHostsTableListPopup(item.header, item.hostName, item.items),
+ popupBody = popup.bodyClass.create();
+ expect(popup.header).to.equal(item.header);
+ expect(popupBody.get('hostName')).to.equal(item.hostName);
+ expect(popupBody.get('items')).to.eql(item.items);
+ expect(popupBody.get('isObjectsList')).to.equal(item.isObjectsList);
+ });
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4102d919/ambari-web/test/views/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host_test.js b/ambari-web/test/views/main/host_test.js
index 84579c2..28871b7 100644
--- a/ambari-web/test/views/main/host_test.js
+++ b/ambari-web/test/views/main/host_test.js
@@ -91,54 +91,20 @@ describe('App.MainHostView', function () {
describe('#updateHostsPagination', function () {
beforeEach(function () {
- sinon.stub(view, 'clearExpandedSections', Em.K);
sinon.stub(view, 'updatePagination', Em.K);
});
afterEach(function () {
- view.clearExpandedSections.restore();
view.updatePagination.restore();
});
- it('should execute clearExpandedSections and updatePagination', function () {
+ it('should execute and updatePagination', function () {
view.updateHostsPagination();
- expect(view.clearExpandedSections.calledOnce).to.be.true;
expect(view.updatePagination.calledOnce).to.be.true;
});
});
- describe('#willDestroyElement', function () {
-
- beforeEach(function () {
- sinon.stub(view, 'clearExpandedSections', Em.K);
- });
-
- afterEach(function () {
- view.clearExpandedSections.restore();
- });
-
- it('should execute clearExpandedSections', function () {
- view.willDestroyElement();
- expect(view.clearExpandedSections.calledOnce).to.be.true;
- });
-
- });
-
- describe('#clearExpandedSections', function () {
-
- it('should clear expandedComponentsSections and expandedVersionsSections from controller', function () {
- view.get('controller').setProperties({
- expandedComponentsSections: [''],
- expandedVersionsSections: ['']
- });
- view.clearExpandedSections();
- expect(view.get('controller.expandedComponentsSections')).to.have.length(0);
- expect(view.get('controller.expandedVersionsSections')).to.have.length(0);
- });
-
- });
-
describe('#HostView', function () {
var hostView;
@@ -152,109 +118,78 @@ describe('App.MainHostView', function () {
});
});
- describe('#didInsertElement', function () {
-
- var cases = [
- {
- expandedSections: ['h0'],
- isCollapsed: false,
- title: '{0} section should be expanded'
- },
- {
- expandedSections: ['h1'],
- isCollapsed: true,
- title: '{0} section should be collapsed'
- }
- ],
- testMethod = function (item, elementsName, arrayName, propertyName) {
- it(item.title.format(elementsName), function () {
- hostView.set('content.hostName', 'h0');
- hostView.set('controller.' + arrayName, item.expandedSections);
- hostView.didInsertElement();
- expect(App.tooltip.calledOnce).to.be.true;
- expect(hostView.get(propertyName)).to.equal(item.isCollapsed);
- });
- };
+ describe('#displayComponents', function () {
beforeEach(function () {
- sinon.stub(App, 'tooltip', Em.K);
+ sinon.stub(App, 'showHostsTableListPopup', Em.K);
});
afterEach(function () {
- App.tooltip.restore();
- });
-
- cases.forEach(function (item) {
- testMethod(item, 'components', 'expandedComponentsSections', 'isComponentsCollapsed');
- testMethod(item, 'versions', 'expandedVersionsSections', 'isVersionsCollapsed');
+ App.showHostsTableListPopup.restore();
});
- });
-
- describe('#toggleList', function () {
-
- var cases = [
- {
- isCollapsed: false,
- isCollapsedAfter: true,
- expandedSections: ['h0'],
- expandedSectionsAfter: [],
- title: 'section becomes collapsed'
- },
- {
- isCollapsed: true,
- isCollapsedAfter: false,
- expandedSections: [],
- expandedSectionsAfter: ['h0'],
- title: 'section becomes expanded'
- }
- ];
-
- cases.forEach(function (item) {
- it(item.title, function () {
- hostView.set('content.hostName', 'h0');
- hostView.set('isComponentsCollapsed', item.isCollapsed);
- hostView.set('controller.expandedComponentsSections', item.expandedSections);
- hostView.toggleList('isComponentsCollapsed', 'expandedComponentsSections');
- expect(hostView.get('isComponentsCollapsed')).to.equal(item.isCollapsedAfter);
- expect(hostView.get('controller.expandedComponentsSections')).to.eql(item.expandedSectionsAfter);
+ it('should display host components in modal popup', function () {
+ hostView.set('content', {
+ hostName: 'h',
+ hostComponents: [
+ {
+ displayName: 'c0'
+ },
+ {
+ displayName: 'c1'
+ }
+ ]
});
+ hostView.displayComponents();
+ expect(App.showHostsTableListPopup.calledOnce).to.be.true;
+ expect(App.showHostsTableListPopup.calledWith(Em.I18n.t('common.components'), 'h', ['c0', 'c1'])).to.be.true;
});
});
- describe('#toggleComponents', function () {
+ describe('#displayVersions', function () {
beforeEach(function () {
- sinon.stub(hostView, 'toggleList', Em.K);
+ sinon.stub(App, 'showHostsTableListPopup', Em.K);
});
afterEach(function () {
- hostView.toggleList.restore();
- });
-
- it('should toggle components list', function () {
- hostView.toggleComponents();
- expect(hostView.toggleList.calledOnce).to.be.true;
- expect(hostView.toggleList.calledWith('isComponentsCollapsed', 'expandedComponentsSections')).to.be.true;
+ App.showHostsTableListPopup.restore();
});
- });
-
- describe('#toggleVersions', function () {
-
- beforeEach(function () {
- sinon.stub(hostView, 'toggleList', Em.K);
- });
-
- afterEach(function () {
- hostView.toggleList.restore();
- });
-
- it('should toggle components list', function () {
- hostView.toggleVersions();
- expect(hostView.toggleList.calledOnce).to.be.true;
- expect(hostView.toggleList.calledWith('isVersionsCollapsed', 'expandedVersionsSections')).to.be.true;
+ it('should display stack versions in modal popup', function () {
+ hostView.set('content', {
+ hostName: 'h',
+ stackVersions: [
+ Em.Object.create({
+ displayName: 'v0',
+ status: 'CURRENT',
+ isVisible: true
+ }),
+ Em.Object.create({
+ displayName: 'v1',
+ status: 'OUT_OF_SYNC',
+ isVisible: true
+ }),
+ Em.Object.create({
+ displayName: 'v2',
+ status: 'INSTALL_FAILED',
+ isVisible: false
+ })
+ ]
+ });
+ hostView.displayVersions();
+ expect(App.showHostsTableListPopup.calledOnce).to.be.true;
+ expect(App.showHostsTableListPopup.calledWith(Em.I18n.t('common.versions'), 'h', [
+ {
+ name: 'v0',
+ status: 'Current'
+ },
+ {
+ name: 'v1',
+ status: 'Out Of Sync'
+ }
+ ])).to.be.true;
});
});