فهرست منبع

AMBARI-7038. Main menu disappears after view-page refresh. (onechiporenko)

Oleg Nechiporenko 10 سال پیش
والد
کامیت
17e9890295

+ 4 - 0
ambari-web/app/controllers/application.js

@@ -23,6 +23,10 @@ App.ApplicationController = Em.Controller.extend(App.UserPref, {
 
   name: 'applicationController',
 
+  clusterExists: function() {
+    return !Em.isNone(App.router.get('clusterController.clusterName'));
+  }.property('App.router.clusterController.clusterName'),
+
   clusterName: function () {
     return (App.router.get('clusterController.clusterName') || 'My Cluster');
   }.property('App.router.clusterController.clusterName'),

+ 4 - 2
ambari-web/app/controllers/global/cluster_controller.js

@@ -108,8 +108,10 @@ App.ClusterController = Em.Controller.extend({
   },
 
   loadClusterNameSuccessCallback: function (data) {
-    App.set('clusterName', data.items[0].Clusters.cluster_name);
-    App.set('currentStackVersion', data.items[0].Clusters.version);
+    if (data.items && data.items.length > 0) {
+      App.set('clusterName', data.items[0].Clusters.cluster_name);
+      App.set('currentStackVersion', data.items[0].Clusters.version);
+    }
   },
 
   loadClusterNameErrorCallback: function (request, ajaxOptions, error) {

+ 1 - 1
ambari-web/app/router.js

@@ -287,7 +287,7 @@ App.Router = Em.Router.extend({
           loginController.postLogin(true, true);
         });
       } else {
-        router.transitionTo('views.index');
+        router.transitionTo('main.views.index');
         loginController.postLogin(true,true);
       }
     });

+ 10 - 4
ambari-web/app/routes/main.js

@@ -30,11 +30,17 @@ module.exports = Em.Route.extend({
           if (App.get('testMode')) {
             router.get('mainController').initialize();
           } else {
-            App.router.get('mainController').checkServerClientVersion().done(function () {
-              App.router.get('clusterController').loadClientServerClockDistance().done(function () {
-                router.get('mainController').initialize();
+            if (App.get('clusterName')) {
+              App.router.get('mainController').checkServerClientVersion().done(function () {
+                App.router.get('clusterController').loadClientServerClockDistance().done(function () {
+                  router.get('mainController').initialize();
+                });
               });
-            });
+            }
+            else {
+              App.router.get('clusterController').set('isLoaded', true);
+              App.router.get('mainViewsController').loadAmbariViews();
+            }
           }
         });
         // TODO: redirect to last known state

+ 12 - 10
ambari-web/app/templates/application.hbs

@@ -30,16 +30,18 @@
           {{/if}}
 
           {{#if isClusterDataLoaded}}
-            <a class="brand cluster-name" href="javascript:void(null);" {{bindAttr title="clusterName"}}>
-              <span {{action "showPopup" target="App.router.backgroundOperationsController"}} >{{clusterDisplayName}} </span>
-                {{#with App.router.backgroundOperationsController}}
-                  {{#if allOperationsCount}}
-                      <i class="icon-caret-left ops-count"></i><span class="label operations-count" {{action "showPopup" target="App.router.backgroundOperationsController"}}> {{allOperationsCount}} {{t ops}}</span>
-                  {{else}}
-                      <i class="icon-caret-left"></i><span class="label" {{action "showPopup" target="App.router.backgroundOperationsController"}}>{{allOperationsCount}} {{t ops}}</span>
-                  {{/if}}
-                {{/with}}
-            </a>
+            {{#if clusterExists}}
+              <a class="brand cluster-name" href="javascript:void(null);" {{bindAttr title="clusterName"}}>
+                <span {{action "showPopup" target="App.router.backgroundOperationsController"}} >{{clusterDisplayName}} </span>
+                  {{#with App.router.backgroundOperationsController}}
+                    {{#if allOperationsCount}}
+                        <i class="icon-caret-left ops-count"></i><span class="label operations-count" {{action "showPopup" target="App.router.backgroundOperationsController"}}> {{allOperationsCount}} {{t ops}}</span>
+                    {{else}}
+                        <i class="icon-caret-left"></i><span class="label" {{action "showPopup" target="App.router.backgroundOperationsController"}}>{{allOperationsCount}} {{t ops}}</span>
+                    {{/if}}
+                  {{/with}}
+              </a>
+            {{/if}}
           {{/if}}
 
           {{#if App.router.loggedIn}}

+ 20 - 17
ambari-web/app/views/main/menu.js

@@ -36,27 +36,30 @@ App.MainMenuView = Em.CollectionView.extend({
 
       if (App.router.get('clusterController.isLoaded')) {
 
-        result.push(
-          { label:Em.I18n.t('menu.item.dashboard'), routing:'dashboard', active:'active'},
-          { label:Em.I18n.t('menu.item.services'), routing:'services'},
-          { label:Em.I18n.t('menu.item.hosts'), routing:'hosts'}
-        );
-
-        if (App.supports.mirroring && App.Service.find().findProperty('serviceName', 'FALCON')) {
-          result.push({ label:Em.I18n.t('menu.item.mirroring'), routing:'mirroring'});
-        }
+        if (App.get('clusterName')) {
 
-        if (!App.get('isHadoop2Stack')) {
-          result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'apps'});
-        }
+          result.push(
+            { label:Em.I18n.t('menu.item.dashboard'), routing:'dashboard', active:'active'},
+            { label:Em.I18n.t('menu.item.services'), routing:'services'},
+            { label:Em.I18n.t('menu.item.hosts'), routing:'hosts'}
+          );
 
-        if (App.get('isAdmin')) {
-          result.push({ label:Em.I18n.t('menu.item.admin'), routing:'admin'});
-        }
+          if (App.supports.mirroring && App.Service.find().findProperty('serviceName', 'FALCON')) {
+            result.push({ label:Em.I18n.t('menu.item.mirroring'), routing:'mirroring'});
+          }
 
+          if (!App.get('isHadoop2Stack')) {
+            result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'apps'});
+          }
+
+          if (App.get('isAdmin')) {
+            result.push({ label:Em.I18n.t('menu.item.admin'), routing:'admin'});
+          }
+
+        }
       }
 
-      if (App.supports.views) {
+      if (App.get('supports.views')) {
         result.push({ label:Em.I18n.t('menu.item.views'), routing:'views.index', isView:true, views: this.get('views').filterProperty('visible')});
       }
 
@@ -76,7 +79,7 @@ App.MainMenuView = Em.CollectionView.extend({
    *    Syncs navigation menu with requested URL
    */
   renderOnRoute: function () {
-    if (App.router.get('clusterController.isLoaded')) {
+    if (App.get('clusterName') && App.router.get('clusterController.isLoaded')) {
       var last_url = App.router.location.lastSetURL || location.href.replace(/^[^#]*#/, '');
       if (last_url.substr(1, 4) !== 'main' || !this._childViews) {
         return;