Permalink
Browse files

Merge branch 'release/v0.2.3'

  • Loading branch information...
andzdroid committed Apr 29, 2012
2 parents 7112d89 + 925bb99 commit 48f7f52d4d05a39116991fe7ee3aac5074729a14
Showing with 115 additions and 14 deletions.
  1. +1 −1 package.json
  2. +16 −4 routes/index.js
  3. +22 −8 views/collection.html
  4. +72 −0 views/index.html
  5. +4 −1 views/layout.html
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.2.2",
+ "version": "0.2.3",
"repository": {
"type": "git",
"url": "git://github.com/andzdroid/mongo-express.git"
View
@@ -6,11 +6,23 @@ exports.deleteCollection = coll.deleteCollection;
//Homepage route
exports.index = function(req, res){
- var ctx = {
- title: 'Mongo Express'
- };
+ var db = req.db;
- res.render('index', ctx);
+ //TODO: add possibility to add admin credentials to config and authenticate as admin
+ db.admin(function(err, admin) {
+ admin.serverStatus(function(err, info) {
+ if (err) {
+ //TODO: handle error
+ console.error(err);
+ }
+
+ var ctx = {
+ title: 'Mongo Express',
+ info: info
+ };
+ res.render('index', ctx);
+ });
+ });
};
//Handle form submission when creating new collection
View
@@ -5,22 +5,36 @@
{% block content %}
{% if documents.length == 0 %}
-<p>
+<p class="well">
No documents found.
</p>
{% else %}
-<table class="table">
- {% for document in documents %}
+{% for document in documents %}
+ <pre class="prettyprint">{{ document|json }}</pre>
+ <!--<a href="db/{{ collection }}/{{ document._id }}">Edit</a>-->
+{% endfor %}
+{% endif %}
+
+
+{#
+ # Not very useful, since it doesn't show correct index names
+ # Could use db.coll.getIndexes(), but that is an extra query on every collection page
+<h2>Indexes</h2>
+{% if stats.nindexes == 0 %}
+<p class="well">
+No indexes found.
+</p>
+{% else %}
+<table class="table table-bordered table-striped">
+ {% for size in stats.indexSizes %}
<tr>
- <td>
- <pre class="prettyprint">{{ document|json }}</pre>
- <!--<a href="db/{{ collection }}/{{ document._id }}">Edit</a>-->
- </td>
+ <td>{{ loop.key }}</td>
+ <td>{{ size }} bytes</td>
</tr>
{% endfor %}
</table>
{% endif %}
-
+#}
<h2>Delete Collection</h2>
<form method="POST" action="db/{{ collection }}" class="well">
View
@@ -17,4 +17,76 @@ <h2>Create Collection</h2>
</button>
</form>
+<h2>Server Status</h2>
+<table class="table table-bordered table-striped">
+ <tr>
+ <td class="span2"><strong>Hostname</strong></td>
+ <td class="span3">{{ info.host }}</td>
+ <td class="span2"><strong>MongoDB Version</strong></td>
+ <td class="span3">{{ info.version }}</td>
+ </tr>
+ <tr>
+ <td><strong>Uptime</strong></td>
+ <td>{{ info.uptime }} seconds</td>
+ <td><strong>Server Time</strong></td>
+ <td>{{ info.localTime|date('r') }}</td>
+ </tr>
+ <tr><td colspan="4">&nbsp;</td></tr>
+ <tr>
+ <td><strong>Current Connections</strong></td>
+ <td>{{ info.connections.current }}</td>
+ <td><strong>Available Connections</strong></td>
+ <td>{{ info.connections.available }}</td>
+ </tr>
+ <tr>
+ <td><strong>Active Clients</strong></td>
+ <td>{{ info.globalLock.activeClients.total }}</td>
+ <td><strong>Queued Operations</strong></td>
+ <td>{{ info.globalLock.currentQueue.total }}</td>
+ </tr>
+ <tr>
+ <td><strong>Clients Reading</strong></td>
+ <td>{{ info.globalLock.activeClients.readers }}</td>
+ <td><strong>Clients Writing</strong></td>
+ <td>{{ info.globalLock.activeClients.writers}}</td>
+ </tr>
+ <tr>
+ <td><strong>Read Lock Queue</strong></td>
+ <td>{{ info.globalLock.currentQueue.readers }}</td>
+ <td><strong>Write Lock Queue</strong></td>
+ <td>{{ info.globalLock.currentQueue.writers}}</td>
+ </tr>
+ <tr><td colspan="4">&nbsp;</td></tr>
+ <tr>
+ <td><strong>Disk Flushes</strong></td>
+ <td>{{ info.backgroundFlushing.flushes }}</td>
+ <td><strong>Last Flush</strong></td>
+ <td>{{ info.backgroundFlushing.last_finished|date('r') }}</td>
+ </tr>
+ <tr>
+ <td><strong>Time Spent Flushing</strong></td>
+ <td>{{ info.backgroundFlushing.total_ms }} ms</td>
+ <td><strong>Average Flush Time</strong></td>
+ <td>{{ info.backgroundFlushing.average_ms }} ms</td>
+ </tr>
+ <tr><td colspan="4">&nbsp;</td></tr>
+ <tr>
+ <td><strong>Total Inserts</strong></td>
+ <td>{{ info.opcounters.insert }}</td>
+ <td><strong>Total Queries</strong></td>
+ <td>{{ info.opcounters.query}}</td>
+ </tr>
+ <tr>
+ <td><strong>Total Updates</strong></td>
+ <td>{{ info.opcounters.update}}</td>
+ <td><strong>Total Deletes</strong></td>
+ <td>{{ info.opcounters.delete}}</td>
+ </tr>
+</table>
+
+
+{#
+ # Still need to add global lock time stats and replica set stats
+#}
+
{% endblock %}
View
@@ -7,7 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="stylesheets/bootstrap.css" rel="stylesheet">
- <link href="stylesheets/bootstrap-responsive.css" rel="stylesheet">
<link href="stylesheets/prettify.css" rel="stylesheet" />
<style type="text/css">
body {
@@ -19,6 +18,7 @@
}
</style>
+ <link href="stylesheets/bootstrap-responsive.css" rel="stylesheet">
<script type="text/javascript" src="javascripts/prettify.js"></script>
</head>
@@ -54,7 +54,10 @@
</div>
<div class="span9">
+ <div class="page-header">
<h1>{{ title }}</h1>
+ </div>
+
{% block content %}{% endblock %}
</div>
</div>

0 comments on commit 48f7f52

Please sign in to comment.