summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-06-02 20:37:41 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-06-02 20:37:41 +0000
commit303230cb554aa07ce7ada5520b4d3dc0bb89ec51 (patch)
tree5ec7b41f7a0c676f4c16ddd74e934976c8bbbc9e
parentec24327a4892c115e5941ec93f9dcc01e9050fd2 (diff)
Display group reduce results in Futon by default.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@662554 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/browse.js62
-rw-r--r--share/www/script/couch_tests.js4
-rw-r--r--share/www/style/layout.css8
3 files changed, 37 insertions, 37 deletions
diff --git a/share/www/script/browse.js b/share/www/script/browse.js
index ec514f09..d7e3fcee 100644
--- a/share/www/script/browse.js
+++ b/share/www/script/browse.js
@@ -348,6 +348,9 @@ function CouchDatabasePage() {
if (options.count === undefined) {
options.count = parseInt($("#perpage").val(), 10);
}
+ if (options.group === undefined) {
+ options.group = true;
+ }
if ($("#documents thead th.key").is(".desc")) {
options.descending = true;
$.cookies.set(dbName + ".desc", "1");
@@ -363,7 +366,7 @@ function CouchDatabasePage() {
if (resp.offset === undefined) {
resp.offset = 0;
}
- if (resp.total_rows !== null && resp.offset > 0) {
+ if (resp.rows !== null && resp.offset > 0) {
$("#paging a.prev").attr("href", "#" + (resp.offset - options.count)).click(function() {
var firstDoc = resp.rows[0];
page.updateDocumentListing({
@@ -377,7 +380,7 @@ function CouchDatabasePage() {
} else {
$("#paging a.prev").removeAttr("href");
}
- if (resp.total_rows !== null && resp.total_rows - resp.offset > options.count) {
+ if (resp.rows !== null && resp.total_rows - resp.offset > options.count) {
$("#paging a.next").attr("href", "#" + (resp.offset + options.count)).click(function() {
var lastDoc = resp.rows[resp.rows.length - 1];
page.updateDocumentListing({
@@ -392,39 +395,42 @@ function CouchDatabasePage() {
$("#paging a.next").removeAttr("href");
}
- if (resp.total_rows != null) {
- for (var i = 0; i < resp.rows.length; i++) {
- var row = resp.rows[i];
- var tr = $("<tr></tr>");
- var key = row.key;
+ for (var i = 0; i < resp.rows.length; i++) {
+ var row = resp.rows[i];
+ var tr = $("<tr></tr>");
+ var key = row.key;
+ if (row.id) {
$("<td class='key'><a href='document.html?" + encodeURIComponent(db.name) +
- "/" + encodeURIComponent(row.id) + "'><em></em><br>" +
+ "/" + encodeURIComponent(row.id) + "'><strong></strong><br>" +
"<span class='docid'>ID:&nbsp;" + row.id + "</span></a></td>")
- .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
+ .find("strong").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
+ .appendTo(tr);
+ } else {
+ $("<td class='key'><strong></strong></td>")
+ .find("strong").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
.appendTo(tr);
- var value = row.value;
- $("<td class='value'></td>").text(
- value !== null ? prettyPrintJSON(value, 0, "") : "null"
- ).appendTo(tr).dblclick(function() {
- location.href = this.previousSibling.firstChild.href;
- });
- tr.appendTo("#documents tbody.content");
}
- $("#documents tbody.footer td span").text(
- "Showing " + Math.min(resp.total_rows, resp.offset + 1) + "-" +
- (resp.offset + resp.rows.length) + " of " + resp.total_rows +
- " document" + (resp.total_rows != 1 ? "s" : ""));
- $("#documents").removeClass("reduced");
- } else {
- var tr = $("<tr></tr>");
- $("<td class='key'></td>").appendTo(tr);
+ var value = row.value;
$("<td class='value'></td>").text(
- resp.result !== null ? prettyPrintJSON(resp.result) : "null"
- ).appendTo(tr);
+ value !== null ? prettyPrintJSON(value, 0, "") : "null"
+ ).appendTo(tr).dblclick(function() {
+ location.href = this.previousSibling.firstChild.href;
+ });
tr.appendTo("#documents tbody.content");
- $("#documents tbody.footer td span").text("Showing reduce result");
- $("#documents").addClass("reduced");
}
+ var firstNum = 1;
+ var lastNum = totalNum = resp.rows.length;
+ if (resp.total_rows != null) {
+ firstNum = Math.min(resp.total_rows, resp.offset + 1);
+ lastNum = firstNum + resp.rows.length - 1;
+ totalNum = resp.total_rows;
+ $("#paging").show();
+ } else {
+ $("#paging").hide();
+ }
+ $("#documents tbody.footer td span").text(
+ "Showing " + firstNum + "-" + lastNum + " of " + totalNum +
+ " row" + (firstNum != lastNum ? "s" : ""));
$("#documents tbody tr:odd").addClass("odd");
$(document.body).removeClass("loading");
}
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 4d626ca0..523d7d54 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -93,14 +93,14 @@ var tests = {
T(db.info().doc_count == 6);
var reduceFunction = function(keys, values){
- return sum(values);
+ return sum(values);
};
results = db.query(mapFunction, reduceFunction);
T(results.rows[0].value == 33);
- // delete a document
+ // delete a document
T(db.deleteDoc(existingDoc).ok);
// make sure we can't open the doc
diff --git a/share/www/style/layout.css b/share/www/style/layout.css
index 152c1acc..0dd93a19 100644
--- a/share/www/style/layout.css
+++ b/share/www/style/layout.css
@@ -304,18 +304,12 @@ ul.suggest-dropdown li.selected { cursor: pointer; background: Highlight;
}
#documents tbody.content td.key { color: #333; }
#documents tbody.content td.key a { display: block; }
-#documents tbody.content td.key em { font-style: normal; }
+#documents tbody.content td.key a strong { font-weight: normal; }
#documents tbody.content td.key span.docid { color: #999;
font: normal 10px Arial,Helvetica,sans-serif;
}
#documents tbody.content td.value { font-size: 10px; }
-#documents.reduced th.key, #documents.reduced td.key,
-#documents.reduced #paging {
- display: none;
-}
-#documents.reduced td.value { white-space: pre; }
-
/* Document fields table */
#fields { table-layout: fixed; }