You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/09/14 16:44:32 UTC
ambari git commit: AMBARI-13090. Ambari UI doesn't show correct
cluster info (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 0397d527f -> a7152651b
AMBARI-13090. Ambari UI doesn't show correct cluster info (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a7152651
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a7152651
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a7152651
Branch: refs/heads/trunk
Commit: a7152651ba1e4bb5b6ae201d62491e2f944f9f8f
Parents: 0397d52
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon Sep 14 17:41:24 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon Sep 14 17:44:27 2015 +0300
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 50 ++++++++++++--------
ambari-web/app/messages.js | 1 +
ambari-web/app/mixins/common/reload_popup.js | 9 ++--
.../global/cluster_controller_test.js | 15 ++----
.../test/mixins/common/reload_popup_test.js | 28 ++++++++---
5 files changed, 61 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a7152651/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index dbd7a1b..803c2d6 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -19,7 +19,7 @@
var App = require('app');
var stringUtils = require('utils/string_utils');
-App.ClusterController = Em.Controller.extend({
+App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
name: 'clusterController',
isLoaded: false,
ambariProperties: null,
@@ -89,8 +89,8 @@ App.ClusterController = Em.Controller.extend({
/**
* load cluster name
*/
- loadClusterName: function (reload) {
- var dfd = $.Deferred();
+ loadClusterName: function (reload, deferred) {
+ var dfd = deferred || $.Deferred();
if (App.get('clusterName') && !reload) {
App.set('clusterName', this.get('clusterName'));
@@ -100,32 +100,42 @@ App.ClusterController = Em.Controller.extend({
App.ajax.send({
name: 'cluster.load_cluster_name',
sender: this,
- success: 'loadClusterNameSuccessCallback',
- error: 'loadClusterNameErrorCallback'
- }).complete(function () {
- if (!App.get('currentStackVersion')) {
- App.set('currentStackVersion', App.defaultStackVersion);
+ data: {
+ reloadPopupText: Em.I18n.t('app.reloadPopup.noClusterName.text'),
+ errorLogMessage: 'failed on loading cluster name',
+ callback: this.loadClusterName,
+ args: [reload, dfd],
+ shouldUseDefaultHandler: true
+ },
+ success: 'reloadSuccessCallback',
+ error: 'reloadErrorCallback',
+ callback: function () {
+ if (!App.get('currentStackVersion')) {
+ App.set('currentStackVersion', App.defaultStackVersion);
+ }
}
- dfd.resolve();
- });
+ }).then(
+ function () {
+ dfd.resolve();
+ },
+ null
+ );
}
- return dfd.promise()
+ return dfd.promise();
},
- loadClusterNameSuccessCallback: function (data) {
+ reloadSuccessCallback: function (data) {
+ this._super();
if (data.items && data.items.length > 0) {
- App.set('clusterName', data.items[0].Clusters.cluster_name);
- App.set('currentStackVersion', data.items[0].Clusters.version);
+ App.setProperties({
+ clusterName: data.items[0].Clusters.cluster_name,
+ currentStackVersion: data.items[0].Clusters.version,
+ isKerberosEnabled: data.items[0].Clusters.security_type === 'KERBEROS'
+ });
this.set('isClusterNameLoaded', true);
- App.set('isKerberosEnabled', data.items[0].Clusters.security_type === 'KERBEROS');
}
},
- loadClusterNameErrorCallback: function (request, ajaxOptions, error) {
- console.log('failed on loading cluster name');
- this.set('isLoaded', true);
- },
-
/**
* load current server clock in milli-seconds
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/a7152651/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index e91d135..a017d97 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -23,6 +23,7 @@ Em.I18n.translations = {
'app.name.subtitle.experimental':'Ambari Experimental',
'app.reloadPopup.link': 'Reload Page',
'app.reloadPopup.text': 'Trying to connect to server...',
+ 'app.reloadPopup.noClusterName.text': 'Failed to retrieve cluster name, trying to reload...',
'app.reloadPopup.header': 'Reload Page',
'app.loadingPlaceholder': 'Loading...',
http://git-wip-us.apache.org/repos/asf/ambari/blob/a7152651/ambari-web/app/mixins/common/reload_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/reload_popup.js b/ambari-web/app/mixins/common/reload_popup.js
index 1a2a9be..f4159b4 100644
--- a/ambari-web/app/mixins/common/reload_popup.js
+++ b/ambari-web/app/mixins/common/reload_popup.js
@@ -40,7 +40,7 @@ App.ReloadPopupMixin = Em.Mixin.create({
} else {
var times = Em.isNone(params.times) ? App.get('maxRetries') : params.times,
timeout = Em.isNone(params.timeout) ? App.get('timeout') : params.timeout;
- this.showReloadPopup();
+ this.showReloadPopup(params.reloadPopupText);
if (this.get('retryCount') < times) {
if (params.callback) {
var self = this;
@@ -53,8 +53,9 @@ App.ReloadPopupMixin = Em.Mixin.create({
}
},
- showReloadPopup: function () {
- var self = this;
+ showReloadPopup: function (text) {
+ var self = this,
+ bodyText = text || this.t('app.reloadPopup.text');
if (!this.get('reloadPopup')) {
this.set('reloadPopup', App.ModalPopup.show({
primary: null,
@@ -62,7 +63,7 @@ App.ReloadPopupMixin = Em.Mixin.create({
showFooter: false,
header: this.t('app.reloadPopup.header'),
body: "<div id='reload_popup' class='alert alert-info'><div class='spinner'><span>" +
- this.t('app.reloadPopup.text') + "</span></div></div><div><a href='javascript:void(null)' onclick='location.reload();'>" +
+ bodyText + "</span></div></div><div><a href='javascript:void(null)' onclick='location.reload();'>" +
this.t('app.reloadPopup.link') + "</a></div>",
encodeBody: false,
onClose: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/a7152651/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index e6a18a0..2e84fc9 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -69,10 +69,10 @@ describe('App.clusterController', function () {
modelSetup.setupStackVersion(this, 'HDP-2.0.5');
sinon.stub(App.ajax, 'send', function () {
return {
- complete: function (callback) {
+ then: function (successCallback) {
App.set('clusterName', 'clusterNameFromServer');
App.set('currentStackVersion', 'HDP-2.0.5');
- callback();
+ successCallback();
}
}
});
@@ -107,7 +107,7 @@ describe('App.clusterController', function () {
});
- describe('#loadClusterNameSuccessCallback', function () {
+ describe('#reloadSuccessCallback', function () {
var test_data = {
"items": [
{
@@ -119,19 +119,12 @@ describe('App.clusterController', function () {
]
};
it('Check cluster', function () {
- controller.loadClusterNameSuccessCallback(test_data);
+ controller.reloadSuccessCallback(test_data);
expect(App.get('clusterName')).to.equal('tdk');
expect(App.get('currentStackVersion')).to.equal('HDP-1.3.0');
});
});
- describe('#loadClusterNameErrorCallback', function () {
- controller.loadClusterNameErrorCallback();
- it('', function () {
- expect(controller.get('isLoaded')).to.equal(true);
- });
- });
-
describe('#getServerClockSuccessCallback()', function () {
var testCases = [
{
http://git-wip-us.apache.org/repos/asf/ambari/blob/a7152651/ambari-web/test/mixins/common/reload_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/reload_popup_test.js b/ambari-web/test/mixins/common/reload_popup_test.js
index 1018983..32b815f 100644
--- a/ambari-web/test/mixins/common/reload_popup_test.js
+++ b/ambari-web/test/mixins/common/reload_popup_test.js
@@ -30,22 +30,36 @@ describe('App.ReloadPopupMixin', function () {
describe('#showReloadPopup', function () {
- var mockObj = {
- key: 'value'
- };
+ var spanRegExp = new RegExp('<span>([\\s\\S]+)<\/span>'),
+ cases = [
+ {
+ result: Em.I18n.t('app.reloadPopup.text'),
+ title: 'should show modal popup with default message'
+ },
+ {
+ text: 'text',
+ result: 'text',
+ title: 'should show modal popup with custom message'
+ }
+ ];
beforeEach(function () {
- sinon.stub(App.ModalPopup, 'show').returns(mockObj);
+ sinon.stub(App.ModalPopup, 'show', function (popup) {
+ return popup.body;
+ });
});
afterEach(function () {
App.ModalPopup.show.restore();
});
- it('should show modal popup', function () {
- obj.showReloadPopup();
- expect(obj.get('reloadPopup')).to.eql(mockObj);
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ obj.showReloadPopup(item.text);
+ expect(obj.get('reloadPopup').match(spanRegExp)[1]).to.equal(item.result);
+ });
});
+
});
describe('#closeReloadPopup', function () {