You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/05 22:56:51 UTC

[36/40] ambari git commit: AMBARI-14871: Better messages when Ambari web UI can't resolve hosts to build quicklinks (dili)

AMBARI-14871: Better messages when Ambari web UI can't resolve hosts to build quicklinks (dili)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 14d53f79156b0b0badb118714948be883881f213
Parents: 13325ab
Author: Di Li <di...@apache.org>
Authored: Fri Feb 5 12:56:39 2016 -0500
Committer: Di Li <di...@apache.org>
Committed: Fri Feb 5 12:56:39 2016 -0500

----------------------------------------------------------------------
 ambari-web/app/messages.js                           |  5 +++--
 ambari-web/app/templates/main/service/item.hbs       |  2 +-
 ambari-web/app/views/common/quick_view_link_view.js  | 14 +++++++++++---
 ambari-web/test/views/common/quick_link_view_test.js | 13 +++++++++++--
 4 files changed, 26 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/14d53f79/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a8b5db6..9be6d86 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2850,8 +2850,9 @@ Em.I18n.translations = {
   'common.combobox.dropdown.issues': 'Show property issues',
   'common.combobox.dropdown.warnings': 'Show property warnings',
 
-  'quick.links.error.label': 'Hostname is undefined',
-  'quick.links.error.label2': 'Quick Links are not available',
+  'quick.links.error.quicklinks.unavailable.label': 'Quick Links are not available',
+  'quick.links.error.nohosts.label': 'Failed to obtain host information for {0}',
+  'quick.links.error.oozie.label': 'Quick Links are not available. Make sure Oozie server is running.',
   'quick.links.publicHostName': '{0} ({1})',
   'quick.links.label.active': 'Active',
   'quick.links.label.standby': 'Standby',

http://git-wip-us.apache.org/repos/asf/ambari/blob/14d53f79/ambari-web/app/templates/main/service/item.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/item.hbs b/ambari-web/app/templates/main/service/item.hbs
index f61695e..bc7f05f 100644
--- a/ambari-web/app/templates/main/service/item.hbs
+++ b/ambari-web/app/templates/main/service/item.hbs
@@ -43,7 +43,7 @@
                       <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
                     {{/each}}
                   {{else}}
-                    <div class="alert alert-danger"><small>{{t quick.links.error.label2}}</small></div>
+                    <div class="alert alert-danger"><small>{{t quick.links.error.quicklinks.unavailable.label}}</small></div>
                   {{/if}}
                 {{/if}}
               {{else}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/14d53f79/ambari-web/app/views/common/quick_view_link_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/quick_view_link_view.js b/ambari-web/app/views/common/quick_view_link_view.js
index c2f7dcc..567f65c 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -25,6 +25,8 @@ App.QuickViewLinks = Em.View.extend({
 
   hasQuickLinksConfiged: false,
 
+  quickLinksErrorMessage: '',
+
   /**
    * service which has blank target of link
    * @type {Array}
@@ -317,9 +319,9 @@ App.QuickViewLinks = Em.View.extend({
    * set empty links
    */
   setEmptyLinks: function () {
+    //display an error message
     var quickLinks = [{
-      label: this.t('quick.links.error.label'),
-      url: 'javascript:alert("' + this.t('contact.administrator') + '");return false;'
+      label: this.get('quickLinksErrorMessage')
     }];
     this.set('quickLinks', quickLinks);
     this.set('isLoaded', true);
@@ -432,10 +434,14 @@ App.QuickViewLinks = Em.View.extend({
       .filterProperty('workStatus', 'STARTED')
       .mapProperty('hostName');
 
-    return hosts.filter(function (host) {
+    var oozieHostsArray = hosts.filter(function (host) {
       host.status = Em.I18n.t('quick.links.label.active');
       return activeOozieServers.contains(host.hostName);
     }, this);
+
+    if (oozieHostsArray.length == 0)
+      this.set('quickLinksErrorMessage', Em.I18n.t('quick.links.error.oozie.label'));
+    return oozieHostsArray;
   },
 
   /**
@@ -506,6 +512,8 @@ App.QuickViewLinks = Em.View.extend({
    * @method getHosts
    */
   getHosts: function (response, serviceName) {
+    //The default error message when we cannot obtain the host information for the given service
+    this.set('quickLinksErrorMessage', Em.I18n.t('quick.links.error.nohosts.label').format(serviceName));
     if (App.get('singleNodeInstall')) {
       return [{
         hostName: App.get('singleNodeAlias'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/14d53f79/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index 93a235c..3a604fe 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -334,8 +334,7 @@ describe('App.QuickViewLinks', function () {
     it("empty links are set", function () {
       quickViewLinks.setEmptyLinks();
       expect(quickViewLinks.get('quickLinks')).to.eql([{
-        label: quickViewLinks.t('quick.links.error.label'),
-        url: 'javascript:alert("' + quickViewLinks.t('contact.administrator') + '");return false;' // eslint-disable-line no-script-url
+        label: quickViewLinks.get('quickLinksErrorMessage'),
       }]);
       expect(quickViewLinks.get('isLoaded')).to.be.true;
     });
@@ -352,6 +351,16 @@ describe('App.QuickViewLinks', function () {
       quickViewLinks.processOozieHosts([host]);
       expect(host.status).to.equal(Em.I18n.t('quick.links.label.active'));
     });
+    it("host status is invalid", function () {
+      quickViewLinks.set('content.hostComponents', [Em.Object.create({
+        componentName: 'OOZIE_SERVER',
+        workStatus: 'INSTALLED',
+        hostName: 'host1'
+      })]);
+      var host = {hostName: 'host1'};
+      quickViewLinks.processOozieHosts([host]);
+      expect(quickViewLinks.get('quickLinksErrorMessage')).to.equal(Em.I18n.t('quick.links.error.oozie.label'));
+    });
   });
 
   describe("#processHdfsHosts()", function () {