Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes COUCHDB-547 - Adding a View Compaction Button

Thanks to Joshua Bronson for the patch.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@831485 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 78088d9faa123bcae39ed16dd0e15f8d41b34bd3 1 parent 97dc2de
@davisp davisp authored
View
1  THANKS
@@ -37,5 +37,6 @@ suggesting improvements or submitting changes. Some of these people are:
* Dan Walters <dan@danwalters.net>
* Curt Arnold <carnold@apache.org>
* Gustavo Niemeyer
+ * Joshua Bronson <jabronson@gmail.com>
For a list of authors see the `AUTHORS` file.
View
4 share/www/database.html
@@ -37,7 +37,7 @@
$(function() {
if (page.redirecting) return;
- $("h1 strong").text(page.db.name);
+ $("h1 strong").html('<a href="?' + page.db.name + '">' + page.db.name + '</a>');
var viewPath = page.viewName || "_all_docs";
if (viewPath != "_temp_view" && viewPath != "_design_docs") {
$("h1 a.raw").attr("href", "/" + encodeURIComponent(page.db.name) +
@@ -100,6 +100,7 @@
$("#toolbar button.add").click(page.newDocument);
$("#toolbar button.compact").click(page.compactDatabase);
$("#toolbar button.delete").click(page.deleteDatabase);
+ $("#toolbar button.compactview").click(page.compactView);
$('#jumpto input').addPlaceholder("Document ID").suggest(function(text, callback) {
page.db.allDocs({
@@ -146,6 +147,7 @@
<li><button class="add">New Document</button></li>
<li><button class="compact">Compact Database…</button></li>
<li><button class="delete">Delete Database…</button></li>
+ <li><button class="compactview" style="display: none">Compact View…</button></li>
</ul>
<div id="viewcode" class="collapsed" style="display: none">
View
2  share/www/dialog/_compact_database.html
@@ -17,7 +17,7 @@
<fieldset>
<p class="help">
Compacting a database removes deleted documents and previous revisions.
- It is an <strong>irreversible operation</strong> and my take
+ It is an <strong>irreversible operation</strong> and may take
a while to complete for large databases.
</p>
</fieldset>
View
28 share/www/dialog/_compact_view.html
@@ -0,0 +1,28 @@
+<!--
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+
+-->
+<form action="" method="post">
+ <h2>Compact View</h2>
+ <fieldset>
+ <p class="help">
+ View compaction will affect all views in this design document. This
+ operation may take some time to complete. Your views will still operate
+ normally during compaction.
+ </p>
+ </fieldset>
+ <div class="buttons">
+ <button type="submit">Compact</button>
+ <button type="button" class="cancel">Cancel</button>
+ </div>
+</form>
View
15 share/www/script/futon.browse.js
@@ -138,6 +138,20 @@
});
}
+ this.compactView = function() {
+ var groupname = page.viewName.substring(8,
+ page.viewName.indexOf('/_view'));
+ $.showDialog("dialog/_compact_view.html", {
+ submit: function(data, callback) {
+ db.compactView(groupname, {
+ success: function(resp) {
+ callback();
+ }
+ });
+ }
+ });
+ }
+
this.deleteDatabase = function() {
$.showDialog("dialog/_delete_database.html", {
submit: function(data, callback) {
@@ -638,6 +652,7 @@
options.endkey = options.descending ? "_design" : "_design0";
db.allDocs(options);
} else {
+ $("button.compactview").show();
$("#viewcode").show();
var currentMapCode = $("#viewcode_map").val();
var currentReduceCode = $.trim($("#viewcode_reduce").val()) || null;
View
10 share/www/script/jquery.couch.js
@@ -111,6 +111,16 @@
"The database could not be compacted"
);
},
+ compactView: function(groupname, options) {
+ $.extend(options, {successStatus: 202});
+ ajax({
+ type: "POST", url: this.uri + "_compact/" + groupname,
+ data: "", processData: false
+ },
+ options,
+ "The view could not be compacted"
+ );
+ },
create: function(options) {
$.extend(options, {successStatus: 201});
ajax({
View
1  share/www/style/layout.css
@@ -230,6 +230,7 @@ body.fullwidth #wrap { margin-right: 0; }
#toolbar button:active { background-position: 2px -62px; color: #000; }
#toolbar button.add { background-image: url(../image/add.png); }
#toolbar button.compact { background-image: url(../image/compact.png); }
+#toolbar button.compactview { background-image: url(../image/compact.png); }
#toolbar button.delete { background-image: url(../image/delete.png); }
#toolbar button.load { background-image: url(../image/load.png); }
#toolbar button.run { background-image: url(../image/run.png); }

0 comments on commit 78088d9

Please sign in to comment.
Something went wrong with that request. Please try again.