You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/22 17:24:22 UTC

[12/15] git commit: updated refs/heads/1809-compact-and-clean to 489a6c2

compact and clean up working


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1213c8ad
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1213c8ad
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1213c8ad

Branch: refs/heads/1809-compact-and-clean
Commit: 1213c8addf9514c15328970ac751033d66125454
Parents: 5a9e7fd
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Oct 16 13:24:09 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Oct 22 14:25:30 2013 +0200

----------------------------------------------------------------------
 .../compaction/assets/less/compaction.less      |  8 +++
 src/fauxton/app/addons/compaction/resources.js  | 17 ++++++
 .../app/addons/compaction/templates/layout.html | 33 +++++++-----
 src/fauxton/app/addons/compaction/views.js      | 56 +++++++++++++++++++-
 src/fauxton/settings.json.default               |  4 +-
 5 files changed, 103 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/1213c8ad/src/fauxton/app/addons/compaction/assets/less/compaction.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/assets/less/compaction.less b/src/fauxton/app/addons/compaction/assets/less/compaction.less
new file mode 100644
index 0000000..c197d9a
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/assets/less/compaction.less
@@ -0,0 +1,8 @@
+
+.compaction-option {
+  background-color: #F7F7F7;
+  border: 1px solid #DDD;
+  margin-bottom: 30px;
+  padding: 10px;
+
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/1213c8ad/src/fauxton/app/addons/compaction/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/resources.js b/src/fauxton/app/addons/compaction/resources.js
index d0180ef..b6fa4bc 100644
--- a/src/fauxton/app/addons/compaction/resources.js
+++ b/src/fauxton/app/addons/compaction/resources.js
@@ -17,5 +17,22 @@ define([
 
 function (app, FauxtonAPI) {
   var Compaction = FauxtonAPI.addon();
+
+  Compaction.compactDB = function (db) {
+    return $.ajax({
+      url: db.url() + '/_compact',
+      contentType: 'application/json',
+      type: 'POST'
+    });
+  };
+
+  Compaction.cleanupViews = function (db) {
+    return $.ajax({
+      url: db.url() + '/_view_cleanup',
+      contentType: 'application/json',
+      type: 'POST'
+    });
+  }
+
   return Compaction;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/1213c8ad/src/fauxton/app/addons/compaction/templates/layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/templates/layout.html b/src/fauxton/app/addons/compaction/templates/layout.html
index 56bcbc2..08a2078 100644
--- a/src/fauxton/app/addons/compaction/templates/layout.html
+++ b/src/fauxton/app/addons/compaction/templates/layout.html
@@ -11,17 +11,26 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 License for the specific language governing permissions and limitations under
 the License.
 -->
+<div class="row">
+  <div class="span12 compaction-option">
+    <h3> Compact Database </h3>
+    <p>Compacting a database removes deleted documents and previous revisions. It is an irreversible operation and may take a while to complete for large databases.</p>
+    <button id="compact-db" class="btn btn-large btn-primary"> Run </button>
+  </div>
+</div>
 
-<table class="table table-striped table-bordered">
-  <tbody>
-  <tr> 
-    <td>
-      <h3> Compact Database </h3>
-      <p>Compacting a database removes deleted documents and previous revisions. It is an irreversible operation and may take a while to complete for large databases.</p>
-      <button id="compact-db" class="btn btn-large btn-primary"> Run </button>
-    </td>
-  </tr>
-  </tbody>
-
-</table>
+<div class="row">
+  <div class="span12 compaction-option">
+    <h3> Compact Views </h3>
+    <p>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>
+    <button id="compact-view" class="btn btn-large btn-primary"> Run </button>
+  </div>
+</div>
 
+<div class="row">
+  <div class="span12 compaction-option">
+    <h3> Cleanup Views </h3>
+    <p>Cleaning up views in a database removes old view files still stored on the filesystem. It is an irreversible operation.</p>
+    <button id="cleanup-views" class="btn btn-large btn-primary"> Run </button>
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/1213c8ad/src/fauxton/app/addons/compaction/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/views.js b/src/fauxton/app/addons/compaction/views.js
index 67afd5e..457e5f6 100644
--- a/src/fauxton/app/addons/compaction/views.js
+++ b/src/fauxton/app/addons/compaction/views.js
@@ -23,12 +23,66 @@ function (app, FauxtonAPI, Compaction) {
   Compaction.Layout = FauxtonAPI.View.extend({
     template: 'addons/compaction/templates/layout',
 
+    initialize: function () {
+      _.bindAll(this);
+    },
+
     events: {
-      "click compact-db": "compactDB"
+      "click #compact-db": "compactDB",
+      "click #compact-view": "compactDB",
+      "click #cleanup-views": "cleanupViews"
+    },
+
+    disableButton: function (selector, text) {
+      this.$(selector).attr('disabled', 'disabled').text(text);
+    },
+
+    enableButton: function (selector, text) {
+      this.$(selector).removeAttr('disabled').text(text);
     },
 
     compactDB: function (event) {
+      var enableButton = this.enableButton;
       event.preventDefault();
+
+      this.disableButton('#compact-db', 'Compacting...');
+
+      Compaction.compactDB(this.model).then(function () {
+        FauxtonAPI.addNotification({
+          type: 'success',
+          msg: 'Database compaction has started.'
+        });
+      }, function (xhr, error, reason) {
+        console.log(arguments);
+        FauxtonAPI.addNotification({
+          type: 'error',
+          msg: 'Error: ' + JSON.parse(xhr.responseText).reason
+        });
+      }).always(function () {
+        enableButton('#compact-db', 'Run');
+      });
+    },
+
+    cleanupViews: function (event) {
+      var enableButton = this.enableButton;
+      event.preventDefault();
+
+      this.disableButton('#cleanup-view', 'Cleaning...');
+
+      Compaction.cleanupViews(this.model).then(function () {
+        FauxtonAPI.addNotification({
+          type: 'success',
+          msg: 'View cleanup has started.'
+        });
+      }, function (xhr, error, reason) {
+        console.log(arguments);
+        FauxtonAPI.addNotification({
+          type: 'error',
+          msg: 'Error: ' + JSON.parse(xhr.responseText).reason
+        });
+      }).always(function () {
+        enableButton('#cleanup-views', 'Run');
+      });
     }
 
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/1213c8ad/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index 54cc0ce..1b68911 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -8,9 +8,9 @@
   { "name": "plugins" },
   { "name": "contribute" },
   { "name": "permissions" },
-  { "name": "verifyinstall" }
   { "name": "compaction" },
-  { "name": "auth" }
+  { "name": "auth" },
+  { "name": "verifyinstall" }
   ],
     "template": {
       "development": {