You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/08/12 18:52:04 UTC

[2/2] git commit: updated refs/heads/move-auth-sidebar to 4fa26dc

Fauxton move auth to nav


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4fa26dcc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4fa26dcc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4fa26dcc

Branch: refs/heads/move-auth-sidebar
Commit: 4fa26dccae9ba264c23db7ca1b7ef64f8273b8c1
Parents: 891a901
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Aug 12 18:51:43 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Aug 12 18:51:43 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/auth/resources.js        | 35 ++++++---------
 src/fauxton/app/addons/auth/routes.js           | 47 +++++++++++++-------
 .../addons/auth/templates/change_password.html  |  1 +
 .../app/addons/auth/templates/create_admin.html |  1 +
 .../app/addons/auth/templates/nav_dropdown.html | 20 +++++----
 .../addons/auth/templates/nav_link_title.html   | 17 +++----
 src/fauxton/app/api.js                          |  5 +--
 7 files changed, 68 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index d365634..da3acb2 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -301,10 +301,9 @@ function (app, FauxtonAPI) {
     }
   });
 
-  Auth.NavLinkTitle = FauxtonAPI.View.extend({ 
+  Auth.NavLink = FauxtonAPI.View.extend({ 
     template: 'addons/auth/templates/nav_link_title',
     tagName: 'li',
-    className: 'menuDropdownToggle openMenu',
 
     beforeRender: function () {
       this.listenTo(this.model, 'change', this.render);
@@ -325,6 +324,19 @@ function (app, FauxtonAPI) {
       this.listenTo(this.model, 'change', this.render);
     },
 
+    setTab: function (selectedTab) {
+      this.selectedTab = selectedTab;
+      this.$('.active').removeClass('active');
+      var $tab = this.$('a[data-select="' + selectedTab +'"]');
+      $tab.parent().addClass('active');
+    },
+
+    afterRender: function () {
+      if (this.selectedTab) {
+        this.setTab(this.selectedTab);
+      }
+    },
+
     serialize: function () {
       return {
         admin_party: this.model.isAdminParty(),
@@ -333,25 +345,6 @@ function (app, FauxtonAPI) {
     }
   });
 
-  Auth.NavLink = FauxtonAPI.View.extend({
-    className: "dropdown openMenu",
-
-    beforeRender: function () {
-      this.nav_link_name = this.insertView(new Auth.NavLinkTitle({model: this.model}));
-      if (this.model.isAdminParty() || this.model.user()) {
-        this.nav_link_list = this.insertView(new Auth.NavDropDown({model: this.model}));
-      }
-    },
-
-    afterRender: function () {
-      var that = this;
-      //unbind this click incase it has been registered before
-      this.$('.menuDropdownToggle').unbind('click').click(function () {
-        that.$('.menuDropdown').toggle('slow');
-      });
-    },
-  });
-
   Auth.NoAccessView = FauxtonAPI.View.extend({
     template: "addons/auth/templates/noAccess"
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/routes.js b/src/fauxton/app/addons/auth/routes.js
index 779a6a3..ecd45f2 100644
--- a/src/fauxton/app/addons/auth/routes.js
+++ b/src/fauxton/app/addons/auth/routes.js
@@ -17,22 +17,13 @@ define([
 ],
 
 function(app, FauxtonAPI, Auth) {
-
   var authRouteObject = FauxtonAPI.RouteObject.extend({
     layout: 'one_pane',
 
     routes: {
       'login': 'login',
       'logout': 'logout',
-      'changePassword': {
-        route: 'changePassword',
-        roles: ['_admin', '_reader', '_replicator']
-      },
       'createAdmin': 'createAdmin',
-      'addAdmin': {
-        roles: ['_admin'],
-        route: 'addAdmin',
-      },
       'noAccess': 'noAccess'
     },
 
@@ -40,6 +31,7 @@ function(app, FauxtonAPI, Auth) {
       this.crumbs = [{name: 'Login', link:"#"}];
       this.setView('#dashboard-content', new Auth.LoginView({model: FauxtonAPI.session}));
     },
+
     logout: function () {
       FauxtonAPI.addNotification({msg: 'You have been logged out.'});
       FauxtonAPI.session.logout().then(function () {
@@ -57,19 +49,44 @@ function(app, FauxtonAPI, Auth) {
       this.setView('#dashboard-content', new Auth.CreateAdminView({model: FauxtonAPI.session}));
     },
 
-    addAdmin: function () {
-      this.crumbs = [{name: 'Add Admin', link:"#"}];
-      this.setView('#dashboard-content', new Auth.CreateAdminView({login_after: false, model: FauxtonAPI.session}));
-    },
-
     noAccess: function () {
       this.crumbs = [{name: 'Access Denied', link:"#"}];
       this.setView('#dashboard-content', new Auth.NoAccessView());
     },
+  });
+
+  var userRouteObject = FauxtonAPI.RouteObject.extend({
+    layout: 'with_sidebar',
+
+    routes: {
+      'changePassword': {
+        route: 'changePassword',
+        roles: ['_admin', '_reader', '_replicator']
+      },
+      'addAdmin': {
+        roles: ['_admin'],
+        route: 'addAdmin',
+      },
+    },
+    
+    initialize: function () {
+     this.navDrop = this.setView('#sidebar-content', new Auth.NavDropDown({model: FauxtonAPI.session}));
+    },
+
+    changePassword: function () {
+      this.navDrop.setTab('change-password');
+      this.setView('#dashboard-content', new Auth.ChangePassword({model: FauxtonAPI.session}));
+    },
+
+    addAdmin: function () {
+      this.navDrop.setTab('add-admin');
+      this.setView('#dashboard-content', new Auth.CreateAdminView({login_after: false, model: FauxtonAPI.session}));
+    },
 
+    crumbs: [{name: 'User Management', link: '#'}]
   });
 
-  Auth.RouteObjects = [authRouteObject];
+  Auth.RouteObjects = [authRouteObject, userRouteObject];
   
   return Auth;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/templates/change_password.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/change_password.html b/src/fauxton/app/addons/auth/templates/change_password.html
index 39b8778..64b7d1f 100644
--- a/src/fauxton/app/addons/auth/templates/change_password.html
+++ b/src/fauxton/app/addons/auth/templates/change_password.html
@@ -13,6 +13,7 @@ the License.
 -->
 
 <div class="span12">
+  <h2> Change Password </h2>
   <form id="change-password">
     <p class="help-block">
     Enter your new password.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/templates/create_admin.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/create_admin.html b/src/fauxton/app/addons/auth/templates/create_admin.html
index 5e9d260..4715be5 100644
--- a/src/fauxton/app/addons/auth/templates/create_admin.html
+++ b/src/fauxton/app/addons/auth/templates/create_admin.html
@@ -13,6 +13,7 @@ the License.
 -->
 
 <div class="span12">
+  <h2> Add Admin </h2>
   <form id="create-admin-form">
     <input id="username" type="text" name="name" placeholder= "Username:" size="24">
     <br/>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/templates/nav_dropdown.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_dropdown.html b/src/fauxton/app/addons/auth/templates/nav_dropdown.html
index 5d40e08..880a7c1 100644
--- a/src/fauxton/app/addons/auth/templates/nav_dropdown.html
+++ b/src/fauxton/app/addons/auth/templates/nav_dropdown.html
@@ -12,12 +12,16 @@ License for the specific language governing permissions and limitations under
 the License.
 -->
 
-<!-- dropdown menu links -->
-  <% if (admin_party) { %>
-  <li class="menuDropdown"><a id="user-create-admin" href="#createAdmin"> Create Admin </a></li>
-  <% } else if (user) { %>
-  <li class="menuDropdown"><a id="user-create-more-admin" href="#addAdmin"> Create Admins </a></li>
-  <li class="menuDropdown"><a id="user-change-password" href="#changePassword"> Change Password </a></li>
-  <li class="menuDropdown"><a id="user-logout" href="#logout"> Logout </a> </li> 
-  <% } %>
+<div id="sidenav">
+<header class="row-fluid">
+  <h3> <%= user.name %> </h3>
+</header>
+<nav>
+<ul class="nav nav-list">
+  <li class="active" ><a data-select="change-password" id="user-change-password" href="#changePassword"> Change Password </a></li>
+  <li ><a data-select="add-admin" href="#addAdmin"> Create Admins </a></li>
+  <li ><a data-select"user-logout" href="#logout"> Logout </a> </li> 
+</ul>
+</nav>
+</div>
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/addons/auth/templates/nav_link_title.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_link_title.html b/src/fauxton/app/addons/auth/templates/nav_link_title.html
index 2d38b75..8a4469a 100644
--- a/src/fauxton/app/addons/auth/templates/nav_link_title.html
+++ b/src/fauxton/app/addons/auth/templates/nav_link_title.html
@@ -11,15 +11,12 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 License for the specific language governing permissions and limitations under
 the License.
 -->
-<a <% if (!user && !admin_party) { %> href="#login" <% } %> class="fonticon-user fonticon" >
-  <% if (admin_party) { %>
-  Admin Party!
-  <% } else if (user) { %>
-  <%= user.name %>
-  <% } else { %>
-  Login
-  <% } %>
-  <b class="caret"></b>
-</a>
+<% if (admin_party) { %>
+  <a id="user-create-admin" class="fonticon-user fonticon" href="#createAdmin"> Admin Party! </a>
+<% } else if (user) { %>
+  <a  href="#changePassword" class="fonticon-user fonticon" > <%= user.name %> </a>
+<% } else { %>
+  <a  href="#login"  class="fonticon-user fonticon" >  Login </a>
+<% } %>
 
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4fa26dcc/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index fc98866..5e8e424 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -51,10 +51,6 @@ function(app, Fauxton) {
 
     disableLoader: false,
 
-    /*hasRendered: function () {
-      return !!this.__manager__.hasRendered;
-    },*/
-
     forceRender: function () {
       this.hasRendered = false;
     }
@@ -301,6 +297,7 @@ function(app, Fauxton) {
 
           if (!routeObject.disableLoader) {
             routeObjectSpinner.stop();
+            $('.spinner').remove();
           }
 
           if (!view.disableLoader){