styling database info area

This commit is contained in:
maxogden 2011-03-09 16:22:29 -08:00
parent f2a10600c0
commit bf57648c96
2 changed files with 91 additions and 32 deletions

View File

@ -14,7 +14,7 @@
var baseURL = "_rewrite/",
vhost = false;
if (document.location.pathname.indexOf("_design") == -1) {
if ( document.location.pathname.indexOf( "_design" ) == -1 ) {
// in a vhost
vhost = true;
baseURL = "";
@ -25,34 +25,39 @@
* target == ID of the DOM node you wish to render the template into
* data == data object to pass into the mustache template when rendering
*/
function render(template, target, data) {
if (!data) var data = {};
$( "#" + target ).html( $.mustache( $.trim( $( "#" + template + "Template" ).text() ), data ) );
function render( template, target, data ) {
if ( !data ) var data = {};
$( "#" + target ).html( $.mustache( $( "#" + template + "Template" ).text(), data ) );
}
function gotDb(dbInfo) {
function formatDiskSize(bytes) {
return (parseFloat(bytes)/1024/1024).toString().substr(0,4) + "MB"
}
function gotDb( dbInfo ) {
$.extend(dbInfo, {
"host": window.location.host,
"disk_size": formatDiskSize(dbInfo.disk_size)
});
render('db', 'stats', dbInfo);
if( vhost ) dbInfo.db_name = 'db';
var data = {
"db_name": dbInfo.db_name,
"host": window.location.host
}
render( 'db', 'stats', dbInfo );
if(vhost) data.db_name = 'db';
render( 'bulk', 'bulk', dbInfo );
render('url', 'url', data);
}
$.getJSON(baseURL + 'db', gotDb);
$.getJSON( baseURL + 'db', gotDb );
$('.csv').click(function(e) {
$( '.csv' ).click( function( e ) {
function gotHeaders(headers) {
function gotHeaders( headers ) {
window.location.href = baseURL + 'csv?headers=' + headers;
}
$.get(baseURL + 'headers', gotHeaders);
$.get( baseURL + 'headers', gotHeaders );
e.preventDefault();
@ -69,10 +74,9 @@
<div id="main">
<section class="odd">
<h3>DB Stats</h3>
<p class="notice" id="stats"></p>
<div id="stats"></div>
<article class="example">
<p>
<h3>Actions</h3>
@ -84,7 +88,7 @@
<h3>Uploading</h3>
<p>You can bulk upload an array of JSON objects representing your documents to a remote server via HTTP POST. Make sure that they are formatted one document per line:</p>
<p>You can bulk upload an array of JSON documents to a Couch via HTTP POST. Make sure that they are formatted one document per line:</p>
<p>
<pre><code> {
"docs": [
@ -95,7 +99,7 @@
}</code></pre>
</p>
<p>POST to the this URL:</p>
<pre class="code" id="url"></pre>
<pre class="code" id="bulk"></pre>
</section>
</div>
@ -105,12 +109,34 @@
</div>
<script type='text/mustache' id="dbTemplate">
name: {{db_name}}, # docs: {{doc_count}}, disk size: {{disk_size}}
<div id="database" class="single_database">
<div class="group" id="current-head-database">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr class="database_oneline">
<td class="date">
<nobr>DB:</nobr>
</td>
<td class="author">
<a href="#">{{db_name}}</a>
</td>
<td class="message">
<code><a href="http://{{host}}/{{db_name}}">http://{{host}}/{{db_name}}</a> </code>
</td>
<td class="database">
size&nbsp;<a href="#" hotkey="c">{{disk_size}}</a>
</td>
<td class="tree">
docs&nbsp;<a href="http://{{host}}/{{db_name}}/_all_docs?include_docs=true" hotkey="t">{{doc_count}}</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</script>
<script type='text/mustache' id="urlTemplate">
http://{{host}}/{{db_name}}/_bulk_docs
</script>
<script type='text/mustache' id="bulkTemplate"> http://{{host}}/{{db_name}}/_bulk_docs</script>
</body>
</html>
</html>

View File

@ -15,10 +15,6 @@
em { font-style: italic }
ul,
ol { margin: 20px auto 20px auto; padding-left: 30px; }
table { margin: 20px auto 20px auto }
th { font-weight: bold }
th,
td { padding: 5px }
blockquote { margin: 20px 0px 20px 0px }
.container { margin: 50px auto 100px auto; width: 750px; }
#main { padding: 10px; background-color: #FFFFFF; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; }
@ -27,4 +23,41 @@
.code { font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif }
.code { color: #d1d1d1; background-color: #3F3F3F; margin: 0px 0px 20px 0px; padding: 5px; font-size: 13px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; }
.notice { background-color: #FFF9D8; margin-top: 20px; padding: 10px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; }
.ribbon { position: absolute; top: 0; right: 0; border: 0; }
.ribbon { position: absolute; top: 0; right: 0; border: 0; }
#database{overflow:hidden;}
#database h2{margin:0;}
#database .group{border-top:1px solid #bedce7;}
#database .separator{padding-top:1em;}
#database .envelope{border-bottom:1px solid #bedce7;border-left:1px solid #bedce7;border-right:1px solid #bedce7;padding:0 .7em .7em .7em;background:#eaf2f5 url(/images/modules/database/bg_gradient.gif) 0 100% repeat-x;overflow:hidden;}
#database .envelope.selected{background:#fffeeb!important;}
#database .envelope.selected .machine span{border-bottom:1px dotted #4183c4;}
#database.single_database .envelope .machine span{border-bottom:1px dotted #4183c4;}
#database .human{padding-top:.7em;float:left;width:50em;}
#database .human .refs{font-size:150%;}
#database .human .message{font-size:80%;font-family:Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;}
#database .human .message pre{white-space:pre-wrap;word-wrap:break-word;width:48em;}
#database .human .message a{color:#000;}
#database .human .message a.vis{color:#4183c4;}
#database .human .actor{clear:left;margin-top:.75em;}
#database .human .actor .gravatar{border:1px solid #d0d0d0;padding:2px;background-color:white;float:left;line-height:0;margin-right:.7em;}
#database .human .actor .name{line-height:1.5em;}
#database .human .actor .name a{color:#000;}
#database .human .actor .name span{color:#888;font-size:90%;}
#database .human .actor .date{color:#888;font-size:90%;line-height:1em;}
#database .machine{float:right;width:18em;padding:.8em 0 .8em 1.2em;border-left:1px solid #bedce7;color:#808080;font-family:Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:.85em;line-height:1.5em;}
#database .database_oneline{background:#eaf2f5 url(/images/modules/database/bg_gradient.gif) 0 100% repeat-x;}
#database .database_oneline td{border-bottom:1px solid #bedce7;}
#database .database_oneline .date{color:#888;width:1%;padding:0 1em 0 .5em;border-left:1px solid #bedce7;}
#database .database_oneline .author{width:15%;}
#database .database_oneline .gravatar{width:1%;}
#database .database_oneline .gravatar img{border:1px solid #d0d0d0;padding:1px;background-color:white;float:left;margin-right:.4em;}
#database .database_oneline .author a{font-weight:bold;color:black;}
#database .database_oneline .message{font-size:75%;}
#database .database_oneline .message a{color:black;}
#database .database_oneline .database,#database .database_oneline .tree{width:1%;font-family:Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:90%;color:#808080;border-left:1px solid #bedce7;padding:.6em .5em;}
#database .database_oneline .tree{border-right:1px solid #bedce7;}
a{color:#4183c4;text-decoration:none;}
a:hover{text-decoration:underline;}
.usingMouse a{outline:none;}