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/10/26 13:58:49 UTC

ambari git commit: AMBARI-13559. JS error on quick links if service wasn't installed successfully using ASW (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 0e8dddabd -> 402d97912


AMBARI-13559. JS error on quick links if service wasn't installed successfully using ASW (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 402d97912d2aff501eb6ae1ecedd780c342284fe
Parents: 0e8ddda
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Oct 26 14:32:33 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Oct 26 14:32:33 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/styles/application.less          |  9 ++++
 ambari-web/app/templates/main/service/item.hbs  | 10 +++--
 .../app/views/common/quick_view_link_view.js    | 43 ++++++++++++++++----
 .../test/views/common/quick_link_view_test.js   | 12 +++++-
 5 files changed, 62 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/402d9791/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 7056141..a358f60 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2736,6 +2736,7 @@ Em.I18n.translations = {
   '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.publicHostName': '{0} ({1})',
   'quick.links.label.active': 'Active',
   'quick.links.label.standby': 'Standby',

http://git-wip-us.apache.org/repos/asf/ambari/blob/402d9791/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 491e59c..1d018f1 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -2452,6 +2452,15 @@ a:focus {
       position: absolute;
     }
   }
+
+  .dropdown-menu {
+    width: 170px;
+  }
+  .alert {
+    padding: 0 2px;
+    margin: 0 2px;
+  }
+
   .dropdown-submenu {
     &> a:after {
       border-left-color: #333;

http://git-wip-us.apache.org/repos/asf/ambari/blob/402d9791/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 b13b1c2..f276884 100644
--- a/ambari-web/app/templates/main/service/item.hbs
+++ b/ambari-web/app/templates/main/service/item.hbs
@@ -38,9 +38,13 @@
                     </li>
                   {{/each}}
                 {{else}}
-                  {{#each view.quickLinks}}
-                    <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
-                  {{/each}}
+                  {{#if view.quickLinks}}
+                    {{#each view.quickLinks}}
+                      <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>
+                  {{/if}}
                 {{/if}}
               {{else}}
                 <div class="spinner"></div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/402d9791/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 89b855e..c6cff1b 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -227,6 +227,7 @@ App.QuickViewLinks = Em.View.extend({
       return [App.get('singleNodeAlias')];
     }
     var hosts = [];
+    var host;
     switch (serviceName) {
       case 'OOZIE':
         // active OOZIE components
@@ -239,13 +240,19 @@ App.QuickViewLinks = Em.View.extend({
             });
           });
         } else if (components && components.length === 1) {
-          hosts[0] = this.findComponentHost(response.items, 'OOZIE_SERVER');
+          host = this.findComponentHost(response.items, 'OOZIE_SERVER');
+          if (host) {
+            hosts[0] = host;
+          }
         }
         break;
       case "HDFS":
         if (this.get('content.snameNode')) {
           // not HA
-          hosts[0] = this.findComponentHost(response.items, 'NAMENODE');
+          host = this.findComponentHost(response.items, 'NAMENODE');
+          if (host) {
+            hosts[0] = host;
+          }
         } else {
           // HA enabled, need both two namenodes hosts
           this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').forEach(function (component) {
@@ -294,8 +301,14 @@ App.QuickViewLinks = Em.View.extend({
               hosts.push({'publicHostName': item.Hosts.public_host_name});
             });
           }
-        } else {
-          hosts[0] = masterComponents[0].Hosts.public_host_name;
+        }
+        else {
+          if (masterComponents[0]) {
+            host = masterComponents[0].Hosts.public_host_name;
+            if (host) {
+              hosts[0] = host;
+            }
+          }
         }
         break;
       case "YARN":
@@ -317,21 +330,33 @@ App.QuickViewLinks = Em.View.extend({
             hosts.push(newHost);
           }, this);
         } else {
-          hosts[0] = this.findComponentHost(response.items, 'RESOURCEMANAGER');
+          host = this.findComponentHost(response.items, "RESOURCEMANAGER");
+          if (host) {
+            hosts[0] = host;
+          }
         }
         break;
       case "STORM":
-        hosts[0] = this.findComponentHost(response.items, "STORM_UI_SERVER");
+        host = this.findComponentHost(response.items, "STORM_UI_SERVER");
+        if (host) {
+          hosts[0] = host;
+        }
         break;
       case "ACCUMULO":
-        hosts[0] = this.findComponentHost(response.items, "ACCUMULO_MONITOR");
+        host = this.findComponentHost(response.items, "ACCUMULO_MONITOR");
+        if (host) {
+          hosts[0] = host;
+        }
         break;
       case "ATLAS":
-        hosts[0] = this.findComponentHost(response.items, "ATLAS_SERVER");
+        host = this.findComponentHost(response.items, "ATLAS_SERVER");
+        if (host) {
+          hosts[0] = host;
+        }
         break;
       default:
         var service = App.StackService.find().findProperty('serviceName', serviceName);
-        if (service && service.get('hasMaster')) {
+        if (service && service.get('hasMaster') && App.Service.find(serviceName).get('hostComponents').someProperty('isMaster')) {
           hosts[0] = this.findComponentHost(response.items, this.get('content.hostComponents') && this.get('content.hostComponents').findProperty('isMaster', true).get('componentName'));
         }
         break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/402d9791/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 3d38836..5462c0c 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -502,11 +502,21 @@ describe('App.QuickViewLinks', function () {
             hasMaster: false
           })
         ];
-      })
+      });
+      sinon.stub(App.Service, 'find', function () {
+        return Em.Object.create({
+          hostComponents: Em.A([
+            Em.Object.create({
+              isMaster: true
+            })
+          ])
+        });
+      });
     });
 
     after(function () {
       App.StackService.find.restore();
+      App.Service.find.restore();
     });
 
     afterEach(function () {