You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2014/08/29 14:17:02 UTC
[38/50] [abbrv] git commit: Adds users filter.
Adds users filter.
Project: http://git-wip-us.apache.org/repos/asf/rave/repo
Commit: http://git-wip-us.apache.org/repos/asf/rave/commit/7e2cf54c
Tree: http://git-wip-us.apache.org/repos/asf/rave/tree/7e2cf54c
Diff: http://git-wip-us.apache.org/repos/asf/rave/diff/7e2cf54c
Branch: refs/heads/angular
Commit: 7e2cf54c2f50db6c78215bdc1fed696afbf128a4
Parents: 26240a1
Author: Jmeas <je...@gmail.com>
Authored: Wed Aug 20 12:28:31 2014 -0400
Committer: Jmeas <je...@gmail.com>
Committed: Wed Aug 20 12:28:31 2014 -0400
----------------------------------------------------------------------
.../mock-api/modules/users/endpoint.js | 2 +-
.../mock-api/modules/users/users-util.js | 13 ++-
rave-portal-ng/src/less/core/core.less | 5 +
.../admin/users/controllers/search-form.js | 91 ++++++++++++++++
.../subapps/admin/users/controllers/users.js | 24 +----
.../subapps/admin/users/templates/users.html | 105 ++++++++++---------
rave-portal-ng/src/subapps/admin/users/users.js | 3 +
.../templates/create-account.html | 1 -
8 files changed, 170 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/mock-api/modules/users/endpoint.js
----------------------------------------------------------------------
diff --git a/rave-portal-ng/mock-api/modules/users/endpoint.js b/rave-portal-ng/mock-api/modules/users/endpoint.js
index 0ef4a20..9b8277d 100644
--- a/rave-portal-ng/mock-api/modules/users/endpoint.js
+++ b/rave-portal-ng/mock-api/modules/users/endpoint.js
@@ -15,7 +15,7 @@ define(function(require) {
// Return our paginated data
get: function(url, data, headers, params, currentUser) {
var currentPage = params.page || 1;
- return [200, usersUtil.getPage(currentPage)];
+ return [200, usersUtil.getPage(currentPage, params.filter)];
}
});
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/mock-api/modules/users/users-util.js
----------------------------------------------------------------------
diff --git a/rave-portal-ng/mock-api/modules/users/users-util.js b/rave-portal-ng/mock-api/modules/users/users-util.js
index 5f866b0..71e92e2 100644
--- a/rave-portal-ng/mock-api/modules/users/users-util.js
+++ b/rave-portal-ng/mock-api/modules/users/users-util.js
@@ -16,15 +16,22 @@ define(function(require) {
return api.db.query('users');
},
- // Get the list of all users
- getPage: function(currentPage) {
+ // Get the list of users, optionally filtering by filter string
+ getPage: function(currentPage, filter) {
// Get the page size from the database
var pageSize = preferencesUtil.getPreference('pageSize');
+ // Get a naive list of users from the DB
var allUsers = usersUtil.getAll();
- // Get a naive list of users from the DB
+ // Filter them, if filter is passed
+ if (filter) {
+ allUsers = _.filter(allUsers, function(user) {
+ return user.username.indexOf(filter) > -1;
+ });
+ }
+
var filteredUsers = [];
_.each(allUsers, function(rawUser) {
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/less/core/core.less
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/less/core/core.less b/rave-portal-ng/src/less/core/core.less
index a1f4407..57462a0 100644
--- a/rave-portal-ng/src/less/core/core.less
+++ b/rave-portal-ng/src/less/core/core.less
@@ -33,6 +33,11 @@
display: none !important;
}
+.bold-link {
+ font-weight: bold;
+ cursor: pointer;
+}
+
/* Sticky footer */
* {
margin: 0;
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/subapps/admin/users/controllers/search-form.js
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/subapps/admin/users/controllers/search-form.js b/rave-portal-ng/src/subapps/admin/users/controllers/search-form.js
new file mode 100644
index 0000000..8511477
--- /dev/null
+++ b/rave-portal-ng/src/subapps/admin/users/controllers/search-form.js
@@ -0,0 +1,91 @@
+/*
+ * searchForm
+ * A controller for a users page. It keeps our
+ * data up-to-date as the user filters things.
+ *
+ */
+
+define(function(require) {
+
+ // Return the categories resource
+ return ['$scope', 'usersResource', 'pagination',
+ function($scope, usersResource, pagination) {
+
+ // Our paginationPages
+ $scope.paginationPages = pagination.paginationPages;
+
+ $scope.prevPageDisabled = function() {
+ if (!$scope.currentPage) {
+ return 'disabled';
+ }
+ return $scope.currentPage === 1 ? 'disabled' : '';
+ };
+
+ $scope.nextPageDisabled = function() {
+ if (!$scope.usersMeta) {
+ return 'disabled';
+ }
+ var maxPage = $scope.currentPage === $scope.usersMeta.pageCount;
+ var noPages = !$scope.usersMeta.pageCount;
+ return maxPage || noPages ? 'disabled' : '';
+ };
+
+ // Whether or not we show the table
+ $scope.showResults = function() {
+
+ // If there aren't any users, we assume that there will be.
+ // So we still show the table.
+ if (!$scope.users) {
+ return true;
+ }
+
+ // If there are users, we won't show the table if the
+ // length is 0.
+ else {
+ return !!$scope.users.length;
+ }
+ };
+
+ $scope.clearSearch = function() {
+ var usersList = usersResource.get();
+
+ usersList.$promise
+ .then(function(response) {
+ $scope.users = response.data;
+
+ var usersMeta = usersList.metadata;
+
+ // Coerce each piece of metadata to a number.
+ _.each(usersMeta, function(val, key) {
+ usersMeta[key] = +val;
+ });
+
+ $scope.usersMeta = usersMeta;
+ })
+ .catch(function() {
+ });
+ };
+
+ $scope.search = function() {
+ var usersList = usersResource.get({
+ filter: $scope.filter
+ });
+
+ usersList.$promise
+ .then(function(response) {
+ $scope.users = response.data;
+
+ var usersMeta = usersList.metadata;
+
+ // Coerce each piece of metadata to a number.
+ _.each(usersMeta, function(val, key) {
+ usersMeta[key] = +val;
+ });
+
+ $scope.usersMeta = usersMeta;
+ })
+ .catch(function() {
+ });
+ };
+ }];
+});
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/subapps/admin/users/controllers/users.js
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/subapps/admin/users/controllers/users.js b/rave-portal-ng/src/subapps/admin/users/controllers/users.js
index 2125847..0bcde03 100644
--- a/rave-portal-ng/src/subapps/admin/users/controllers/users.js
+++ b/rave-portal-ng/src/subapps/admin/users/controllers/users.js
@@ -1,13 +1,12 @@
/*
* usersController
- * Sets up our data & pagination.
+ * This controller sets up our initial data.
*
*/
define(function(require) {
- return ['$scope', '$stateParams', 'pagination', 'usersList', '$rootScope',
- function($scope, $stateParams, pagination, usersList, $rootScope) {
-
+ return ['$scope', '$stateParams', 'pagination', 'usersList', 'usersResource',
+ function($scope, $stateParams, pagination, usersList, usersResource) {
$scope.currentPage = +$stateParams.page || 0;
usersList.$promise.then(function() {
@@ -22,22 +21,5 @@ define(function(require) {
$scope.usersMeta = usersMeta;
});
-
- // Our paginationPages
- $scope.paginationPages = pagination.paginationPages;
-
- $scope.prevPageDisabled = function() {
- if (!$scope.currentPage) {
- return 'disabled';
- }
- return $scope.currentPage === 1 ? 'disabled' : '';
- };
-
- $scope.nextPageDisabled = function() {
- if (!$scope.usersMeta) {
- return 'disabled';
- }
- return $scope.currentPage === $scope.usersMeta.pageCount ? 'disabled' : '';
- };
}];
});
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/subapps/admin/users/templates/users.html
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/subapps/admin/users/templates/users.html b/rave-portal-ng/src/subapps/admin/users/templates/users.html
index f53f36a..3cb0241 100644
--- a/rave-portal-ng/src/subapps/admin/users/templates/users.html
+++ b/rave-portal-ng/src/subapps/admin/users/templates/users.html
@@ -1,8 +1,54 @@
<article ui-view>
- <h2>
- Showing {{ usersMeta.start }} - {{ usersMeta.end }} of {{ usersMeta.totalUsers }} results
- </h2>
- <div class="searchHeading paginationHeading">
+ <form class="form-horizontal search-form" ng-controller="searchCtrl">
+ <h2>
+ Showing {{ usersMeta.start }} - {{ usersMeta.end }} of {{ usersMeta.totalUsers }} results
+ </h2>
+ <div class="searchHeading paginationHeading">
+ <div class="pagination">
+ <ul>
+ <li ng-switch on="prevPageDisabled()" ng-class="prevPageDisabled()">
+ <a ng-switch-when="disabled"><</a>
+ <a ng-switch-default ui-sref="portal.admin.users({page:usersMeta.currentPage-1})"><</a>
+ </li>
+ <li ng-repeat="n in paginationPages(usersMeta.currentPage, usersMeta.pageCount)" ng-class="{ active: n == usersMeta.currentPage }">
+ <a ui-sref="portal.admin.users({page:n})">{{ n }}</a>
+ </li>
+ <li ng-switch on="nextPageDisabled()" ng-class="nextPageDisabled()">
+ <a ng-switch-when="disabled">></a>
+ <a ng-switch-default ui-sref="portal.admin.users({page:usersMeta.currentPage+1})">></a>
+ </li>
+ </ul>
+ </div>
+ <fieldset>
+ <div class="input-append">
+ <input class="input-medium" type="search" id="searchTerm" name="searchTerm" value="" placeholder="Search Users" ng-model="filter">
+ <button class="btn btn-primary" ng-click="search()">Search</button>
+ </div>
+ </fieldset>
+ </div>
+ <div ng-show="!showResults()" class="alert alert-warning">
+ There were no results. <a ng-click="clearSearch()" class="bold-link">Clear search.</a>
+ </div>
+ <table class="table table-striped table-bordered table-condensed" ng-show="showResults()">
+ <thead>
+ <tr>
+ <th>Username</th>
+ <th>Email</th>
+ <th>Account Enabled</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="user in users">
+ <td>
+ <a ui-sref="portal.admin.users.detail({id: user.ID, page: null})">
+ {{ user.username }}
+ </a>
+ </td>
+ <td>{{ user.email }}</td>
+ <td>{{ user.enabled }}</td>
+ </tr>
+ </tbody>
+ </table>
<div class="pagination">
<ul>
<li ng-switch on="prevPageDisabled()" ng-class="prevPageDisabled()">
@@ -17,48 +63,11 @@
<a ng-switch-default ui-sref="portal.admin.users({page:usersMeta.currentPage+1})">></a>
</li>
</ul>
- </div>
- <form class="form-horizontal search-form" action="/portal/app/admin/users/search" method="get">
- <fieldset>
- <div class="input-append">
- <input class="input-medium" type="search" id="searchTerm" name="searchTerm" value="" placeholder="Search Users">
- <button class="btn btn-primary" type="submit" value="Search">Search</button>
- </div>
- </fieldset>
- </form>
- </div>
- <table class="table table-striped table-bordered table-condensed">
- <thead>
- <tr>
- <th>Username</th>
- <th>Email</th>
- <th>Account Enabled</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="user in users">
- <td>
- <a ui-sref="portal.admin.users.detail({id: user.ID, page: null})">
- {{ user.username }}
- </a>
- </td>
- <td>{{ user.email }}</td>
- <td>{{ user.enabled }}</td>
- </tr>
- </tbody>
- </table>
- <div class="pagination">
- <ul>
- <li ng-switch on="prevPageDisabled()" ng-class="prevPageDisabled()">
- <a ng-switch-when="disabled"><</a>
- <a ng-switch-default ui-sref="portal.admin.users({page:usersMeta.currentPage-1})"><</a>
- </li>
- <li ng-repeat="n in paginationPages(usersMeta.currentPage, usersMeta.pageCount)" ng-class="{ active: n == usersMeta.currentPage }">
- <a ui-sref="portal.admin.users({page:n})">{{ n }}</a>
- </li>
- <li ng-switch on="nextPageDisabled()" ng-class="nextPageDisabled()">
- <a ng-switch-when="disabled">></a>
- <a ng-switch-default ui-sref="portal.admin.users({page:usersMeta.currentPage+1})">></a>
- </li>
- </ul>
+ <fieldset>
+ <legend>Add New User</legend>
+ <br>
+ <button class="btn btn-primary" href="/portal/app/admin/adduser?referringPageId=1"><i class="icon-plus icon-white"></i> Add user</button>
+ <br>
+ </fieldset>
+ </form>
</article>
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/subapps/admin/users/users.js
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/subapps/admin/users/users.js b/rave-portal-ng/src/subapps/admin/users/users.js
index 47936fc..ef10e2b 100644
--- a/rave-portal-ng/src/subapps/admin/users/users.js
+++ b/rave-portal-ng/src/subapps/admin/users/users.js
@@ -31,6 +31,9 @@ define(function(require) {
var userCtrl = require('./controllers/user');
users.controller('userCtrl', userCtrl);
+ var searchCtrl = require('./controllers/search-form');
+ users.controller('searchCtrl', searchCtrl);
+
// Register the routes
var routes = require('./routes');
users.config(routes);
http://git-wip-us.apache.org/repos/asf/rave/blob/7e2cf54c/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html
----------------------------------------------------------------------
diff --git a/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html b/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html
index ab55c20..5e7eaa9 100644
--- a/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html
+++ b/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html
@@ -132,5 +132,4 @@
<br>You should receive the confirmation email that was sent to {{ email }} shortly.
</div>
</div>
-
</div>