Permalink
Browse files

Merge branch 'release/v0.13.0'

  • Loading branch information...
2 parents 96164be + 06b7a63 commit e1f2fba153bf14919b45a3c9595fcf9420cebab6 @andzdroid andzdroid committed May 11, 2012
Showing with 124 additions and 8 deletions.
  1. +17 −0 HISTORY.md
  2. +21 −3 README.md
  3. +3 −1 config.js
  4. +1 −1 package.json
  5. +39 −3 routes/collection.js
  6. +43 −0 views/collection.html
View
@@ -0,0 +1,17 @@
+0.13.0
+------
+
+* Added version history
+* Added MIT license
+* Added pager links above document list
+* Added pagination links below document list
+* Added config option to set number of documents displayed per page
+
+0.12.0
+------
+
+* Added async package to dependencies
+* Added system.users to list of un-editable collections
+* Changed config file to allow lists of databases and associated auth details
+* Added support for regular MongoDB users
+* Removed requirement for admin access to the MongoDB server
View
@@ -21,21 +21,26 @@ Planned features:
* Support for replica set connections
* Web-based command-line interface
* Site authentication
+* REST interface
+
Limitations
-----------
-* Requires documents to have an _id property
+* Requires documents to have a document._id property
* Cannot edit document._id property
-* No pagination yet, can only view first 20 documents (WILL BE FIXED SOON!)
Screenshots
-----------
-Click here for screenshots:
+<img src="http://i.imgur.com/DOi3b.png" title="Viewing documents in a collection" />
+
+Click here for more screenshots:
[http://imgur.com/a/OTZHe](http://imgur.com/a/OTZHe)
+These screenshots are from version 0.11.0.
+
Usage
-----
@@ -59,3 +64,16 @@ To run:
To use:
Visit http://localhost:8081 or whatever URL/port you entered into your config.
+
+
+License
+-------
+MIT License
+
+Copyright (c) 2012 Chun-hao Hu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -41,11 +41,13 @@ module.exports = {
},
site: {
//baseUrl: the URL that mongo express will be located at
- //Remember to add the trailing forward slash at the end!
+ //Remember to add the forward slash at the end!
baseUrl: 'http://localhost:8081/',
port: 8081
},
options: {
+ //documentsPerPage: how many documents you want to see at once in collection view
+ documentsPerPage: 10,
//editorTheme: Name of the theme you want to use for displaying documents
//See http://codemirror.net/demo/theme.html for all examples
editorTheme: "rubyblue",
View
@@ -2,7 +2,7 @@
"author": "Chun-hao Hu <hu.chunhao@gmail.com> (http://blog.huchunhao.com)",
"name": "mongo-express",
"description": "Web-based admin interface for MongoDB",
- "version": "0.12.0",
+ "version": "0.13.0",
"repository": {
"type": "git",
"url": "git://github.com/andzdroid/mongo-express.git"
View
@@ -2,18 +2,54 @@ var config = require('../config');
//view all entries in a collection
exports.viewCollection = function(req, res, next) {
+ //var limit = parseInt(req.params.limit, 10) || config.options.documentsPerPage;
+ var limit = config.options.documentsPerPage;
+ var skip = parseInt(req.query.skip, 10) || 0;
+
var query_options = {
- limit: 20,
- skip: 0
+ limit: limit,
+ skip: skip
};
req.collection.find({}, query_options).toArray(function(err, items) {
req.collection.stats(function(err, stats) {
+
+ //Pagination
+ //Have to do this here, swig template doesn't allow any calculations :(
+ var prev, back2, here, next2, next, last;
+
+ prev = {
+ page: Math.round((skip - limit) / limit) + 1,
+ skip: skip - limit
+ };
+ prev2 = {
+ page: Math.round((skip - limit * 2) / limit) + 1,
+ skip: skip - limit * 2
+ };
+ next2 = {
+ page: Math.round((skip + limit * 2) / limit) + 1,
+ skip: skip + limit * 2
+ };
+ next = {
+ page: Math.round((skip + limit) / limit) + 1,
+ skip: skip + limit
+ };
+ here = Math.round(skip / limit) + 1;
+ last = (Math.ceil(stats.count / limit) - 1) * limit;
+
var ctx = {
title: 'Viewing Collection: ' + req.collectionName,
documents: items,
stats: stats,
- editorTheme: config.options.editorTheme
+ editorTheme: config.options.editorTheme,
+ limit: limit,
+ skip: skip,
+ prev: prev,
+ prev2: prev2,
+ next2: next2,
+ next: next,
+ here: here,
+ last: last
};
res.render('collection', ctx);
View
@@ -102,6 +102,19 @@
</script>
{% endif %}
+<ul class="pager span7">
+ <li class="previous"><a href="db/{{ dbName }}/{{ collectionName }}?skip=0">&larr; First</a></li>
+ <li{% if prev.skip < 0 %} class="disabled"{% endif %}>
+ <a{% if prev.skip >= 0 %} href="db/{{ dbName }}/{{ collectionName }}?skip={{ prev.skip }}"{% endif %}>&larr; Prev</a>
+ </li>
+
+ <li{% if next.skip >= stats.count %} class="disabled"{% endif %}>
+ <a{% if next.skip < stats.count %} href="db/{{ dbName }}/{{ collectionName }}?skip={{ next.skip }}"{% endif %}>Next &rarr;</a>
+ </li>
+
+ <li class="next"><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ last }}">Last &rarr;</a></li>
+</ul>
+
{% for document in documents %}
<div class="row">
<div class="span8">
@@ -133,6 +146,36 @@
</div>
{% endfor %}
+<div class="pagination pagination-centered span7">
+ <ul>
+ {%- if prev2.skip >= 0 %}
+ <li><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ prev2.skip }}">{{ prev2.page }}</a></li>
+ {% else %}
+ <li><a>&nbsp;</a></li>
+ {%- endif %}
+
+ {%- if prev.skip >= 0 %}
+ <li><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ prev.skip }}">{{ prev.page }}</a></li>
+ {% else %}
+ <li><a>&nbsp;</a></li>
+ {%- endif %}
+
+ <li class="active"><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ skip }}">{{ here }}</a></li>
+
+ {%- if next.skip < stats.count %}
+ <li><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ next.skip }}">{{ next.page }}</a></li>
+ {% else %}
+ <li><a>&nbsp;</a></li>
+ {% endif %}
+
+ {%- if next2.skip < stats.count %}
+ <li><a href="db/{{ dbName }}/{{ collectionName }}?skip={{ next2.skip }}">{{ next2.page }}</a></li>
+ {% else %}
+ <li><a>&nbsp;</a></li>
+ {% endif %}
+ </ul>
+</div>
+
{% endif %}

0 comments on commit e1f2fba

Please sign in to comment.