Repository: ambari Updated Branches: refs/heads/trunk 5a5f16de9 -> f2ca027f0
AMBARI-14261. Loading freeze after login as a view user (rzang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f2ca027f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f2ca027f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f2ca027f Branch: refs/heads/trunk Commit: f2ca027f0290211b683d8dffb668f11813d13125 Parents: 5a5f16d Author: Richard Zang <rz...@apache.org> Authored: Tue Dec 8 15:28:56 2015 -0800 Committer: Richard Zang <rz...@apache.org> Committed: Tue Dec 8 15:28:56 2015 -0800 ---------------------------------------------------------------------- ambari-web/app/app.js | 3 +++ ambari-web/app/controllers/application.js | 4 ++++ ambari-web/app/router.js | 5 ++--- ambari-web/app/routes/main.js | 11 ++++++++--- ambari-web/app/templates/application.hbs | 2 +- ambari-web/app/views/main/menu.js | 15 ++++++++------- 6 files changed, 26 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/app.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js index 881bfc3..9009c00 100644 --- a/ambari-web/app/app.js +++ b/ambari-web/app/app.js @@ -37,6 +37,9 @@ module.exports = Em.Application.create({ isOperator: false, isPermissionDataLoaded: false, auth: null, + isOnlyViewUser: function() { + return App.auth && (App.auth.length == 0 || (App.isAuthorized('VIEW.USE') && App.auth.length == 1)); + }.property('auth'), /** * @type {boolean} http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/controllers/application.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/application.js b/ambari-web/app/controllers/application.js index 12d33eb..c623118 100644 --- a/ambari-web/app/controllers/application.js +++ b/ambari-web/app/controllers/application.js @@ -45,6 +45,10 @@ App.ApplicationController = Em.Controller.extend(App.UserPref, { isExistingClusterDataLoaded: Em.computed.and('App.router.clusterInstallCompleted', 'isClusterDataLoaded'), + enableLinks: function() { + return this.isExistingClusterDataLoaded && !App.get('isOnlyViewUser'); + }.property(), + /** * Determines if "Exit" menu-item should be shown * It should if cluster isn't installed http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/router.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js index 36a2353..92b2bae 100644 --- a/ambari-web/app/router.js +++ b/ambari-web/app/router.js @@ -360,7 +360,6 @@ App.Router = Em.Router.extend({ var privileges = params.loginData.privileges || []; var router = this; var isAdmin = privileges.mapProperty('PrivilegeInfo.permission_name').contains('AMBARI.ADMINISTRATOR'); - var isOnlyViewUser = App.auth && (App.auth.length == 0 || (App.isAuthorized('VIEW.USE') && App.auth.length == 1)); App.set('isAdmin', isAdmin); @@ -377,13 +376,13 @@ App.Router = Em.Router.extend({ isOperator: true }); } - if (isOnlyViewUser) { + if (App.get('isOnlyViewUser')) { router.transitionToViews(); } else { router.transitionToApp(); } } else { - if (isOnlyViewUser) { + if (App.get('isOnlyViewUser')) { router.transitionToViews(); } else { router.transitionToAdminView(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/routes/main.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js index 46315ae..cae1035 100644 --- a/ambari-web/app/routes/main.js +++ b/ambari-web/app/routes/main.js @@ -38,9 +38,14 @@ module.exports = Em.Route.extend(App.RouterRedirections, { } else { if (router.get('clusterInstallCompleted')) { App.router.get('clusterController').loadClientServerClockDistance().done(function () { - App.router.get('clusterController').checkDetailedRepoVersion().done(function () { - router.get('mainController').initialize(); - }); + if (!App.get('isOnlyViewUser')) { + App.router.get('clusterController').checkDetailedRepoVersion().done(function () { + router.get('mainController').initialize(); + }); + } else { + App.router.transitionTo('main.views.index'); + App.router.get('clusterController').set('isLoaded', true); // hide loading bar + } }); } else { http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/templates/application.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/application.hbs b/ambari-web/app/templates/application.hbs index 190f439..9da0da5 100644 --- a/ambari-web/app/templates/application.hbs +++ b/ambari-web/app/templates/application.hbs @@ -21,7 +21,7 @@ <div class="navbar navbar-static-top"> <div class="navbar-inner"> <div class="container main-container"> - {{#if isExistingClusterDataLoaded}} + {{#if enableLinks}} <a {{translateAttr href="topnav.logo.href"}} class="logo"><img src="/img/logo-white.png" alt="Apache Ambari" title="Apache Ambari"></a> <a class="brand" {{translateAttr href="topnav.logo.href"}} title="Apache Ambari">{{t app.name}}</a> http://git-wip-us.apache.org/repos/asf/ambari/blob/f2ca027f/ambari-web/app/views/main/menu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/menu.js b/ambari-web/app/views/main/menu.js index 2c12aec..fc0f42b 100644 --- a/ambari-web/app/views/main/menu.js +++ b/ambari-web/app/views/main/menu.js @@ -35,13 +35,14 @@ App.MainMenuView = Em.CollectionView.extend({ if (App.router.get('loggedIn')) { if (App.router.get('clusterController.isLoaded') && App.get('router.clusterInstallCompleted')) { - - 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', hasAlertsLabel: true}, - { label: Em.I18n.t('menu.item.alerts'), routing: 'alerts'} - ); + if (!App.get('isOnlyViewUser')) { + 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', hasAlertsLabel: true}, + {label: Em.I18n.t('menu.item.alerts'), routing: 'alerts'} + ); + } if (App.isAuthorized('CLUSTER.TOGGLE_KERBEROS, CLUSTER.UPGRADE_DOWNGRADE_STACK')) { result.push({ label: Em.I18n.t('menu.item.admin'), routing: 'admin'}); }