瀏覽代碼

AMBARI-6567. Views: Browser refresh leaves a blank page (Buzhor Denys via alexantonenko)

Alex Antonenko 11 年之前
父節點
當前提交
e784e26310

+ 1 - 0
ambari-web/app/controllers.js

@@ -126,6 +126,7 @@ require('controllers/main/mirroring/datasets_controller');
 require('controllers/main/mirroring/jobs_controller');
 require('controllers/main/mirroring/manage_clusters_controller');
 require('controllers/main/views_controller');
+require('controllers/main/views/details_controller');
 require('controllers/wizard/slave_component_groups_controller');
 require('controllers/wizard/step0_controller');
 require('controllers/wizard/step1_controller');

+ 1 - 4
ambari-web/app/controllers/main/views_controller.js

@@ -21,12 +21,9 @@ var App = require('app');
 App.MainViewsController = Em.Controller.extend({
   name:'mainViewsController',
 
-  selectedView: null,
-
   setView: function(event) {
     if(event.context){
-      this.set('selectedView', event.context);
       App.router.transitionTo('main.views.viewDetails', event.context);
     }
   }
-})
+});

+ 6 - 13
ambari-web/app/routes/main.js

@@ -72,18 +72,7 @@ module.exports = Em.Route.extend({
 
   views: Em.Route.extend({
     route: '/views',
-    connectOutlets: function (router, context) {
-      router.get('mainController').connectOutlet('mainViews');
-    },
     index: Em.Route.extend({
-      route: '/',
-      enter: function (router) {
-        Em.run.next(function () {
-          router.transitionTo('allViews');
-        });
-      }
-    }),
-    allViews: Em.Route.extend({
       route: '/',
       connectOutlets: function (router, context) {
         router.get('mainController').connectOutlet('mainViews');
@@ -91,8 +80,12 @@ module.exports = Em.Route.extend({
     }),
     viewDetails: Em.Route.extend({
       route: '/:viewName/:version/:instanceName',
-      connectOutlets: function (router, view) {
-        router.get('mainController').connectOutlet('mainViewsDetails');
+      connectOutlets: function (router, params) {
+        router.get('mainController').dataLoading().done(function() {
+          // find and set content for `mainViewsDetails` and associated controller
+          router.get('mainController').connectOutlet('mainViewsDetails', App.router.get('clusterController.ambariViews')
+            .findProperty('href', ['/views', params.viewName, params.version, params.instanceName].join('/')));
+        });
       }
     })
   }),

+ 2 - 2
ambari-web/app/views/main/views/details.js

@@ -28,7 +28,7 @@ App.MainViewsDetailsView = Em.View.extend({
   seamless: "seamless",
 
   src: function() {
-    return window.location.origin + App.router.get('mainViewsController.selectedView.href');
-  }.property('App.MainViewsController.selectedView')
+    return window.location.origin + this.get('controller.content.href');
+  }.property('controller.content')
 
 });

+ 21 - 0
ambari-web/app/views/main/views/details_controller.js

@@ -0,0 +1,21 @@
+/**
+ * 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.
+ */
+
+App.MainViewsDetailsController = Em.Controller.extend({
+  name:'mainViewsDetailsController'
+});