Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
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
davisp committed Oct 30, 2009
1 parent f225272 commit cfd1cfcd1bf43fc79ffde81decfadc37c745f71e
Showing 6 changed files with 58 additions and 2 deletions.
@@ -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 @@ <h1>
<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">
@@ -17,7 +17,7 @@ <h2>Compact Database</h2>
<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>
@@ -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>
@@ -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;
@@ -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({
@@ -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 cfd1cfc

Please sign in to comment.